List of usage examples for org.eclipse.jdt.core CompletionProposal FIELD_IMPORT
int FIELD_IMPORT
To view the source code for org.eclipse.jdt.core CompletionProposal FIELD_IMPORT.
Click Source Link
From source file:com.google.gwt.eclipse.core.uibinder.contentassist.computers.ProposalComputerFactory.java
License:Open Source License
/** * Creates a proposal computer for autocompleting the java classes for the * <ui:import field="___" />/* w w w. j av a 2 s. c om*/ */ public static IProposalComputer newUiImportFieldProposalComputer(ContentAssistRequest contentAssistRequest, IJavaProject javaProject, String packageName) { IDOMAttr attribute = XmlContentAssistUtilities.getAttribute(contentAssistRequest); if (attribute == null || attribute.getOwnerElement() == null) { return null; } // Ensure we are autocompleting an 'ui:import' element attribute if (!UiBinderConstants.UI_BINDER_IMPORT_ELEMENT_NAME.equals(attribute.getOwnerElement().getLocalName())) { return null; } // Ensure we are autocompleting the 'field' attribute if (!attribute.equals(UiBinderXmlModelUtilities.getFieldAttribute(attribute.getOwnerElement()))) { return null; } String attrValue = XmlContentAssistUtilities.getAttributeValueUsingMatchString(contentAssistRequest); CodeCompleteProposalComputer ccpc = new CodeCompleteProposalComputer( new int[] { CompletionProposal.TYPE_REF, CompletionProposal.PACKAGE_REF, CompletionProposal.FIELD_IMPORT, CompletionProposal.FIELD_REF }, javaProject, attrValue, XmlContentAssistUtilities.getAttributeValueOffset(contentAssistRequest), attrValue.length(), packageName, true); return ccpc; }
From source file:com.google.gwt.eclipse.core.uibinder.contentassist.computers.ProposalGeneratingCompletionRequestor.java
License:Open Source License
protected ICompletionProposal createProposal(CompletionProposal javaProposal) { String completion = String.valueOf(javaProposal.getCompletion()); int kind = javaProposal.getKind(); if (kind == CompletionProposal.TYPE_REF) { // Make sure it is fully qualified completion = JavaContentAssistUtilities.getFullyQualifiedTypeName(javaProposal); }/*from ww w . j ava 2 s. c o m*/ if (forceFullyQualifiedFieldNames && (kind == CompletionProposal.FIELD_IMPORT || kind == CompletionProposal.FIELD_REF)) { char[] decSig = javaProposal.getDeclarationSignature(); if (decSig != null && decSig.length > 2) { // declaration signatures for objects are like Ljava.lang.String;, so lop off first // and last chars completion = new String(decSig, 1, decSig.length - 2) + "." + new String(javaProposal.getCompletion()); completion = completion.replace('$', '.'); } } ICompletionProposal jdtCompletionProposal = JavaContentAssistUtilities .getJavaCompletionProposal(javaProposal, context, javaProject); return ReplacementCompletionProposal.fromExistingCompletionProposal(completion, replaceOffset, replaceLength, jdtCompletionProposal); }
From source file:com.google.gwt.eclipse.core.uibinder.contentassist.computers.ProposalGeneratingCompletionRequestor.java
License:Open Source License
private void ignoreAll() { int[] ignoredKinds = new int[] { CompletionProposal.ANONYMOUS_CLASS_DECLARATION, CompletionProposal.FIELD_REF, CompletionProposal.KEYWORD, CompletionProposal.LABEL_REF, CompletionProposal.LOCAL_VARIABLE_REF, CompletionProposal.METHOD_REF, CompletionProposal.METHOD_DECLARATION, CompletionProposal.PACKAGE_REF, CompletionProposal.TYPE_REF, CompletionProposal.VARIABLE_DECLARATION, CompletionProposal.POTENTIAL_METHOD_DECLARATION, CompletionProposal.METHOD_NAME_REFERENCE, CompletionProposal.ANNOTATION_ATTRIBUTE_REF, CompletionProposal.JAVADOC_FIELD_REF, CompletionProposal.JAVADOC_METHOD_REF, CompletionProposal.JAVADOC_TYPE_REF, CompletionProposal.JAVADOC_VALUE_REF, CompletionProposal.JAVADOC_PARAM_REF, CompletionProposal.JAVADOC_BLOCK_TAG, CompletionProposal.JAVADOC_INLINE_TAG, CompletionProposal.FIELD_IMPORT, CompletionProposal.METHOD_IMPORT, CompletionProposal.TYPE_IMPORT }; for (int kind : ignoredKinds) { setIgnored(kind, true);// w w w . j ava 2 s. c o m } }
From source file:edu.brown.cs.bubbles.bedrock.BedrockUtil.java
License:Open Source License
/********************************************************************************/ static void outputCompletion(CompletionProposal cp, IvyXmlWriter xw) { xw.begin("COMPLETION"); fieldValue(xw, "ACCESSIBILITY", cp.getAccessibility(), accessibility_types); if (cp.isConstructor()) xw.field("CONSTRUCTOR", true); xw.field("TEXT", cp.getCompletion()); xw.field("INDEX", cp.getCompletionLocation()); xw.field("DECLKEY", cp.getDeclarationKey()); switch (cp.getKind()) { case CompletionProposal.ANNOTATION_ATTRIBUTE_REF: case CompletionProposal.ANONYMOUS_CLASS_DECLARATION: case CompletionProposal.FIELD_IMPORT: case CompletionProposal.FIELD_REF: case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER: case CompletionProposal.METHOD_IMPORT: case CompletionProposal.METHOD_REF: case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER: case CompletionProposal.METHOD_DECLARATION: case CompletionProposal.POTENTIAL_METHOD_DECLARATION: xw.field("DECLSIGN", cp.getDeclarationSignature()); break;/*w ww . j a v a 2s . com*/ case CompletionProposal.PACKAGE_REF: case CompletionProposal.TYPE_IMPORT: case CompletionProposal.TYPE_REF: xw.field("DOTNAME", cp.getDeclarationSignature()); break; } fieldFlags(xw, "ACCESS", cp.getFlags(), access_flags); xw.field("FLAGS", cp.getFlags()); xw.field("KEY", cp.getKey()); xw.field("NAME", cp.getName()); xw.field("RELEVANCE", cp.getRelevance()); xw.field("REPLACE_START", cp.getReplaceStart()); xw.field("REPLACE_END", cp.getReplaceEnd()); xw.field("SIGNATURE", cp.getSignature()); xw.field("TOKEN_START", cp.getTokenStart()); xw.field("TOKEN_END", cp.getTokenEnd()); fieldValue(xw, "KIND", cp.getKind(), completion_types); if (cp instanceof ICompletionProposalExtension4) { ICompletionProposalExtension4 icp4 = (ICompletionProposalExtension4) cp; xw.field("AUTO", icp4.isAutoInsertable()); } if (CompletionFlags.isStaticImport(cp.getAdditionalFlags())) xw.field("STATICIMPORT", true); if (cp.getKind() == CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER || cp.getKind() == CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER) { xw.field("RECEIVER_SIGN", cp.getReceiverSignature()); xw.field("RECEIVER_START", cp.getReceiverStart()); xw.field("RECEIVER_END", cp.getReceiverEnd()); } xw.field("RCVR", cp.getReceiverSignature()); xw.cdataElement("DESCRIPTION", cp.toString()); CompletionProposal[] rq = cp.getRequiredProposals(); if (rq != null) { xw.begin("REQUIRED"); for (CompletionProposal xcp : rq) outputCompletion(xcp, xw); xw.end("REQUIRED"); } xw.end("COMPLETION"); }
From source file:iot.jcypher.eclipse.JCypherCompletionProposalComputer.java
License:Apache License
private List<ICompletionProposal> internalComputeCompletionProposals(int offset, JavaContentAssistInvocationContext context) { ICompilationUnit unit = context.getCompilationUnit(); if (unit == null) return Collections.emptyList(); ITextViewer viewer = context.getViewer(); CompletionProposalCollector collector = createCollector(context); collector.setInvocationContext(context); collector.setAllowsRequiredProposals(CompletionProposal.FIELD_REF, CompletionProposal.TYPE_REF, true); collector.setAllowsRequiredProposals(CompletionProposal.FIELD_REF, CompletionProposal.TYPE_IMPORT, true); collector.setAllowsRequiredProposals(CompletionProposal.FIELD_REF, CompletionProposal.FIELD_IMPORT, true); collector.setAllowsRequiredProposals(CompletionProposal.METHOD_REF, CompletionProposal.TYPE_REF, true); collector.setAllowsRequiredProposals(CompletionProposal.METHOD_REF, CompletionProposal.TYPE_IMPORT, true); collector.setAllowsRequiredProposals(CompletionProposal.METHOD_REF, CompletionProposal.METHOD_IMPORT, true); collector.setAllowsRequiredProposals(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF, true);/*from w w w . ja v a 2 s . com*/ collector.setAllowsRequiredProposals(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF, true); collector.setAllowsRequiredProposals(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, CompletionProposal.TYPE_REF, true); collector.setAllowsRequiredProposals(CompletionProposal.TYPE_REF, CompletionProposal.TYPE_REF, true); try { Point selection = viewer.getSelectedRange(); if (selection.y > 0) collector.setReplacementLength(selection.y); unit.codeComplete(offset, collector, fTimeoutProgressMonitor); } catch (OperationCanceledException x) { fErrorMessage = "Code assist took too long and is incomplete. Please close the list and type more characters"; } catch (JavaModelException x) { Shell shell = viewer.getTextWidget().getShell(); if (x.isDoesNotExist() && !unit.getJavaProject().isOnClasspath(unit)) MessageDialog.openInformation(shell, "Cannot Perform Operation", "The compilation unit is not on the build path of a Java project."); else ErrorDialog.openError(shell, "Error Accessing Compilation Unit", "Cannot access compilation unit", x.getStatus()); } ICompletionProposal[] javaProposals = collector.getJavaCompletionProposals(); List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>(Arrays.asList(javaProposals)); if (proposals.size() == 0) { String error = collector.getErrorMessage(); if (error.length() > 0) fErrorMessage = error; } return buildJCypherProposals(proposals); }
From source file:org.eclipse.flux.jdt.services.CompletionProposalReplacementProvider.java
License:Open Source License
public StringBuilder createReplacement(CompletionProposal proposal, char trigger, List<Integer> positions) { StringBuilder completionBuffer = new StringBuilder(); if (isSupportingRequiredProposals(proposal)) { CompletionProposal[] requiredProposals = proposal.getRequiredProposals(); for (int i = 0; requiredProposals != null && i < requiredProposals.length; i++) { if (requiredProposals[i].getKind() == CompletionProposal.TYPE_REF) { appendRequiredType(completionBuffer, requiredProposals[i], trigger, positions); } else if (requiredProposals[i].getKind() == CompletionProposal.TYPE_IMPORT) { appendImportProposal(completionBuffer, requiredProposals[i], proposal.getKind()); } else if (requiredProposals[i].getKind() == CompletionProposal.METHOD_IMPORT) { appendImportProposal(completionBuffer, requiredProposals[i], proposal.getKind()); } else if (requiredProposals[i].getKind() == CompletionProposal.FIELD_IMPORT) { appendImportProposal(completionBuffer, requiredProposals[i], proposal.getKind()); } else { /*/* w w w . ja v a 2 s.c o m*/ * In 3.3 we only support the above required proposals, see * CompletionProposal#getRequiredProposals() */ Assert.isTrue(false); } } } // boolean isSmartTrigger= isSmartTrigger(trigger); appendReplacementString(completionBuffer, proposal, positions); // String replacement; // if (isSmartTrigger || trigger == (char) 0) { // int referenceOffset= offset - prefix.length() + completionBuffer.length(); // //add ; to the replacement string if replacement string do not end with a semicolon and the document do not already have a ; at the reference offset. // if (trigger == ';' // && proposal.getCompletion()[proposal.getCompletion().length - 1] != ';' // && (referenceOffset >= compilationUnit.getBuffer() // .getLength() || compilationUnit.getBuffer() // .getChar(referenceOffset) != ';')) { // completionBuffer.append(';'); // } // } else { // StringBuffer buffer= new StringBuffer(getReplacementString()); // // // fix for PR #5533. Assumes that no eating takes place. // if ((getCursorPosition() > 0 && getCursorPosition() <= buffer.length() && buffer.charAt(getCursorPosition() - 1) != trigger)) { // // insert trigger ';' for methods with parameter at the end of the replacement string and not at the cursor position. // int length= getReplacementString().length(); // if (trigger == ';' && getCursorPosition() != length) { // if (buffer.charAt(length - 1) != trigger) { // buffer.insert(length, trigger); // } // } else { // buffer.insert(getCursorPosition(), trigger); // setCursorPosition(getCursorPosition() + 1); // } // } // // replacement= buffer.toString(); // setReplacementString(replacement); // } // // // PR 47097 // if (isSmartTrigger) { // // avoid inserting redundant semicolon when smart insert is enabled. // if (!(trigger == ';' && (completionBuffer.charAt(completionBuffer.length() - 1) == ';' /*|| document.getChar(referenceOffset) == ';'*/))) { //$NON-NLS-1$ // handleSmartTrigger(trigger, offset - prefix.length() + completionBuffer.length()); // } // } return completionBuffer; }
From source file:org.eclipse.flux.jdt.services.CompletionProposalReplacementProvider.java
License:Open Source License
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 {//from ww w .jav a 2s . c o m /* * 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(','); 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; //$NON-NLS-1$ } // 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; //$NON-NLS-1$ qualifiedTypeName = String.valueOf(Signature.getSignatureSimpleName(qualifiedType)); } buffer.append(qualifiedTypeName); buffer.append('.'); return buffer; }
From source file:org.eclipse.flux.jdt.services.ContentAssistService.java
License:Open Source License
protected JSONArray computeContentAssist(String username, String resourcePath, int offset, String prefix) throws JSONException { final List<CompletionProposal> proposals = new ArrayList<CompletionProposal>(); final CompletionContext[] completionContextParam = new CompletionContext[] { null }; ICompilationUnit liveEditUnit = liveEditUnits.getLiveEditUnit(username, resourcePath); try {//from w w w . ja v a 2s .com if (liveEditUnit != null) { CompletionRequestor collector = new CompletionRequestor() { @Override public void accept(CompletionProposal proposal) { proposals.add(proposal); } @Override public void acceptContext(CompletionContext context) { super.acceptContext(context); completionContextParam[0] = context; } }; // Allow completions for unresolved types - since 3.3 collector.setAllowsRequiredProposals(CompletionProposal.FIELD_REF, CompletionProposal.TYPE_REF, true); collector.setAllowsRequiredProposals(CompletionProposal.FIELD_REF, CompletionProposal.TYPE_IMPORT, true); collector.setAllowsRequiredProposals(CompletionProposal.FIELD_REF, CompletionProposal.FIELD_IMPORT, true); collector.setAllowsRequiredProposals(CompletionProposal.METHOD_REF, CompletionProposal.TYPE_REF, true); collector.setAllowsRequiredProposals(CompletionProposal.METHOD_REF, CompletionProposal.TYPE_IMPORT, true); collector.setAllowsRequiredProposals(CompletionProposal.METHOD_REF, CompletionProposal.METHOD_IMPORT, true); collector.setAllowsRequiredProposals(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF, true); collector.setAllowsRequiredProposals(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF, true); collector.setAllowsRequiredProposals(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, CompletionProposal.TYPE_REF, true); collector.setAllowsRequiredProposals(CompletionProposal.TYPE_REF, CompletionProposal.TYPE_REF, true); liveEditUnit.codeComplete(offset, collector, new NullProgressMonitor()); } } catch (JavaModelException e) { e.printStackTrace(); } List<JSONObject> jsonProposals = new ArrayList<JSONObject>(proposals.size()); CompletionContext completionContext = completionContextParam[0]; for (CompletionProposal proposal : proposals) { JSONObject jsonDescription = getDescription(proposal, completionContext); ProposalReplcamentInfo replacementInfo = new CompletionProposalReplacementProvider(liveEditUnit, proposal, completionContext, offset, prefix).createReplacement(); JSONObject jsonProposal = new JSONObject(); jsonProposal.put("description", jsonDescription); jsonProposal.put("proposal", replacementInfo.replacement); int initOffset = offset - prefix.length(); if (replacementInfo.extraChanges != null) { jsonProposal.put("additionalEdits", Utils.editsToJsonArray(replacementInfo.extraChanges)); initOffset += Utils.getOffsetAdjustment(replacementInfo.extraChanges, initOffset); } if (replacementInfo.positions != null && !replacementInfo.positions.isEmpty()) { jsonProposal.put("positions", getPositions(replacementInfo.positions, initOffset)); } jsonProposal.put("escapePosition", initOffset + replacementInfo.replacement.length()); jsonProposal.put("style", "attributedString"); jsonProposal.put("replace", true); jsonProposal.put("relevance", proposal.getRelevance()); jsonProposals.add(jsonProposal); } Collections.sort(jsonProposals, new Comparator<JSONObject>() { @Override public int compare(JSONObject o1, JSONObject o2) { try { int diff = o2.getInt("relevance") - o1.getInt("relevance"); if (diff == 0) { JSONArray nameDescription1 = o1.getJSONObject("description").getJSONArray("segments"); JSONArray nameDescription2 = o2.getJSONObject("description").getJSONArray("segments"); StringBuilder nameBuffer1 = new StringBuilder(); for (int i = 0; i < nameDescription1.length(); i++) { nameBuffer1.append(nameDescription1.getJSONObject(i).getString("value")); } StringBuilder nameBuffer2 = new StringBuilder(); for (int i = 0; i < nameDescription2.length(); i++) { nameBuffer2.append(nameDescription2.getJSONObject(i).getString("value")); } return nameBuffer1.toString().compareTo(nameBuffer2.toString()); } else { return diff; } } catch (JSONException e) { return -1; } } }); return new JSONArray(jsonProposals); }
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$ }// w ww. j a va2s .c om 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.eclipse.objectteams.otdt.tests.model.CompletionTestsRequestor2.java
License:Open Source License
protected String getElementName(CompletionProposal proposal) { switch (proposal.getKind()) { case CompletionProposal.ANONYMOUS_CLASS_DECLARATION: return new String(Signature.getSignatureSimpleName(proposal.getDeclarationSignature())); case CompletionProposal.TYPE_REF: case CompletionProposal.TYPE_IMPORT: case CompletionProposal.JAVADOC_TYPE_REF: return new String(Signature.getSignatureSimpleName(proposal.getSignature())); case CompletionProposal.FIELD_REF: case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER: case CompletionProposal.KEYWORD: case CompletionProposal.LABEL_REF: case CompletionProposal.LOCAL_VARIABLE_REF: case CompletionProposal.METHOD_REF: case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER: case CompletionProposal.METHOD_DECLARATION: case CompletionProposal.VARIABLE_DECLARATION: case CompletionProposal.POTENTIAL_METHOD_DECLARATION: case CompletionProposal.METHOD_NAME_REFERENCE: //{ObjectTeams: new kinds: case CompletionProposal.OT_METHOD_SPEC: case CompletionProposal.OT_FIELD_SPEC: case CompletionProposal.OT_CALLOUT_GET: case CompletionProposal.OT_CALLOUT_SET: case CompletionProposal.OT_CALLOUT_DECLARATION: case CompletionProposal.OT_CALLOUT_OVERRIDE_DECLARATION: case CompletionProposal.OT_CALLIN_DECLARATION: // SH}/*from ww w . j a v a2 s.com*/ case CompletionProposal.ANNOTATION_ATTRIBUTE_REF: case CompletionProposal.JAVADOC_BLOCK_TAG: case CompletionProposal.JAVADOC_INLINE_TAG: case CompletionProposal.JAVADOC_FIELD_REF: case CompletionProposal.JAVADOC_METHOD_REF: case CompletionProposal.JAVADOC_PARAM_REF: case CompletionProposal.JAVADOC_VALUE_REF: case CompletionProposal.FIELD_IMPORT: case CompletionProposal.METHOD_IMPORT: return new String(proposal.getName()); case CompletionProposal.PACKAGE_REF: return new String(proposal.getDeclarationSignature()); } return ""; }