Java Code Examples for org.eclipse.jdt.core.CompletionProposal#CONSTRUCTOR_INVOCATION
The following examples show how to use
org.eclipse.jdt.core.CompletionProposal#CONSTRUCTOR_INVOCATION .
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: 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 2
Source File: JavaMethodCompletionProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected boolean isValidPrefix(String prefix) { if (super.isValidPrefix(prefix)) return true; String word= TextProcessor.deprocess(getDisplayString()); if (fProposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION) { int start= word.indexOf(JavaElementLabels.CONCAT_STRING) + JavaElementLabels.CONCAT_STRING.length(); word= word.substring(start); return isPrefix(prefix, word) || isPrefix(prefix, new String(fProposal.getName())); } if (isInJavadoc()) { int idx = word.indexOf("{@link "); //$NON-NLS-1$ if (idx==0) { word = word.substring(7); } else { idx = word.indexOf("{@value "); //$NON-NLS-1$ if (idx==0) { word = word.substring(8); } } } return isPrefix(prefix, word); }
Example 3
Source File: JavaMethodCompletionProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected String getPrefix(IDocument document, int offset) { if (fProposal.getKind() != CompletionProposal.CONSTRUCTOR_INVOCATION) return super.getPrefix(document, offset); int replacementOffset= fProposal.getRequiredProposals()[0].getReplaceStart(); try { int length= offset - replacementOffset; if (length > 0) return document.get(replacementOffset, length); } catch (BadLocationException x) { } return ""; //$NON-NLS-1$ }
Example 4
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 5
Source File: CompletionProposalReplacementProvider.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private void appendMethodNameReplacement(StringBuilder buffer, CompletionProposal proposal) { if (proposal.getKind() == CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER) { String coreCompletion = String.valueOf(proposal.getCompletion()); if (client.isCompletionSnippetsSupported()) { coreCompletion = CompletionUtils.sanitizeCompletion(coreCompletion); } // String lineDelimiter = TextUtilities.getDefaultLineDelimiter(getTextViewer().getDocument()); // String replacement= CodeFormatterUtil.format(CodeFormatter.K_EXPRESSION, coreCompletion, 0, lineDelimiter, fInvocationContext.getProject()); // buffer.append(replacement.substring(0, replacement.lastIndexOf('.') + 1)); buffer.append(coreCompletion); } if (proposal.getKind() != CompletionProposal.CONSTRUCTOR_INVOCATION) { String str = new String(proposal.getName()); if (client.isCompletionSnippetsSupported()) { str = CompletionUtils.sanitizeCompletion(str); } buffer.append(str); } }
Example 6
Source File: AbstractJavaCompletionProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Tells whether required proposals are supported by this proposal. * * @return <code>true</code> if required proposals are supported by this proposal * @see CompletionProposal#getRequiredProposals() * @since 3.3 */ protected boolean isSupportingRequiredProposals() { if (fInvocationContext == null) return false; ProposalInfo proposalInfo= getProposalInfo(); if (!(proposalInfo instanceof MemberProposalInfo || proposalInfo instanceof AnonymousTypeProposalInfo)) return false; CompletionProposal proposal= ((MemberProposalInfo)proposalInfo).fProposal; 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); }
Example 7
Source File: LazyJavaCompletionProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected int computeRelevance() { final int baseRelevance= fProposal.getRelevance() * 16; switch (fProposal.getKind()) { case CompletionProposal.PACKAGE_REF: return baseRelevance + 0; case CompletionProposal.LABEL_REF: return baseRelevance + 1; case CompletionProposal.KEYWORD: return baseRelevance + 2; case CompletionProposal.TYPE_REF: case CompletionProposal.ANONYMOUS_CLASS_DECLARATION: case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION: return baseRelevance + 3; case CompletionProposal.METHOD_REF: case CompletionProposal.CONSTRUCTOR_INVOCATION: case CompletionProposal.METHOD_NAME_REFERENCE: case CompletionProposal.METHOD_DECLARATION: case CompletionProposal.ANNOTATION_ATTRIBUTE_REF: return baseRelevance + 4; case CompletionProposal.POTENTIAL_METHOD_DECLARATION: return baseRelevance + 4 /* + 99 */; case CompletionProposal.FIELD_REF: return baseRelevance + 5; case CompletionProposal.LOCAL_VARIABLE_REF: case CompletionProposal.VARIABLE_DECLARATION: return baseRelevance + 6; default: return baseRelevance; } }
Example 8
Source File: CompletionProposalCollector.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Computes the relevance for a given <code>CompletionProposal</code>. * <p> * Subclasses may replace, but usually should not need to. * </p> * @param proposal the proposal to compute the relevance for * @return the relevance for <code>proposal</code> */ protected int computeRelevance(CompletionProposal proposal) { final int baseRelevance= proposal.getRelevance() * 16; switch (proposal.getKind()) { case CompletionProposal.PACKAGE_REF: return baseRelevance + 0; case CompletionProposal.LABEL_REF: return baseRelevance + 1; case CompletionProposal.KEYWORD: return baseRelevance + 2; case CompletionProposal.TYPE_REF: case CompletionProposal.ANONYMOUS_CLASS_DECLARATION: case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION: return baseRelevance + 3; case CompletionProposal.METHOD_REF: case CompletionProposal.CONSTRUCTOR_INVOCATION: case CompletionProposal.METHOD_NAME_REFERENCE: case CompletionProposal.METHOD_DECLARATION: case CompletionProposal.ANNOTATION_ATTRIBUTE_REF: return baseRelevance + 4; case CompletionProposal.POTENTIAL_METHOD_DECLARATION: return baseRelevance + 4 /* + 99 */; case CompletionProposal.FIELD_REF: return baseRelevance + 5; case CompletionProposal.LOCAL_VARIABLE_REF: case CompletionProposal.VARIABLE_DECLARATION: return baseRelevance + 6; default: return baseRelevance; } }
Example 9
Source File: JavaMethodCompletionProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected IContextInformation computeContextInformation() { // no context information for METHOD_NAME_REF proposals (e.g. for static imports) // https://bugs.eclipse.org/bugs/show_bug.cgi?id=94654 if ((fProposal.getKind() == CompletionProposal.METHOD_REF || fProposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION) && hasParameters() && (getReplacementString().endsWith(RPAREN) || getReplacementString().endsWith(SEMICOLON) || getReplacementString().length() == 0)) { ProposalContextInformation contextInformation= new ProposalContextInformation(fProposal); if (fContextInformationPosition != 0 && fProposal.getCompletion().length == 0) contextInformation.setContextInformationPosition(fContextInformationPosition); return contextInformation; } return super.computeContextInformation(); }
Example 10
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 11
Source File: JavaMethodCompletionProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected boolean isOffsetValid(int offset) { if (fProposal.getKind() != CompletionProposal.CONSTRUCTOR_INVOCATION) return super.isOffsetValid(offset); return fProposal.getRequiredProposals()[0].getReplaceStart() <= offset; }
Example 12
Source File: JavaMethodCompletionProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public CharSequence getPrefixCompletionText(IDocument document, int completionOffset) { if (hasArgumentList() || fProposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION) { String completion= String.valueOf(fProposal.getName()); if (isCamelCaseMatching()) { String prefix= getPrefix(document, completionOffset); return getCamelCaseCompound(prefix, completion); } return completion; } return super.getPrefixCompletionText(document, completionOffset); }
Example 13
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 14
Source File: CompletionProposalReplacementProvider.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
private void updateReplacement(CompletionProposal proposal, CompletionItem item, char trigger, boolean isResolving) { // reset importRewrite this.importRewrite = TypeProposalUtils.createImportRewrite(compilationUnit); List<org.eclipse.lsp4j.TextEdit> additionalTextEdits = new ArrayList<>(); StringBuilder completionBuffer = new StringBuilder(); Range range = null; if (isSupportingRequiredProposals(proposal)) { CompletionProposal[] requiredProposals = proposal.getRequiredProposals(); if (requiredProposals != null) { for (CompletionProposal requiredProposal : requiredProposals) { switch (requiredProposal.getKind()) { case CompletionProposal.TYPE_IMPORT: case CompletionProposal.METHOD_IMPORT: case CompletionProposal.FIELD_IMPORT: appendImportProposal(completionBuffer, requiredProposal, proposal.getKind()); break; case CompletionProposal.TYPE_REF: org.eclipse.lsp4j.TextEdit edit = toRequiredTypeEdit(requiredProposal, trigger, proposal.canUseDiamond(context)); if (proposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION || proposal.getKind() == CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION || proposal.getKind() == CompletionProposal.ANONYMOUS_CLASS_DECLARATION) { completionBuffer.append(edit.getNewText()); range = edit.getRange(); } else { additionalTextEdits.add(edit); } break; default: /* * In 3.3 we only support the above required proposals, see * CompletionProposal#getRequiredProposals() */ Assert.isTrue(false); } } } } if (range == null) { boolean completionOverwrite = preferences.isCompletionOverwrite(); if (!completionOverwrite && (proposal.getKind() == CompletionProposal.METHOD_REF || proposal.getKind() == CompletionProposal.LOCAL_VARIABLE_REF || proposal.getKind() == CompletionProposal.FIELD_REF)) { // See https://github.com/redhat-developer/vscode-java/issues/462 int end = proposal.getReplaceEnd(); if (end > offset) { proposal.setReplaceRange(proposal.getReplaceStart(), offset); } } range = toReplacementRange(proposal); } if (proposal.getKind() == CompletionProposal.METHOD_DECLARATION) { appendMethodOverrideReplacement(completionBuffer, proposal); } else if (proposal.getKind() == CompletionProposal.POTENTIAL_METHOD_DECLARATION && proposal instanceof GetterSetterCompletionProposal) { appendMethodPotentialReplacement(completionBuffer, (GetterSetterCompletionProposal) proposal); } else if (proposal.getKind() == CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION || proposal.getKind() == CompletionProposal.ANONYMOUS_CLASS_DECLARATION) { appendAnonymousClass(completionBuffer, proposal, range); } else { appendReplacementString(completionBuffer, proposal); } //select insertTextFormat. if (client.isCompletionSnippetsSupported()) { item.setInsertTextFormat(InsertTextFormat.Snippet); } else { item.setInsertTextFormat(InsertTextFormat.PlainText); } String text = completionBuffer.toString(); if (range != null) { item.setTextEdit(new org.eclipse.lsp4j.TextEdit(range, text)); } else { // fallback item.setInsertText(text); } if (!client.isResolveAdditionalTextEditsSupport() || isResolving) { addImports(additionalTextEdits); if(!additionalTextEdits.isEmpty()){ item.setAdditionalTextEdits(additionalTextEdits); } } }
Example 15
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 16
Source File: CompletionProposalLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Creates and returns a decorated image descriptor for a completion proposal. * * @param proposal the proposal for which to create an image descriptor * @return the created image descriptor, or <code>null</code> if no image is available */ public ImageDescriptor createImageDescriptor(CompletionProposal proposal) { final int flags= proposal.getFlags(); ImageDescriptor descriptor; switch (proposal.getKind()) { case CompletionProposal.METHOD_DECLARATION: case CompletionProposal.METHOD_NAME_REFERENCE: case CompletionProposal.METHOD_REF: case CompletionProposal.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.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION: descriptor= JavaElementImageProvider.getMethodImageDescriptor(false, flags); break; case CompletionProposal.TYPE_REF: switch (Signature.getTypeSignatureKind(proposal.getSignature())) { case Signature.CLASS_TYPE_SIGNATURE: descriptor= JavaElementImageProvider.getTypeImageDescriptor(false, false, flags, false); break; case Signature.TYPE_VARIABLE_SIGNATURE: descriptor= JavaPluginImages.DESC_OBJS_TYPEVARIABLE; break; default: descriptor= null; } break; case CompletionProposal.FIELD_REF: case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER: descriptor= JavaElementImageProvider.getFieldImageDescriptor(false, flags); break; case CompletionProposal.LOCAL_VARIABLE_REF: case CompletionProposal.VARIABLE_DECLARATION: descriptor= JavaPluginImages.DESC_OBJS_LOCAL_VARIABLE; break; case CompletionProposal.PACKAGE_REF: descriptor= JavaPluginImages.DESC_OBJS_PACKAGE; break; case CompletionProposal.KEYWORD: case CompletionProposal.LABEL_REF: descriptor= null; break; case CompletionProposal.JAVADOC_METHOD_REF: case CompletionProposal.JAVADOC_TYPE_REF: case CompletionProposal.JAVADOC_FIELD_REF: case CompletionProposal.JAVADOC_VALUE_REF: case CompletionProposal.JAVADOC_BLOCK_TAG: case CompletionProposal.JAVADOC_INLINE_TAG: case CompletionProposal.JAVADOC_PARAM_REF: descriptor = JavaPluginImages.DESC_OBJS_JAVADOCTAG; break; default: descriptor= null; Assert.isTrue(false); } if (descriptor == null) return null; return decorateImageDescriptor(descriptor, proposal); }
Example 17
Source File: CompletionProposalRequestor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
private CompletionItemKind mapKind(final CompletionProposal proposal) { //When a new CompletionItemKind is added, don't forget to update SUPPORTED_KINDS int kind = proposal.getKind(); int flags = proposal.getFlags(); switch (kind) { case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION: case CompletionProposal.CONSTRUCTOR_INVOCATION: return CompletionItemKind.Constructor; case CompletionProposal.ANONYMOUS_CLASS_DECLARATION: case CompletionProposal.TYPE_REF: if (Flags.isInterface(flags)) { return CompletionItemKind.Interface; } else if (Flags.isEnum(flags)) { return CompletionItemKind.Enum; } return CompletionItemKind.Class; case CompletionProposal.FIELD_IMPORT: case CompletionProposal.METHOD_IMPORT: case CompletionProposal.METHOD_NAME_REFERENCE: case CompletionProposal.PACKAGE_REF: case CompletionProposal.TYPE_IMPORT: case CompletionProposal.MODULE_DECLARATION: case CompletionProposal.MODULE_REF: return CompletionItemKind.Module; case CompletionProposal.FIELD_REF: if (Flags.isEnum(flags)) { return CompletionItemKind.EnumMember; } if (Flags.isStatic(flags) && Flags.isFinal(flags)) { return CompletionItemKind.Constant; } return CompletionItemKind.Field; case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER: return CompletionItemKind.Field; case CompletionProposal.KEYWORD: return CompletionItemKind.Keyword; case CompletionProposal.LABEL_REF: return CompletionItemKind.Reference; case CompletionProposal.LOCAL_VARIABLE_REF: case CompletionProposal.VARIABLE_DECLARATION: return CompletionItemKind.Variable; case CompletionProposal.METHOD_DECLARATION: case CompletionProposal.METHOD_REF: case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER: case CompletionProposal.POTENTIAL_METHOD_DECLARATION: return CompletionItemKind.Method; //text case CompletionProposal.ANNOTATION_ATTRIBUTE_REF: case CompletionProposal.JAVADOC_BLOCK_TAG: case CompletionProposal.JAVADOC_FIELD_REF: case CompletionProposal.JAVADOC_INLINE_TAG: case CompletionProposal.JAVADOC_METHOD_REF: case CompletionProposal.JAVADOC_PARAM_REF: case CompletionProposal.JAVADOC_TYPE_REF: case CompletionProposal.JAVADOC_VALUE_REF: default: return CompletionItemKind.Text; } }
Example 18
Source File: CompletionProposalDescriptionProvider.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
/** * Updates the description fields of the item. * * @param proposal * @param item */ public void updateDescription(CompletionProposal proposal, CompletionItem item) { switch (proposal.getKind()) { case CompletionProposal.METHOD_NAME_REFERENCE: case CompletionProposal.METHOD_REF: case CompletionProposal.CONSTRUCTOR_INVOCATION: case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER: case CompletionProposal.POTENTIAL_METHOD_DECLARATION: if (fContext != null && fContext.isInJavadoc()) { createJavadocMethodProposalLabel(proposal, item); break; } createMethodProposalLabel(proposal, item); break; case CompletionProposal.METHOD_DECLARATION: createOverrideMethodProposalLabel(proposal, item); break; case CompletionProposal.ANONYMOUS_CLASS_DECLARATION: case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION: createAnonymousTypeLabel(proposal, item); break; case CompletionProposal.TYPE_REF: createTypeProposalLabel(proposal, item); break; case CompletionProposal.JAVADOC_TYPE_REF: createJavadocTypeProposalLabel(proposal, item); break; case CompletionProposal.JAVADOC_FIELD_REF: case CompletionProposal.JAVADOC_VALUE_REF: case CompletionProposal.JAVADOC_BLOCK_TAG: case CompletionProposal.JAVADOC_INLINE_TAG: case CompletionProposal.JAVADOC_PARAM_REF: createJavadocSimpleProposalLabel(proposal, item); break; case CompletionProposal.JAVADOC_METHOD_REF: createJavadocMethodProposalLabel(proposal, item); break; case CompletionProposal.PACKAGE_REF: case CompletionProposal.MODULE_DECLARATION: case CompletionProposal.MODULE_REF: createPackageProposalLabel(proposal, item); break; case CompletionProposal.ANNOTATION_ATTRIBUTE_REF: case CompletionProposal.FIELD_REF: case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER: createLabelWithTypeAndDeclaration(proposal, item); break; case CompletionProposal.LOCAL_VARIABLE_REF: case CompletionProposal.VARIABLE_DECLARATION: createSimpleLabelWithType(proposal, item); break; case CompletionProposal.KEYWORD: case CompletionProposal.LABEL_REF: item.setLabel(createSimpleLabel(proposal).toString()); break; default: JavaLanguageServerPlugin.logInfo(new String(proposal.getName()) + " is of type " + getProposal(proposal)); Assert.isTrue(false); } }
Example 19
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 20
Source File: CompletionProposalRequestor.java From java-debug with Eclipse Public License 1.0 | 4 votes |
private CompletionItemKind mapKind(final int kind) { // When a new CompletionItemKind is added, don't forget to update // SUPPORTED_KINDS switch (kind) { case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION: case CompletionProposal.CONSTRUCTOR_INVOCATION: return CompletionItemKind.Constructor; case CompletionProposal.ANONYMOUS_CLASS_DECLARATION: case CompletionProposal.TYPE_REF: return CompletionItemKind.Class; case CompletionProposal.FIELD_IMPORT: case CompletionProposal.METHOD_IMPORT: case CompletionProposal.METHOD_NAME_REFERENCE: case CompletionProposal.PACKAGE_REF: case CompletionProposal.TYPE_IMPORT: return CompletionItemKind.Module; case CompletionProposal.FIELD_REF: case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER: return CompletionItemKind.Field; case CompletionProposal.KEYWORD: return CompletionItemKind.Keyword; case CompletionProposal.LABEL_REF: return CompletionItemKind.Reference; case CompletionProposal.LOCAL_VARIABLE_REF: case CompletionProposal.VARIABLE_DECLARATION: return CompletionItemKind.Variable; case CompletionProposal.METHOD_DECLARATION: case CompletionProposal.METHOD_REF: case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER: case CompletionProposal.POTENTIAL_METHOD_DECLARATION: return CompletionItemKind.Function; // text case CompletionProposal.ANNOTATION_ATTRIBUTE_REF: case CompletionProposal.JAVADOC_BLOCK_TAG: case CompletionProposal.JAVADOC_FIELD_REF: case CompletionProposal.JAVADOC_INLINE_TAG: case CompletionProposal.JAVADOC_METHOD_REF: case CompletionProposal.JAVADOC_PARAM_REF: case CompletionProposal.JAVADOC_TYPE_REF: case CompletionProposal.JAVADOC_VALUE_REF: default: return CompletionItemKind.Text; } }