List of usage examples for org.eclipse.jdt.core CompletionContext TL_STATEMENT_START
int TL_STATEMENT_START
To view the source code for org.eclipse.jdt.core CompletionContext TL_STATEMENT_START.
Click Source Link
From source file:org.eclipse.e4.internal.tools.jdt.templates.E4TemplateCompletionProposalComputer.java
License:Open Source License
protected TemplateEngine computeCompletionEngine(JavaContentAssistInvocationContext context) { ICompilationUnit unit = context.getCompilationUnit(); if (unit == null) return null; IJavaProject javaProject = unit.getJavaProject(); if (javaProject == null) return null; if (isE4OnClasspath(javaProject)) { CompletionContext coreContext = context.getCoreContext(); if (coreContext != null) { int tokenLocation = coreContext.getTokenLocation(); if ((tokenLocation & CompletionContext.TL_MEMBER_START) != 0) { return fE4MembersTemplateEngine; }/* ww w.j av a 2s. co m*/ if ((tokenLocation & CompletionContext.TL_STATEMENT_START) != 0) { return fE4StatementsTemplateEngine; } } return fE4TemplateEngine; } return null; }
From source file:org.eclipse.objectteams.otdt.tests.model.CompletionTestsRequestor2.java
License:Open Source License
public String getContext() { if (this.context == null) return ""; StringBuffer buffer = new StringBuffer(); if (!this.shortContext) { buffer.append("completion offset="); buffer.append(context.getOffset()); buffer.append('\n'); buffer.append("completion range=["); buffer.append(context.getTokenStart()); buffer.append(", "); buffer.append(context.getTokenEnd()); buffer.append("]\n"); char[] token = context.getToken(); buffer.append("completion token="); if (token == null) { buffer.append("null"); } else {/*from w ww . ja v a 2s . com*/ buffer.append('\"'); buffer.append(token); buffer.append('\"'); } buffer.append('\n'); buffer.append("completion token kind="); int tokenKind = context.getTokenKind(); if (tokenKind == CompletionContext.TOKEN_KIND_STRING_LITERAL) { buffer.append("TOKEN_KIND_STRING_LITERAL"); } else if (tokenKind == CompletionContext.TOKEN_KIND_NAME) { buffer.append("TOKEN_KIND_NAME"); } else { buffer.append("TOKEN_KIND_UNKNOWN"); } buffer.append('\n'); } char[][] expectedTypesSignatures = this.context.getExpectedTypesSignatures(); buffer.append("expectedTypesSignatures="); if (expectedTypesSignatures == null) { buffer.append(NULL_LITERAL); } else { buffer.append('{'); for (int i = 0; i < expectedTypesSignatures.length; i++) { if (i > 0) buffer.append(','); buffer.append(expectedTypesSignatures[i]); } buffer.append('}'); } buffer.append('\n'); char[][] expectedTypesKeys = this.context.getExpectedTypesKeys(); buffer.append("expectedTypesKeys="); if (expectedTypesSignatures == null) { buffer.append(NULL_LITERAL); } else { buffer.append('{'); for (int i = 0; i < expectedTypesKeys.length; i++) { if (i > 0) buffer.append(','); buffer.append(expectedTypesKeys[i]); } buffer.append('}'); } if (!this.shortContext) { buffer.append('\n'); int locationType = this.context.getTokenLocation(); if (locationType == 0) { buffer.append("completion token location=UNKNOWN"); //$NON-NLS-1$ } else { buffer.append("completion token location={"); //$NON-NLS-1$ boolean first = true; if ((locationType & CompletionContext.TL_MEMBER_START) != 0) { if (!first) buffer.append(','); buffer.append("MEMBER_START"); //$NON-NLS-1$ first = false; } if ((locationType & CompletionContext.TL_STATEMENT_START) != 0) { if (!first) buffer.append(','); buffer.append("STATEMENT_START"); //$NON-NLS-1$ first = false; } buffer.append('}'); } } if (this.computeEnclosingElement) { buffer.append('\n'); buffer.append("enclosingElement="); //$NON-NLS-1$ JavaElement enclosingElement = (JavaElement) this.context.getEnclosingElement(); if (enclosingElement == null) { buffer.append("null"); //$NON-NLS-1$ } else { buffer.append(enclosingElement.toStringWithAncestors(true /*show resolved info*/)); } } if (this.computeVisibleElements) { buffer.append('\n'); IJavaElement[] visibleElements = this.context.getVisibleElements(this.assignableType); buffer.append("visibleElements="); //$NON-NLS-1$ if (visibleElements == null) { buffer.append("null"); //$NON-NLS-1$ } else if (visibleElements.length == 0) { buffer.append("{}"); //$NON-NLS-1$ } else { buffer.append('{'); buffer.append('\n'); for (int i = 0; i < visibleElements.length; i++) { JavaElement element = (JavaElement) visibleElements[i]; buffer.append('\t'); buffer.append(element.toStringWithAncestors(true /*show resolved info*/)); buffer.append(",\n"); //$NON-NLS-1$ } buffer.append('}'); } } //buffer.append('\n'); return buffer.toString(); }
From source file:org.eclipse.recommenders.internal.snipmatch.rcp.completion.JavaContentAssistProcessor.java
License:Open Source License
@VisibleForTesting static Location getLocation(ContentAssistInvocationContext context, String partition) { if (partition.equals(JAVA_DOC)) { return Location.JAVADOC; }/*from w w w . j a v a 2s . c o m*/ if (partition.equals(JAVA_SINGLE_LINE_COMMENT) || partition.equals(JAVA_MULTI_LINE_COMMENT)) { return Location.JAVA_FILE; } JavaContentAssistInvocationContext javaContext = (JavaContentAssistInvocationContext) context; CompletionContext coreContext = javaContext.getCoreContext(); if (coreContext == null) { return Location.JAVA_FILE; } if (coreContext.isInJavadoc()) { return Location.JAVADOC; } int tokenLocation = coreContext.getTokenLocation(); if ((tokenLocation & CompletionContext.TL_MEMBER_START) != 0) { return Location.JAVA_TYPE_MEMBERS; } if ((tokenLocation & CompletionContext.TL_STATEMENT_START) != 0) { return Location.JAVA_STATEMENTS; } return Location.JAVA_FILE; }
From source file:org.springframework.ide.eclipse.boot.templates.BootTemplateCompletionProposalComputer.java
License:Open Source License
@Override protected TemplateEngine computeCompletionEngine(JavaContentAssistInvocationContext context) { ICompilationUnit unit = context.getCompilationUnit(); if (unit == null) return null; IJavaProject javaProject = unit.getJavaProject(); if (javaProject == null) return null; if (isContextTypeOnClasspath(javaProject)) { CompletionContext coreContext = context.getCoreContext(); if (coreContext != null) { int tokenLocation = coreContext.getTokenLocation(); if ((tokenLocation & CompletionContext.TL_MEMBER_START) != 0) { return fMembersTemplateEngine; }/*from ww w . ja v a2 s . co m*/ if ((tokenLocation & CompletionContext.TL_STATEMENT_START) != 0) { return fStatementsTemplateEngine; } } return fAllTemplateEngine; } return null; }