use of org.intellij.lang.xpath.psi.XPathExpression in project intellij-community by JetBrains.
the class HardwiredNamespacePrefix method createVisitor.
protected Visitor createVisitor(final InspectionManager manager, final boolean isOnTheFly) {
return new Visitor(manager, isOnTheFly) {
protected void checkExpression(XPathExpression expression) {
if (!(expression instanceof XPathBinaryExpression)) {
return;
}
final XPathBinaryExpression expr = (XPathBinaryExpression) expression;
if (expr.getOperator() == XPathTokenTypes.EQ) {
final XPathExpression lop = expr.getLOperand();
final XPathExpression rop = expr.getROperand();
if (isNameComparison(lop, rop)) {
assert rop != null;
final ProblemDescriptor p = manager.createProblemDescriptor(rop, "Hardwired namespace prefix", isOnTheFly, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
addProblem(p);
} else if (isNameComparison(rop, lop)) {
assert lop != null;
final ProblemDescriptor p = manager.createProblemDescriptor(lop, "Hardwired namespace prefix", isOnTheFly, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
addProblem(p);
} else if (isNameFunctionCall(lop)) {
// TODO
} else if (isNameFunctionCall(rop)) {
// TODO
}
}
}
};
}
use of org.intellij.lang.xpath.psi.XPathExpression in project intellij-community by JetBrains.
the class MakeTypeExplicitFix method invokeImpl.
public void invokeImpl(Project project, PsiFile file) throws IncorrectOperationException {
XPathExpression myElement = (XPathExpression) getStartElement();
if (myType == XPathType.BOOLEAN) {
if (myElement.getType() == XPathType.STRING) {
final String text;
if (ExpectedTypeUtil.isExplicitConversion(myElement)) {
final XPathExpression expr = ExpectedTypeUtil.unparenthesize(myElement);
assert expr != null;
text = ((XPathFunctionCall) expr).getArgumentList()[0].getText();
} else {
text = myElement.getText();
}
replace("string-length(" + text + ") > 0");
return;
} else if (myElement.getType() == XPathType.NODESET) {
replace("count(" + myElement.getText() + ") > 0");
return;
}
}
replace(myType.getName() + "(" + myElement.getText() + ")");
}
use of org.intellij.lang.xpath.psi.XPathExpression in project intellij-community by JetBrains.
the class XsltVariableImpl method getType.
@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;
}
use of org.intellij.lang.xpath.psi.XPathExpression in project intellij-community by JetBrains.
the class XPath2ExpressionTest method getExpression.
private XPathExpression getExpression() throws NoSuchMethodException {
final XPathFile file = (XPathFile) myFixture.getFile();
final XPathExpression expression = file.getExpression();
assertNotNull(expression);
return expression;
}
use of org.intellij.lang.xpath.psi.XPathExpression in project intellij-community by JetBrains.
the class XPath2ExpressionTest method doTest.
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;
}
Aggregations