use of org.intellij.lang.xpath.psi.XPathBinaryExpression 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.XPathBinaryExpression 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;
}
use of org.intellij.lang.xpath.psi.XPathBinaryExpression in project intellij-community by JetBrains.
the class RemoveExplicitConversionFix method invokeImpl.
public void invokeImpl(Project project, PsiFile file) throws IncorrectOperationException {
PsiElement myElement = getStartElement();
final XPathExpression arg0 = ((XPathFunctionCall) myElement).getArgumentList()[0];
final XPathExpression outer = PsiTreeUtil.getParentOfType(myElement, XPathExpression.class);
if (arg0 instanceof XPathBinaryExpression && outer instanceof XPathBinaryExpression) {
// TODO make this smarter by determining operator precedence
replace("(" + arg0.getText() + ")");
} else {
replace(arg0.getText());
}
}
Aggregations