From f687ea05c2fb26fa3f6745ad41b26f108444c29b Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Wed, 20 Nov 2024 10:02:37 +0100 Subject: [PATCH] Cleanup. --- .../org-netbeans-modules-java-completion.sig | 16 ++++---------- .../java/completion/JavaCompletionTask.java | 16 +++++++------- .../java/completion/CompletionTestBase.java | 22 ++++--------------- .../editor/java/JavaCompletionCollector.java | 6 ++--- .../editor/java/JavaCompletionItem.java | 10 ++++----- .../java/JavaCompletionItemFactory.java | 8 +++---- .../editor/java/LazyJavaCompletionItem.java | 10 ++++----- 7 files changed, 31 insertions(+), 57 deletions(-) diff --git a/java/java.completion/nbproject/org-netbeans-modules-java-completion.sig b/java/java.completion/nbproject/org-netbeans-modules-java-completion.sig index f80375312123..21d34200b392 100644 --- a/java/java.completion/nbproject/org-netbeans-modules-java-completion.sig +++ b/java/java.completion/nbproject/org-netbeans-modules-java-completion.sig @@ -1,5 +1,5 @@ #Signature file v4.1 -#Version 2.13.0 +#Version 2.11.0 CLSS public abstract interface java.io.Serializable @@ -8,10 +8,8 @@ meth public abstract int compareTo({java.lang.Comparable%0}) CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.Enum%0}>> cons protected init(java.lang.String,int) -innr public final static EnumDesc intf java.io.Serializable intf java.lang.Comparable<{java.lang.Enum%0}> -intf java.lang.constant.Constable meth protected final java.lang.Object clone() throws java.lang.CloneNotSupportedException meth protected final void finalize() meth public final boolean equals(java.lang.Object) @@ -20,7 +18,6 @@ meth public final int hashCode() meth public final int ordinal() meth public final java.lang.Class<{java.lang.Enum%0}> getDeclaringClass() meth public final java.lang.String name() -meth public final java.util.Optional> describeConstable() meth public java.lang.String toString() meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.lang.Class<{%%0}>,java.lang.String) supr java.lang.Object @@ -35,7 +32,6 @@ CLSS public java.lang.Object cons public init() meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException meth protected void finalize() throws java.lang.Throwable - anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="9") meth public boolean equals(java.lang.Object) meth public final java.lang.Class getClass() meth public final void notify() @@ -72,9 +68,6 @@ CLSS public abstract interface !annotation java.lang.annotation.Target intf java.lang.annotation.Annotation meth public abstract java.lang.annotation.ElementType[] value() -CLSS public abstract interface java.lang.constant.Constable -meth public abstract java.util.Optional describeConstable() - CLSS public final org.netbeans.modules.java.completion.JavaCompletionTask<%0 extends java.lang.Object> fld protected final int caretOffset fld protected final java.util.concurrent.Callable cancel @@ -95,8 +88,7 @@ meth public static <%0 extends java.lang.Object> org.netbeans.modules.java.compl anno 4 org.netbeans.api.annotations.common.NullAllowed() meth public void run(org.netbeans.modules.parsing.api.ResultIterator) throws java.lang.Exception supr org.netbeans.modules.parsing.api.UserTask -hfds ABSTRACT_KEYWORD,ASSERT_KEYWORD,BLOCK_KEYWORDS,BOOLEAN_KEYWORD,BREAK_KEYWORD,BYTE_KEYWORD,CASE_KEYWORD,CATCH_KEYWORD,CHAR_KEYWORD,CLASS_BODY_KEYWORDS,CLASS_KEYWORD,COLON,CONTINUE_KEYWORD,DEFAULT_KEYWORD,DOUBLE_KEYWORD,DO_KEYWORD,ELSE_KEYWORD,EMPTY,ENUM_KEYWORD,ERROR,EXPORTS_KEYWORD,EXTENDS_KEYWORD,FALSE_KEYWORD,FINALLY_KEYWORD,FINAL_KEYWORD,FLOAT_KEYWORD,FOR_KEYWORD,IF_KEYWORD,IMPLEMENTS_KEYWORD,IMPORT_KEYWORD,INIT,INSTANCEOF_KEYWORD,INTERFACE_KEYWORD,INT_KEYWORD,JAVA_LANG_CLASS,JAVA_LANG_ITERABLE,JAVA_LANG_OBJECT,JAVA_LANG_STRING,LONG_KEYWORD,MODULE_BODY_KEYWORDS,MODULE_KEYWORD,NATIVE_KEYWORD,NEW_KEYWORD,NON_SEALED_KEYWORD,NULL_KEYWORD,OPENS_KEYWORD,OPEN_KEYWORD,PACKAGE_KEYWORD,PERMITS_KEYWORD,PRIM_KEYWORDS,PRIVATE_KEYWORD,PROTECTED_KEYWORD,PROVIDES_KEYWORD,PUBLIC_KEYWORD,RECORD_KEYWORD,REQUIRES_KEYWORD,RETURN_KEYWORD,SEALED_KEYWORD,SEMI,SHORT_KEYWORD,SPACE,STATEMENT_KEYWORDS,STATEMENT_SPACE_KEYWORDS,STATIC_KEYWORD,STRICT_KEYWORD,SUPER_KEYWORD,SWITCH_KEYWORD,SYNCHRONIZED_KEYWORD,THIS_KEYWORD,THROWS_KEYWORD,THROW_KEYWORD,TO_KEYWORD,TRANSIENT_KEYWORD,TRANSITIVE_KEYWORD,TRUE_KEYWORD,TRY_KEYWORD,USES_KEYWORD,VAR_KEYWORD,VOID_KEYWORD,VOLATILE_KEYWORD,WHEN_KEYWORD,WHILE_KEYWORD,WITH_KEYWORD,YIELD_KEYWORD,anchorOffset,hasAdditionalClasses,hasAdditionalMembers,itemFactory,options,results -hcls AddTypeItem +hfds ABSTRACT_KEYWORD,ASSERT_KEYWORD,BLOCK_KEYWORDS,BOOLEAN_KEYWORD,BREAK_KEYWORD,BYTE_KEYWORD,CASE_KEYWORD,CATCH_KEYWORD,CHAR_KEYWORD,CLASS_BODY_KEYWORDS,CLASS_KEYWORD,COLON,CONTINUE_KEYWORD,DEFAULT_KEYWORD,DOUBLE_KEYWORD,DO_KEYWORD,ELSE_KEYWORD,EMPTY,ENUM_KEYWORD,ERROR,EXPORTS_KEYWORD,EXTENDS_KEYWORD,FALSE_KEYWORD,FINALLY_KEYWORD,FINAL_KEYWORD,FLOAT_KEYWORD,FOR_KEYWORD,IF_KEYWORD,IMPLEMENTS_KEYWORD,IMPORT_KEYWORD,INIT,INSTANCEOF_KEYWORD,INTERFACE_KEYWORD,INT_KEYWORD,JAVA_LANG_CLASS,JAVA_LANG_ITERABLE,JAVA_LANG_OBJECT,LONG_KEYWORD,MODULE_BODY_KEYWORDS,MODULE_KEYWORD,NATIVE_KEYWORD,NEW_KEYWORD,NON_SEALED_KEYWORD,NULL_KEYWORD,OPENS_KEYWORD,OPEN_KEYWORD,PACKAGE_KEYWORD,PERMITS_KEYWORD,PRIM_KEYWORDS,PRIVATE_KEYWORD,PROTECTED_KEYWORD,PROVIDES_KEYWORD,PUBLIC_KEYWORD,RECORD_KEYWORD,REQUIRES_KEYWORD,RETURN_KEYWORD,SEALED_KEYWORD,SEMI,SHORT_KEYWORD,SPACE,STATEMENT_KEYWORDS,STATEMENT_SPACE_KEYWORDS,STATIC_KEYWORD,STRICT_KEYWORD,SUPER_KEYWORD,SWITCH_KEYWORD,SYNCHRONIZED_KEYWORD,THIS_KEYWORD,THROWS_KEYWORD,THROW_KEYWORD,TO_KEYWORD,TRANSIENT_KEYWORD,TRANSITIVE_KEYWORD,TRUE_KEYWORD,TRY_KEYWORD,USES_KEYWORD,VAR_KEYWORD,VOID_KEYWORD,VOLATILE_KEYWORD,WHEN_KEYWORD,WHILE_KEYWORD,WITH_KEYWORD,YIELD_KEYWORD,anchorOffset,hasAdditionalClasses,hasAdditionalMembers,itemFactory,options,results CLSS public abstract interface static org.netbeans.modules.java.completion.JavaCompletionTask$ItemFactory<%0 extends java.lang.Object> outer org.netbeans.modules.java.completion.JavaCompletionTask @@ -113,8 +105,8 @@ meth public abstract {org.netbeans.modules.java.completion.JavaCompletionTask$It meth public abstract {org.netbeans.modules.java.completion.JavaCompletionTask$ItemFactory%0} createOverrideMethodItem(org.netbeans.api.java.source.CompilationInfo,javax.lang.model.element.ExecutableElement,javax.lang.model.type.ExecutableType,int,boolean) meth public abstract {org.netbeans.modules.java.completion.JavaCompletionTask$ItemFactory%0} createPackageItem(java.lang.String,int,boolean) meth public abstract {org.netbeans.modules.java.completion.JavaCompletionTask$ItemFactory%0} createParametersItem(org.netbeans.api.java.source.CompilationInfo,javax.lang.model.element.ExecutableElement,javax.lang.model.type.ExecutableType,int,boolean,int,java.lang.String) -meth public abstract {org.netbeans.modules.java.completion.JavaCompletionTask$ItemFactory%0} createStaticMemberItem(org.netbeans.api.java.source.CompilationInfo,javax.lang.model.type.DeclaredType,javax.lang.model.element.Element,javax.lang.model.type.TypeMirror,boolean,int,boolean,boolean,boolean) -meth public abstract {org.netbeans.modules.java.completion.JavaCompletionTask$ItemFactory%0} createStaticMemberItem(org.netbeans.api.java.source.ElementHandle,java.lang.String,int,boolean,org.netbeans.api.java.source.support.ReferencesCount,org.netbeans.modules.parsing.api.Source,boolean) +meth public abstract {org.netbeans.modules.java.completion.JavaCompletionTask$ItemFactory%0} createStaticMemberItem(org.netbeans.api.java.source.CompilationInfo,javax.lang.model.type.DeclaredType,javax.lang.model.element.Element,javax.lang.model.type.TypeMirror,boolean,int,boolean,boolean) +meth public abstract {org.netbeans.modules.java.completion.JavaCompletionTask$ItemFactory%0} createStaticMemberItem(org.netbeans.api.java.source.ElementHandle,java.lang.String,int,boolean,org.netbeans.api.java.source.support.ReferencesCount,org.netbeans.modules.parsing.api.Source) meth public abstract {org.netbeans.modules.java.completion.JavaCompletionTask$ItemFactory%0} createThisOrSuperConstructorItem(org.netbeans.api.java.source.CompilationInfo,javax.lang.model.element.ExecutableElement,javax.lang.model.type.ExecutableType,int,boolean,java.lang.String) meth public abstract {org.netbeans.modules.java.completion.JavaCompletionTask$ItemFactory%0} createTypeItem(org.netbeans.api.java.source.CompilationInfo,javax.lang.model.element.TypeElement,javax.lang.model.type.DeclaredType,int,org.netbeans.api.java.source.support.ReferencesCount,boolean,boolean,boolean,boolean,boolean,boolean) meth public abstract {org.netbeans.modules.java.completion.JavaCompletionTask$ItemFactory%0} createTypeItem(org.netbeans.api.java.source.ElementHandle,java.util.EnumSet,int,org.netbeans.api.java.source.support.ReferencesCount,org.netbeans.modules.parsing.api.Source,boolean,boolean,boolean) diff --git a/java/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java b/java/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java index fb90e14c86ac..fb03fd583e45 100644 --- a/java/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java +++ b/java/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java @@ -107,9 +107,9 @@ public static interface ItemFactory { T createAttributeValueItem(CompilationInfo info, String value, String documentation, TypeElement element, int substitutionOffset, ReferencesCount referencesCount); - T createStaticMemberItem(CompilationInfo info, DeclaredType type, Element memberElem, TypeMirror memberType, boolean multipleVersions, int substitutionOffset, boolean isDeprecated, boolean addSemicolon, boolean smartType); + T createStaticMemberItem(CompilationInfo info, DeclaredType type, Element memberElem, TypeMirror memberType, boolean multipleVersions, int substitutionOffset, boolean isDeprecated, boolean addSemicolon); - T createStaticMemberItem(ElementHandle handle, String name, int substitutionOffset, boolean addSemicolon, ReferencesCount referencesCount, Source source, boolean smartType); + T createStaticMemberItem(ElementHandle handle, String name, int substitutionOffset, boolean addSemicolon, ReferencesCount referencesCount, Source source); T createChainedMembersItem(CompilationInfo info, List chainedElems, List chainedTypes, int substitutionOffset, boolean isDeprecated, boolean addSemicolon); @@ -2652,7 +2652,7 @@ public void addTypeItem(CompilationInfo info, TypeElement elem, DeclaredType typ continue; } //not filtering deprecated, etc., as those may be needed for exhaustiveness: - results.add(itemFactory.createStaticMemberItem(info, type, enumConstant, enumConstant.asType(), false, anchorOffset, info.getElements().isDeprecated(enumConstant), false, true)); + results.add(itemFactory.createStaticMemberItem(info, type, enumConstant, enumConstant.asType(), false, anchorOffset, info.getElements().isDeprecated(enumConstant), false)); } } } @@ -3577,7 +3577,7 @@ public boolean accept(Element e, TypeMirror t) { }; for (Element ee : controller.getElementUtilities().getMembers(type, acceptor)) { if (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(ee)) { - results.add(itemFactory.createStaticMemberItem(env.getController(), type, ee, asMemberOf(ee, type, types), false, anchorOffset, elements.isDeprecated(ee), false, true)); + results.add(itemFactory.createStaticMemberItem(env.getController(), type, ee, asMemberOf(ee, type, types), false, anchorOffset, elements.isDeprecated(ee), false)); } } } @@ -3661,7 +3661,7 @@ public boolean accept(Element e, TypeMirror t) { }; for (Element ee : controller.getElementUtilities().getMembers(type, acceptor)) { if (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(ee)) { - results.add(itemFactory.createStaticMemberItem(env.getController(), type, ee, asMemberOf(ee, type, types), false, anchorOffset, elements.isDeprecated(ee), env.addSemicolon(), true)); + results.add(itemFactory.createStaticMemberItem(env.getController(), type, ee, asMemberOf(ee, type, types), false, anchorOffset, elements.isDeprecated(ee), env.addSemicolon())); } } } @@ -3698,7 +3698,7 @@ public boolean accept(Element e, TypeMirror t) { } ExecutableType et = (ExecutableType) asMemberOf(e, enclClass != null ? enclClass.asType() : null, types); if (e.getEnclosingElement() != enclClass && conflictsWithLocalMethods(e.getSimpleName(), enclClass, methodsIn)) { - results.add(itemFactory.createStaticMemberItem(env.getController(), (DeclaredType)e.getEnclosingElement().asType(), e, et, false, anchorOffset, elements.isDeprecated(e), env.addSemicolon(), true)); + results.add(itemFactory.createStaticMemberItem(env.getController(), (DeclaredType)e.getEnclosingElement().asType(), e, et, false, anchorOffset, elements.isDeprecated(e), env.addSemicolon())); } else { results.add(itemFactory.createExecutableItem(env.getController(), (ExecutableElement) e, et, anchorOffset, null, env.getScope().getEnclosingClass() != e.getEnclosingElement(), elements.isDeprecated(e), false, env.addSemicolon(), isOfSmartType(env, getCorrectedReturnType(env, et, (ExecutableElement) e, enclClass != null ? enclClass.asType() : null), smartTypes), env.assignToVarPos(), false)); } @@ -3870,7 +3870,7 @@ public boolean accept(Element e, TypeMirror t) { for (DeclaredType dt : dts) { if (startsWith(env, dt.asElement().getSimpleName().toString())) { for (Element ee : controller.getElementUtilities().getMembers(dt, acceptor)) { - results.add(itemFactory.createStaticMemberItem(env.getController(), dt, ee, asMemberOf(ee, dt, types), false, anchorOffset, elements.isDeprecated(ee), env.addSemicolon(), true)); + results.add(itemFactory.createStaticMemberItem(env.getController(), dt, ee, asMemberOf(ee, dt, types), false, anchorOffset, elements.isDeprecated(ee), env.addSemicolon())); } } } @@ -3967,7 +3967,7 @@ private void addAllStaticMemberNames(final Env env) { } for (String name : symbols.getSymbols()) { if (!Utilities.isExcludeMethods() || !Utilities.isExcluded(symbols.getEnclosingType().getQualifiedName() + '.' + name)) { - results.add(itemFactory.createStaticMemberItem(symbols.getEnclosingType(), name, anchorOffset, env.addSemicolon(), env.getReferencesCount(), controller.getSnapshot().getSource(), true)); + results.add(itemFactory.createStaticMemberItem(symbols.getEnclosingType(), name, anchorOffset, env.addSemicolon(), env.getReferencesCount(), controller.getSnapshot().getSource())); } } } diff --git a/java/java.completion/test/unit/src/org/netbeans/modules/java/completion/CompletionTestBase.java b/java/java.completion/test/unit/src/org/netbeans/modules/java/completion/CompletionTestBase.java index d1131bc73004..1a611aab224f 100644 --- a/java/java.completion/test/unit/src/org/netbeans/modules/java/completion/CompletionTestBase.java +++ b/java/java.completion/test/unit/src/org/netbeans/modules/java/completion/CompletionTestBase.java @@ -22,9 +22,7 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; -import java.io.Reader; import java.io.Writer; -import java.nio.file.Files; import java.util.*; import javax.lang.model.element.*; @@ -35,7 +33,6 @@ import javax.lang.model.type.TypeMirror; import javax.lang.model.util.Elements; import javax.swing.text.Document; -import junit.framework.AssertionFailedError; import org.netbeans.api.java.lexer.JavaTokenId; import org.netbeans.api.java.source.*; @@ -111,18 +108,7 @@ protected void performTest(String source, int caretPos, String textToInsert, Str File goldenFile = getGoldenFile(goldenFileName); File diffFile = new File(getWorkDir(), getName() + ".diff"); - try { - assertFile(output, goldenFile, diffFile); - } catch (AssertionFailedError err) { - try (Reader input = Files.newBufferedReader(diffFile.toPath())) { - int r; - - while ((r = input.read()) != (-1)) { - System.err.print((char) r); - } - } - throw err; - } + assertFile(output, goldenFile, diffFile); LifecycleManager.getDefault().saveAll(); } @@ -539,7 +525,7 @@ public CI createAttributeValueItem(CompilationInfo info, String value, String do } @Override - public CI createStaticMemberItem(CompilationInfo info, DeclaredType type, Element memberElem, TypeMirror memberType, boolean multipleVersions, int substitutionOffset, boolean isDeprecated, boolean addSemicolon, boolean smartType) { + public CI createStaticMemberItem(CompilationInfo info, DeclaredType type, Element memberElem, TypeMirror memberType, boolean multipleVersions, int substitutionOffset, boolean isDeprecated, boolean addSemicolon) { switch (memberElem.getKind()) { case METHOD: case ENUM_CONSTANT: @@ -591,14 +577,14 @@ public CI createStaticMemberItem(CompilationInfo info, DeclaredType type, Elemen sb.append(')'); sortParams.append(')'); } - return new CI(sb.toString(), (memberElem.getKind().isField() ? 720 : 750) - (smartType ? SMART_TYPE : 0), memberElem.getKind().isField() ? memberName + "#" + typeName : memberName + "#" + ((cnt < 10 ? "0" : "") + cnt) + "#" + sortParams.toString() + "#" + typeName); //NOI18N + return new CI(sb.toString(), (memberElem.getKind().isField() ? 720 : 750) - SMART_TYPE, memberElem.getKind().isField() ? memberName + "#" + typeName : memberName + "#" + ((cnt < 10 ? "0" : "") + cnt) + "#" + sortParams.toString() + "#" + typeName); //NOI18N default: throw new IllegalArgumentException("kind=" + memberElem.getKind()); } } @Override - public CI createStaticMemberItem(ElementHandle handle, String name, int substitutionOffset, boolean addSemicolon, ReferencesCount referencesCount, Source source, boolean smartType) { + public CI createStaticMemberItem(ElementHandle handle, String name, int substitutionOffset, boolean addSemicolon, ReferencesCount referencesCount, Source source) { String fqn = handle.getQualifiedName(); int weight = 50; if (fqn.startsWith("java.lang") || fqn.startsWith("java.util")) { // NOI18N diff --git a/java/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionCollector.java b/java/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionCollector.java index bddc6dbc8e8c..a68dc91894fa 100644 --- a/java/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionCollector.java +++ b/java/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionCollector.java @@ -665,7 +665,7 @@ public Completion createAttributeValueItem(CompilationInfo info, String value, S private static final Object KEY_IMPORT_TEXT_EDITS = new Object(); @Override - public Completion createStaticMemberItem(CompilationInfo info, DeclaredType type, Element memberElem, TypeMirror memberType, boolean multipleVersions, int substitutionOffset, boolean isDeprecated, boolean addSemicolon, boolean smartType) { + public Completion createStaticMemberItem(CompilationInfo info, DeclaredType type, Element memberElem, TypeMirror memberType, boolean multipleVersions, int substitutionOffset, boolean isDeprecated, boolean addSemicolon) { //TODO: prefer static imports (but would be much slower?) //TODO: should be resolveImport instead of addImports: Map imports = (Map) info.getCachedValue(KEY_IMPORT_TEXT_EDITS); @@ -740,7 +740,7 @@ public Completion createStaticMemberItem(CompilationInfo info, DeclaredType type .labelDescription(memberTypeName) .insertText(insertText.toString()) .insertTextFormat(asTemplate ? Completion.TextFormat.Snippet : Completion.TextFormat.PlainText) - .sortText(String.format("%04d%s", (memberElem.getKind().isField() ? 720 : 750) + (smartType ? 1000 : 0), sortText)); + .sortText(String.format("%04d%s", memberElem.getKind().isField() ? 720 : 750, sortText)); if (labelDetail.length() > 0) { builder.labelDetail(labelDetail.toString()); } @@ -758,7 +758,7 @@ public Completion createStaticMemberItem(CompilationInfo info, DeclaredType type } @Override - public Completion createStaticMemberItem(ElementHandle handle, String name, int substitutionOffset, boolean addSemicolon, ReferencesCount referencesCount, Source source, boolean smartType) { + public Completion createStaticMemberItem(ElementHandle handle, String name, int substitutionOffset, boolean addSemicolon, ReferencesCount referencesCount, Source source) { return null; //TODO: fill } diff --git a/java/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItem.java b/java/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItem.java index 09945ede0eaa..40555e740711 100644 --- a/java/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItem.java +++ b/java/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItem.java @@ -248,12 +248,12 @@ public static JavaCompletionItem createAttributeValueItem(CompilationInfo info, return new AttributeValueItem(info, value, documentation, element, substitutionOffset, referencesCount, whiteList); } - public static JavaCompletionItem createStaticMemberItem(CompilationInfo info, DeclaredType type, Element memberElem, TypeMirror memberType, boolean multipleVersions, int substitutionOffset, boolean isDeprecated, boolean addSemicolon, boolean smartType, WhiteListQuery.WhiteList whiteList) { + public static JavaCompletionItem createStaticMemberItem(CompilationInfo info, DeclaredType type, Element memberElem, TypeMirror memberType, boolean multipleVersions, int substitutionOffset, boolean isDeprecated, boolean addSemicolon, WhiteListQuery.WhiteList whiteList) { switch (memberElem.getKind()) { case METHOD: case ENUM_CONSTANT: case FIELD: - return new StaticMemberItem(info, type, memberElem, memberType, multipleVersions, substitutionOffset, isDeprecated, addSemicolon, smartType, whiteList); + return new StaticMemberItem(info, type, memberElem, memberType, multipleVersions, substitutionOffset, isDeprecated, addSemicolon, whiteList); default: throw new IllegalArgumentException("kind=" + memberElem.getKind()); } @@ -3357,9 +3357,8 @@ static class StaticMemberItem extends WhiteListJavaCompletionItem { private String sortText; private String leftText; private String rightText; - private final boolean smartType; - private StaticMemberItem(CompilationInfo info, DeclaredType type, Element memberElem, TypeMirror memberType, boolean multipleVersions, int substitutionOffset, boolean isDeprecated, boolean addSemicolon, boolean smartType, WhiteListQuery.WhiteList whiteList) { + private StaticMemberItem(CompilationInfo info, DeclaredType type, Element memberElem, TypeMirror memberType, boolean multipleVersions, int substitutionOffset, boolean isDeprecated, boolean addSemicolon, WhiteListQuery.WhiteList whiteList) { super(substitutionOffset, ElementHandle.create(memberElem), whiteList); type = (DeclaredType) info.getTypes().erasure(type); this.typeHandle = TypeMirrorHandle.create(type); @@ -3379,12 +3378,11 @@ private StaticMemberItem(CompilationInfo info, DeclaredType type, Element member this.params.add(new ParamDesc(tm.toString(), Utilities.getTypeName(info, tm, false, ((ExecutableElement)memberElem).isVarArgs() && !tIt.hasNext()).toString(), it.next().getSimpleName().toString())); } } - this.smartType = smartType; } @Override public int getSortPriority() { - int p = (getElementHandle().getKind().isField() ? 720 : 750) - (smartType ? SMART_TYPE : 0); + int p = (getElementHandle().getKind().isField() ? 720 : 750) - SMART_TYPE; return isDeprecated ? p + DEPRECATED : p; } diff --git a/java/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItemFactory.java b/java/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItemFactory.java index ac08274cb7e4..41836d865f4e 100644 --- a/java/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItemFactory.java +++ b/java/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItemFactory.java @@ -158,13 +158,13 @@ public JavaCompletionItem createAttributeValueItem(CompilationInfo info, String } @Override - public JavaCompletionItem createStaticMemberItem(CompilationInfo info, DeclaredType type, Element memberElem, TypeMirror memberType, boolean multipleVersions, int substitutionOffset, boolean isDeprecated, boolean addSemicolon, boolean smartType) { - return JavaCompletionItem.createStaticMemberItem(info, type, memberElem, memberType, multipleVersions, substitutionOffset, isDeprecated, addSemicolon, smartType, whiteList); + public JavaCompletionItem createStaticMemberItem(CompilationInfo info, DeclaredType type, Element memberElem, TypeMirror memberType, boolean multipleVersions, int substitutionOffset, boolean isDeprecated, boolean addSemicolon) { + return JavaCompletionItem.createStaticMemberItem(info, type, memberElem, memberType, multipleVersions, substitutionOffset, isDeprecated, addSemicolon, whiteList); } @Override - public JavaCompletionItem createStaticMemberItem(ElementHandle handle, String name, int substitutionOffset, boolean addSemicolon, ReferencesCount referencesCount, Source source, boolean smartType) { - return LazyJavaCompletionItem.createStaticMemberItem(handle, name, substitutionOffset, addSemicolon, referencesCount, source, smartType, whiteList); + public JavaCompletionItem createStaticMemberItem(ElementHandle handle, String name, int substitutionOffset, boolean addSemicolon, ReferencesCount referencesCount, Source source) { + return LazyJavaCompletionItem.createStaticMemberItem(handle, name, substitutionOffset, addSemicolon, referencesCount, source, whiteList); } @Override diff --git a/java/java.editor/src/org/netbeans/modules/editor/java/LazyJavaCompletionItem.java b/java/java.editor/src/org/netbeans/modules/editor/java/LazyJavaCompletionItem.java index 4d422555b2fc..d798704f42f1 100644 --- a/java/java.editor/src/org/netbeans/modules/editor/java/LazyJavaCompletionItem.java +++ b/java/java.editor/src/org/netbeans/modules/editor/java/LazyJavaCompletionItem.java @@ -64,8 +64,8 @@ public static JavaCompletionItem createTypeItem(ElementHandle handl return new TypeItem(handle, kinds, substitutionOffset, referencesCount, source, insideNew, addTypeVars, afterExtends, whiteList); } - public static JavaCompletionItem createStaticMemberItem(ElementHandle handle, String name, int substitutionOffset, boolean addSemicolon, ReferencesCount referencesCount, Source source, boolean smartType, WhiteListQuery.WhiteList whiteList) { - return new StaticMemberItem(handle, name, substitutionOffset, addSemicolon, referencesCount, source, smartType, whiteList); + public static JavaCompletionItem createStaticMemberItem(ElementHandle handle, String name, int substitutionOffset, boolean addSemicolon, ReferencesCount referencesCount, Source source, WhiteListQuery.WhiteList whiteList) { + return new StaticMemberItem(handle, name, substitutionOffset, addSemicolon, referencesCount, source, whiteList); } private LazyJavaCompletionItem(int substitutionOffset, ElementHandle handle, Source source, WhiteListQuery.WhiteList whiteList) { @@ -241,14 +241,12 @@ private static class StaticMemberItem extends LazyJavaCompletionItem handle, String name, int substitutionOffset, boolean addSemicolon, ReferencesCount referencesCount, Source source, boolean smartType, WhiteListQuery.WhiteList whiteList) { + private StaticMemberItem(ElementHandle handle, String name, int substitutionOffset, boolean addSemicolon, ReferencesCount referencesCount, Source source, WhiteListQuery.WhiteList whiteList) { super(substitutionOffset, handle, source, whiteList); this.name = name; this.sortText = new LazySortText(this.name, handle.getQualifiedName(), handle, referencesCount); this.addSemicolon = addSemicolon; - this.smartType = smartType; } @Override @@ -273,7 +271,7 @@ protected JavaCompletionItem getDelegate(CompilationInfo info, Scope scope, Type } if (element != null) { name = element.getSimpleName().toString(); - return createStaticMemberItem(info, (DeclaredType) te.asType(), element, element.asType(), multiVersion, substitutionOffset, elements.isDeprecated(element), addSemicolon, smartType, getWhiteList()); + return createStaticMemberItem(info, (DeclaredType) te.asType(), element, element.asType(), multiVersion, substitutionOffset, elements.isDeprecated(element), addSemicolon, getWhiteList()); } } return null;