mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
JavaASTFactory elimination
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -25,11 +24,13 @@ import com.intellij.psi.impl.compiled.ClsAnnotationImpl;
|
||||
import com.intellij.psi.impl.java.stubs.impl.PsiAnnotationStubImpl;
|
||||
import com.intellij.psi.impl.java.stubs.index.JavaAnnotationIndex;
|
||||
import com.intellij.psi.impl.source.tree.LightTreeUtil;
|
||||
import com.intellij.psi.impl.source.tree.java.AnnotationElement;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiAnnotationImpl;
|
||||
import com.intellij.psi.stubs.IndexSink;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
import com.intellij.psi.stubs.StubOutputStream;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -41,6 +42,12 @@ public class JavaAnnotationElementType extends JavaStubElementType<PsiAnnotation
|
||||
super("ANNOTATION");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new AnnotationElement();
|
||||
}
|
||||
|
||||
public PsiAnnotation createPsi(final PsiAnnotationStub stub) {
|
||||
if (isCompiled(stub)) {
|
||||
return new ClsAnnotationImpl(stub);
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -48,7 +47,7 @@ import java.io.IOException;
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
public class JavaClassElementType extends JavaStubElementType<PsiClassStub, PsiClass> {
|
||||
public abstract class JavaClassElementType extends JavaStubElementType<PsiClassStub, PsiClass> {
|
||||
public JavaClassElementType(@NotNull @NonNls final String id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
+8
-1
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -22,10 +21,12 @@ import com.intellij.lang.LighterAST;
|
||||
import com.intellij.psi.PsiClassInitializer;
|
||||
import com.intellij.psi.impl.java.stubs.impl.PsiClassInitializerStubImpl;
|
||||
import com.intellij.psi.impl.source.PsiClassInitializerImpl;
|
||||
import com.intellij.psi.impl.source.tree.java.ClassInitializerElement;
|
||||
import com.intellij.psi.stubs.IndexSink;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
import com.intellij.psi.stubs.StubOutputStream;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -37,6 +38,12 @@ public class JavaClassInitializerElementType extends JavaStubElementType<PsiClas
|
||||
super("CLASS_INITIALIZER");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new ClassInitializerElement();
|
||||
}
|
||||
|
||||
public PsiClassInitializer createPsi(final PsiClassInitializerStub stub) {
|
||||
assert !isCompiled(stub);
|
||||
return new PsiClassInitializerImpl(stub);
|
||||
|
||||
+1
-2
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -46,7 +45,7 @@ import java.util.List;
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
public class JavaClassReferenceListElementType extends JavaStubElementType<PsiClassReferenceListStub, PsiReferenceList> {
|
||||
public abstract class JavaClassReferenceListElementType extends JavaStubElementType<PsiClassReferenceListStub, PsiReferenceList> {
|
||||
public JavaClassReferenceListElementType(@NotNull @NonNls String id) {
|
||||
super(id, true);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -48,7 +47,7 @@ import java.io.IOException;
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
public class JavaFieldStubElementType extends JavaStubElementType<PsiFieldStub, PsiField> {
|
||||
public abstract class JavaFieldStubElementType extends JavaStubElementType<PsiFieldStub, PsiField> {
|
||||
private static final int INITIALIZER_LENGTH_LIMIT = 1000;
|
||||
|
||||
public JavaFieldStubElementType(@NotNull @NonNls final String id) {
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -22,10 +21,12 @@ import com.intellij.lang.LighterASTNode;
|
||||
import com.intellij.psi.PsiImportList;
|
||||
import com.intellij.psi.impl.java.stubs.impl.PsiImportListStubImpl;
|
||||
import com.intellij.psi.impl.source.PsiImportListImpl;
|
||||
import com.intellij.psi.impl.source.tree.java.ImportListElement;
|
||||
import com.intellij.psi.stubs.IndexSink;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
import com.intellij.psi.stubs.StubOutputStream;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -37,6 +38,12 @@ public class JavaImportListElementType extends JavaStubElementType<PsiImportList
|
||||
super("IMPORT_LIST");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new ImportListElement();
|
||||
}
|
||||
|
||||
public PsiImportList createPsi(final PsiImportListStub stub) {
|
||||
assert !isCompiled(stub);
|
||||
return new PsiImportListImpl(stub);
|
||||
|
||||
+1
-2
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -43,7 +42,7 @@ import java.io.IOException;
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
public class JavaImportStatementElementType extends JavaStubElementType<PsiImportStatementStub, PsiImportStatementBase> {
|
||||
public abstract class JavaImportStatementElementType extends JavaStubElementType<PsiImportStatementStub, PsiImportStatementBase> {
|
||||
public JavaImportStatementElementType(@NonNls @NotNull final String id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -49,7 +48,7 @@ import java.util.List;
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
public class JavaMethodElementType extends JavaStubElementType<PsiMethodStub, PsiMethod> {
|
||||
public abstract class JavaMethodElementType extends JavaStubElementType<PsiMethodStub, PsiMethod> {
|
||||
public JavaMethodElementType(@NonNls final String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
+8
-1
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -25,10 +24,12 @@ import com.intellij.psi.impl.compiled.ClsModifierListImpl;
|
||||
import com.intellij.psi.impl.java.stubs.impl.PsiModifierListStubImpl;
|
||||
import com.intellij.psi.impl.source.PsiModifierListImpl;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.source.tree.java.ModifierListElement;
|
||||
import com.intellij.psi.stubs.IndexSink;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
import com.intellij.psi.stubs.StubOutputStream;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -40,6 +41,12 @@ public class JavaModifierListElementType extends JavaStubElementType<PsiModifier
|
||||
super("MODIFIER_LIST");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new ModifierListElement();
|
||||
}
|
||||
|
||||
public PsiModifierList createPsi(final PsiModifierListStub stub) {
|
||||
if (isCompiled(stub)) {
|
||||
return new ClsModifierListImpl(stub);
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -28,11 +27,13 @@ import com.intellij.psi.impl.java.stubs.impl.PsiParameterStubImpl;
|
||||
import com.intellij.psi.impl.source.PsiParameterImpl;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.source.tree.LightTreeUtil;
|
||||
import com.intellij.psi.impl.source.tree.java.ParameterElement;
|
||||
import com.intellij.psi.stubs.IndexSink;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
import com.intellij.psi.stubs.StubOutputStream;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -44,6 +45,12 @@ public class JavaParameterElementType extends JavaStubElementType<PsiParameterSt
|
||||
super("PARAMETER");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new ParameterElement();
|
||||
}
|
||||
|
||||
public PsiParameter createPsi(final PsiParameterStub stub) {
|
||||
if (isCompiled(stub)) {
|
||||
return new ClsParameterImpl(stub);
|
||||
|
||||
+8
-1
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -23,10 +22,12 @@ import com.intellij.psi.PsiParameterList;
|
||||
import com.intellij.psi.impl.compiled.ClsParameterListImpl;
|
||||
import com.intellij.psi.impl.java.stubs.impl.PsiParameterListStubImpl;
|
||||
import com.intellij.psi.impl.source.PsiParameterListImpl;
|
||||
import com.intellij.psi.impl.source.tree.java.ParameterListElement;
|
||||
import com.intellij.psi.stubs.IndexSink;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
import com.intellij.psi.stubs.StubOutputStream;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -38,6 +39,12 @@ public class JavaParameterListElementType extends JavaStubElementType<PsiParamet
|
||||
super("PARAMETER_LIST");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new ParameterListElement();
|
||||
}
|
||||
|
||||
public PsiParameterList createPsi(final PsiParameterListStub stub) {
|
||||
if (isCompiled(stub)) {
|
||||
return new ClsParameterListImpl(stub);
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -22,13 +21,15 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.stubs.ILightStubElementType;
|
||||
import com.intellij.psi.stubs.PsiFileStub;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.tree.ICompositeElementType;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
public abstract class JavaStubElementType<StubT extends StubElement, PsiT extends PsiElement> extends ILightStubElementType<StubT, PsiT> {
|
||||
public abstract class JavaStubElementType<StubT extends StubElement, PsiT extends PsiElement>
|
||||
extends ILightStubElementType<StubT, PsiT> implements ICompositeElementType {
|
||||
private final boolean myLeftBound;
|
||||
|
||||
protected JavaStubElementType(@NotNull @NonNls final String debugName) {
|
||||
|
||||
@@ -13,40 +13,122 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.impl.source.JavaFileElementType;
|
||||
import com.intellij.psi.impl.source.tree.java.*;
|
||||
import com.intellij.psi.tree.IStubFileElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
package com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.psi.impl.source.JavaFileElementType;
|
||||
import com.intellij.psi.tree.IStubFileElementType;
|
||||
|
||||
public interface JavaStubElementTypes {
|
||||
JavaClassElementType CLASS = new JavaClassElementType("CLASS");
|
||||
JavaClassElementType ANONYMOUS_CLASS = new JavaClassElementType("ANONYMOUS_CLASS");
|
||||
JavaClassElementType ENUM_CONSTANT_INITIALIZER = new JavaClassElementType("ENUM_CONSTANT_INITIALIZER");
|
||||
|
||||
JavaModifierListElementType MODIFIER_LIST = new JavaModifierListElementType();
|
||||
JavaMethodElementType METHOD = new JavaMethodElementType("METHOD");
|
||||
JavaMethodElementType ANNOTATION_METHOD = new JavaMethodElementType("ANNOTATION_METHOD");
|
||||
JavaFieldStubElementType FIELD = new JavaFieldStubElementType("FIELD");
|
||||
JavaFieldStubElementType ENUM_CONSTANT = new JavaFieldStubElementType("ENUM_CONSTANT");
|
||||
|
||||
JavaAnnotationElementType ANNOTATION = new JavaAnnotationElementType();
|
||||
JavaClassReferenceListElementType EXTENDS_LIST = new JavaClassReferenceListElementType("EXTENDS_LIST");
|
||||
JavaClassReferenceListElementType IMPLEMENTS_LIST = new JavaClassReferenceListElementType("IMPLEMENTS_LIST");
|
||||
JavaClassReferenceListElementType THROWS_LIST = new JavaClassReferenceListElementType("THROWS_LIST");
|
||||
JavaClassReferenceListElementType EXTENDS_BOUND_LIST = new JavaClassReferenceListElementType("EXTENDS_BOUND_LIST");
|
||||
|
||||
JavaParameterElementType PARAMETER = new JavaParameterElementType();
|
||||
JavaParameterListElementType PARAMETER_LIST = new JavaParameterListElementType();
|
||||
JavaTypeParameterElementType TYPE_PARAMETER = new JavaTypeParameterElementType();
|
||||
JavaTypeParameterListElementType TYPE_PARAMETER_LIST = new JavaTypeParameterListElementType();
|
||||
JavaClassInitializerElementType CLASS_INITIALIZER = new JavaClassInitializerElementType();
|
||||
JavaImportListElementType IMPORT_LIST = new JavaImportListElementType();
|
||||
JavaImportStatementElementType IMPORT_STATEMENT = new JavaImportStatementElementType("IMPORT_STATEMENT");
|
||||
JavaImportStatementElementType IMPORT_STATIC_STATEMENT = new JavaImportStatementElementType("IMPORT_STATIC_STATEMENT");
|
||||
|
||||
JavaClassElementType CLASS = new JavaClassElementType("CLASS") {
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new ClassElement(this);
|
||||
}
|
||||
};
|
||||
JavaClassElementType ANONYMOUS_CLASS = new JavaClassElementType("ANONYMOUS_CLASS") {
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new AnonymousClassElement();
|
||||
}
|
||||
};
|
||||
JavaClassElementType ENUM_CONSTANT_INITIALIZER = new JavaClassElementType("ENUM_CONSTANT_INITIALIZER") {
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new EnumConstantInitializerElement();
|
||||
}
|
||||
};
|
||||
|
||||
JavaMethodElementType METHOD = new JavaMethodElementType("METHOD") {
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new MethodElement();
|
||||
}
|
||||
};
|
||||
JavaMethodElementType ANNOTATION_METHOD = new JavaMethodElementType("ANNOTATION_METHOD") {
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new AnnotationMethodElement();
|
||||
}
|
||||
};
|
||||
|
||||
JavaFieldStubElementType FIELD = new JavaFieldStubElementType("FIELD") {
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new FieldElement();
|
||||
}
|
||||
};
|
||||
JavaFieldStubElementType ENUM_CONSTANT = new JavaFieldStubElementType("ENUM_CONSTANT") {
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new EnumConstantElement();
|
||||
}
|
||||
};
|
||||
|
||||
JavaClassReferenceListElementType EXTENDS_LIST = new JavaClassReferenceListElementType("EXTENDS_LIST") {
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new ExtendsListElement();
|
||||
}
|
||||
};
|
||||
JavaClassReferenceListElementType IMPLEMENTS_LIST = new JavaClassReferenceListElementType("IMPLEMENTS_LIST") {
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new ImplementsListElement();
|
||||
}
|
||||
};
|
||||
JavaClassReferenceListElementType THROWS_LIST = new JavaClassReferenceListElementType("THROWS_LIST") {
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new PsiThrowsListImpl();
|
||||
}
|
||||
};
|
||||
JavaClassReferenceListElementType EXTENDS_BOUND_LIST = new JavaClassReferenceListElementType("EXTENDS_BOUND_LIST") {
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new TypeParameterExtendsBoundsListElement();
|
||||
}
|
||||
};
|
||||
|
||||
JavaImportStatementElementType IMPORT_STATEMENT = new JavaImportStatementElementType("IMPORT_STATEMENT") {
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new ImportStatementElement();
|
||||
}
|
||||
};
|
||||
JavaImportStatementElementType IMPORT_STATIC_STATEMENT = new JavaImportStatementElementType("IMPORT_STATIC_STATEMENT") {
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new ImportStaticStatementElement();
|
||||
}
|
||||
};
|
||||
|
||||
IStubFileElementType JAVA_FILE = new JavaFileElementType();
|
||||
}
|
||||
+8
-1
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -26,11 +25,13 @@ import com.intellij.psi.impl.compiled.ClsTypeParameterImpl;
|
||||
import com.intellij.psi.impl.java.stubs.impl.PsiTypeParameterStubImpl;
|
||||
import com.intellij.psi.impl.source.tree.LightTreeUtil;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiTypeParameterImpl;
|
||||
import com.intellij.psi.impl.source.tree.java.TypeParameterElement;
|
||||
import com.intellij.psi.stubs.IndexSink;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
import com.intellij.psi.stubs.StubOutputStream;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -42,6 +43,12 @@ public class JavaTypeParameterElementType extends JavaStubElementType<PsiTypePar
|
||||
super("TYPE_PARAMETER");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new TypeParameterElement();
|
||||
}
|
||||
|
||||
public PsiTypeParameter createPsi(final PsiTypeParameterStub stub) {
|
||||
if (isCompiled(stub)) {
|
||||
return new ClsTypeParameterImpl(stub);
|
||||
|
||||
+9
-2
@@ -13,20 +13,21 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.LighterASTNode;
|
||||
import com.intellij.lang.LighterAST;
|
||||
import com.intellij.lang.LighterASTNode;
|
||||
import com.intellij.psi.PsiTypeParameterList;
|
||||
import com.intellij.psi.impl.compiled.ClsTypeParametersListImpl;
|
||||
import com.intellij.psi.impl.java.stubs.impl.PsiTypeParameterListStubImpl;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiTypeParameterListImpl;
|
||||
import com.intellij.psi.impl.source.tree.java.TypeParameterListElement;
|
||||
import com.intellij.psi.stubs.IndexSink;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
import com.intellij.psi.stubs.StubOutputStream;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -38,6 +39,12 @@ public class JavaTypeParameterListElementType extends JavaStubElementType<PsiTyp
|
||||
super("TYPE_PARAMETER_LIST", true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new TypeParameterListElement();
|
||||
}
|
||||
|
||||
public PsiTypeParameterList createPsi(final PsiTypeParameterListStub stub) {
|
||||
if (isCompiled(stub)) {
|
||||
return new ClsTypeParametersListImpl(stub);
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.psi.impl.java.stubs.PsiJavaFileStub;
|
||||
import com.intellij.psi.impl.java.stubs.impl.PsiJavaFileStubImpl;
|
||||
import com.intellij.psi.impl.source.parsing.FileTextParsing;
|
||||
import com.intellij.psi.impl.source.tree.FileElement;
|
||||
import com.intellij.psi.impl.source.tree.java.JavaFileElement;
|
||||
import com.intellij.psi.stubs.IndexSink;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
@@ -68,6 +69,11 @@ public class JavaFileElementType extends ILightStubFileElementType<PsiJavaFileSt
|
||||
return dir == null || dir.getUserData(LanguageLevel.KEY) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode createNode(final CharSequence text) {
|
||||
return new JavaFileElement(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlyweightCapableTreeStructure<LighterASTNode> parseContentsLight(final ASTNode chameleon) {
|
||||
final PsiBuilder builder = JavaParserUtil.createBuilder(chameleon);
|
||||
|
||||
+11
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2010 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.
|
||||
@@ -13,13 +13,18 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.psi.impl.source;
|
||||
|
||||
package com.intellij.psi.impl.source.tree;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
|
||||
import com.intellij.psi.PlainTextTokenTypes;
|
||||
public class PsiDiamondTypeElementImpl extends PsiTypeElementImpl {
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public PsiDiamondTypeElementImpl() {
|
||||
super(JavaElementType.DIAMOND_TYPE);
|
||||
}
|
||||
|
||||
public class PlainTextFileElement extends FileElement{
|
||||
public PlainTextFileElement(CharSequence text) {
|
||||
super(PlainTextTokenTypes.PLAIN_TEXT_FILE, text);
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PsiTypeElement:DIAMOND";
|
||||
}
|
||||
}
|
||||
@@ -44,8 +44,13 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl
|
||||
private volatile PsiType myCachedType = null;
|
||||
private volatile PatchedSoftReference<PsiType> myCachedDetachedType = null;
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public PsiTypeElementImpl() {
|
||||
super(JavaElementType.TYPE);
|
||||
this(JavaElementType.TYPE);
|
||||
}
|
||||
|
||||
protected PsiTypeElementImpl(final IElementType type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public void clearCaches() {
|
||||
|
||||
@@ -13,292 +13,34 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
package com.intellij.psi.impl.source.tree;
|
||||
|
||||
import com.intellij.lang.ASTFactory;
|
||||
import com.intellij.psi.PlainTextTokenTypes;
|
||||
import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.source.*;
|
||||
import com.intellij.psi.impl.source.javadoc.*;
|
||||
import com.intellij.psi.impl.source.tree.java.*;
|
||||
import com.intellij.psi.impl.source.Constants;
|
||||
import com.intellij.psi.impl.source.javadoc.PsiDocTagValueImpl;
|
||||
import com.intellij.psi.impl.source.javadoc.PsiDocTokenImpl;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiIdentifierImpl;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiJavaTokenImpl;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiKeywordImpl;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.IFileElementType;
|
||||
import com.intellij.psi.tree.ILazyParseableElementType;
|
||||
import com.intellij.psi.tree.java.IJavaDocElementType;
|
||||
import com.intellij.psi.tree.java.IJavaElementType;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class JavaASTFactory extends ASTFactory implements Constants {
|
||||
|
||||
@Override
|
||||
public LazyParseableElement createLazy(ILazyParseableElementType type, CharSequence text) {
|
||||
if (type == JavaStubElementTypes.JAVA_FILE) {
|
||||
return new JavaFileElement(text);
|
||||
}
|
||||
else if (type == PlainTextTokenTypes.PLAIN_TEXT_FILE) {
|
||||
return new PlainTextFileElement(text);
|
||||
}
|
||||
else if (type == CODE_FRAGMENT) {
|
||||
return new CodeFragmentElement(text);
|
||||
}
|
||||
else if (type == DUMMY_HOLDER) {
|
||||
return new DummyHolderElement(text);
|
||||
}
|
||||
else if(type instanceof IFileElementType) {
|
||||
return new FileElement(type, text);
|
||||
}
|
||||
else if (type == JavaDocElementType.DOC_COMMENT) {
|
||||
return new PsiDocCommentImpl(text);
|
||||
public CompositeElement createComposite(final IElementType type) {
|
||||
if (type == DOC_TAG_VALUE_TOKEN) {
|
||||
return new PsiDocTagValueImpl();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public CompositeElement createComposite(final IElementType type) {
|
||||
//TODO: Replace whole method with type.createPsiElement();
|
||||
if (type == TYPE_PARAMETER_LIST) {
|
||||
return new TypeParameterListElement();
|
||||
}
|
||||
else if (type == TYPE_PARAMETER) {
|
||||
return new TypeParameterElement();
|
||||
}
|
||||
else if (type == EXTENDS_BOUND_LIST) {
|
||||
return new TypeParameterExtendsBoundsListElement();
|
||||
}
|
||||
else if (type == ERROR_ELEMENT) {
|
||||
return new PsiErrorElementImpl();
|
||||
}
|
||||
else if (type == DOC_TAG) {
|
||||
return new PsiDocTagImpl();
|
||||
}
|
||||
else if (type == DOC_TAG_VALUE_TOKEN) {
|
||||
return new PsiDocTagValueImpl();
|
||||
}
|
||||
else if (type == DOC_METHOD_OR_FIELD_REF) {
|
||||
return new PsiDocMethodOrFieldRef();
|
||||
}
|
||||
else if (type == DOC_PARAMETER_REF) {
|
||||
return new PsiDocParamRef();
|
||||
}
|
||||
else if (type == DOC_INLINE_TAG) {
|
||||
return new PsiInlineDocTagImpl();
|
||||
}
|
||||
else if (type == CLASS) {
|
||||
return new ClassElement(type);
|
||||
}
|
||||
else if (type == ANONYMOUS_CLASS) {
|
||||
return new AnonymousClassElement();
|
||||
}
|
||||
else if (type == ENUM_CONSTANT_INITIALIZER) {
|
||||
return new EnumConstantInitializerElement();
|
||||
}
|
||||
else if (type == FIELD) {
|
||||
return new FieldElement();
|
||||
}
|
||||
else if (type == ENUM_CONSTANT) {
|
||||
return new EnumConstantElement();
|
||||
}
|
||||
else if (type == METHOD) {
|
||||
return new MethodElement();
|
||||
}
|
||||
else if (type == LOCAL_VARIABLE) {
|
||||
return new PsiLocalVariableImpl();
|
||||
}
|
||||
else if (type == PARAMETER) {
|
||||
return new ParameterElement();
|
||||
}
|
||||
else if (type == PARAMETER_LIST) {
|
||||
return new ParameterListElement();
|
||||
}
|
||||
else if (type == CLASS_INITIALIZER) {
|
||||
return new ClassInitializerElement();
|
||||
}
|
||||
else if (type == PACKAGE_STATEMENT) {
|
||||
return new PsiPackageStatementImpl();
|
||||
}
|
||||
else if (type == IMPORT_LIST) {
|
||||
return new ImportListElement();
|
||||
}
|
||||
else if (type == IMPORT_STATEMENT) {
|
||||
return new ImportStatementElement();
|
||||
}
|
||||
else if (type == IMPORT_STATIC_STATEMENT) {
|
||||
return new ImportStaticStatementElement();
|
||||
}
|
||||
else if (type == IMPORT_STATIC_REFERENCE) {
|
||||
return new PsiImportStaticReferenceElementImpl();
|
||||
}
|
||||
else if (type == JAVA_CODE_REFERENCE) {
|
||||
return new PsiJavaCodeReferenceElementImpl();
|
||||
}
|
||||
else if (type == REFERENCE_PARAMETER_LIST) {
|
||||
return new PsiReferenceParameterListImpl();
|
||||
}
|
||||
else if (type == TYPE) {
|
||||
return new PsiTypeElementImpl();
|
||||
}
|
||||
else if (type == MODIFIER_LIST) {
|
||||
return new ModifierListElement();
|
||||
}
|
||||
else if (type == EXTENDS_LIST) {
|
||||
return new ExtendsListElement();
|
||||
}
|
||||
else if (type == IMPLEMENTS_LIST) {
|
||||
return new ImplementsListElement();
|
||||
}
|
||||
else if (type == THROWS_LIST) {
|
||||
return new PsiThrowsListImpl();
|
||||
}
|
||||
else if (type == EXPRESSION_LIST) {
|
||||
return new PsiExpressionListImpl();
|
||||
}
|
||||
else if (type == REFERENCE_EXPRESSION) {
|
||||
return new PsiReferenceExpressionImpl();
|
||||
}
|
||||
else if (type == LITERAL_EXPRESSION) {
|
||||
return new PsiLiteralExpressionImpl();
|
||||
}
|
||||
else if (type == THIS_EXPRESSION) {
|
||||
return new PsiThisExpressionImpl();
|
||||
}
|
||||
else if (type == SUPER_EXPRESSION) {
|
||||
return new PsiSuperExpressionImpl();
|
||||
}
|
||||
else if (type == PARENTH_EXPRESSION) {
|
||||
return new PsiParenthesizedExpressionImpl();
|
||||
}
|
||||
else if (type == METHOD_CALL_EXPRESSION) {
|
||||
return new PsiMethodCallExpressionImpl();
|
||||
}
|
||||
else if (type == TYPE_CAST_EXPRESSION) {
|
||||
return new PsiTypeCastExpressionImpl();
|
||||
}
|
||||
else if (type == PREFIX_EXPRESSION) {
|
||||
return new PsiPrefixExpressionImpl();
|
||||
}
|
||||
else if (type == POSTFIX_EXPRESSION) {
|
||||
return new PsiPostfixExpressionImpl();
|
||||
}
|
||||
else if (type == BINARY_EXPRESSION) {
|
||||
return new PsiBinaryExpressionImpl();
|
||||
}
|
||||
else if (type == CONDITIONAL_EXPRESSION) {
|
||||
return new PsiConditionalExpressionImpl();
|
||||
}
|
||||
else if (type == ASSIGNMENT_EXPRESSION) {
|
||||
return new PsiAssignmentExpressionImpl();
|
||||
}
|
||||
else if (type == NEW_EXPRESSION) {
|
||||
return new PsiNewExpressionImpl();
|
||||
}
|
||||
else if (type == ARRAY_ACCESS_EXPRESSION) {
|
||||
return new PsiArrayAccessExpressionImpl();
|
||||
}
|
||||
else if (type == ARRAY_INITIALIZER_EXPRESSION) {
|
||||
return new PsiArrayInitializerExpressionImpl();
|
||||
}
|
||||
else if (type == INSTANCE_OF_EXPRESSION) {
|
||||
return new PsiInstanceOfExpressionImpl();
|
||||
}
|
||||
else if (type == CLASS_OBJECT_ACCESS_EXPRESSION) {
|
||||
return new PsiClassObjectAccessExpressionImpl();
|
||||
}
|
||||
else if (type == EMPTY_EXPRESSION) {
|
||||
return new PsiEmptyExpressionImpl();
|
||||
}
|
||||
else if (type == EMPTY_STATEMENT) {
|
||||
return new PsiEmptyStatementImpl();
|
||||
}
|
||||
else if (type == BLOCK_STATEMENT) {
|
||||
return new PsiBlockStatementImpl();
|
||||
}
|
||||
else if (type == EXPRESSION_STATEMENT) {
|
||||
return new PsiExpressionStatementImpl();
|
||||
}
|
||||
else if (type == EXPRESSION_LIST_STATEMENT) {
|
||||
return new PsiExpressionListStatementImpl();
|
||||
}
|
||||
else if (type == DECLARATION_STATEMENT) {
|
||||
return new PsiDeclarationStatementImpl();
|
||||
}
|
||||
else if (type == IF_STATEMENT) {
|
||||
return new PsiIfStatementImpl();
|
||||
}
|
||||
else if (type == WHILE_STATEMENT) {
|
||||
return new PsiWhileStatementImpl();
|
||||
}
|
||||
else if (type == FOR_STATEMENT) {
|
||||
return new PsiForStatementImpl();
|
||||
}
|
||||
else if (type == FOREACH_STATEMENT) {
|
||||
return new PsiForeachStatementImpl();
|
||||
}
|
||||
else if (type == DO_WHILE_STATEMENT) {
|
||||
return new PsiDoWhileStatementImpl();
|
||||
}
|
||||
else if (type == SWITCH_STATEMENT) {
|
||||
return new PsiSwitchStatementImpl();
|
||||
}
|
||||
else if (type == SWITCH_LABEL_STATEMENT) {
|
||||
return new PsiSwitchLabelStatementImpl();
|
||||
}
|
||||
else if (type == BREAK_STATEMENT) {
|
||||
return new PsiBreakStatementImpl();
|
||||
}
|
||||
else if (type == CONTINUE_STATEMENT) {
|
||||
return new PsiContinueStatementImpl();
|
||||
}
|
||||
else if (type == RETURN_STATEMENT) {
|
||||
return new PsiReturnStatementImpl();
|
||||
}
|
||||
else if (type == THROW_STATEMENT) {
|
||||
return new PsiThrowStatementImpl();
|
||||
}
|
||||
else if (type == SYNCHRONIZED_STATEMENT) {
|
||||
return new PsiSynchronizedStatementImpl();
|
||||
}
|
||||
else if (type == ASSERT_STATEMENT) {
|
||||
return new PsiAssertStatementImpl();
|
||||
}
|
||||
else if (type == TRY_STATEMENT) {
|
||||
return new PsiTryStatementImpl();
|
||||
}
|
||||
else if (type == LABELED_STATEMENT) {
|
||||
return new PsiLabeledStatementImpl();
|
||||
}
|
||||
else if (type == CATCH_SECTION) {
|
||||
return new PsiCatchSectionImpl();
|
||||
}
|
||||
else if (type == ANNOTATION_METHOD) {
|
||||
return new AnnotationMethodElement();
|
||||
}
|
||||
else if (type == ANNOTATION) {
|
||||
return new AnnotationElement();
|
||||
}
|
||||
else if (type == ANNOTATION_ARRAY_INITIALIZER) {
|
||||
return new PsiArrayInitializerMemberValueImpl();
|
||||
}
|
||||
else if (type == NAME_VALUE_PAIR) {
|
||||
return new PsiNameValuePairImpl();
|
||||
}
|
||||
else if (type == ANNOTATION_PARAMETER_LIST) {
|
||||
return new PsiAnnotationParameterListImpl();
|
||||
}
|
||||
else if (type == METHOD_RECEIVER) {
|
||||
return new PsiMethodReceiverImpl();
|
||||
}
|
||||
else if (type == CODE_BLOCK) {
|
||||
// deep code block parsing
|
||||
return new PsiCodeBlockImpl(null);
|
||||
}
|
||||
|
||||
return new CompositePsiElement(type){};
|
||||
}
|
||||
|
||||
public LeafElement createLeaf(final IElementType type, CharSequence text) {
|
||||
@Override
|
||||
public LeafElement createLeaf(final IElementType type, final CharSequence text) {
|
||||
if (type == C_STYLE_COMMENT || type == END_OF_LINE_COMMENT) {
|
||||
return new PsiCommentImpl(type, text);
|
||||
}
|
||||
@@ -315,6 +57,6 @@ public class JavaASTFactory extends ASTFactory implements Constants {
|
||||
return new PsiDocTokenImpl(type, text);
|
||||
}
|
||||
|
||||
return new LeafPsiElement(type, text);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,70 +20,106 @@ import com.intellij.lang.StdLanguages;
|
||||
import com.intellij.lexer.JavaLexer;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.source.javadoc.PsiDocCommentImpl;
|
||||
import com.intellij.psi.impl.source.javadoc.PsiDocMethodOrFieldRef;
|
||||
import com.intellij.psi.impl.source.javadoc.PsiDocParamRef;
|
||||
import com.intellij.psi.impl.source.javadoc.PsiDocTagImpl;
|
||||
import com.intellij.psi.impl.source.parsing.JavaParsingContext;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiInlineDocTagImpl;
|
||||
import com.intellij.psi.tree.ICompositeElementType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.ILazyParseableElementType;
|
||||
import com.intellij.psi.tree.IReparseableElementType;
|
||||
import com.intellij.psi.tree.java.IJavaDocElementType;
|
||||
import com.intellij.util.CharTable;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
public interface JavaDocElementType {
|
||||
//chameleon
|
||||
IElementType DOC_TAG = new IJavaDocElementType("DOC_TAG");
|
||||
IElementType DOC_TAG_VALUE = new IJavaDocElementType("DOC_TAG_VALUE");
|
||||
IElementType DOC_INLINE_TAG = new IJavaDocElementType("DOC_INLINE_TAG");
|
||||
IElementType DOC_METHOD_OR_FIELD_REF = new IJavaDocElementType("DOC_METHOD_OR_FIELD_REF");
|
||||
IElementType DOC_PARAMETER_REF = new IJavaDocElementType("DOC_PARAMETER_REF");
|
||||
class JavaDocCompositeElementType extends IJavaDocElementType implements ICompositeElementType {
|
||||
private final Constructor<? extends ASTNode> myConstructor;
|
||||
|
||||
ILazyParseableElementType DOC_REFERENCE_HOLDER = new ILazyParseableElementType("DOC_REFERENCE_HOLDER", StdLanguages.JAVA){
|
||||
public ASTNode parseContents(ASTNode chameleon) {
|
||||
private JavaDocCompositeElementType(@NonNls final String debugName, final Class<? extends ASTNode> nodeClass) {
|
||||
super(debugName);
|
||||
myConstructor = ReflectionUtil.getDefaultConstructor(nodeClass);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return ReflectionUtil.createInstance(myConstructor);
|
||||
}
|
||||
}
|
||||
|
||||
class JavaDocLazyElementType extends ILazyParseableElementType {
|
||||
private JavaDocLazyElementType(@NonNls final String debugName) {
|
||||
super(debugName, StdLanguages.JAVA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode createNode(final CharSequence text) {
|
||||
return new LazyParseablePsiElement(this, text);
|
||||
}
|
||||
}
|
||||
|
||||
IElementType DOC_TAG = new JavaDocCompositeElementType("DOC_TAG", PsiDocTagImpl.class);
|
||||
IElementType DOC_INLINE_TAG = new JavaDocCompositeElementType("DOC_INLINE_TAG", PsiInlineDocTagImpl.class);
|
||||
IElementType DOC_METHOD_OR_FIELD_REF = new JavaDocCompositeElementType("DOC_METHOD_OR_FIELD_REF", PsiDocMethodOrFieldRef.class);
|
||||
IElementType DOC_PARAMETER_REF = new JavaDocCompositeElementType("DOC_PARAMETER_REF", PsiDocParamRef.class);
|
||||
|
||||
ILazyParseableElementType DOC_REFERENCE_HOLDER = new JavaDocLazyElementType("DOC_REFERENCE_HOLDER") {
|
||||
public ASTNode parseContents(final ASTNode chameleon) {
|
||||
final CharSequence chars = chameleon.getChars();
|
||||
final PsiManager manager = chameleon.getTreeParent().getPsi().getManager();
|
||||
final PsiElement psi = chameleon.getTreeParent().getPsi();
|
||||
assert psi != null : chameleon;
|
||||
final PsiManager manager = psi.getManager();
|
||||
final CharTable table = SharedImplUtil.findCharTableByTree(chameleon);
|
||||
//no language features from higher java language versions are present in javadoc
|
||||
JavaParsingContext context = new JavaParsingContext(table, LanguageLevel.JDK_1_3);
|
||||
final JavaParsingContext context = new JavaParsingContext(table, LanguageLevel.JDK_1_3);
|
||||
return context.getJavadocParsing().parseJavaDocReference(chars, new JavaLexer(LanguageLevel.JDK_1_3), false, manager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode createNode(CharSequence text) {
|
||||
return new LazyParseablePsiElement(this, text);
|
||||
}
|
||||
};
|
||||
|
||||
ILazyParseableElementType DOC_TYPE_HOLDER = new ILazyParseableElementType("DOC_TYPE_HOLDER", StdLanguages.JAVA){
|
||||
public ASTNode parseContents(ASTNode chameleon) {
|
||||
ILazyParseableElementType DOC_TYPE_HOLDER = new JavaDocLazyElementType("DOC_TYPE_HOLDER") {
|
||||
public ASTNode parseContents(final ASTNode chameleon) {
|
||||
final CharSequence chars = chameleon.getChars();
|
||||
final PsiManager manager = chameleon.getTreeParent().getPsi().getManager();
|
||||
final PsiElement psi = chameleon.getTreeParent().getPsi();
|
||||
assert psi != null : chameleon;
|
||||
final PsiManager manager = psi.getManager();
|
||||
final CharTable table = SharedImplUtil.findCharTableByTree(chameleon);
|
||||
//no language features from higher java language versions are present in javadoc
|
||||
JavaParsingContext context = new JavaParsingContext(table, LanguageLevel.JDK_1_3);
|
||||
final JavaParsingContext context = new JavaParsingContext(table, LanguageLevel.JDK_1_3);
|
||||
return context.getJavadocParsing().parseJavaDocReference(chars, new JavaLexer(LanguageLevel.JDK_1_3), true, manager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode createNode(CharSequence text) {
|
||||
return new LazyParseablePsiElement(this, text);
|
||||
}
|
||||
};
|
||||
|
||||
ILazyParseableElementType DOC_COMMENT = new IReparseableElementType("DOC_COMMENT", StdLanguages.JAVA){
|
||||
public ASTNode parseContents(ASTNode chameleon) {
|
||||
ILazyParseableElementType DOC_COMMENT = new IReparseableElementType("DOC_COMMENT", StdLanguages.JAVA) {
|
||||
@Override
|
||||
public ASTNode createNode(final CharSequence text) {
|
||||
return new PsiDocCommentImpl(text);
|
||||
}
|
||||
|
||||
public ASTNode parseContents(final ASTNode chameleon) {
|
||||
final CharSequence chars = chameleon.getChars();
|
||||
final PsiManager manager = chameleon.getTreeParent().getPsi().getManager();
|
||||
final PsiElement psi = chameleon.getTreeParent().getPsi();
|
||||
assert psi != null : chameleon;
|
||||
final PsiManager manager = psi.getManager();
|
||||
//no higher java language level features are allowed in javadoc
|
||||
final JavaParsingContext context = new JavaParsingContext(SharedImplUtil.findCharTableByTree(chameleon), LanguageLevel.JDK_1_3);
|
||||
return context.getJavadocParsing().parseDocCommentText(manager, chars, 0, chars.length());
|
||||
}
|
||||
|
||||
public boolean isParsable(CharSequence buffer, final Project project) {
|
||||
public boolean isParsable(final CharSequence buffer, final Project project) {
|
||||
final JavaLexer lexer = new JavaLexer(LanguageLevel.JDK_1_5);
|
||||
|
||||
lexer.start(buffer);
|
||||
if(lexer.getTokenType() != DOC_COMMENT) return false;
|
||||
if (lexer.getTokenType() != DOC_COMMENT) return false;
|
||||
lexer.advance();
|
||||
if(lexer.getTokenType() != null) return false;
|
||||
if (lexer.getTokenType() != null) return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,35 +28,54 @@ import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.source.JavaDummyElement;
|
||||
import com.intellij.psi.impl.source.*;
|
||||
import com.intellij.psi.impl.source.parsing.JavaParsingContext;
|
||||
import com.intellij.psi.impl.source.parsing.Parsing;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiCodeBlockImpl;
|
||||
import com.intellij.psi.impl.source.tree.java.*;
|
||||
import com.intellij.psi.text.BlockSupport;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.IErrorCounterReparseableElementType;
|
||||
import com.intellij.psi.tree.ILazyParseableElementType;
|
||||
import com.intellij.psi.tree.ILightLazyParseableElementType;
|
||||
import com.intellij.psi.tree.*;
|
||||
import com.intellij.psi.tree.java.IJavaElementType;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.CharTable;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
import com.intellij.util.diff.FlyweightCapableTreeStructure;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import static com.intellij.lang.PsiBuilderUtil.expect;
|
||||
|
||||
public interface JavaElementType {
|
||||
class JavaCompositeElementType extends IJavaElementType implements ICompositeElementType {
|
||||
private final Constructor<? extends ASTNode> myConstructor;
|
||||
|
||||
private JavaCompositeElementType(@NonNls final String debugName, final Class<? extends ASTNode> nodeClass) {
|
||||
super(debugName);
|
||||
myConstructor = ReflectionUtil.getDefaultConstructor(nodeClass);
|
||||
}
|
||||
|
||||
private JavaCompositeElementType(@NonNls final String debugName, final Class<? extends ASTNode> nodeClass, final boolean leftBound) {
|
||||
super(debugName, leftBound);
|
||||
myConstructor = ReflectionUtil.getDefaultConstructor(nodeClass);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return ReflectionUtil.createInstance(myConstructor);
|
||||
}
|
||||
}
|
||||
|
||||
IElementType CLASS = JavaStubElementTypes.CLASS;
|
||||
IElementType ANONYMOUS_CLASS = JavaStubElementTypes.ANONYMOUS_CLASS;
|
||||
IElementType ENUM_CONSTANT_INITIALIZER = JavaStubElementTypes.ENUM_CONSTANT_INITIALIZER;
|
||||
|
||||
IElementType TYPE_PARAMETER_LIST = JavaStubElementTypes.TYPE_PARAMETER_LIST;
|
||||
IElementType TYPE_PARAMETER = JavaStubElementTypes.TYPE_PARAMETER;
|
||||
|
||||
IElementType IMPORT_LIST = JavaStubElementTypes.IMPORT_LIST;
|
||||
IElementType IMPORT_STATEMENT = JavaStubElementTypes.IMPORT_STATEMENT;
|
||||
IElementType IMPORT_STATIC_STATEMENT = JavaStubElementTypes.IMPORT_STATIC_STATEMENT;
|
||||
|
||||
IElementType MODIFIER_LIST = JavaStubElementTypes.MODIFIER_LIST;
|
||||
IElementType ANNOTATION = JavaStubElementTypes.ANNOTATION;
|
||||
IElementType EXTENDS_LIST = JavaStubElementTypes.EXTENDS_LIST;
|
||||
@@ -65,71 +84,65 @@ public interface JavaElementType {
|
||||
IElementType ENUM_CONSTANT = JavaStubElementTypes.ENUM_CONSTANT;
|
||||
IElementType METHOD = JavaStubElementTypes.METHOD;
|
||||
IElementType ANNOTATION_METHOD = JavaStubElementTypes.ANNOTATION_METHOD;
|
||||
|
||||
IElementType CLASS_INITIALIZER = JavaStubElementTypes.CLASS_INITIALIZER;
|
||||
IElementType PARAMETER = JavaStubElementTypes.PARAMETER;
|
||||
IElementType PARAMETER_LIST = JavaStubElementTypes.PARAMETER_LIST;
|
||||
IElementType EXTENDS_BOUND_LIST = JavaStubElementTypes.EXTENDS_BOUND_LIST;
|
||||
IElementType THROWS_LIST = JavaStubElementTypes.THROWS_LIST;
|
||||
|
||||
IElementType IMPORT_STATIC_REFERENCE = new IJavaElementType("IMPORT_STATIC_REFERENCE");
|
||||
IElementType TYPE = new IJavaElementType("TYPE");
|
||||
IElementType DIAMOND_TYPE = new IJavaElementType("DIAMOND_TYPE");
|
||||
IElementType REFERENCE_PARAMETER_LIST = new IJavaElementType("REFERENCE_PARAMETER_LIST", true);
|
||||
IElementType JAVA_CODE_REFERENCE = new IJavaElementType("JAVA_CODE_REFERENCE");
|
||||
IElementType PACKAGE_STATEMENT = new IJavaElementType("PACKAGE_STATEMENT");
|
||||
IElementType IMPORT_STATIC_REFERENCE = new JavaCompositeElementType("IMPORT_STATIC_REFERENCE", PsiImportStaticReferenceElementImpl.class);
|
||||
IElementType TYPE = new JavaCompositeElementType("TYPE", PsiTypeElementImpl.class);
|
||||
IElementType DIAMOND_TYPE = new JavaCompositeElementType("DIAMOND_TYPE", PsiDiamondTypeElementImpl.class);
|
||||
IElementType REFERENCE_PARAMETER_LIST = new JavaCompositeElementType("REFERENCE_PARAMETER_LIST", PsiReferenceParameterListImpl.class, true);
|
||||
IElementType JAVA_CODE_REFERENCE = new JavaCompositeElementType("JAVA_CODE_REFERENCE", PsiJavaCodeReferenceElementImpl.class);
|
||||
IElementType PACKAGE_STATEMENT = new JavaCompositeElementType("PACKAGE_STATEMENT", PsiPackageStatementImpl.class);
|
||||
IElementType LOCAL_VARIABLE = new JavaCompositeElementType("LOCAL_VARIABLE", PsiLocalVariableImpl.class);
|
||||
IElementType REFERENCE_EXPRESSION = new JavaCompositeElementType("REFERENCE_EXPRESSION", PsiReferenceExpressionImpl.class);
|
||||
IElementType LITERAL_EXPRESSION = new JavaCompositeElementType("LITERAL_EXPRESSION", PsiLiteralExpressionImpl.class);
|
||||
IElementType THIS_EXPRESSION = new JavaCompositeElementType("THIS_EXPRESSION", PsiThisExpressionImpl.class);
|
||||
IElementType SUPER_EXPRESSION = new JavaCompositeElementType("SUPER_EXPRESSION", PsiSuperExpressionImpl.class);
|
||||
IElementType PARENTH_EXPRESSION = new JavaCompositeElementType("PARENTH_EXPRESSION", PsiParenthesizedExpressionImpl.class);
|
||||
IElementType METHOD_CALL_EXPRESSION = new JavaCompositeElementType("METHOD_CALL_EXPRESSION", PsiMethodCallExpressionImpl.class);
|
||||
IElementType TYPE_CAST_EXPRESSION = new JavaCompositeElementType("TYPE_CAST_EXPRESSION", PsiTypeCastExpressionImpl.class);
|
||||
IElementType PREFIX_EXPRESSION = new JavaCompositeElementType("PREFIX_EXPRESSION", PsiPrefixExpressionImpl.class);
|
||||
IElementType POSTFIX_EXPRESSION = new JavaCompositeElementType("POSTFIX_EXPRESSION", PsiPostfixExpressionImpl.class);
|
||||
IElementType BINARY_EXPRESSION = new JavaCompositeElementType("BINARY_EXPRESSION", PsiBinaryExpressionImpl.class);
|
||||
IElementType CONDITIONAL_EXPRESSION = new JavaCompositeElementType("CONDITIONAL_EXPRESSION", PsiConditionalExpressionImpl.class);
|
||||
IElementType ASSIGNMENT_EXPRESSION = new JavaCompositeElementType("ASSIGNMENT_EXPRESSION", PsiAssignmentExpressionImpl.class);
|
||||
IElementType NEW_EXPRESSION = new JavaCompositeElementType("NEW_EXPRESSION", PsiNewExpressionImpl.class);
|
||||
IElementType ARRAY_ACCESS_EXPRESSION = new JavaCompositeElementType("ARRAY_ACCESS_EXPRESSION", PsiArrayAccessExpressionImpl.class);
|
||||
IElementType ARRAY_INITIALIZER_EXPRESSION = new JavaCompositeElementType("ARRAY_INITIALIZER_EXPRESSION", PsiArrayInitializerExpressionImpl.class);
|
||||
IElementType INSTANCE_OF_EXPRESSION = new JavaCompositeElementType("INSTANCE_OF_EXPRESSION", PsiInstanceOfExpressionImpl.class);
|
||||
IElementType CLASS_OBJECT_ACCESS_EXPRESSION = new JavaCompositeElementType("CLASS_OBJECT_ACCESS_EXPRESSION", PsiClassObjectAccessExpressionImpl.class);
|
||||
IElementType EMPTY_EXPRESSION = new JavaCompositeElementType("EMPTY_EXPRESSION", PsiEmptyExpressionImpl.class, true);
|
||||
IElementType EXPRESSION_LIST = new JavaCompositeElementType("EXPRESSION_LIST", PsiExpressionListImpl.class, true);
|
||||
IElementType EMPTY_STATEMENT = new JavaCompositeElementType("EMPTY_STATEMENT", PsiEmptyStatementImpl.class);
|
||||
IElementType BLOCK_STATEMENT = new JavaCompositeElementType("BLOCK_STATEMENT", PsiBlockStatementImpl.class);
|
||||
IElementType EXPRESSION_STATEMENT = new JavaCompositeElementType("EXPRESSION_STATEMENT", PsiExpressionStatementImpl.class);
|
||||
IElementType EXPRESSION_LIST_STATEMENT = new JavaCompositeElementType("EXPRESSION_LIST_STATEMENT", PsiExpressionListStatementImpl.class);
|
||||
IElementType DECLARATION_STATEMENT = new JavaCompositeElementType("DECLARATION_STATEMENT", PsiDeclarationStatementImpl.class);
|
||||
IElementType IF_STATEMENT = new JavaCompositeElementType("IF_STATEMENT", PsiIfStatementImpl.class);
|
||||
IElementType WHILE_STATEMENT = new JavaCompositeElementType("WHILE_STATEMENT", PsiWhileStatementImpl.class);
|
||||
IElementType FOR_STATEMENT = new JavaCompositeElementType("FOR_STATEMENT", PsiForStatementImpl.class);
|
||||
IElementType FOREACH_STATEMENT = new JavaCompositeElementType("FOREACH_STATEMENT", PsiForeachStatementImpl.class);
|
||||
IElementType DO_WHILE_STATEMENT = new JavaCompositeElementType("DO_WHILE_STATEMENT", PsiDoWhileStatementImpl.class);
|
||||
IElementType SWITCH_STATEMENT = new JavaCompositeElementType("SWITCH_STATEMENT", PsiSwitchStatementImpl.class);
|
||||
IElementType SWITCH_LABEL_STATEMENT = new JavaCompositeElementType("SWITCH_LABEL_STATEMENT", PsiSwitchLabelStatementImpl.class);
|
||||
IElementType BREAK_STATEMENT = new JavaCompositeElementType("BREAK_STATEMENT", PsiBreakStatementImpl.class);
|
||||
IElementType CONTINUE_STATEMENT = new JavaCompositeElementType("CONTINUE_STATEMENT", PsiContinueStatementImpl.class);
|
||||
IElementType RETURN_STATEMENT = new JavaCompositeElementType("RETURN_STATEMENT", PsiReturnStatementImpl.class);
|
||||
IElementType THROW_STATEMENT = new JavaCompositeElementType("THROW_STATEMENT", PsiThrowStatementImpl.class);
|
||||
IElementType SYNCHRONIZED_STATEMENT = new JavaCompositeElementType("SYNCHRONIZED_STATEMENT", PsiSynchronizedStatementImpl.class);
|
||||
IElementType TRY_STATEMENT = new JavaCompositeElementType("TRY_STATEMENT", PsiTryStatementImpl.class);
|
||||
IElementType LABELED_STATEMENT = new JavaCompositeElementType("LABELED_STATEMENT", PsiLabeledStatementImpl.class);
|
||||
IElementType ASSERT_STATEMENT = new JavaCompositeElementType("ASSERT_STATEMENT", PsiAssertStatementImpl.class);
|
||||
IElementType CATCH_SECTION = new JavaCompositeElementType("CATCH_SECTION", PsiCatchSectionImpl.class);
|
||||
IElementType ANNOTATION_ARRAY_INITIALIZER = new JavaCompositeElementType("ANNOTATION_ARRAY_INITIALIZER", PsiArrayInitializerMemberValueImpl.class);
|
||||
IElementType NAME_VALUE_PAIR = new JavaCompositeElementType("NAME_VALUE_PAIR", PsiNameValuePairImpl.class, true);
|
||||
IElementType ANNOTATION_PARAMETER_LIST = new JavaCompositeElementType("ANNOTATION_PARAMETER_LIST", PsiAnnotationParameterListImpl.class, true);
|
||||
IElementType METHOD_RECEIVER = new JavaCompositeElementType("METHOD_RECEIVER", PsiMethodReceiverImpl.class);
|
||||
|
||||
IElementType LOCAL_VARIABLE = new IJavaElementType("LOCAL_VARIABLE");
|
||||
IElementType REFERENCE_EXPRESSION = new IJavaElementType("REFERENCE_EXPRESSION");
|
||||
IElementType LITERAL_EXPRESSION = new IJavaElementType("LITERAL_EXPRESSION");
|
||||
IElementType THIS_EXPRESSION = new IJavaElementType("THIS_EXPRESSION");
|
||||
IElementType SUPER_EXPRESSION = new IJavaElementType("SUPER_EXPRESSION");
|
||||
IElementType PARENTH_EXPRESSION = new IJavaElementType("PARENTH_EXPRESSION");
|
||||
IElementType METHOD_CALL_EXPRESSION = new IJavaElementType("METHOD_CALL_EXPRESSION");
|
||||
IElementType TYPE_CAST_EXPRESSION = new IJavaElementType("TYPE_CAST_EXPRESSION");
|
||||
IElementType PREFIX_EXPRESSION = new IJavaElementType("PREFIX_EXPRESSION");
|
||||
IElementType POSTFIX_EXPRESSION = new IJavaElementType("POSTFIX_EXPRESSION");
|
||||
IElementType BINARY_EXPRESSION = new IJavaElementType("BINARY_EXPRESSION");
|
||||
IElementType CONDITIONAL_EXPRESSION = new IJavaElementType("CONDITIONAL_EXPRESSION");
|
||||
IElementType ASSIGNMENT_EXPRESSION = new IJavaElementType("ASSIGNMENT_EXPRESSION");
|
||||
IElementType NEW_EXPRESSION = new IJavaElementType("NEW_EXPRESSION");
|
||||
IElementType ARRAY_ACCESS_EXPRESSION = new IJavaElementType("ARRAY_ACCESS_EXPRESSION");
|
||||
IElementType ARRAY_INITIALIZER_EXPRESSION = new IJavaElementType("ARRAY_INITIALIZER_EXPRESSION");
|
||||
IElementType INSTANCE_OF_EXPRESSION = new IJavaElementType("INSTANCE_OF_EXPRESSION");
|
||||
IElementType CLASS_OBJECT_ACCESS_EXPRESSION = new IJavaElementType("CLASS_OBJECT_ACCESS_EXPRESSION");
|
||||
IElementType EMPTY_EXPRESSION = new IJavaElementType("EMPTY_EXPRESSION", true);
|
||||
|
||||
IElementType EXPRESSION_LIST = new IJavaElementType("EXPRESSION_LIST", true);
|
||||
|
||||
IElementType EMPTY_STATEMENT = new IJavaElementType("EMPTY_STATEMENT");
|
||||
IElementType BLOCK_STATEMENT = new IJavaElementType("BLOCK_STATEMENT");
|
||||
IElementType EXPRESSION_STATEMENT = new IJavaElementType("EXPRESSION_STATEMENT");
|
||||
IElementType EXPRESSION_LIST_STATEMENT = new IJavaElementType("EXPRESSION_LIST_STATEMENT");
|
||||
IElementType DECLARATION_STATEMENT = new IJavaElementType("DECLARATION_STATEMENT");
|
||||
IElementType IF_STATEMENT = new IJavaElementType("IF_STATEMENT");
|
||||
IElementType WHILE_STATEMENT = new IJavaElementType("WHILE_STATEMENT");
|
||||
IElementType FOR_STATEMENT = new IJavaElementType("FOR_STATEMENT");
|
||||
IElementType FOREACH_STATEMENT = new IJavaElementType("FOREACH_STATEMENT");
|
||||
IElementType DO_WHILE_STATEMENT = new IJavaElementType("DO_WHILE_STATEMENT");
|
||||
IElementType SWITCH_STATEMENT = new IJavaElementType("SWITCH_STATEMENT");
|
||||
IElementType SWITCH_LABEL_STATEMENT = new IJavaElementType("SWITCH_LABEL_STATEMENT");
|
||||
IElementType BREAK_STATEMENT = new IJavaElementType("BREAK_STATEMENT");
|
||||
IElementType CONTINUE_STATEMENT = new IJavaElementType("CONTINUE_STATEMENT");
|
||||
IElementType RETURN_STATEMENT = new IJavaElementType("RETURN_STATEMENT");
|
||||
IElementType THROW_STATEMENT = new IJavaElementType("THROW_STATEMENT");
|
||||
IElementType SYNCHRONIZED_STATEMENT = new IJavaElementType("SYNCHRONIZED_STATEMENT");
|
||||
IElementType TRY_STATEMENT = new IJavaElementType("TRY_STATEMENT");
|
||||
IElementType LABELED_STATEMENT = new IJavaElementType("LABELED_STATEMENT");
|
||||
IElementType ASSERT_STATEMENT = new IJavaElementType("ASSERT_STATEMENT");
|
||||
|
||||
IElementType CATCH_SECTION = new IJavaElementType("CATCH_SECTION");
|
||||
|
||||
IElementType ANNOTATION_ARRAY_INITIALIZER = new IJavaElementType("ANNOTATION_ARRAY_INITIALIZER");
|
||||
IElementType NAME_VALUE_PAIR = new IJavaElementType("NAME_VALUE_PAIR", true);
|
||||
IElementType ANNOTATION_PARAMETER_LIST = new IJavaElementType("ANNOTATION_PARAMETER_LIST", true);
|
||||
IElementType METHOD_RECEIVER = new IJavaElementType("METHOD_RECEIVER");
|
||||
|
||||
class ICodeBlockElementType extends IErrorCounterReparseableElementType {
|
||||
class ICodeBlockElementType extends IErrorCounterReparseableElementType implements ICompositeElementType {
|
||||
private ICodeBlockElementType() {
|
||||
super("CODE_BLOCK", StdLanguages.JAVA);
|
||||
}
|
||||
@@ -139,6 +152,12 @@ public interface JavaElementType {
|
||||
return new PsiCodeBlockImpl(text);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new PsiCodeBlockImpl(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode parseContents(final ASTNode chameleon) {
|
||||
if (JavaParserDefinition.USE_NEW_PARSER) {
|
||||
@@ -277,7 +296,17 @@ public interface JavaElementType {
|
||||
}
|
||||
};
|
||||
|
||||
IElementType DUMMY_ELEMENT = new ILazyParseableElementType("DUMMY_ELEMENT", StdLanguages.JAVA) {
|
||||
class JavaDummyElementType extends ILazyParseableElementType implements ICompositeElementType {
|
||||
private JavaDummyElementType() {
|
||||
super("DUMMY_ELEMENT", StdLanguages.JAVA);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new CompositePsiElement(this) { };
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ASTNode parseContents(final ASTNode chameleon) {
|
||||
@@ -285,5 +314,6 @@ public interface JavaElementType {
|
||||
final JavaDummyElement dummyElement = (JavaDummyElement)chameleon;
|
||||
return JavaParserUtil.parseFragment(chameleon, dummyElement.getParser(), dummyElement.consumeAll(), dummyElement.getLanguageLevel());
|
||||
}
|
||||
};
|
||||
}
|
||||
IElementType DUMMY_ELEMENT = new JavaDummyElementType();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ PsiJavaFile:New15.java
|
||||
PsiReferenceParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeElement:
|
||||
PsiElement(DIAMOND_TYPE)
|
||||
PsiTypeElement:DIAMOND
|
||||
<empty list>
|
||||
PsiJavaToken:GT('>')
|
||||
PsiExpressionList
|
||||
|
||||
@@ -5,6 +5,6 @@ PsiJavaFile:Type7.java
|
||||
PsiReferenceParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeElement:
|
||||
PsiElement(DIAMOND_TYPE)
|
||||
PsiTypeElement:DIAMOND
|
||||
<empty list>
|
||||
PsiJavaToken:GT('>')
|
||||
@@ -20,6 +20,7 @@ import com.intellij.lexer.LexerUtil;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.impl.source.CharTableImpl;
|
||||
import com.intellij.psi.impl.source.CodeFragmentElement;
|
||||
import com.intellij.psi.impl.source.DummyHolderElement;
|
||||
import com.intellij.psi.impl.source.codeStyle.CodeEditUtil;
|
||||
import com.intellij.psi.impl.source.tree.*;
|
||||
import com.intellij.psi.tree.*;
|
||||
@@ -39,14 +40,18 @@ public abstract class ASTFactory {
|
||||
|
||||
@Nullable
|
||||
public LazyParseableElement createLazy(final ILazyParseableElementType type, final CharSequence text) {
|
||||
return DEFAULT.createLazy(type, text);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract CompositeElement createComposite(final IElementType type);
|
||||
public CompositeElement createComposite(final IElementType type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract LeafElement createLeaf(final IElementType type, final CharSequence text);
|
||||
public LeafElement createLeaf(final IElementType type, final CharSequence text) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// factory methods
|
||||
|
||||
@@ -58,6 +63,9 @@ public abstract class ASTFactory {
|
||||
if (type == TokenType.CODE_FRAGMENT) {
|
||||
return new CodeFragmentElement(null);
|
||||
}
|
||||
else if (type == TokenType.DUMMY_HOLDER) {
|
||||
return new DummyHolderElement(text);
|
||||
}
|
||||
|
||||
final LazyParseableElement customLazy = factory(type).createLazy(type, text);
|
||||
return customLazy != null ? customLazy : DEFAULT.createLazy(type, text);
|
||||
@@ -69,10 +77,6 @@ public abstract class ASTFactory {
|
||||
return (CompositeElement)((ICompositeElementType)type).createCompositeNode();
|
||||
}
|
||||
|
||||
if (type == TokenType.CODE_FRAGMENT) {
|
||||
return new CodeFragmentElement(null);
|
||||
}
|
||||
|
||||
final CompositeElement customComposite = factory(type).createComposite(type);
|
||||
return customComposite != null ? customComposite : DEFAULT.createComposite(type);
|
||||
}
|
||||
@@ -159,6 +163,7 @@ public abstract class ASTFactory {
|
||||
return new PsiCommentImpl(type, text);
|
||||
}
|
||||
}
|
||||
|
||||
return new LeafPsiElement(type, text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,15 +81,10 @@ public class ReflectionUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
//void f() {} sdfg
|
||||
public static String declarationToString(final GenericDeclaration anInterface) {
|
||||
|
||||
return anInterface.toString()
|
||||
|
||||
+ Arrays.asList(anInterface.getTypeParameters())
|
||||
+
|
||||
|
||||
" loaded by " + ((Class)anInterface).getClassLoader();
|
||||
+ " loaded by " + ((Class)anInterface).getClassLoader();
|
||||
}
|
||||
|
||||
public static Class<?> getRawType(Type type) {
|
||||
@@ -160,9 +155,7 @@ public class ReflectionUtil {
|
||||
|
||||
private static void collectFields(final Class clazz, final ArrayList<Field> result) {
|
||||
final Field[] fields = clazz.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
result.add(field);
|
||||
}
|
||||
result.addAll(Arrays.asList(fields));
|
||||
final Class superClass = clazz.getSuperclass();
|
||||
if (superClass != null) {
|
||||
collectFields(superClass, result);
|
||||
@@ -270,4 +263,36 @@ public class ReflectionUtil {
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> Constructor<T> getDefaultConstructor(final Class<T> aClass) {
|
||||
try {
|
||||
final Constructor<T> constructor = aClass.getConstructor();
|
||||
constructor.setAccessible(true);
|
||||
return constructor;
|
||||
}
|
||||
catch (NoSuchMethodException e) {
|
||||
LOG.error("No default constructor in " + aClass, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> T createInstance(final Constructor<T> constructor, final Object... args) {
|
||||
try {
|
||||
return constructor.newInstance(args);
|
||||
}
|
||||
catch (InstantiationException e) {
|
||||
LOG.error(e);
|
||||
return null;
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
LOG.error(e);
|
||||
return null;
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
LOG.error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user