mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Optimize type info creation for constructor stubs
This commit is contained in:
+11
-10
@@ -131,6 +131,11 @@ public class TypeInfo {
|
||||
return new TypeInfo(StringRef.fromString(text), (byte)arrayCount, isEllipsis, list);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static TypeInfo createConstructorType() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static TypeInfo create(final LighterAST tree, final LighterASTNode element, final StubElement parentStub) {
|
||||
final String text;
|
||||
@@ -153,18 +158,14 @@ public class TypeInfo {
|
||||
}
|
||||
}
|
||||
|
||||
if (typeElement == null) {
|
||||
if (element.getTokenType() == JavaElementType.METHOD) {
|
||||
return NULL; // constructor
|
||||
}
|
||||
else if (element.getTokenType() == JavaElementType.FIELD) {
|
||||
final List<LighterASTNode> fields = LightTreeUtil.getChildrenOfType(tree, tree.getParent(element), JavaElementType.FIELD);
|
||||
final int idx = fields.indexOf(element);
|
||||
for (int i = idx - 1; i >= 0 && typeElement == null; i--) { // int i, j
|
||||
typeElement = LightTreeUtil.firstChildOfType(tree, fields.get(i), JavaElementType.TYPE);
|
||||
}
|
||||
if (typeElement == null && element.getTokenType() == JavaElementType.FIELD) {
|
||||
final List<LighterASTNode> fields = LightTreeUtil.getChildrenOfType(tree, tree.getParent(element), JavaElementType.FIELD);
|
||||
final int idx = fields.indexOf(element);
|
||||
for (int i = idx - 1; i >= 0 && typeElement == null; i--) { // int i, j
|
||||
typeElement = LightTreeUtil.firstChildOfType(tree, fields.get(i), JavaElementType.TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
assert typeElement != null : element + " in " + parentStub;
|
||||
|
||||
isEllipsis = (LightTreeUtil.firstChildOfType(tree, typeElement, JavaTokenType.ELLIPSIS) != null);
|
||||
|
||||
@@ -94,8 +94,6 @@ public abstract class JavaMethodElementType extends JavaStubElementType<PsiMetho
|
||||
|
||||
@Override
|
||||
public PsiMethodStub createStub(final LighterAST tree, final LighterASTNode node, final StubElement parentStub) {
|
||||
final TypeInfo typeInfo = TypeInfo.create(tree, node, parentStub);
|
||||
|
||||
String name = null;
|
||||
boolean isConstructor = true;
|
||||
boolean isVarArgs = false;
|
||||
@@ -137,6 +135,7 @@ public abstract class JavaMethodElementType extends JavaStubElementType<PsiMetho
|
||||
}
|
||||
}
|
||||
|
||||
final TypeInfo typeInfo = isConstructor ? TypeInfo.createConstructorType() : TypeInfo.create(tree, node, parentStub);
|
||||
final boolean isAnno = (node.getTokenType() == JavaElementType.ANNOTATION_METHOD);
|
||||
final byte flags = PsiMethodStubImpl.packFlags(isConstructor, isAnno, isVarArgs, isDeprecatedByComment, hasDeprecatedAnnotation);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user