Examples of JavaContentAssistInvocationContext


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

  public final ICompilationUnit getCompilationUnit(final ContentAssistInvocationContext context)
  {
    ICompilationUnit cunit = null;
    if (context instanceof JavaContentAssistInvocationContext)
    {
      JavaContentAssistInvocationContext jcontext = (JavaContentAssistInvocationContext) context;

      if (jcontext.getCoreContext() != null)
      {
        cunit = jcontext.getCompilationUnit();
      }
    }
    return cunit;
  }
View Full Code Here

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

   */
  public List<ICompletionProposal> computeCompletionProposals(final ContentAssistInvocationContext context, final IProgressMonitor monitor) {
    boolean wasEmpty = proposals.isEmpty();

    if (context instanceof JavaContentAssistInvocationContext) {
      final JavaContentAssistInvocationContext jcaic = (JavaContentAssistInvocationContext) context;
      final IType expectedType = jcaic.getExpectedType();
      if (expectedType != null && "String".equals(expectedType.getElementName())) {

        final IDocument document = jcaic.getDocument();
        final ICompilationUnit cu = jcaic.getCompilationUnit();

        final IRegion wcr = DocumentHelper.findWicketComponentRegion(document, context.getInvocationOffset());
        if (wcr != null) {
          final IRegion javaRegion = DocumentHelper.findWord(document, wcr.getOffset());
          try {
View Full Code Here

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

    assertEquals(proposal.computeCompletionProposals(context, monitor).size(), 0);

    final ICompilationUnit cu = JavaCore.createCompilationUnitFrom(javaFile);
    ITextViewer viewer = new TextViewer(new Shell(), 0);
    int offset = 420;
    context = new JavaContentAssistInvocationContext(viewer, offset, new CompilationUnitEditor()) {
      @SuppressWarnings("restriction")
      @Override
      public IType getExpectedType() {
        JavaElement je = null;
        return new ResolvedBinaryType(je, "String", "java.lang.String");
View Full Code Here

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

  /*
   * @see org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor#createContext(org.eclipse.jface.text.ITextViewer, int)
   */
  protected ContentAssistInvocationContext createContext(ITextViewer viewer, int offset) {
    JavaContentAssistInvocationContext context = new JavaContentAssistInvocationContext(viewer, offset, fEditor) {
      private WojCompletionProposalLabelProvider fLabelProvider;
     
      public CompletionProposalLabelProvider getLabelProvider() {
        if(fLabelProvider == null) {
          fLabelProvider = new WojCompletionProposalLabelProvider();
View Full Code Here

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

    public List computeCompletionProposals(
      ContentAssistInvocationContext context, IProgressMonitor monitor) {
    if (!(context instanceof JavaContentAssistInvocationContext)) {
      return Collections.EMPTY_LIST;
    }
    JavaContentAssistInvocationContext javaContext = (JavaContentAssistInvocationContext)context;
       
    ITextViewer viewer = javaContext.getViewer();
    int offset = javaContext.getInvocationOffset();
    ICompletionProposal[] computeCompletionProposals =
      processor.computeCompletionProposals(viewer, offset);
    return Arrays.asList(computeCompletionProposals);
  }
View Full Code Here

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

          IDE.EDITOR_KEY, GroovyEditor.EDITOR_ID);
    }

    JavaEditor editor = (JavaEditor)EditorUtility.openInEditor(unit);
    JavaSourceViewer viewer = (JavaSourceViewer)editor.getViewer();
    JavaContentAssistInvocationContext context =
      new JavaContentAssistInvocationContext(viewer, offset, editor);

    IJavaCompletionProposalComputer computer =
      new GroovyCompletionProposalComputer();
    List<ICompletionProposal> proposals =
      computer.computeCompletionProposals(context, null);
View Full Code Here

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

  @Override
  public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context,
      IProgressMonitor monitor) {
    if (context instanceof JavaContentAssistInvocationContext) {
      JavaContentAssistInvocationContext javaContext = (JavaContentAssistInvocationContext) context;

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

        ICompilationUnit cu = javaContext.getCompilationUnit();

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

          int invocationOffset = context.getInvocationOffset();
          IJavaElement element = cu.getElementAt(invocationOffset);
          cu.makeConsistent(monitor);

          // check for type/method/field specific annotation
          // proposal computers
          if (element instanceof SourceRefElement
              && ((SourceRefElement) element).getElementInfo() instanceof AnnotatableInfo) {
            SourceRefElement sourceRefElement = (SourceRefElement) element;
            IAnnotation[] annotations = sourceRefElement.getAnnotations();
            for (IAnnotation annotation : annotations) {
              String annotationName = annotation.getElementName();

              if (javaContext.getViewer() instanceof SourceViewer) {
                // SourceViewer sourceViewer = (SourceViewer)
                // javaContext.getViewer();
                // AssistContext assistContext = new
                // AssistContext(cu, sourceViewer,
                // invocationOffset, 0);
View Full Code Here

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

  @Override
  public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context,
      IProgressMonitor monitor) {
    if (context instanceof JavaContentAssistInvocationContext) {
      JavaContentAssistInvocationContext javaContext = (JavaContentAssistInvocationContext) context;

      // check if project is a spring project
      if (SpringCoreUtils.isSpringProject(javaContext.getProject().getProject())) {
        ICompilationUnit cu = javaContext.getCompilationUnit();
        if (ProposalCalculatorUtil.hasAnnotationOnType(cu, "Controller")) {
          ITextViewer viewer = javaContext.getViewer();

          if (viewer instanceof SourceViewer) {
            SourceViewer sourceViewer = (SourceViewer) viewer;
            int invocationOffset = context.getInvocationOffset();
            AssistContext assistContext = new AssistContext(cu, sourceViewer, invocationOffset, 0, SharedASTProvider.WAIT_NO);
View Full Code Here

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

      if (editorPart instanceof CompilationUnitEditor) {
        CompilationUnitEditor sourceEditor = (CompilationUnitEditor) editorPart;
        ITextViewer sourceViewer = sourceEditor.getViewer();

        JavaContentAssistInvocationContext testContext = new JavaContentAssistInvocationContext(sourceViewer,
            offset, editorPart);

        return testContext;
      }
      else {
View Full Code Here

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

  @Override
  public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context,
      IProgressMonitor monitor) {

    if (context instanceof JavaContentAssistInvocationContext) {
      JavaContentAssistInvocationContext javaContext = (JavaContentAssistInvocationContext) context;
      ICompilationUnit cu = javaContext.getCompilationUnit();
      try {
        int invocationOffset = context.getInvocationOffset();
        IJavaElement element = cu.getElementAt(invocationOffset);
        if (element instanceof IType) {
          IType type = (IType) element;
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.