Package org.eclipse.jdt.ui.text.java

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


  public void testProposal() {
    long start = System.nanoTime();

    QWickieProposalComputer proposal = new QWickieProposalComputer();
    proposal.sessionStarted();
    ContentAssistInvocationContext context = new ContentAssistInvocationContext(javaDocument, 0);
    IProgressMonitor monitor = new NullProgressMonitor();
    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");
      }

      @Override
      public IDocument getDocument() {
        String content = javaDocument.get();
        javaDocument.set(content.replace("message", "messag"));
        return javaDocument;
      }

      @Override
      public ICompilationUnit getCompilationUnit() {
        return cu;
      }
    };

    List<ICompletionProposal> proposals = proposal.computeCompletionProposals(context, monitor);
    assertEquals(2, proposals.size());
    assertEquals("&lt;div wicket:id=\"<b>message</b>\">&lt;/div>", proposals.get(0).getAdditionalProposalInfo());
    assertEquals("message", proposals.get(0).getDisplayString());
    assertEquals(415, proposals.get(0).getSelection(javaDocument).x);
    assertEquals("&lt;div wicket:id=\"<b>message2</b>\">&lt;/div>", proposals.get(1).getAdditionalProposalInfo());
    assertEquals("message2", proposals.get(1).getDisplayString());
    assertEquals(415, proposals.get(1).getSelection(javaDocument).x);

    offset = 421;
    context = new ContentAssistInvocationContext(viewer, offset) {
      @Override
      public IDocument getDocument() {
        return javaDocument;
      }
    };
View Full Code Here


    return true;
  }

  private List<IJavaCompletionProposal> getProposals(String label, int invocationOffset) {
    ContentAssistInvocationContext context = createTestContext(invocationOffset);
    if (context instanceof JavaContentAssistInvocationContext) {
      ICompilationUnit cu = ((JavaContentAssistInvocationContext) context).getCompilationUnit();
      BodyDeclaration bodyDecl = QuickfixUtils.getTypeDecl(label, cu);
      if (bodyDecl instanceof TypeDeclaration) {
        TypeDeclaration typeDecl = (TypeDeclaration) bodyDecl;
View Full Code Here

      fail("############" + label + ": offest is " + offset + ", characterIndex is " + characterIndex
          + " characterOffset should be " + (referencePosition - offset));
    }
    else {

      ContentAssistInvocationContext context = createTestContext(characterIndex);
      List<ICompletionProposal> proposals = computer.computeCompletionProposals(context, null);

      assertValidcontextConfigurationProposals(proposals, prefix, postfix, label);
    }
  }
View Full Code Here

    String label = "testFilenameCompletion";
    String referenceString = "TestL ";

    int referencePosition = testFileText.indexOf(referenceString) - characterOffset;

    ContentAssistInvocationContext context = createTestContext(referencePosition);
    List<ICompletionProposal> proposals = computer.computeCompletionProposals(context, null);
    assertTrue(proposals.size() == 3);

  }
View Full Code Here

    String label = "testMultidirectoryFilenameCompletion";

    int position = testFileText.indexOf(label) + newlineLength + label.length()
        + "\t@ContextConfiguration(locations = { \"subdir".length() - 1;

    ContentAssistInvocationContext context = createTestContext(position);
    List<ICompletionProposal> proposals = computer.computeCompletionProposals(context, null);
    assertTrue(proposals.size() == 1);

    String expectedString = "classpath:subdir/content-configuration-assist-test.xml";
View Full Code Here

    String label = "testFilenameCompletionWithAdditionalFilename";
    String referenceString = "TestK ";

    int referencePosition = testFileText.indexOf(referenceString) - characterOffset;

    ContentAssistInvocationContext context = createTestContext(referencePosition);
    List<ICompletionProposal> proposals = computer.computeCompletionProposals(context, null);
    assertTrue(proposals.size() == 2);

  }
View Full Code Here

    String label = "testAfterQuoteNonExistentFile";
    String referenceString = "TestB ";

    int referencePosition = testFileText.indexOf(referenceString) - characterOffset;

    ContentAssistInvocationContext context = createTestContext(referencePosition);
    List<ICompletionProposal> proposals = computer.computeCompletionProposals(context, null);
    assertTrue(proposals.size() == 0);

  }
View Full Code Here

    String label = "testAfterQuoteNonExistentFile";
    String referenceString = "TestE ";

    int referencePosition = testFileText.indexOf(referenceString) - characterOffset;

    ContentAssistInvocationContext context = createTestContext(referencePosition);
    List<ICompletionProposal> proposals = computer.computeCompletionProposals(context, null);
    assertTrue(proposals.size() == 0);

  }
View Full Code Here

    String label = "testAfterQuoteNonExistentFile";
    String referenceString = "TestF ";

    int referencePosition = testFileText.indexOf(referenceString) - characterOffset;

    ContentAssistInvocationContext context = createTestContext(referencePosition);
    List<ICompletionProposal> proposals = computer.computeCompletionProposals(context, null);
    assertTrue(proposals.size() == 0);

  }
View Full Code Here

    String label = "testAfterQuoteNonExistentFileWithBrace";
    String referenceString = "TestG ";

    int referencePosition = testFileText.indexOf(referenceString) - characterOffset;

    ContentAssistInvocationContext context = createTestContext(referencePosition);
    List<ICompletionProposal> proposals = computer.computeCompletionProposals(context, null);
    assertTrue(proposals.size() == 0);

  }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext

Copyright © 2018 www.massapicom. 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.