List of usage examples for org.eclipse.jdt.core CompletionContext getTokenLocation
public int getTokenLocation()
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; }/*from www . j av a 2s .c o m*/ if ((tokenLocation & CompletionContext.TL_STATEMENT_START) != 0) { return fE4StatementsTemplateEngine; } } return fE4TemplateEngine; } return null; }
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 a2s . 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 w w w. j a v a 2 s. c o m*/ if ((tokenLocation & CompletionContext.TL_STATEMENT_START) != 0) { return fStatementsTemplateEngine; } } return fAllTemplateEngine; } return null; }