mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
XPath Visitor Support
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.intellij.lang.xpath.psi;
|
||||
|
||||
import org.intellij.lang.xpath.psi.impl.XPath2ElementImpl;
|
||||
|
||||
/*
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: sweinreuter
|
||||
* Date: 08.04.11
|
||||
*/
|
||||
public class XPath2ElementVisitor extends XPathElementVisitor {
|
||||
public void visitXPath2TypeReference(XPath2TypeReference o) {
|
||||
visitXPathElement(o);
|
||||
}
|
||||
|
||||
public void visitXPath2InstanceOf(XPath2InstanceOf o) {
|
||||
visitXPathExpression(o);
|
||||
// visitXPath2TypeReference(o);
|
||||
}
|
||||
|
||||
public void visitXPath2QuantifiedExpr(XPath2QuantifiedExpr o) {
|
||||
visitXPathExpression(o);
|
||||
// visitXPathVariableDeclaration(o);
|
||||
}
|
||||
|
||||
public void visitXPath2TreatAs(XPath2TreatAs o) {
|
||||
visitXPathExpression(o);
|
||||
// visitXPath2TypeReference(o);
|
||||
}
|
||||
|
||||
public void visitXPath2If(XPath2If o) {
|
||||
visitXPathExpression(o);
|
||||
}
|
||||
|
||||
public void visitXPath2Cast(XPath2Cast o) {
|
||||
visitXPathExpression(o);
|
||||
// visitXPath2TypeReference(o);
|
||||
}
|
||||
|
||||
public void visitXPathVariableDeclaration(XPathVariableDeclaration o) {
|
||||
visitXPathElement(o);
|
||||
}
|
||||
|
||||
public void visitXPath2Sequence(XPath2Sequence o) {
|
||||
visitXPathExpression(o);
|
||||
}
|
||||
|
||||
public void visitXPath2For(XPath2For o) {
|
||||
visitXPathExpression(o);
|
||||
// visitXPathVariableDeclaration(o);
|
||||
}
|
||||
|
||||
public void visitXPath2TypeElement(XPath2TypeElement o) {
|
||||
visitQNameElement(o);
|
||||
}
|
||||
|
||||
public void visitXPath2Castable(XPath2Castable o) {
|
||||
visitXPathExpression(o);
|
||||
// visitXPath2TypeReference(o);
|
||||
}
|
||||
|
||||
public void visitXPath2RangeExpression(XPath2RangeExpression o) {
|
||||
visitXPathExpression(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitXPathElement(XPathElement o) {
|
||||
if (o instanceof XPath2ElementImpl) {
|
||||
visitXPath2Element(o);
|
||||
} else {
|
||||
super.visitXPathElement(o);
|
||||
}
|
||||
}
|
||||
|
||||
public void visitXPath2Element(XPathElement element) {
|
||||
super.visitXPathElement(element);
|
||||
}
|
||||
}
|
||||
@@ -28,4 +28,7 @@ public interface XPathBinaryExpression extends XPathExpression {
|
||||
|
||||
@NotNull
|
||||
XPathElementType getOperator();
|
||||
|
||||
@NotNull
|
||||
String getOperationSign();
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.intellij.lang.xpath.psi;
|
||||
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
|
||||
/*
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: sweinreuter
|
||||
* Date: 08.04.11
|
||||
*/
|
||||
public class XPathElementVisitor extends PsiElementVisitor {
|
||||
public void visitXPathString(XPathString o) {
|
||||
visitXPathExpression(o);
|
||||
}
|
||||
|
||||
public void visitXPathPrefixExpression(XPathPrefixExpression o) {
|
||||
visitXPathExpression(o);
|
||||
}
|
||||
|
||||
public void visitXPathVariable(XPathVariable o) {
|
||||
visitXPathElement(o);
|
||||
}
|
||||
|
||||
public void visitXPathToken(XPathToken o) {
|
||||
visitXPathElement(o);
|
||||
}
|
||||
|
||||
public void visitXPathNodeTypeTest(XPathNodeTypeTest o) {
|
||||
visitXPathFunctionCall(o);
|
||||
}
|
||||
|
||||
public void visitXPathPredicate(XPathPredicate o) {
|
||||
visitXPathElement(o);
|
||||
}
|
||||
|
||||
public void visitQNameElement(QNameElement o) {
|
||||
visitXPathElement(o);
|
||||
}
|
||||
|
||||
public void visitXPathNodeTest(XPathNodeTest o) {
|
||||
visitQNameElement(o);
|
||||
}
|
||||
|
||||
public void visitXPathFunctionCall(XPathFunctionCall o) {
|
||||
visitXPathExpression(o);
|
||||
// visitQNameElement(o);
|
||||
}
|
||||
|
||||
public void visitXPathBinaryExpression(XPathBinaryExpression o) {
|
||||
visitXPathExpression(o);
|
||||
}
|
||||
|
||||
public void visitXPathExpression(XPathExpression o) {
|
||||
visitXPathElement(o);
|
||||
}
|
||||
|
||||
public void visitXPathParenthesizedExpression(XPathParenthesizedExpression o) {
|
||||
visitXPathExpression(o);
|
||||
}
|
||||
|
||||
public void visitXPathStep(XPathStep o) {
|
||||
visitXPathExpression(o);
|
||||
}
|
||||
|
||||
public void visitXPathAxisSpecifier(XPathAxisSpecifier o) {
|
||||
visitXPathElement(o);
|
||||
}
|
||||
|
||||
public void visitXPathNumber(XPathNumber o) {
|
||||
visitXPathExpression(o);
|
||||
}
|
||||
|
||||
public void visitXPathVariableReference(XPathVariableReference o) {
|
||||
visitXPathExpression(o);
|
||||
// visitQNameElement(o);
|
||||
}
|
||||
|
||||
public void visitXPathFilterExpression(XPathFilterExpression o) {
|
||||
visitXPathExpression(o);
|
||||
}
|
||||
|
||||
public void visitXPathFunction(XPathFunction o) {
|
||||
visitXPathElement(o);
|
||||
}
|
||||
|
||||
public void visitXPathLocationPath(XPathLocationPath o) {
|
||||
visitXPathExpression(o);
|
||||
}
|
||||
|
||||
public void visitXPathElement(XPathElement o) {
|
||||
visitElement(o);
|
||||
}
|
||||
}
|
||||
@@ -17,12 +17,13 @@ package org.intellij.lang.xpath.psi.impl;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import org.intellij.lang.xpath.psi.XPath2Cast;
|
||||
import org.intellij.lang.xpath.psi.XPath2ElementVisitor;
|
||||
import org.intellij.lang.xpath.psi.XPath2TypeElement;
|
||||
import org.intellij.lang.xpath.psi.XPathType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class XPath2CastImpl extends XPathElementImpl implements XPath2Cast {
|
||||
public class XPath2CastImpl extends XPath2ElementImpl implements XPath2Cast {
|
||||
public XPath2CastImpl(ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
@@ -39,4 +40,8 @@ public class XPath2CastImpl extends XPathElementImpl implements XPath2Cast {
|
||||
final XPathType type = getTargetType();
|
||||
return type != null ? type : XPathType.UNKNOWN;
|
||||
}
|
||||
|
||||
public void accept(XPath2ElementVisitor visitor) {
|
||||
visitor.visitXPath2Cast(this);
|
||||
}
|
||||
}
|
||||
+6
-5
@@ -16,14 +16,11 @@
|
||||
package org.intellij.lang.xpath.psi.impl;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import org.intellij.lang.xpath.psi.XPath2Castable;
|
||||
import org.intellij.lang.xpath.psi.XPath2Type;
|
||||
import org.intellij.lang.xpath.psi.XPath2TypeElement;
|
||||
import org.intellij.lang.xpath.psi.XPathType;
|
||||
import org.intellij.lang.xpath.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class XPath2CastableImpl extends XPathElementImpl implements XPath2Castable {
|
||||
public class XPath2CastableImpl extends XPath2ElementImpl implements XPath2Castable {
|
||||
public XPath2CastableImpl(ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
@@ -40,4 +37,8 @@ public class XPath2CastableImpl extends XPathElementImpl implements XPath2Castab
|
||||
public XPathType getType() {
|
||||
return XPath2Type.BOOLEAN;
|
||||
}
|
||||
|
||||
public void accept(XPath2ElementVisitor visitor) {
|
||||
visitor.visitXPath2Castable(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.intellij.lang.xpath.psi.impl;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import org.intellij.lang.xpath.psi.XPath2ElementVisitor;
|
||||
import org.intellij.lang.xpath.psi.XPathElementVisitor;
|
||||
|
||||
/*
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: sweinreuter
|
||||
* Date: 08.04.11
|
||||
*/
|
||||
public class XPath2ElementImpl extends XPathElementImpl {
|
||||
public XPath2ElementImpl(ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
public void accept(XPath2ElementVisitor visitor) {
|
||||
visitor.visitXPath2Element(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void accept(XPathElementVisitor visitor) {
|
||||
if (visitor instanceof XPath2ElementVisitor) {
|
||||
accept((XPath2ElementVisitor)visitor);
|
||||
} else {
|
||||
super.accept(visitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,12 +18,13 @@ package org.intellij.lang.xpath.psi.impl;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.intellij.lang.xpath.XPath2ElementTypes;
|
||||
import org.intellij.lang.xpath.psi.XPath2ElementVisitor;
|
||||
import org.intellij.lang.xpath.psi.XPath2For;
|
||||
import org.intellij.lang.xpath.psi.XPathExpression;
|
||||
import org.intellij.lang.xpath.psi.XPathType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class XPath2ForImpl extends XPath2VariableDeclarationImpl implements XPath2For {
|
||||
public class XPath2ForImpl extends XPath2VariableDeclarationImpl implements XPath2For {
|
||||
public XPath2ForImpl(ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
@@ -39,4 +40,8 @@ public class XPath2ForImpl extends XPath2VariableDeclarationImpl implements XPa
|
||||
final ASTNode node = getNode().findChildByType(XPath2ElementTypes.BODY);
|
||||
return node != null ? PsiTreeUtil.findChildOfType(node.getPsi(), XPathExpression.class) : null;
|
||||
}
|
||||
|
||||
public void accept(XPath2ElementVisitor visitor) {
|
||||
visitor.visitXPath2For(this);
|
||||
}
|
||||
}
|
||||
@@ -16,12 +16,13 @@
|
||||
package org.intellij.lang.xpath.psi.impl;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import org.intellij.lang.xpath.psi.XPath2ElementVisitor;
|
||||
import org.intellij.lang.xpath.psi.XPath2If;
|
||||
import org.intellij.lang.xpath.psi.XPathExpression;
|
||||
import org.intellij.lang.xpath.psi.XPathType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class XPath2IfImpl extends XPathElementImpl implements XPath2If {
|
||||
public class XPath2IfImpl extends XPath2ElementImpl implements XPath2If {
|
||||
public XPath2IfImpl(ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
@@ -48,4 +49,8 @@ public class XPath2IfImpl extends XPathElementImpl implements XPath2If {
|
||||
public XPathExpression getElseBranch() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void accept(XPath2ElementVisitor visitor) {
|
||||
visitor.visitXPath2If(this);
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -20,7 +20,7 @@ import org.intellij.lang.xpath.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class XPath2InstanceOfImpl extends XPathElementImpl implements XPath2InstanceOf {
|
||||
public class XPath2InstanceOfImpl extends XPath2ElementImpl implements XPath2InstanceOf {
|
||||
public XPath2InstanceOfImpl(ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
@@ -37,4 +37,8 @@ public class XPath2InstanceOfImpl extends XPathElementImpl implements XPath2Inst
|
||||
public XPathType getType() {
|
||||
return XPath2Type.BOOLEAN;
|
||||
}
|
||||
|
||||
public void accept(XPath2ElementVisitor visitor) {
|
||||
visitor.visitXPath2InstanceOf(this);
|
||||
}
|
||||
}
|
||||
+5
@@ -18,6 +18,7 @@ package org.intellij.lang.xpath.psi.impl;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.intellij.lang.xpath.XPath2ElementTypes;
|
||||
import org.intellij.lang.xpath.psi.XPath2ElementVisitor;
|
||||
import org.intellij.lang.xpath.psi.XPath2QuantifiedExpr;
|
||||
import org.intellij.lang.xpath.psi.XPathExpression;
|
||||
import org.intellij.lang.xpath.psi.XPathType;
|
||||
@@ -38,4 +39,8 @@ public class XPath2QuantifiedExprImpl extends XPath2VariableDeclarationImpl impl
|
||||
final ASTNode node = getNode().findChildByType(XPath2ElementTypes.BODY);
|
||||
return node != null ? PsiTreeUtil.findChildOfType(node.getPsi(), XPathExpression.class) : null;
|
||||
}
|
||||
|
||||
public void accept(XPath2ElementVisitor visitor) {
|
||||
visitor.visitXPath2QuantifiedExpr(this);
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -19,7 +19,7 @@ import com.intellij.lang.ASTNode;
|
||||
import org.intellij.lang.xpath.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class XPath2RangeExpressionImpl extends XPathElementImpl implements XPath2RangeExpression {
|
||||
public class XPath2RangeExpressionImpl extends XPath2ElementImpl implements XPath2RangeExpression {
|
||||
public XPath2RangeExpressionImpl(ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
@@ -41,4 +41,8 @@ public class XPath2RangeExpressionImpl extends XPathElementImpl implements XPath
|
||||
public XPathType getType() {
|
||||
return XPath2SequenceType.create(XPath2Type.INTEGER, XPath2SequenceType.Cardinality.ZERO_OR_MORE);
|
||||
}
|
||||
|
||||
public void accept(XPath2ElementVisitor visitor) {
|
||||
visitor.visitXPath2RangeExpression(this);
|
||||
}
|
||||
}
|
||||
+6
-5
@@ -16,13 +16,10 @@
|
||||
package org.intellij.lang.xpath.psi.impl;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import org.intellij.lang.xpath.psi.XPath2Sequence;
|
||||
import org.intellij.lang.xpath.psi.XPath2Type;
|
||||
import org.intellij.lang.xpath.psi.XPathExpression;
|
||||
import org.intellij.lang.xpath.psi.XPathType;
|
||||
import org.intellij.lang.xpath.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class XPath2SequenceImpl extends XPathElementImpl implements XPath2Sequence {
|
||||
public class XPath2SequenceImpl extends XPath2ElementImpl implements XPath2Sequence {
|
||||
public XPath2SequenceImpl(ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
@@ -38,4 +35,8 @@ public class XPath2SequenceImpl extends XPathElementImpl implements XPath2Sequen
|
||||
public XPathType getType() {
|
||||
return XPath2Type.SEQUENCE;
|
||||
}
|
||||
|
||||
public void accept(XPath2ElementVisitor visitor) {
|
||||
visitor.visitXPath2Sequence(this);
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -16,12 +16,13 @@
|
||||
package org.intellij.lang.xpath.psi.impl;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import org.intellij.lang.xpath.psi.XPath2ElementVisitor;
|
||||
import org.intellij.lang.xpath.psi.XPath2TreatAs;
|
||||
import org.intellij.lang.xpath.psi.XPath2TypeElement;
|
||||
import org.intellij.lang.xpath.psi.XPathType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class XPath2TreatAsImpl extends XPathElementImpl implements XPath2TreatAs {
|
||||
public class XPath2TreatAsImpl extends XPath2ElementImpl implements XPath2TreatAs {
|
||||
public XPath2TreatAsImpl(ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
@@ -37,4 +38,8 @@ public class XPath2TreatAsImpl extends XPathElementImpl implements XPath2TreatAs
|
||||
final XPath2TypeElement node = findChildByClass(XPath2TypeElement.class);
|
||||
return node != null ? node.getDeclaredType() : XPathType.UNKNOWN;
|
||||
}
|
||||
|
||||
public void accept(XPath2ElementVisitor visitor) {
|
||||
visitor.visitXPath2TreatAs(this);
|
||||
}
|
||||
}
|
||||
+6
-5
@@ -19,15 +19,12 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.intellij.lang.xpath.XPathTokenTypes;
|
||||
import org.intellij.lang.xpath.psi.PrefixedName;
|
||||
import org.intellij.lang.xpath.psi.XPath2Type;
|
||||
import org.intellij.lang.xpath.psi.XPath2TypeElement;
|
||||
import org.intellij.lang.xpath.psi.XPathType;
|
||||
import org.intellij.lang.xpath.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
public class XPath2TypeElementImpl extends XPathElementImpl implements XPath2TypeElement {
|
||||
public class XPath2TypeElementImpl extends XPath2ElementImpl implements XPath2TypeElement {
|
||||
public XPath2TypeElementImpl(ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
@@ -83,4 +80,8 @@ public class XPath2TypeElementImpl extends XPathElementImpl implements XPath2Typ
|
||||
}
|
||||
return super.getReferences();
|
||||
}
|
||||
|
||||
public void accept(XPath2ElementVisitor visitor) {
|
||||
visitor.visitXPath2TypeElement(this);
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -19,6 +19,7 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.intellij.lang.xpath.XPath2ElementTypes;
|
||||
import org.intellij.lang.xpath.psi.XPath2ElementVisitor;
|
||||
import org.intellij.lang.xpath.psi.XPathExpression;
|
||||
import org.intellij.lang.xpath.psi.XPathVariable;
|
||||
import org.intellij.lang.xpath.psi.XPathVariableDeclaration;
|
||||
@@ -31,7 +32,7 @@ import java.util.List;
|
||||
* User: sweinreuter
|
||||
* Date: 10.01.11
|
||||
*/
|
||||
public class XPath2VariableDeclarationImpl extends XPathElementImpl implements XPathVariableDeclaration {
|
||||
public class XPath2VariableDeclarationImpl extends XPath2ElementImpl implements XPathVariableDeclaration {
|
||||
public XPath2VariableDeclarationImpl(ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
@@ -61,4 +62,8 @@ public class XPath2VariableDeclarationImpl extends XPathElementImpl implements X
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void accept(XPath2ElementVisitor visitor) {
|
||||
visitor.visitXPathVariableDeclaration(this);
|
||||
}
|
||||
}
|
||||
@@ -53,4 +53,8 @@ public class XPath2VariableImpl extends XPathElementImpl implements XPathVariabl
|
||||
public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException {
|
||||
return replace(XPathChangeUtil.createVariableReference(this, name));
|
||||
}
|
||||
|
||||
public void accept(XPathElementVisitor visitor) {
|
||||
visitor.visitXPathVariable(this);
|
||||
}
|
||||
}
|
||||
+5
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.intellij.lang.xpath.psi.impl;
|
||||
|
||||
import org.intellij.lang.xpath.psi.XPathElementVisitor;
|
||||
import org.intellij.lang.xpath.psi.XPathAxisSpecifier;
|
||||
import org.intellij.lang.xpath.psi.Axis;
|
||||
import org.intellij.lang.xpath.XPathTokenTypes;
|
||||
@@ -43,4 +44,8 @@ public class XPathAxisSpecifierImpl extends XPathElementImpl implements XPathAxi
|
||||
final boolean b = node.getChildren(XPathTokenTypes.AXIS).length == 0;
|
||||
return b && node.findChildByType(XPathTokenTypes.AT) == null;
|
||||
}
|
||||
|
||||
public void accept(XPathElementVisitor visitor) {
|
||||
visitor.visitXPathAxisSpecifier(this);
|
||||
}
|
||||
}
|
||||
+12
-4
@@ -18,10 +18,7 @@ package org.intellij.lang.xpath.psi.impl;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.intellij.lang.xpath.*;
|
||||
import org.intellij.lang.xpath.psi.XPath2Type;
|
||||
import org.intellij.lang.xpath.psi.XPathBinaryExpression;
|
||||
import org.intellij.lang.xpath.psi.XPathExpression;
|
||||
import org.intellij.lang.xpath.psi.XPathType;
|
||||
import org.intellij.lang.xpath.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -55,6 +52,13 @@ public class XPathBinaryExpressionImpl extends XPathElementImpl implements XPath
|
||||
return elementType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getOperationSign() {
|
||||
final ASTNode[] nodes = getNode().getChildren(BINARY_OPERATIONS);
|
||||
return nodes[0].getText();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public XPathType getType() {
|
||||
final XPathElementType operator = getOperator();
|
||||
@@ -132,4 +136,8 @@ public class XPathBinaryExpressionImpl extends XPathElementImpl implements XPath
|
||||
private static boolean is(XPathExpression op, XPathType type) {
|
||||
return op != null && (type instanceof XPath2Type ? type.isAssignableFrom(op.getType()) : type == op.getType());
|
||||
}
|
||||
|
||||
public void accept(XPathElementVisitor visitor) {
|
||||
visitor.visitXPathBinaryExpression(this);
|
||||
}
|
||||
}
|
||||
@@ -16,18 +16,17 @@
|
||||
|
||||
package org.intellij.lang.xpath.psi.impl;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFileFactory;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.LocalTimeCounter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import org.intellij.lang.xpath.XPathFile;
|
||||
import org.intellij.lang.xpath.XPathFileType;
|
||||
import org.intellij.lang.xpath.context.ContextProvider;
|
||||
import org.intellij.lang.xpath.psi.XPathExpression;
|
||||
import org.intellij.lang.xpath.psi.XPathVariableReference;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class XPathChangeUtil {
|
||||
private XPathChangeUtil() {
|
||||
@@ -48,13 +47,13 @@ public class XPathChangeUtil {
|
||||
|
||||
@NotNull
|
||||
public static XPathFile createXPathFile(PsiElement context, String text) {
|
||||
final XPathFile file = createXPathFile(context.getProject(), text);
|
||||
final XPathFile file = createXPathFile(context.getProject(), text, context.getContainingFile().getFileType());
|
||||
ContextProvider.copy(context.getContainingFile(), file);
|
||||
return file;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static XPathFile createXPathFile(Project project, String text) {
|
||||
return (XPathFile)PsiFileFactory.getInstance(project).createFileFromText("dummy.xpath", XPathFileType.XPATH, text, LocalTimeCounter.currentTime(), true);
|
||||
public static XPathFile createXPathFile(Project project, String text, FileType fileType) {
|
||||
return (XPathFile)PsiFileFactory.getInstance(project).createFileFromText("dummy." + fileType.getDefaultExtension(), fileType, text, LocalTimeCounter.currentTime(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.extapi.psi.ASTWrapperPsiElement;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.intellij.lang.xpath.XPath2ElementTypes;
|
||||
import org.intellij.lang.xpath.XPathElementTypes;
|
||||
@@ -27,6 +28,7 @@ import org.intellij.lang.xpath.XPathTokenTypes;
|
||||
import org.intellij.lang.xpath.context.ContextProvider;
|
||||
import org.intellij.lang.xpath.context.XPathVersion;
|
||||
import org.intellij.lang.xpath.psi.XPathElement;
|
||||
import org.intellij.lang.xpath.psi.XPathElementVisitor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class XPathElementImpl extends ASTWrapperPsiElement implements XPathElement {
|
||||
@@ -125,4 +127,17 @@ public class XPathElementImpl extends ASTWrapperPsiElement implements XPathEleme
|
||||
public XPathVersion getXPathVersion() {
|
||||
return getContainingFile().getXPathVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void accept(@NotNull PsiElementVisitor visitor) {
|
||||
if (visitor instanceof XPathElementVisitor) {
|
||||
accept((XPathElementVisitor)visitor);
|
||||
} else {
|
||||
super.accept(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
public void accept(XPathElementVisitor visitor) {
|
||||
visitor.visitXPathElement(this);
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -54,4 +54,8 @@ public class XPathFilterExpressionImpl extends XPathElementImpl implements XPath
|
||||
assert nodes.length == 1;
|
||||
return (XPathPredicate)nodes[0].getPsi();
|
||||
}
|
||||
|
||||
public void accept(XPathElementVisitor visitor) {
|
||||
visitor.visitXPathFilterExpression(this);
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -280,6 +280,14 @@ public class XPathFunctionCallImpl extends XPathElementImpl implements XPathFunc
|
||||
public XPathVersion getXPathVersion() {
|
||||
return getElement().getXPathVersion();
|
||||
}
|
||||
|
||||
public void accept(XPathElementVisitor visitor) {
|
||||
visitor.visitXPathFunction(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void accept(XPathElementVisitor visitor) {
|
||||
visitor.visitXPathFunctionCall(this);
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -48,4 +48,8 @@ public class XPathLocationPathImpl extends XPathElementImpl implements XPathLoca
|
||||
final XPathExpression pathExpression = getFirstStep();
|
||||
return pathExpression instanceof XPathStep && ((XPathStep)pathExpression).isAbsolute();
|
||||
}
|
||||
|
||||
public void accept(XPathElementVisitor visitor) {
|
||||
visitor.visitXPathLocationPath(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,4 +116,8 @@ public class XPathNodeTestImpl extends XPathElementImpl implements XPathNodeTest
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
}
|
||||
|
||||
public void accept(XPathElementVisitor visitor) {
|
||||
visitor.visitXPathNodeTest(this);
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -16,6 +16,7 @@
|
||||
package org.intellij.lang.xpath.psi.impl;
|
||||
|
||||
import org.intellij.lang.xpath.XPathTokenTypes;
|
||||
import org.intellij.lang.xpath.psi.XPathElementVisitor;
|
||||
import org.intellij.lang.xpath.psi.NodeType;
|
||||
import org.intellij.lang.xpath.psi.XPathNodeTypeTest;
|
||||
import org.intellij.lang.xpath.psi.XPathType;
|
||||
@@ -47,4 +48,8 @@ public class XPathNodeTypeTestImpl extends XPathFunctionCallImpl implements XPat
|
||||
protected ASTNode getNameNode() {
|
||||
return getNode().findChildByType(XPathTokenTypes.NODE_TYPE);
|
||||
}
|
||||
|
||||
public void accept(final XPathElementVisitor visitor) {
|
||||
visitor.visitXPathNodeTypeTest(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.intellij.lang.xpath.psi.impl;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import org.intellij.lang.xpath.context.XPathVersion;
|
||||
import org.intellij.lang.xpath.psi.XPathElementVisitor;
|
||||
import org.intellij.lang.xpath.psi.XPath2Type;
|
||||
import org.intellij.lang.xpath.psi.XPathNumber;
|
||||
import org.intellij.lang.xpath.psi.XPathType;
|
||||
@@ -36,4 +37,8 @@ public class XPathNumberImpl extends XPathElementImpl implements XPathNumber {
|
||||
public double getValue() {
|
||||
return Double.parseDouble(getText());
|
||||
}
|
||||
|
||||
public void accept(XPathElementVisitor visitor) {
|
||||
visitor.visitXPathNumber(this);
|
||||
}
|
||||
}
|
||||
+5
@@ -17,6 +17,7 @@ package org.intellij.lang.xpath.psi.impl;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import org.intellij.lang.xpath.XPath2ElementTypes;
|
||||
import org.intellij.lang.xpath.psi.XPathElementVisitor;
|
||||
import org.intellij.lang.xpath.psi.XPathExpression;
|
||||
import org.intellij.lang.xpath.psi.XPathParenthesizedExpression;
|
||||
import org.intellij.lang.xpath.psi.XPathType;
|
||||
@@ -39,4 +40,8 @@ public class XPathParenthesizedExpressionImpl extends XPathElementImpl implement
|
||||
final ASTNode[] nodes = getNode().getChildren(XPath2ElementTypes.EXPRESSIONS);
|
||||
return (XPathExpression)(nodes.length > 0 ? nodes[0].getPsi() : null);
|
||||
}
|
||||
|
||||
public void accept(XPathElementVisitor visitor) {
|
||||
visitor.visitXPathParenthesizedExpression(this);
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ package org.intellij.lang.xpath.psi.impl;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import org.intellij.lang.xpath.XPath2ElementTypes;
|
||||
import org.intellij.lang.xpath.psi.XPathElementVisitor;
|
||||
import org.intellij.lang.xpath.psi.XPathExpression;
|
||||
import org.intellij.lang.xpath.psi.XPathPredicate;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -31,4 +32,8 @@ public class XPathPredicateImpl extends XPathElementImpl implements XPathPredica
|
||||
final ASTNode[] nodes = getNode().getChildren(XPath2ElementTypes.EXPRESSIONS);
|
||||
return (XPathExpression)(nodes.length > 0 ? nodes[0].getPsi() : null);
|
||||
}
|
||||
|
||||
public void accept(XPathElementVisitor visitor) {
|
||||
visitor.visitXPathPredicate(this);
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -19,6 +19,7 @@ import com.intellij.lang.ASTNode;
|
||||
import org.intellij.lang.xpath.XPath2ElementTypes;
|
||||
import org.intellij.lang.xpath.XPathElementType;
|
||||
import org.intellij.lang.xpath.XPathTokenTypes;
|
||||
import org.intellij.lang.xpath.psi.XPathElementVisitor;
|
||||
import org.intellij.lang.xpath.psi.XPathExpression;
|
||||
import org.intellij.lang.xpath.psi.XPathPrefixExpression;
|
||||
import org.intellij.lang.xpath.psi.XPathType;
|
||||
@@ -51,4 +52,8 @@ public class XPathPrefixExpressionImpl extends XPathElementImpl implements XPath
|
||||
assert elementType != null;
|
||||
return elementType;
|
||||
}
|
||||
|
||||
public void accept(XPathElementVisitor visitor) {
|
||||
visitor.visitXPathPrefixExpression(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,4 +118,8 @@ public class XPathStepImpl extends XPathElementImpl implements XPathStep {
|
||||
public boolean isAbsolute() {
|
||||
return getPreviousStep() == null && getNode().getChildren(XPathTokenTypes.PATH_OPS).length > 0;
|
||||
}
|
||||
|
||||
public void accept(XPathElementVisitor visitor) {
|
||||
visitor.visitXPathStep(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.intellij.lang.xpath.psi.impl;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.Language;
|
||||
import org.intellij.lang.xpath.XPath2Language;
|
||||
import org.intellij.lang.xpath.psi.XPathElementVisitor;
|
||||
import org.intellij.lang.xpath.psi.XPathString;
|
||||
import org.intellij.lang.xpath.psi.XPathType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -60,4 +61,8 @@ public class XPathStringImpl extends XPathElementImpl implements XPathString {
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public void accept(XPathElementVisitor visitor) {
|
||||
visitor.visitXPathString(this);
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ package org.intellij.lang.xpath.psi.impl;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.intellij.lang.xpath.psi.XPathElementVisitor;
|
||||
import org.intellij.lang.xpath.psi.XPathToken;
|
||||
|
||||
public class XPathTokenImpl extends XPathElementImpl implements XPathToken {
|
||||
@@ -27,4 +28,8 @@ public class XPathTokenImpl extends XPathElementImpl implements XPathToken {
|
||||
public IElementType getTokenType() {
|
||||
return getNode().getElementType();
|
||||
}
|
||||
|
||||
public void accept(XPathElementVisitor visitor) {
|
||||
visitor.visitXPathToken(this);
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -159,4 +159,8 @@ public class XPathVariableReferenceImpl extends XPathElementImpl implements XPat
|
||||
public boolean equals(Object obj) {
|
||||
return obj == this;
|
||||
}
|
||||
|
||||
public void accept(XPathElementVisitor visitor) {
|
||||
visitor.visitXPathVariableReference(this);
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -35,6 +35,8 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import org.intellij.lang.xpath.completion.CompletionLists;
|
||||
import org.intellij.lang.xpath.context.ContextProvider;
|
||||
import org.intellij.lang.xpath.context.XPathVersion;
|
||||
import org.intellij.lang.xpath.psi.XPathElement;
|
||||
import org.intellij.lang.xpath.psi.XPathElementVisitor;
|
||||
import org.intellij.lang.xpath.xslt.XsltSupport;
|
||||
import org.intellij.lang.xpath.xslt.psi.XsltElement;
|
||||
import org.intellij.lang.xpath.xslt.psi.XsltElementFactory;
|
||||
@@ -203,8 +205,16 @@ abstract class XsltElementImpl extends LightElement implements Iconable, Navigat
|
||||
return canNavigate();
|
||||
}
|
||||
|
||||
public void accept(@NotNull XPathElementVisitor visitor) {
|
||||
visitor.visitXPathElement((XPathElement)this);
|
||||
}
|
||||
|
||||
public void accept(@NotNull PsiElementVisitor visitor) {
|
||||
if (visitor instanceof XPathElementVisitor && this instanceof XPathElement) {
|
||||
accept((XPathElementVisitor)visitor);
|
||||
} else {
|
||||
myElement.accept(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-1
@@ -22,11 +22,11 @@ import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.intellij.lang.xpath.context.ContextProvider;
|
||||
import org.intellij.lang.xpath.context.functions.Function;
|
||||
import org.intellij.lang.xpath.context.functions.FunctionImpl;
|
||||
import org.intellij.lang.xpath.context.functions.Parameter;
|
||||
import org.intellij.lang.xpath.psi.XPath2Type;
|
||||
import org.intellij.lang.xpath.psi.XPathElementVisitor;
|
||||
import org.intellij.lang.xpath.psi.XPathType;
|
||||
import org.intellij.lang.xpath.xslt.XsltSupport;
|
||||
import org.intellij.lang.xpath.xslt.psi.XsltFunction;
|
||||
@@ -130,4 +130,8 @@ public class XsltFunctionImpl extends XsltElementImpl implements XsltFunction, I
|
||||
public int getMinArity() {
|
||||
return getFunction().getMinArity();
|
||||
}
|
||||
|
||||
public void accept(@NotNull XPathElementVisitor visitor) {
|
||||
visitor.visitXPathFunction(this);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-7
@@ -15,19 +15,18 @@
|
||||
*/
|
||||
package org.intellij.lang.xpath.xslt.psi.impl;
|
||||
|
||||
import org.intellij.lang.xpath.xslt.XsltSupport;
|
||||
import org.intellij.lang.xpath.xslt.impl.XsltIncludeIndex;
|
||||
import org.intellij.lang.xpath.xslt.psi.XsltElementFactory;
|
||||
import org.intellij.lang.xpath.xslt.psi.XsltParameter;
|
||||
import org.intellij.lang.xpath.xslt.psi.XsltTemplate;
|
||||
import org.intellij.lang.xpath.xslt.util.XsltCodeInsightUtil;
|
||||
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.CommonProcessors;
|
||||
import com.intellij.util.Icons;
|
||||
import org.intellij.lang.xpath.xslt.XsltSupport;
|
||||
import org.intellij.lang.xpath.xslt.impl.XsltIncludeIndex;
|
||||
import org.intellij.lang.xpath.xslt.psi.XsltElementFactory;
|
||||
import org.intellij.lang.xpath.xslt.psi.XsltParameter;
|
||||
import org.intellij.lang.xpath.xslt.psi.XsltTemplate;
|
||||
import org.intellij.lang.xpath.xslt.util.XsltCodeInsightUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
+5
@@ -20,6 +20,7 @@ import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.xml.XmlAttribute;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.Icons;
|
||||
import org.intellij.lang.xpath.psi.XPathElementVisitor;
|
||||
import org.intellij.lang.xpath.psi.XPathExpression;
|
||||
import org.intellij.lang.xpath.psi.XPathType;
|
||||
import org.intellij.lang.xpath.psi.XPathVariableReference;
|
||||
@@ -95,4 +96,8 @@ public class XsltVariableImpl extends XsltElementImpl implements XsltVariable {
|
||||
final String name = getName();
|
||||
return name != null && "type:void".equals(QNameUtil.createQName(name, getTag()).getNamespaceURI());
|
||||
}
|
||||
|
||||
public void accept(@NotNull XPathElementVisitor visitor) {
|
||||
visitor.visitXPathVariable(this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user