当前位置: 首页>>代码示例>>Java>>正文


Java XPathType类代码示例

本文整理汇总了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;
        }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ImplicitTypeConversion.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:Xslt2ContextProvider.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:XsltContextProviderBase.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:XsltVariableImpl.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:XPath2ExpressionTest.java

示例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);
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ImplicitTypeConversion.java

示例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));
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:ImplicitTypeConversion.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:RedundantTypeConversion.java

示例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),
    };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:XsltQuickFixFactory.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:XsltContextProviderBase.java

示例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();
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:XsltFunctionImpl.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:FunctionDeclarationParsing.java

示例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;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:XPathNumberImpl.java

示例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));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:XPath2StaticTypeTest.java

示例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));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:XPath2StaticTypeTest.java


注:本文中的org.intellij.lang.xpath.psi.XPathType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。