Examples of JavaContentAssistInvocationContext


Examples of org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext

      IEditorPart editorPart = openEditor();

      if (editorPart instanceof CompilationUnitEditor) {
        CompilationUnitEditor sourceEditor = (CompilationUnitEditor) editorPart;
        ITextViewer sourceViewer = sourceEditor.getViewer();
        JavaContentAssistInvocationContext testContext = new JavaContentAssistInvocationContext(sourceViewer,
            offset, editorPart);
        return testContext;
      }
      else {
        assertTrue(false);
View Full Code Here

Examples of org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext

    if (!(context instanceof JavaContentAssistInvocationContext)) {
      return super.computeCompletionProposals(context, monitor);
    }

    JavaContentAssistInvocationContext javaContext = (JavaContentAssistInvocationContext) context;

    CompletionContext coreContext = javaContext.getCoreContext();
    if (coreContext != null) {
      int tokenLocation = coreContext.getTokenLocation();
      if ((tokenLocation & CompletionContext.TL_MEMBER_START) == 0) {
        return super.computeCompletionProposals(context, monitor);
      }
    }

    if (!SpringCoreUtils.isSpringProject(javaContext.getProject().getProject())) {
      return super.computeCompletionProposals(context, monitor);
    }

    ITextViewer viewer = context.getViewer();
    IDocument document = viewer.getDocument();

    try {
      int invocationOffset = context.getInvocationOffset();
      int start = invocationOffset;
      int end = invocationOffset;

      while (start != 0 && Character.isUnicodeIdentifierPart(document.getChar(start - 1))) {
        start--;
      }

      if (start < 0) {
        return super.computeCompletionProposals(context, monitor);
      }

      String prefix = document.get(start, end - start);
      if (!"findby".startsWith(prefix.toLowerCase())) {
        return super.computeCompletionProposals(context, monitor);
      }

      if (!(viewer instanceof ISourceViewer)) {
        return super.computeCompletionProposals(context, monitor);
      }

      IType expectedType = javaContext.getExpectedType();

      if (expectedType == null) {
        expectedType = javaContext.getCompilationUnit().findPrimaryType();
      }
      if (expectedType == null) {
        return super.computeCompletionProposals(javaContext, monitor);
      }
      if (!isSpringDataRepository(expectedType, javaContext.getProject())) {
        return super.computeCompletionProposals(javaContext, monitor);
      }

      List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
View Full Code Here

Examples of org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext

    if (!(context instanceof JavaContentAssistInvocationContext)) {
      return Collections.emptyList();
    }

    JavaContentAssistInvocationContext javaContext = (JavaContentAssistInvocationContext) context;

    if (!SpringCoreUtils.isSpringProject(javaContext.getProject().getProject())) {
      return Collections.emptyList();
    }
   
    if (javaContext.getCoreContext() == null) {
      return Collections.emptyList();
    }

    ICompilationUnit cu = javaContext.getCompilationUnit();

    try {
      int invocationOffset = context.getInvocationOffset();
      IJavaElement element = cu.getElementAt(invocationOffset);
View Full Code Here

Examples of org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext

      IProgressMonitor monitor) {

    List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();

    if (context instanceof JavaContentAssistInvocationContext) {
      JavaContentAssistInvocationContext javaContext = (JavaContentAssistInvocationContext) context;

      // check if project is a spring project
      if (SpringCoreUtils.isSpringProject(javaContext.getProject().getProject())) {

        ITextViewer viewer = javaContext.getViewer();
        IDocument document = viewer.getDocument();

        try {
          int invocationOffset = context.getInvocationOffset();
          int start = invocationOffset;
          int end = invocationOffset;

          while (start != 0 && Character.isUnicodeIdentifierPart(document.getChar(start - 1))) {
            start--;
          }

          if (start > 0) {
            if (document.getChar(start - 1) == '@') {
              String annotation = document.get(start, end - start);
              if ("qualifier".startsWith(annotation.toLowerCase())) {
                if (viewer instanceof ISourceViewer) {
                  AssistContext assistContext = new AssistContext(javaContext.getCompilationUnit(),
                      (ISourceViewer) viewer, start - 1, end - start + 1);
                  ASTNode annotationNode = assistContext.getCoveredNode();
                  BodyDeclaration decl = getParentDeclaration(annotationNode);

                  if (decl instanceof FieldDeclaration) {
View Full Code Here

Examples of org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext

public class FXBeanJavaCompletionProposalComputer implements IJavaCompletionProposalComputer {
 
  @Override
  public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
    if (context instanceof JavaContentAssistInvocationContext && false) {
      JavaContentAssistInvocationContext javaContext= (JavaContentAssistInvocationContext) context;
      CompletionContext completionContext = javaContext.getCoreContext();
      IJavaElement enclosingElement= null;
      if( completionContext.isExtended() ) {
        enclosingElement = completionContext.getEnclosingElement()
      } else {
        try {
          enclosingElement = javaContext.getCompilationUnit().getElementAt(context.getInvocationOffset() + 1);
        } catch (JavaModelException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.