Java Code Examples for org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder#computeCompletionProposals()

The following examples show how to use org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder#computeCompletionProposals() . 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: EclipseBug28DirtyStateModifierContentAssistTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Assert that all the given texts are not in the proposal.
 *
 * TODO: Move this function into {@link ContentAssistProcessorTestBuilder}.
 *
 * @param builder the proposal builder.
 * @param notExpectations the texts to not be proposed.
 * @return the builder.
 * @throws Exception
 * @since 2.11
 */
protected static ContentAssistProcessorTestBuilder assertNoText(ContentAssistProcessorTestBuilder builder,
		String... notExpectations) throws Exception {
	ICompletionProposal[] computeCompletionProposals = builder.computeCompletionProposals();

	if (computeCompletionProposals == null) {
		computeCompletionProposals = new ICompletionProposal[0];
	}

	Arrays.sort(notExpectations);
	List<String> sortedNotExpectations = Lists.newArrayList();
	for (String expectation : notExpectations) {
		sortedNotExpectations.add(LineDelimiters.toPlatform(expectation));
	}

	for (final ICompletionProposal completionProposal : computeCompletionProposals) {
		String proposedText = getProposedText(completionProposal);
		Assert.assertFalse("Unexpected proposal '" + proposedText + "'",
				sortedNotExpectations.contains(proposedText));
	}

	return builder;
}
 
Example 2
Source File: Bug462915Test.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * make sure inject is not proposed
 */
@Test
public void testTestPreConditionsWork() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class A {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("inject");
    _builder.newLine();
    _builder.append("}");
    final String model = _builder.toString();
    ContentAssistProcessorTestBuilder _append = this.newBuilder().append(model);
    int _indexOf = model.indexOf("inject");
    int _plus = (_indexOf + 6);
    final ICompletionProposal[] proposals = _append.computeCompletionProposals(_plus);
    Assert.assertEquals("Did not expect to find any proposal", 0, ((List<ICompletionProposal>)Conversions.doWrapArray(proposals)).size());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 3
Source File: Bug462915Test.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * make sure additional proposal infos can be calculated
 */
@Test
public void testAdditionalProposalInfoWorks() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class A {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("test");
    _builder.newLine();
    _builder.append("}");
    final String model = _builder.toString();
    ContentAssistProcessorTestBuilder _append = this.newBuilder().append(model);
    int _indexOf = model.indexOf("test");
    int _plus = (_indexOf + 4);
    final ICompletionProposal[] proposals = _append.computeCompletionProposals(_plus);
    Assert.assertEquals("More than one proposal found", 1, ((List<ICompletionProposal>)Conversions.doWrapArray(proposals)).size());
    final ICompletionProposal proposal = IterableExtensions.<ICompletionProposal>head(((Iterable<ICompletionProposal>)Conversions.doWrapArray(proposals)));
    Assert.assertEquals("test - JUnit test method", proposal.getDisplayString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@Test");
    _builder_1.newLine();
    _builder_1.append("def void testName() {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.newLine();
    _builder_1.append("}");
    Assert.assertEquals(Strings.toUnixLineSeparator(_builder_1).toString(), proposal.getAdditionalProposalInfo());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}