Java Code Examples for org.eclipse.jdt.core.CompletionProposal#getKind()
The following examples show how to use
org.eclipse.jdt.core.CompletionProposal#getKind() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompletionProposalLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Creates and returns a parameter list of the given method or type proposal suitable for * display. The list does not include parentheses. The lower bound of parameter types is * returned. * <p> * Examples: * * <pre> * "void method(int i, String s)" -> "int i, String s" * "? extends Number method(java.lang.String s, ? super Number n)" -> "String s, Number n" * </pre> * * </p> * * @param proposal the proposal to create the parameter list for * @return the list of comma-separated parameters suitable for display */ public String createParameterList(CompletionProposal proposal) { String paramList; int kind= proposal.getKind(); switch (kind) { case CompletionProposal.METHOD_REF: case CompletionProposal.CONSTRUCTOR_INVOCATION: paramList= appendUnboundedParameterList(new StyledString(), proposal).getString(); return Strings.markJavaElementLabelLTR(paramList); case CompletionProposal.TYPE_REF: case CompletionProposal.JAVADOC_TYPE_REF: paramList= appendTypeParameterList(new StyledString(), proposal).getString(); return Strings.markJavaElementLabelLTR(paramList); case CompletionProposal.ANONYMOUS_CLASS_DECLARATION: case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION: paramList= appendUnboundedParameterList(new StyledString(), proposal).getString(); return Strings.markJavaElementLabelLTR(paramList); default: Assert.isLegal(false); return null; // dummy } }
Example 2
Source File: CompletionProposalDescriptionProvider.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
/** * Creates and returns a parameter list of the given method or type proposal suitable for * display. The list does not include parentheses. The lower bound of parameter types is * returned. * <p> * Examples: * * <pre> * "void method(int i, String s)" -> "int i, String s" * "? extends Number method(java.lang.String s, ? super Number n)" -> "String s, Number n" * </pre> * * </p> * * @param proposal the proposal to create the parameter list for * @return the list of comma-separated parameters suitable for display */ public StringBuilder createParameterList(CompletionProposal proposal) { int kind= proposal.getKind(); switch (kind) { case CompletionProposal.METHOD_REF: case CompletionProposal.CONSTRUCTOR_INVOCATION: return appendUnboundedParameterList(new StringBuilder(), proposal); case CompletionProposal.TYPE_REF: case CompletionProposal.JAVADOC_TYPE_REF: return appendTypeParameterList(new StringBuilder(), proposal); case CompletionProposal.ANONYMOUS_CLASS_DECLARATION: case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION: return appendUnboundedParameterList(new StringBuilder(), proposal); default: Assert.isLegal(false); return null; // dummy } }
Example 3
Source File: CompilationUnitCompletion.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public void accept(CompletionProposal proposal) { String name= String.valueOf(proposal.getCompletion()); String signature= String.valueOf(proposal.getSignature()); switch (proposal.getKind()) { case CompletionProposal.LOCAL_VARIABLE_REF: // collect local variables fLocalVariables.add(new Variable(name, signature)); break; case CompletionProposal.FIELD_REF: // collect local variables fFields.add(new Variable(name, signature)); break; default: break; } }
Example 4
Source File: CompletionProposalRequestor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Override public void accept(CompletionProposal proposal) { if (isFiltered(proposal)) { return; } if (!isIgnored(proposal.getKind())) { if (proposal.getKind() == CompletionProposal.POTENTIAL_METHOD_DECLARATION) { acceptPotentialMethodDeclaration(proposal); } else { if (proposal.getKind() == CompletionProposal.PACKAGE_REF && unit.getParent() != null && String.valueOf(proposal.getCompletion()).equals(unit.getParent().getElementName())) { // Hacky way to boost relevance of current package, for package completions, until // https://bugs.eclipse.org/518140 is fixed proposal.setRelevance(proposal.getRelevance() + 1); } proposals.add(proposal); } } }
Example 5
Source File: JsniCompletionProposalCollector.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
@Override protected IJavaCompletionProposal createJavaCompletionProposal( CompletionProposal proposal) { IJavaCompletionProposal defaultProposal = super.createJavaCompletionProposal(proposal); // For members of inner classes, there's a bug in the JDT which results in // the declaration signature of the proposal missing the outer classes, so // we have to manually set the signature instead. if (proposal.getKind() == CompletionProposal.METHOD_REF || proposal.getKind() == CompletionProposal.FIELD_REF) { char[] typeSignature = Signature.createTypeSignature(qualifiedTypeName, true).toCharArray(); proposal.setDeclarationSignature(typeSignature); } return JsniCompletionProposal.create(defaultProposal, proposal, getCompilationUnit().getJavaProject(), refOffset, refLength); }
Example 6
Source File: CompletionProposalDescriptionProvider.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
/** * Creates and returns the method signature suitable for display. * * @param proposal * the proposal to create the description for * @return the string of method signature suitable for display */ public StringBuilder createMethodProposalDescription(CompletionProposal proposal) { int kind = proposal.getKind(); StringBuilder description = new StringBuilder(); switch (kind) { case CompletionProposal.METHOD_REF: case CompletionProposal.METHOD_NAME_REFERENCE: case CompletionProposal.POTENTIAL_METHOD_DECLARATION: case CompletionProposal.CONSTRUCTOR_INVOCATION: // method name description.append(proposal.getName()); // parameters description.append('('); appendUnboundedParameterList(description, proposal); description.append(')'); // return type if (!proposal.isConstructor()) { // TODO remove SignatureUtil.fix83600 call when bugs are fixed char[] returnType = createTypeDisplayName(SignatureUtil.getUpperBound(Signature.getReturnType(SignatureUtil.fix83600(proposal.getSignature())))); description.append(RETURN_TYPE_SEPARATOR); description.append(returnType); } } return description; // dummy }
Example 7
Source File: WidgetProposalComputer.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
@Override protected ICompletionProposal createProposal(CompletionProposal proposal) { if (proposal.getKind() != CompletionProposal.TYPE_REF) { return null; } // NOTE: Resulting qualified name is dot-separated, even for enclosing // types. Generic signatures are not produced. See // org.eclipse.jdt.internal.codeassist.CompletionEngine.createTypeProposal. String qualifiedTypeName = String.valueOf(Signature.toCharArray(proposal.getSignature())); String typePackage = JavaUtilities.getPackageName(qualifiedTypeName); String typeSimpleName = Signature.getSimpleName(qualifiedTypeName); if (packageName != null && !typePackage.equals(packageName)) { return null; } ICompletionProposal javaCompletionProposal = JavaContentAssistUtilities.getJavaCompletionProposal( proposal, getContext(), getJavaProject()); if (javaCompletionProposal != null) { return new WidgetProposal(typeSimpleName, typePackage, null, javaCompletionProposal.getDisplayString(), javaCompletionProposal.getImage(), getReplaceOffset(), getReplaceLength(), packageManager); } else { return new WidgetProposal(typeSimpleName, typePackage, null, typeSimpleName, null, getReplaceOffset(), getReplaceLength(), packageManager); } }
Example 8
Source File: CompletionProposalReplacementProvider.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private boolean isSupportingRequiredProposals(CompletionProposal proposal) { return proposal != null && (proposal.getKind() == CompletionProposal.METHOD_REF || proposal.getKind() == CompletionProposal.FIELD_REF || proposal.getKind() == CompletionProposal.TYPE_REF || proposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION || proposal.getKind() == CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION || proposal.getKind() == CompletionProposal.ANONYMOUS_CLASS_DECLARATION); }
Example 9
Source File: CompletionProposalCollector.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} * <p> * Subclasses may replace, but usually should not need to. Consider * replacing * {@linkplain #createJavaCompletionProposal(CompletionProposal) createJavaCompletionProposal} * instead. * </p> */ @Override public void accept(CompletionProposal proposal) { long start= DEBUG ? System.currentTimeMillis() : 0; try { if (isFiltered(proposal)) return; if (proposal.getKind() == CompletionProposal.POTENTIAL_METHOD_DECLARATION) { acceptPotentialMethodDeclaration(proposal); } else { IJavaCompletionProposal javaProposal= createJavaCompletionProposal(proposal); if (javaProposal != null) { fJavaProposals.add(javaProposal); if (proposal.getKind() == CompletionProposal.KEYWORD) fKeywords.add(javaProposal); } } } catch (IllegalArgumentException e) { // all signature processing method may throw IAEs // https://bugs.eclipse.org/bugs/show_bug.cgi?id=84657 // don't abort, but log and show all the valid proposals JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, "Exception when processing proposal for: " + String.valueOf(proposal.getCompletion()), e)); //$NON-NLS-1$ } if (DEBUG) fUITime += System.currentTimeMillis() - start; }
Example 10
Source File: AnonymousTypeCompletionProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public CharSequence getPrefixCompletionText(IDocument document, int completionOffset) { CompletionProposal coreProposal= ((MemberProposalInfo)getProposalInfo()).fProposal; if (coreProposal.getKind() != CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION) return super.getPrefixCompletionText(document, completionOffset); return String.valueOf(coreProposal.getName()); }
Example 11
Source File: JsniCompletionProposal.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Return proposals only for references to a package, type, field, method or * constructor (and nothing else). */ public static IJavaCompletionProposal create( IJavaCompletionProposal jdtProposal, CompletionProposal wrappedProposal, IJavaProject javaProject, int replaceOffset, int replaceLength) { switch (wrappedProposal.getKind()) { case CompletionProposal.PACKAGE_REF: case CompletionProposal.TYPE_REF: case CompletionProposal.FIELD_REF: case CompletionProposal.METHOD_REF: return new JsniCompletionProposal(jdtProposal, wrappedProposal, javaProject, replaceOffset, replaceLength); default: return null; } }
Example 12
Source File: JavaElementToken.java From Pydev with Eclipse Public License 1.0 | 5 votes |
public JavaElementToken(String rep, String doc, String args, String parentPackage, int type, IJavaElement javaElement, CompletionProposal completionProposal) { super(rep, doc, args, parentPackage, type, null); this.javaElement = javaElement; this.completionProposalKind = completionProposal.getKind(); this.completionProposalFlags = completionProposal.getFlags(); if (HAS_ADDITIONAL_FLAGS) { this.completionProposalAdditionalFlags = completionProposal.getAdditionalFlags(); } this.completionPropsoalSignature = completionProposal.getSignature(); }
Example 13
Source File: CompletionProposalRequestor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
/** * copied from * org.eclipse.jdt.ui.text.java.CompletionProposalCollector.getDeclaringType(CompletionProposal) */ protected final char[] getDeclaringType(CompletionProposal proposal) { switch (proposal.getKind()) { case CompletionProposal.METHOD_DECLARATION: case CompletionProposal.METHOD_NAME_REFERENCE: case CompletionProposal.JAVADOC_METHOD_REF: case CompletionProposal.METHOD_REF: case CompletionProposal.CONSTRUCTOR_INVOCATION: case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION: case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER: case CompletionProposal.ANNOTATION_ATTRIBUTE_REF: case CompletionProposal.POTENTIAL_METHOD_DECLARATION: case CompletionProposal.ANONYMOUS_CLASS_DECLARATION: case CompletionProposal.FIELD_REF: case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER: case CompletionProposal.JAVADOC_FIELD_REF: case CompletionProposal.JAVADOC_VALUE_REF: char[] declaration = proposal.getDeclarationSignature(); // special methods may not have a declaring type: methods defined on arrays etc. // Currently known: class literals don't have a declaring type - use Object if (declaration == null) { return "java.lang.Object".toCharArray(); //$NON-NLS-1$ } return Signature.toCharArray(declaration); case CompletionProposal.PACKAGE_REF: case CompletionProposal.MODULE_REF: case CompletionProposal.MODULE_DECLARATION: return proposal.getDeclarationSignature(); case CompletionProposal.JAVADOC_TYPE_REF: case CompletionProposal.TYPE_REF: return Signature.toCharArray(proposal.getSignature()); case CompletionProposal.LOCAL_VARIABLE_REF: case CompletionProposal.VARIABLE_DECLARATION: case CompletionProposal.KEYWORD: case CompletionProposal.LABEL_REF: case CompletionProposal.JAVADOC_BLOCK_TAG: case CompletionProposal.JAVADOC_INLINE_TAG: case CompletionProposal.JAVADOC_PARAM_REF: return null; default: Assert.isTrue(false); return null; } }
Example 14
Source File: JavaTypeCompletionProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public void accept(CompletionProposal proposal) { switch (proposal.getKind()) { case CompletionProposal.PACKAGE_REF : char[] packageName= proposal.getDeclarationSignature(); if (TypeFilter.isFiltered(packageName)) return; addAdjustedCompletion( new String(packageName), new String(proposal.getCompletion()), proposal.getReplaceStart(), proposal.getReplaceEnd(), proposal.getRelevance(), JavaPluginImages.DESC_OBJS_PACKAGE); return; case CompletionProposal.TYPE_REF : char[] signature= proposal.getSignature(); char[] fullName= Signature.toCharArray(signature); if (TypeFilter.isFiltered(fullName)) return; StringBuffer buf= new StringBuffer(); buf.append(Signature.getSimpleName(fullName)); if (buf.length() == 0) return; // this is the dummy class, whose $ have been converted to dots char[] typeQualifier= Signature.getQualifier(fullName); if (typeQualifier.length > 0) { buf.append(JavaElementLabels.CONCAT_STRING); buf.append(typeQualifier); } String name= buf.toString(); // Only fully qualify if it's a top level type: boolean fullyQualify= fFullyQualify && CharOperation.equals(proposal.getDeclarationSignature(), typeQualifier); ImageDescriptor typeImageDescriptor; switch (Signature.getTypeSignatureKind(signature)) { case Signature.TYPE_VARIABLE_SIGNATURE : typeImageDescriptor= JavaPluginImages.DESC_OBJS_TYPEVARIABLE; break; case Signature.CLASS_TYPE_SIGNATURE : typeImageDescriptor= JavaElementImageProvider.getTypeImageDescriptor(false, false, proposal.getFlags(), false); break; default : typeImageDescriptor= null; } addAdjustedTypeCompletion( name, new String(proposal.getCompletion()), proposal.getReplaceStart(), proposal.getReplaceEnd(), proposal.getRelevance(), typeImageDescriptor, fullyQualify ? new String(fullName) : null); return; case CompletionProposal.KEYWORD: if (! fEnableBaseTypes) return; String keyword= new String(proposal.getName()); if ( (fEnableVoid && VOID.equals(keyword)) || (fEnableBaseTypes && BASE_TYPES.contains(keyword)) ) addAdjustedCompletion( keyword, new String(proposal.getCompletion()), proposal.getReplaceStart(), proposal.getReplaceEnd(), proposal.getRelevance(), null); return; default : return; } }
Example 15
Source File: CompletionProposalCollector.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Returns the type signature of the declaring type of a * <code>CompletionProposal</code>, or <code>null</code> for proposals * that do not have a declaring type. The return value is <em>not</em> * <code>null</code> for proposals of the following kinds: * <ul> * <li>METHOD_DECLARATION</li> * <li>METHOD_NAME_REFERENCE</li> * <li>METHOD_REF</li> * <li>ANNOTATION_ATTRIBUTE_REF</li> * <li>POTENTIAL_METHOD_DECLARATION</li> * <li>ANONYMOUS_CLASS_DECLARATION</li> * <li>FIELD_REF</li> * <li>PACKAGE_REF (returns the package, but no type)</li> * <li>TYPE_REF</li> * </ul> * * @param proposal the completion proposal to get the declaring type for * @return the type signature of the declaring type, or <code>null</code> if there is none * @see Signature#toCharArray(char[]) */ protected final char[] getDeclaringType(CompletionProposal proposal) { switch (proposal.getKind()) { case CompletionProposal.METHOD_DECLARATION: case CompletionProposal.METHOD_NAME_REFERENCE: case CompletionProposal.JAVADOC_METHOD_REF: case CompletionProposal.METHOD_REF: case CompletionProposal.CONSTRUCTOR_INVOCATION: case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION: case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER: case CompletionProposal.ANNOTATION_ATTRIBUTE_REF: case CompletionProposal.POTENTIAL_METHOD_DECLARATION: case CompletionProposal.ANONYMOUS_CLASS_DECLARATION: case CompletionProposal.FIELD_REF: case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER: case CompletionProposal.JAVADOC_FIELD_REF: case CompletionProposal.JAVADOC_VALUE_REF: char[] declaration= proposal.getDeclarationSignature(); // special methods may not have a declaring type: methods defined on arrays etc. // Currently known: class literals don't have a declaring type - use Object if (declaration == null) return "java.lang.Object".toCharArray(); //$NON-NLS-1$ return Signature.toCharArray(declaration); case CompletionProposal.PACKAGE_REF: return proposal.getDeclarationSignature(); case CompletionProposal.JAVADOC_TYPE_REF: case CompletionProposal.TYPE_REF: return Signature.toCharArray(proposal.getSignature()); case CompletionProposal.LOCAL_VARIABLE_REF: case CompletionProposal.VARIABLE_DECLARATION: case CompletionProposal.KEYWORD: case CompletionProposal.LABEL_REF: case CompletionProposal.JAVADOC_BLOCK_TAG: case CompletionProposal.JAVADOC_INLINE_TAG: case CompletionProposal.JAVADOC_PARAM_REF: return null; default: Assert.isTrue(false); return null; } }
Example 16
Source File: SimilarElementsRequestor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public void accept(CompletionProposal proposal) { if (proposal.getKind() == CompletionProposal.TYPE_REF) { addType(proposal.getSignature(), proposal.getFlags(), proposal.getRelevance()); } }
Example 17
Source File: CompletionProposalReplacementProvider.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
private StringBuilder appendImportProposal(StringBuilder buffer, CompletionProposal proposal, int coreKind) { int proposalKind= proposal.getKind(); String qualifiedTypeName= null; char[] qualifiedType= null; if (proposalKind == CompletionProposal.TYPE_IMPORT) { qualifiedType= proposal.getSignature(); qualifiedTypeName= String.valueOf(Signature.toCharArray(qualifiedType)); } else if (proposalKind == CompletionProposal.METHOD_IMPORT || proposalKind == CompletionProposal.FIELD_IMPORT) { qualifiedType= Signature.getTypeErasure(proposal.getDeclarationSignature()); qualifiedTypeName= String.valueOf(Signature.toCharArray(qualifiedType)); } else { /* * In 3.3 we only support the above import proposals, see * CompletionProposal#getRequiredProposals() */ Assert.isTrue(false); } /* Add imports if the preference is on. */ if (importRewrite != null) { if (proposalKind == CompletionProposal.TYPE_IMPORT) { String simpleType= importRewrite.addImport(qualifiedTypeName, null); if (coreKind == CompletionProposal.METHOD_REF) { buffer.append(simpleType); buffer.append(COMMA); return buffer; } } else { String res= importRewrite.addStaticImport(qualifiedTypeName, String.valueOf(proposal.getName()), proposalKind == CompletionProposal.FIELD_IMPORT, null); int dot= res.lastIndexOf('.'); if (dot != -1) { buffer.append(importRewrite.addImport(res.substring(0, dot), null)); buffer.append('.'); return buffer; } } return buffer; } // Case where we don't have an import rewrite (see allowAddingImports) if (compilationUnit != null && isImplicitImport(Signature.getQualifier(qualifiedTypeName), compilationUnit)) { /* No imports for implicit imports. */ if (proposal.getKind() == CompletionProposal.TYPE_IMPORT && coreKind == CompletionProposal.FIELD_REF) { return buffer; } qualifiedTypeName= String.valueOf(Signature.getSignatureSimpleName(qualifiedType)); } buffer.append(qualifiedTypeName); buffer.append('.'); return buffer; }
Example 18
Source File: CompletionProposalLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Returns a version of <code>descriptor</code> decorated according to * the passed <code>modifier</code> flags. * * @param descriptor the image descriptor to decorate * @param proposal the proposal * @return an image descriptor for a method proposal * @see Flags */ private ImageDescriptor decorateImageDescriptor(ImageDescriptor descriptor, CompletionProposal proposal) { int adornments= 0; int flags= proposal.getFlags(); int kind= proposal.getKind(); boolean deprecated= Flags.isDeprecated(flags); if (!deprecated) { CompletionProposal[] requiredProposals= proposal.getRequiredProposals(); if (requiredProposals != null) { for (int i= 0; i < requiredProposals.length; i++) { CompletionProposal requiredProposal= requiredProposals[i]; if (requiredProposal.getKind() == CompletionProposal.TYPE_REF) { deprecated |= Flags.isDeprecated(requiredProposal.getFlags()); } } } } if (deprecated) adornments |= JavaElementImageDescriptor.DEPRECATED; if (kind == CompletionProposal.FIELD_REF || kind == CompletionProposal.METHOD_DECLARATION || kind == CompletionProposal.METHOD_NAME_REFERENCE || kind == CompletionProposal.METHOD_REF || kind == CompletionProposal.CONSTRUCTOR_INVOCATION) if (Flags.isStatic(flags)) adornments |= JavaElementImageDescriptor.STATIC; if (kind == CompletionProposal.METHOD_DECLARATION || kind == CompletionProposal.METHOD_NAME_REFERENCE || kind == CompletionProposal.METHOD_REF || kind == CompletionProposal.CONSTRUCTOR_INVOCATION) if (Flags.isSynchronized(flags)) adornments |= JavaElementImageDescriptor.SYNCHRONIZED; if (kind == CompletionProposal.METHOD_DECLARATION || kind == CompletionProposal.METHOD_NAME_REFERENCE || kind == CompletionProposal.METHOD_REF) if (Flags.isDefaultMethod(flags)) adornments|= JavaElementImageDescriptor.DEFAULT_METHOD; if (kind == CompletionProposal.ANNOTATION_ATTRIBUTE_REF) if (Flags.isAnnnotationDefault(flags)) adornments|= JavaElementImageDescriptor.ANNOTATION_DEFAULT; if (kind == CompletionProposal.TYPE_REF && Flags.isAbstract(flags) && !Flags.isInterface(flags)) adornments |= JavaElementImageDescriptor.ABSTRACT; if (kind == CompletionProposal.FIELD_REF) { if (Flags.isFinal(flags)) adornments |= JavaElementImageDescriptor.FINAL; if (Flags.isTransient(flags)) adornments |= JavaElementImageDescriptor.TRANSIENT; if (Flags.isVolatile(flags)) adornments |= JavaElementImageDescriptor.VOLATILE; } return new JavaElementImageDescriptor(descriptor, adornments, JavaElementImageProvider.SMALL_SIZE); }
Example 19
Source File: CompletionProposalCollector.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Creates a new java completion proposal from a core proposal. This may * involve computing the display label and setting up some context. * <p> * This method is called for every proposal that will be displayed to the * user, which may be hundreds. Implementations should therefore defer as * much work as possible: Labels should be computed lazily to leverage * virtual table usage, and any information only needed when * <em>applying</em> a proposal should not be computed yet. * </p> * <p> * Implementations may return <code>null</code> if a proposal should not * be included in the list presented to the user. * </p> * <p> * Subclasses may extend or replace this method. * </p> * * @param proposal the core completion proposal to create a UI proposal for * @return the created java completion proposal, or <code>null</code> if * no proposal should be displayed */ protected IJavaCompletionProposal createJavaCompletionProposal(CompletionProposal proposal) { switch (proposal.getKind()) { case CompletionProposal.KEYWORD: return createKeywordProposal(proposal); case CompletionProposal.PACKAGE_REF: return createPackageProposal(proposal); case CompletionProposal.TYPE_REF: return createTypeProposal(proposal); case CompletionProposal.JAVADOC_TYPE_REF: return createJavadocLinkTypeProposal(proposal); case CompletionProposal.FIELD_REF: case CompletionProposal.JAVADOC_FIELD_REF: case CompletionProposal.JAVADOC_VALUE_REF: return createFieldProposal(proposal); case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER: return createFieldWithCastedReceiverProposal(proposal); case CompletionProposal.METHOD_REF: case CompletionProposal.CONSTRUCTOR_INVOCATION: case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER: case CompletionProposal.METHOD_NAME_REFERENCE: case CompletionProposal.JAVADOC_METHOD_REF: return createMethodReferenceProposal(proposal); case CompletionProposal.METHOD_DECLARATION: return createMethodDeclarationProposal(proposal); case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION: return createAnonymousTypeProposal(proposal, getInvocationContext()); case CompletionProposal.ANONYMOUS_CLASS_DECLARATION: return createAnonymousTypeProposal(proposal, null); case CompletionProposal.LABEL_REF: return createLabelProposal(proposal); case CompletionProposal.LOCAL_VARIABLE_REF: case CompletionProposal.VARIABLE_DECLARATION: return createLocalVariableProposal(proposal); case CompletionProposal.ANNOTATION_ATTRIBUTE_REF: return createAnnotationAttributeReferenceProposal(proposal); case CompletionProposal.JAVADOC_BLOCK_TAG: case CompletionProposal.JAVADOC_PARAM_REF: return createJavadocSimpleProposal(proposal); case CompletionProposal.JAVADOC_INLINE_TAG: return createJavadocInlineTagProposal(proposal); case CompletionProposal.POTENTIAL_METHOD_DECLARATION: default: return null; } }
Example 20
Source File: SimilarElementsRequestor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
@Override public void accept(CompletionProposal proposal) { if (proposal.getKind() == CompletionProposal.TYPE_REF) { addType(proposal.getSignature(), proposal.getFlags(), proposal.getRelevance()); } }