本文整理汇总了Java中org.intellij.lang.xpath.psi.XPathType类的典型用法代码示例。如果您正苦于以下问题:Java XPathType类的具体用法?Java XPathType怎么用?Java XPathType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XPathType类属于org.intellij.lang.xpath.psi包,在下文中一共展示了XPathType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isCheckedConversion
import org.intellij.lang.xpath.psi.XPathType; //导入依赖的package包/类
private boolean isCheckedConversion(XPathType exprType, XPathType type) {
if (exprType == XPathType.NODESET) {
if (type == XPathType.STRING && OPTIONS.get(0)) return true;
if (type == XPathType.NUMBER && OPTIONS.get(4)) return true;
if (type == XPathType.BOOLEAN && OPTIONS.get(8)) return true;
} else if (exprType == XPathType.STRING) {
if (type == XPathType.NUMBER && OPTIONS.get(5)) return true;
if (type == XPathType.BOOLEAN && OPTIONS.get(9)) return true;
} else if (exprType == XPathType.NUMBER) {
if (type == XPathType.STRING && OPTIONS.get(2)) return true;
if (type == XPathType.BOOLEAN && OPTIONS.get(10)) return true;
} else if (exprType == XPathType.BOOLEAN) {
if (type == XPathType.STRING && OPTIONS.get(3)) return true;
if (type == XPathType.NUMBER && OPTIONS.get(11)) return true;
}
return false;
}
示例2: getTypeForTag
import org.intellij.lang.xpath.psi.XPathType; //导入依赖的package包/类
@Override
protected XPathType getTypeForTag(XmlTag tag, String attribute) {
if ("select".equals(attribute)) {
final String tagName = tag.getLocalName();
if ("sequence".equals(tagName)) {
final XPathType declaredType = XsltCodeInsightUtil.getDeclaredType(tag);
if (declaredType != null) {
return declaredType;
}
if (XsltSupport.isFunction(tag.getParentTag())) {
final XsltFunction func = XsltElementFactory.getInstance().wrapElement(tag.getParentTag(), XsltFunction.class);
return func.getReturnType();
}
return XPath2Type.SEQUENCE;
} else if ("value-of".equals(tagName) || "copy-of".equals(tagName) || "for-each".equals(tagName)) {
return XPath2Type.SEQUENCE;
}
} else if ("group-by".equals(attribute)) {
return XPath2Type.ITEM;
}
return super.getTypeForTag(tag, attribute);
}
示例3: getTypeForTag
import org.intellij.lang.xpath.psi.XPathType; //导入依赖的package包/类
protected XPathType getTypeForTag(XmlTag tag, String attribute) {
String tagName = tag.getLocalName();
if ("select".equals(attribute)) {
if ("copy-of".equals(tagName) || "for-each".equals(tagName) || "apply-templates".equals(tagName)) {
return XPathType.NODESET;
} else if ("value-of".equals(tagName) || "sort".equals(tagName)) {
return XPathType.STRING;
}
return XPathType.ANY;
} else if ("test".equals(attribute)) {
if ("if".equals(tagName) || "when".equals(tagName)) {
return XPathType.BOOLEAN;
}
} else if ("number".equals(attribute)) {
if ("value".equals(tagName)) {
return XPathType.NUMBER;
}
}
return XPathType.UNKNOWN;
}
示例4: getType
import org.intellij.lang.xpath.psi.XPathType; //导入依赖的package包/类
@NotNull
public XPathType getType() {
final XPathType declaredType = XsltCodeInsightUtil.getDeclaredType(getTag());
if (declaredType != null) {
return declaredType;
}
final XmlAttribute attr = getTag().getAttribute("type", XsltSupport.PLUGIN_EXTENSIONS_NS);
if (attr != null) {
return XPathType.fromString(attr.getValue());
}
final XPathExpression value = getValue();
if (value instanceof XPathVariableReference) {
// recursive reference <xsl:variable name="foo" select="$foo" />
final XPathVariableReference reference = (XPathVariableReference)value;
if (reference.resolve() == this) {
return XPathType.UNKNOWN;
}
}
return value != null ? value.getType() : XPathType.UNKNOWN;
}
示例5: doTest
import org.intellij.lang.xpath.psi.XPathType; //导入依赖的package包/类
protected XPathType doTest(boolean symmetric) throws Throwable {
myFixture.configureByFile(getTestFileName() + ".xpath2");
final XPathExpression expression = getExpression();
// all these cases must be green
myFixture.checkHighlighting();
if (symmetric && expression instanceof XPathBinaryExpression) {
final XPathBinaryExpression expr = (XPathBinaryExpression)expression;
if (expr.getLOperand().getType() != expr.getROperand().getType()) {
myFixture.configureByText(XPathFileType.XPATH2,
expr.getROperand().getText() + " " + expr.getOperationSign() + " " + expr.getLOperand().getText());
assertEquals(getExpression().getType(), expression.getType());
myFixture.checkHighlighting();
}
}
final XPathType type = expression.getType();
if (type instanceof XPath2SequenceType) {
return ((XPath2SequenceType)type).getType();
}
return type;
}
示例6: checkExpression
import org.intellij.lang.xpath.psi.XPathType; //导入依赖的package包/类
protected void checkExpression(@NotNull XPathExpression expression) {
final XPathType expectedType = ExpectedTypeUtil.getExpectedType(expression);
// conversion to NODESET is impossible (at least not in a portable way) and is flagged by annotator
if (expectedType != XPathType.NODESET && expectedType != XPathType.UNKNOWN) {
final boolean isExplicit = FLAG_EXPLICIT_CONVERSION &&
ExpectedTypeUtil.isExplicitConversion(expression);
checkExpressionOfType(expression, expectedType, isExplicit);
}
}
示例7: checkExpressionOfType
import org.intellij.lang.xpath.psi.XPathType; //导入依赖的package包/类
private void checkExpressionOfType(@NotNull XPathExpression expression, XPathType type, boolean explicit) {
final XPathType exprType = expression.getType();
if (exprType.isAbstract() || type.isAbstract()) return;
if (exprType != type && (explicit || isCheckedConversion(exprType, type))) {
if (explicit && exprType == XPathType.STRING && type == XPathType.BOOLEAN) {
final XPathExpression expr = ExpectedTypeUtil.unparenthesize(expression);
if (expr instanceof XPathFunctionCall && IGNORE_NODESET_TO_BOOLEAN_VIA_STRING &&
((XPathFunctionCall)expr).getArgumentList()[0].getType() == XPathType.NODESET)
{
return;
}
}
final LocalQuickFix[] fixes;
if (type != XPathType.NODESET) {
final XPathQuickFixFactory fixFactory = ContextProvider.getContextProvider(expression).getQuickFixFactory();
explicit = explicit && !(exprType == XPathType.STRING && type == XPathType.BOOLEAN);
fixes = fixFactory.createImplicitTypeConversionFixes(expression, type, explicit);
} else {
fixes = null;
}
addProblem(myManager.createProblemDescriptor(expression,
"Expression should be of type '" + type.getName() + "'", myOnTheFly, fixes,
ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
}
}
示例8: isSameType
import org.intellij.lang.xpath.psi.XPathType; //导入依赖的package包/类
private boolean isSameType(XPathExpression expression, XPathType convertedType) {
XPathType type = ExpectedTypeUtil.mapType(expression, expression.getType());
while (type instanceof XPath2SequenceType) {
type = ((XPath2SequenceType)type).getType();
}
while (convertedType instanceof XPath2SequenceType) {
convertedType = ((XPath2SequenceType)convertedType).getType();
}
return ExpectedTypeUtil.mapType(expression, convertedType) == type;
}
示例9: createImplicitTypeConversionFixes
import org.intellij.lang.xpath.psi.XPathType; //导入依赖的package包/类
public Fix<XPathExpression>[] createImplicitTypeConversionFixes(XPathExpression expression, XPathType type, boolean explicit) {
//noinspection unchecked
return explicit ? new Fix[]{
new RemoveExplicitConversionFix(expression),
new MakeTypeExplicitFix(expression, type),
} : new Fix[]{
new MakeTypeExplicitFix(expression, type),
};
}
示例10: getExpectedType
import org.intellij.lang.xpath.psi.XPathType; //导入依赖的package包/类
@NotNull
public XPathType getExpectedType(XPathExpression expr) {
final XmlTag tag = PsiTreeUtil.getContextOfType(expr, XmlTag.class, true);
if (tag != null && XsltSupport.isXsltTag(tag)) {
final XsltElement element = XsltElementFactory.getInstance().wrapElement(tag, XsltElement.class);
if (element instanceof XsltVariable) {
return ((XsltVariable)element).getType();
} else {
final XmlAttribute attr = PsiTreeUtil.getContextOfType(expr, XmlAttribute.class, true);
if (attr != null) {
if (element instanceof XsltWithParam) {
final XmlAttribute nameAttr = tag.getAttribute("name", null);
if (nameAttr != null) {
final XmlAttributeValue valueElement = nameAttr.getValueElement();
if (valueElement != null) {
final PsiReference[] references = valueElement.getReferences();
for (PsiReference reference : references) {
final PsiElement psiElement = reference.resolve();
if (psiElement instanceof XsltVariable) {
return ((XsltVariable)psiElement).getType();
}
}
}
}
} else {
final String name = attr.getName();
return getTypeForTag(tag, name);
}
}
}
}
return XPathType.UNKNOWN;
}
示例11: getFunction
import org.intellij.lang.xpath.psi.XPathType; //导入依赖的package包/类
private Function getFunction() {
final XPathType returnType = XsltCodeInsightUtil.getDeclaredType(getTag());
final XmlTag[] params = getTag().findSubTags("param", XsltSupport.XSLT_NS);
final Parameter[] parameters = ContainerUtil.map2Array(params, Parameter.class, PARAM_MAPPER);
return new FunctionImpl(null, returnType != null ? returnType : XPathType.UNKNOWN, parameters) {
@Override
public String getName() {
return getQName().getLocalPart();
}
};
}
示例12: mapType
import org.intellij.lang.xpath.psi.XPathType; //导入依赖的package包/类
public static XPathType mapType(String type, XPath2SequenceType.Cardinality c) {
if ("none".equals(type)) {
return XPathType.UNKNOWN;
}
XPathType r = null;
if ("numeric".equals(type)) {
r = XPath2Type.NUMERIC;
} else if (type.startsWith("xs:")) {
final String base = type.substring(3);
r = XPath2Type.fromName(new QName(XPath2Type.XMLSCHEMA_NS, base));
if (r == null) {
r = XPathType.fromString(base);
}
} else {
if (type.endsWith("()")) {
r = XPath2Type.fromName(new QName("", type));
}
}
if (r != null) {
if (c != null) {
r = XPath2SequenceType.create(r, c);
}
return r;
}
return XPathType.fromString(type);
}
示例13: getType
import org.intellij.lang.xpath.psi.XPathType; //导入依赖的package包/类
@NotNull
public XPathType getType() {
if (getXPathVersion() == XPathVersion.V1) {
return XPathType.NUMBER;
} else {
if (isScientificNotation()) {
return XPath2Type.DOUBLE;
} else if (textContains('.')) {
return XPath2Type.DECIMAL;
}
return XPath2Type.INTEGER;
}
}
示例14: testBooleanAssignability
import org.intellij.lang.xpath.psi.XPathType; //导入依赖的package包/类
public void testBooleanAssignability() {
// via "effective boolean value"
assertTrue(XPathType.isAssignable(XPath2Type.BOOLEAN, XPath2Type.STRING));
assertTrue(XPathType.isAssignable(XPath2Type.BOOLEAN, XPath2Type.NUMERIC));
assertTrue(XPathType.isAssignable(XPath2Type.BOOLEAN, XPath2Type.INTEGER));
assertFalse(XPathType.isAssignable(XPath2Type.BOOLEAN_STRICT, XPath2Type.STRING));
}
示例15: testNumericAssignability
import org.intellij.lang.xpath.psi.XPathType; //导入依赖的package包/类
public void testNumericAssignability() {
assertTrue(XPathType.isAssignable(XPath2Type.FLOAT, XPath2Type.INTEGER));
assertTrue(XPathType.isAssignable(XPath2Type.FLOAT, XPath2Type.DECIMAL));
assertTrue(XPathType.isAssignable(XPath2Type.DOUBLE, XPath2Type.FLOAT));
assertTrue(XPathType.isAssignable(XPath2Type.DOUBLE, XPath2Type.INTEGER));
assertTrue(XPathType.isAssignable(XPath2Type.DOUBLE, XPath2Type.DECIMAL));
assertFalse(XPathType.isAssignable(XPath2Type.FLOAT, XPath2Type.DOUBLE));
assertFalse(XPathType.isAssignable(XPath2Type.DECIMAL, XPath2Type.DOUBLE));
assertFalse(XPathType.isAssignable(XPath2Type.NUMERIC, XPath2Type.BOOLEAN));
}