Java Code Examples for org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext#getCoreContext()
The following examples show how to use
org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext#getCoreContext() .
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: SWTTemplateCompletionProposalComputer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@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 (isSWTOnClasspath(javaProject)) { CompletionContext coreContext= context.getCoreContext(); if (coreContext != null) { int tokenLocation= coreContext.getTokenLocation(); if ((tokenLocation & CompletionContext.TL_MEMBER_START) != 0) { return fSWTMembersTemplateEngine; } if ((tokenLocation & CompletionContext.TL_STATEMENT_START) != 0) { return fSWTStatementsTemplateEngine; } } return fSWTTemplateEngine; } return null; }
Example 2
Source File: TemplateCompletionProposalComputer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected TemplateEngine computeCompletionEngine(JavaContentAssistInvocationContext context) { try { String partition= TextUtilities.getContentType(context.getDocument(), IJavaPartitions.JAVA_PARTITIONING, context.getInvocationOffset(), true); if (partition.equals(IJavaPartitions.JAVA_DOC)) return fJavadocTemplateEngine; else { CompletionContext coreContext= context.getCoreContext(); if (coreContext != null) { int tokenLocation= coreContext.getTokenLocation(); if ((tokenLocation & CompletionContext.TL_MEMBER_START) != 0) { return fJavaMembersTemplateEngine; } if ((tokenLocation & CompletionContext.TL_STATEMENT_START) != 0) { return fJavaStatementsTemplateEngine; } } return fJavaTemplateEngine; } } catch (BadLocationException x) { return null; } }
Example 3
Source File: JFaceCompletionProposalComputer.java From saneclipse with Eclipse Public License 1.0 | 5 votes |
@Override protected TemplateEngine computeCompletionEngine(JavaContentAssistInvocationContext context) { final ICompilationUnit unit = context.getCompilationUnit(); if (unit == null) { return null; } final IJavaProject javaProject = unit.getJavaProject(); if (javaProject == null) { return null; } if (isJFaceOnClasspath(javaProject)) { final CompletionContext coreContext = context.getCoreContext(); if (coreContext != null) { final int tokenLocation = coreContext.getTokenLocation(); if ((tokenLocation & CompletionContext.TL_MEMBER_START) != 0) { return jFaceMembersTemplateEngine; } if ((tokenLocation & CompletionContext.TL_STATEMENT_START) != 0) { return jFaceStatementsTemplateEngine; } } return jFaceTemplateEngine; } return null; }
Example 4
Source File: PostfixCompletionProposalComputer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override protected TemplateEngine computeCompletionEngine(JavaContentAssistInvocationContext context) { ICompilationUnit unit = context.getCompilationUnit(); if (unit == null) return null; IJavaProject javaProject = unit.getJavaProject(); if (javaProject == null) return null; CompletionContext coreContext = context.getCoreContext(); if (coreContext != null) { int tokenLocation= coreContext.getTokenLocation(); int tokenStart= coreContext.getTokenStart(); int tokenKind= coreContext.getTokenKind(); /* // XXX print out tokenlocation stuff (debugging) System.out.println("All Tokens: " + CompletionContext.TL_CONSTRUCTOR_START + " " + CompletionContext.TL_MEMBER_START + " " + CompletionContext.TL_STATEMENT_START); System.out.println("Token Start: " + coreContext.getTokenStart()); System.out.println("Token End: " + coreContext.getTokenEnd()); System.out.println("Token Kind: " + coreContext.getTokenKind()); System.out.println("Token Location: " + coreContext.getTokenLocation()); System.out.println("Enclosing Element: " + coreContext.getEnclosingElement()); System.out.println("Offset: " + coreContext.getOffset()); System.out.println("Token Array: " + Arrays.toString(coreContext.getToken())); System.out.println("Kind Tokens: " + CompletionContext.TOKEN_KIND_NAME + ", " + CompletionContext.TOKEN_KIND_STRING_LITERAL + ", " + CompletionContext.TOKEN_KIND_UNKNOWN); */ if (context.getViewer().getSelectedRange().y > 0) { // If there is an active selection we do not want to contribute to the CA return null; } if ((tokenLocation == 0 && tokenStart > -1) || ((tokenLocation & CompletionContext.TL_MEMBER_START) != 0 && tokenKind == CompletionContext.TOKEN_KIND_NAME && tokenStart > -1) || (tokenLocation == 0 && isAfterDot(context.getDocument(), context.getInvocationOffset()))) { analyzeCoreContext(context, coreContext); return postfixCompletionTemplateEngine; } } return null; }
Example 5
Source File: ParameterGuessingProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 3 votes |
/** * Creates a {@link ParameterGuessingProposal} or <code>null</code> if the core context isn't available or extended. * * @param proposal the original completion proposal * @param context the currrent context * @param fillBestGuess if set, the best guess will be filled in * * @return a proposal or <code>null</code> */ public static ParameterGuessingProposal createProposal(CompletionProposal proposal, JavaContentAssistInvocationContext context, boolean fillBestGuess) { CompletionContext coreContext= context.getCoreContext(); if (coreContext != null && coreContext.isExtended()) { return new ParameterGuessingProposal(proposal, context, coreContext, fillBestGuess); } return null; }