List of usage examples for org.eclipse.jdt.core CompletionProposal findParameterNames
public char[][] findParameterNames(IProgressMonitor monitor)
From source file:org.eclipse.flux.jdt.services.CompletionProposalDescriptionProvider.java
License:Open Source License
/** * Appends the parameter list to <code>buffer</code>. * * @param buffer the buffer to append to * @param methodProposal the method proposal * @return the modified <code>buffer</code> *///from ww w . j av a 2 s .co m private StringBuilder appendUnboundedParameterList(StringBuilder buffer, CompletionProposal methodProposal) { // TODO remove once https://bugs.eclipse.org/bugs/show_bug.cgi?id=85293 // gets fixed. char[] signature = SignatureUtil.fix83600(methodProposal.getSignature()); char[][] parameterNames = methodProposal.findParameterNames(null); char[][] parameterTypes = Signature.getParameterTypes(signature); for (int i = 0; i < parameterTypes.length; i++) parameterTypes[i] = createTypeDisplayName(SignatureUtil.getLowerBound(parameterTypes[i])); if (Flags.isVarargs(methodProposal.getFlags())) { int index = parameterTypes.length - 1; parameterTypes[index] = convertToVararg(parameterTypes[index]); } return appendParameterSignature(buffer, parameterTypes, parameterNames); }
From source file:org.eclipse.flux.jdt.services.CompletionProposalReplacementProvider.java
License:Open Source License
private void appendGuessingCompletion(StringBuilder buffer, CompletionProposal proposal, List<Integer> positions) { char[][] parameterNames = proposal.findParameterNames(null); int count = parameterNames.length; for (int i = 0; i < count; i++) { if (i != 0) { buffer.append(COMMA);/*from w w w . j a va 2 s .com*/ buffer.append(SPACE); } char[] argument = parameterNames[i]; positions.add(buffer.length()); positions.add(argument.length); buffer.append(argument); } }
From source file:org.eclipse.jst.jsp.ui.internal.contentassist.JSPELProposalCollector.java
License:Open Source License
protected IJavaCompletionProposal createJavaCompletionProposal(CompletionProposal proposal) { JSPCompletionProposal jspProposal = null; if (null == proposal || null == proposal.getName()) return (null); String rawName = new String(proposal.getName()); String completion = null;/* w ww . java 2 s . c om*/ if (proposal.getKind() == CompletionProposal.METHOD_REF && proposal.findParameterNames(null).length == 0) { if (rawName.length() > 3 && rawName.startsWith("get")) { //$NON-NLS-1$ completion = rawName.substring(3, 4).toLowerCase() + rawName.substring(4, rawName.length()); } else { return null; } // java offset int offset = proposal.getReplaceStart(); // replacement length //-3 for "get" pre text on the java proposal int length = proposal.getReplaceEnd() - offset - 3; // translate offset from Java > JSP offset = getTranslation().getJspOffset(offset); // cursor position after must be calculated int positionAfter = offset + completion.length(); // from java proposal IJavaCompletionProposal javaProposal = super.createJavaCompletionProposal(proposal); Image image = null; String longDisplayString = javaProposal.getDisplayString(); int fistSpaceIndex = longDisplayString.indexOf(' '); String shortDisplayString = longDisplayString; if (fistSpaceIndex != -1) { shortDisplayString = longDisplayString.substring(fistSpaceIndex); } String displayString = completion + " " + shortDisplayString; //$NON-NLS-1$ IContextInformation contextInformation = javaProposal.getContextInformation(); String additionalInfo = javaProposal.getAdditionalProposalInfo(); int relevance = javaProposal.getRelevance(); boolean updateLengthOnValidate = true; jspProposal = new JSPCompletionProposal(completion, offset, length, positionAfter, image, displayString, contextInformation, additionalInfo, relevance, updateLengthOnValidate); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=124483 // set wrapped java proposal so additional info can be calculated on demand jspProposal.setJavaCompletionProposal(javaProposal); return jspProposal; } else { return null; } }
From source file:org.eclipse.objectteams.otdt.tests.model.CompletionTestsRequestor2.java
License:Open Source License
protected StringBuffer printProposal(CompletionProposal proposal, int tab, StringBuffer buffer) { for (int i = 0; i < tab; i++) { buffer.append(" "); //$NON-NLS-1$ }//from w w w . ja v a2s . c o m buffer.append(getElementName(proposal)); buffer.append('['); switch (proposal.getKind()) { case CompletionProposal.ANONYMOUS_CLASS_DECLARATION: buffer.append("ANONYMOUS_CLASS_DECLARATION"); //$NON-NLS-1$ break; case CompletionProposal.FIELD_REF: buffer.append("FIELD_REF"); //$NON-NLS-1$ break; case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER: buffer.append("FIELD_REF_WITH_CASTED_RECEIVER"); //$NON-NLS-1$ break; case CompletionProposal.KEYWORD: buffer.append("KEYWORD"); //$NON-NLS-1$ break; case CompletionProposal.LABEL_REF: buffer.append("LABEL_REF"); //$NON-NLS-1$ break; case CompletionProposal.LOCAL_VARIABLE_REF: buffer.append("LOCAL_VARIABLE_REF"); //$NON-NLS-1$ break; case CompletionProposal.METHOD_DECLARATION: buffer.append("METHOD_DECLARATION"); //$NON-NLS-1$ if (proposal.isConstructor()) { buffer.append("<CONSTRUCTOR>"); //$NON-NLS-1$ } break; case CompletionProposal.METHOD_REF: buffer.append("METHOD_REF"); //$NON-NLS-1$ if (proposal.isConstructor()) { buffer.append("<CONSTRUCTOR>"); //$NON-NLS-1$ } break; case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER: buffer.append("METHOD_REF_WITH_CASTED_RECEIVER"); //$NON-NLS-1$ if (proposal.isConstructor()) { buffer.append("<CONSTRUCTOR>"); //$NON-NLS-1$ } break; case CompletionProposal.PACKAGE_REF: buffer.append("PACKAGE_REF"); //$NON-NLS-1$ break; case CompletionProposal.TYPE_REF: buffer.append("TYPE_REF"); //$NON-NLS-1$ break; case CompletionProposal.VARIABLE_DECLARATION: buffer.append("VARIABLE_DECLARATION"); //$NON-NLS-1$ break; case CompletionProposal.POTENTIAL_METHOD_DECLARATION: buffer.append("POTENTIAL_METHOD_DECLARATION"); //$NON-NLS-1$ break; case CompletionProposal.METHOD_NAME_REFERENCE: //{ObjectTeams: original "METHOD_IMPORT" is now misleading (used for rhs short method spec, too) buffer.append("METHOD_NAME_REF"); //$NON-NLS-1$ // SH} break; //{ObjectTeams: new kinds: case CompletionProposal.OT_METHOD_SPEC: buffer.append("METHOD_SPEC"); //$NON-NLS-1$ break; case CompletionProposal.OT_FIELD_SPEC: buffer.append("FIELD_SPEC"); //$NON-NLS-1$ break; case CompletionProposal.OT_CALLOUT_GET: buffer.append("CALLOUT_GET"); //$NON-NLS-1$ break; case CompletionProposal.OT_CALLOUT_SET: buffer.append("CALLOUT_SET"); //$NON-NLS-1$ break; case CompletionProposal.OT_CALLOUT_DECLARATION: buffer.append("CALLOUT_DECLARATION"); //$NON-NLS-1$ break; case CompletionProposal.OT_CALLOUT_OVERRIDE_DECLARATION: buffer.append("CALLOUT_OVERRIDE_DECLARATION"); //$NON-NLS-1$ break; case CompletionProposal.OT_CALLIN_DECLARATION: buffer.append("CALLIN_DECLARATION"); //$NON-NLS-1$ break; // SH} case CompletionProposal.ANNOTATION_ATTRIBUTE_REF: buffer.append("ANNOTATION_ATTRIBUTE_REF"); //$NON-NLS-1$ break; case CompletionProposal.JAVADOC_BLOCK_TAG: buffer.append("JAVADOC_BLOCK_TAG"); //$NON-NLS-1$ break; case CompletionProposal.JAVADOC_INLINE_TAG: buffer.append("JAVADOC_INLINE_TAG"); //$NON-NLS-1$ break; case CompletionProposal.JAVADOC_FIELD_REF: buffer.append("JAVADOC_FIELD_REF"); //$NON-NLS-1$ break; case CompletionProposal.JAVADOC_METHOD_REF: buffer.append("JAVADOC_METHOD_REF"); //$NON-NLS-1$ break; case CompletionProposal.JAVADOC_TYPE_REF: buffer.append("JAVADOC_TYPE_REF"); //$NON-NLS-1$ break; case CompletionProposal.JAVADOC_PARAM_REF: buffer.append("JAVADOC_PARAM_REF"); //$NON-NLS-1$ break; case CompletionProposal.JAVADOC_VALUE_REF: buffer.append("JAVADOC_VALUE_REF"); //$NON-NLS-1$ break; case CompletionProposal.FIELD_IMPORT: buffer.append("FIELD_IMPORT"); //$NON-NLS-1$ break; case CompletionProposal.METHOD_IMPORT: buffer.append("METHOD_IMPORT"); //$NON-NLS-1$ break; case CompletionProposal.TYPE_IMPORT: buffer.append("TYPE_IMPORT"); //$NON-NLS-1$ break; default: buffer.append("PROPOSAL"); //$NON-NLS-1$ break; } buffer.append("]{"); buffer.append(proposal.getCompletion() == null ? NULL_LITERAL : proposal.getCompletion()); buffer.append(", "); buffer.append( proposal.getDeclarationSignature() == null ? NULL_LITERAL : proposal.getDeclarationSignature()); buffer.append(", "); buffer.append(proposal.getSignature() == null ? NULL_LITERAL : proposal.getSignature()); char[] receiverSignature = proposal.getReceiverSignature(); if (receiverSignature != null) { buffer.append(", "); buffer.append(receiverSignature); } if (this.showUniqueKeys) { buffer.append(", "); buffer.append(proposal.getDeclarationKey() == null ? NULL_LITERAL : proposal.getDeclarationKey()); buffer.append(", "); buffer.append(proposal.getKey() == null ? NULL_LITERAL : proposal.getKey()); } buffer.append(", "); buffer.append(proposal.getName() == null ? NULL_LITERAL : proposal.getName()); if (this.showParameterNames) { char[][] parameterNames = proposal.findParameterNames(null); buffer.append(", "); if (parameterNames == null || parameterNames.length <= 0) { buffer.append(NULL_LITERAL); } else { buffer.append("("); for (int i = 0; i < parameterNames.length; i++) { if (i > 0) buffer.append(", "); buffer.append(parameterNames[i]); } buffer.append(")"); } } if (this.showPositions) { buffer.append(", "); if (this.showTokenPositions || receiverSignature != null) buffer.append("replace"); buffer.append("["); buffer.append(proposal.getReplaceStart()); buffer.append(", "); buffer.append(proposal.getReplaceEnd()); buffer.append("]"); } if (this.showTokenPositions) { buffer.append(", token["); buffer.append(proposal.getTokenStart()); buffer.append(", "); buffer.append(proposal.getTokenEnd()); buffer.append("]"); } if (this.showPositions && receiverSignature != null) { buffer.append(", receiver["); buffer.append(proposal.getReceiverStart()); buffer.append(", "); buffer.append(proposal.getReceiverEnd()); buffer.append("]"); } buffer.append(", "); buffer.append(proposal.getRelevance()); buffer.append('}'); if (this.showMissingTypes) { CompletionProposal[] requiredProposals = proposal.getRequiredProposals(); if (requiredProposals != null) { int length = requiredProposals.length; System.arraycopy(requiredProposals, 0, requiredProposals = new CompletionProposal[length], 0, length); quickSort(requiredProposals, 0, length - 1); for (int i = 0; i < length; i++) { buffer.append('\n'); printProposal(requiredProposals[i], tab + 1, buffer); } } } return buffer; }
From source file:org.jboss.tools.vscode.java.internal.CompletionProposalReplacementProvider.java
License:Open Source License
private void appendGuessingCompletion(StringBuilder buffer, CompletionProposal proposal, List<Integer> positions) { char[][] parameterNames = proposal.findParameterNames(null); int count = parameterNames.length; for (int i = 0; i < count; i++) { if (i != 0) { buffer.append(COMMA);//from www. j av a2 s .c o m buffer.append(SPACE); } char[] argument = parameterNames[i]; positions.add(buffer.length()); positions.add(argument.length); buffer.append("{{"); buffer.append(argument); buffer.append("}}"); } }