mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-67727: Quickfix
This commit is contained in:
+2
-2
@@ -24,11 +24,11 @@ import org.intellij.lang.xpath.psi.XPathBinaryExpression;
|
||||
import org.intellij.lang.xpath.psi.impl.XPathChangeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class ConsecutiveComparisonFix implements IntentionAction {
|
||||
class ExpressionReplacementFix implements IntentionAction {
|
||||
private final String myReplacement;
|
||||
private final XPathBinaryExpression myExpr;
|
||||
|
||||
public ConsecutiveComparisonFix(String replacement, XPathBinaryExpression expr) {
|
||||
public ExpressionReplacementFix(String replacement, XPathBinaryExpression expr) {
|
||||
myReplacement = replacement;
|
||||
myExpr = expr;
|
||||
}
|
||||
+12
-2
@@ -112,7 +112,14 @@ public final class XPathAnnotator extends XPath2ElementVisitor implements Annota
|
||||
if (operator != XPathTokenTypes.STAR && XPath2TokenTypes.KEYWORDS.contains(operator)) {
|
||||
final String op = o.getOperationSign();
|
||||
if (o.getText().startsWith(operand.getText() + op)) {
|
||||
myHolder.createErrorAnnotation(o, "Number literal must be followed by whitespace in XPath 2");
|
||||
final Annotation annotation =
|
||||
myHolder.createErrorAnnotation(o, "Number literal must be followed by whitespace in XPath 2");
|
||||
|
||||
final XPathExpression rOperand = o.getROperand();
|
||||
if (rOperand != null) {
|
||||
final String replacement = operand.getText() + " " + op + " " + rOperand.getText();
|
||||
annotation.registerFix(new ExpressionReplacementFix(replacement, o));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,7 +130,7 @@ public final class XPathAnnotator extends XPath2ElementVisitor implements Annota
|
||||
final XPathExpression rOperand = o.getROperand();
|
||||
if (rOperand != null) {
|
||||
final String replacement = "(" + operand.getText() + ") " + o.getOperationSign() + " " + rOperand.getText();
|
||||
annotation.registerFix(new ConsecutiveComparisonFix(replacement, o));
|
||||
annotation.registerFix(new ExpressionReplacementFix(replacement, o));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,6 +210,9 @@ public final class XPathAnnotator extends XPath2ElementVisitor implements Annota
|
||||
|
||||
private static void checkFunctionCall(AnnotationHolder holder, XPathFunctionCall call, @NotNull ContextProvider contextProvider) {
|
||||
final ASTNode node = call.getNode().findChildByType(XPathTokenTypes.FUNCTION_NAME);
|
||||
if (node == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final QName name = contextProvider.getQName(call);
|
||||
final XPathFunction function = call.resolve();
|
||||
|
||||
Reference in New Issue
Block a user