Java 类org.eclipse.xtext.junit4.ui.ContentAssistProcessorTestBuilder 实例源码

项目:xtext-maven-example    文件:ContentAssistTest.java   
@Test
public void testHelloCompletion() {
  Display _default = Display.getDefault();
  _default.syncExec(
    new Runnable() {
      public void run() {
        try {
          ContentAssistProcessorTestBuilder _newBuilder = ContentAssistTest.this.newBuilder();
          ContentAssistProcessorTestBuilder _append = _newBuilder.append("pack");
          _append.assertText("package");
        } catch (Throwable _e) {
          throw Exceptions.sneakyThrow(_e);
        }
      }
    });
}
项目:xtext-maven-example    文件:ContentAssistTest.java   
@Test
public void testExclMarkCompletion() {
  Display _default = Display.getDefault();
  _default.syncExec(
    new Runnable() {
      public void run() {
        try {
          ContentAssistProcessorTestBuilder _newBuilder = ContentAssistTest.this.newBuilder();
          ContentAssistProcessorTestBuilder _append = _newBuilder.append("par");
          _append.assertText("param");
        } catch (Throwable _e) {
          throw Exceptions.sneakyThrow(_e);
        }
      }
    });
}
项目:xtext-maven-example    文件:ContentAssistTest.java   
@Test
public void testHelloCompletion() {
  Display _default = Display.getDefault();
  _default.syncExec(
    new Runnable() {
      public void run() {
        try {
          ContentAssistProcessorTestBuilder _newBuilder = ContentAssistTest.this.newBuilder();
          ContentAssistProcessorTestBuilder _append = _newBuilder.append("pack");
          _append.assertText("package");
        } catch (Throwable _e) {
          throw Exceptions.sneakyThrow(_e);
        }
      }
    });
}
项目:xtext-maven-example    文件:ContentAssistTest.java   
@Test
public void testExclMarkCompletion() {
  Display _default = Display.getDefault();
  _default.syncExec(
    new Runnable() {
      public void run() {
        try {
          ContentAssistProcessorTestBuilder _newBuilder = ContentAssistTest.this.newBuilder();
          ContentAssistProcessorTestBuilder _append = _newBuilder.append("par");
          _append.assertText("param");
        } catch (Throwable _e) {
          throw Exceptions.sneakyThrow(_e);
        }
      }
    });
}
项目:packtpub-xtext-book-examples    文件:SmallJavaContentAssistTest.java   
@Test
public void testMembers() {
  try {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class A {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("A f;");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("A m() { return null; }");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("A n() { this. ");
    ContentAssistProcessorTestBuilder _append = _newBuilder.append(_builder.toString());
    _append.assertText("f", "m", "n");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:dsl-devkit    文件:AcfContentAssistProcessorTestBuilder.java   
/**
 * {@inheritDoc} Code copied from parent. Override required to run in UI because of getSourceViewer, which creates a new Shell.
 */
@Override
public ContentAssistProcessorTestBuilder assertMatchString(final String matchString) throws Exception {
  BadLocationException exception = UiThreadDispatcher.dispatchAndWait(new Function<BadLocationException>() {
    @Override
    public BadLocationException run() {
      String currentModelToParse = getModel();
      final XtextResource xtextResource = loadHelper.getResourceFor(new StringInputStream(currentModelToParse));
      final IXtextDocument xtextDocument = getDocument(xtextResource, currentModelToParse);
      XtextSourceViewerConfiguration configuration = get(XtextSourceViewerConfiguration.class);
      Shell shell = new Shell();
      try {
        ISourceViewer sourceViewer = getSourceViewer(shell, xtextDocument, configuration);
        IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
        String contentType = xtextDocument.getContentType(currentModelToParse.length());
        if (contentAssistant.getContentAssistProcessor(contentType) != null) {
          ContentAssistContext.Factory factory = get(ContentAssistContext.Factory.class);
          ContentAssistContext[] contexts = factory.create(sourceViewer, currentModelToParse.length(), xtextResource);
          for (ContentAssistContext context : contexts) {
            Assert.assertTrue("matchString = '" + matchString + "', actual: '" + context.getPrefix() + "'", "".equals(context.getPrefix())
                || matchString.equals(context.getPrefix()));
          }
        } else {
          Assert.fail("No content assistant for content type " + contentType);
        }
      } catch (BadLocationException e) {
        return e;
      } finally {
        shell.dispose();
      }
      return null;
    }
  });
  if (exception != null) {
    throw exception;
  }
  return this;
}
项目:packtpub-xtext-book-examples    文件:SmallJavaContentAssistTest.java   
@Test
public void testProtectedMembers() {
  try {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class A1 {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("private A1 priv;");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("protected A1 prot;");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public A1 pub;");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("private A1 privM() { return null; }");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("protected A1 protM() { return null; }");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public A1 pubM() { return null; }");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class B1 extends A1 {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("A1 n() { new A1(). ");
    ContentAssistProcessorTestBuilder _append = _newBuilder.append(_builder.toString());
    _append.assertText("prot", "pub", "protM", "pubM");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:packtpub-xtext-book-examples    文件:SmallJavaContentAssistTest.java   
@Test
public void testPrivateMembers() {
  try {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class A1 {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("private A1 priv;");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("protected A1 prot;");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public A1 pub;");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("private A1 privM() { return null; }");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("protected A1 protM() { return null; }");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public A1 pubM() { return null; }");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class B1 {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("A1 n() { new A1(). ");
    ContentAssistProcessorTestBuilder _append = _newBuilder.append(_builder.toString());
    _append.assertText("pub", "pubM");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:packtpub-xtext-book-examples    文件:EntitiesContentAssistTest.java   
@Test
public void testEmptyProgram() {
  try {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    _newBuilder.assertText("entity");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:packtpub-xtext-book-examples    文件:EntitiesContentAssistTest.java   
@Test
public void testSuperEntity() {
  try {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    ContentAssistProcessorTestBuilder _append = _newBuilder.append("entity E extends ");
    _append.assertText("E");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:packtpub-xtext-book-examples    文件:EntitiesContentAssistTest.java   
@Test
public void testSuperEntity2() {
  try {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    ContentAssistProcessorTestBuilder _append = _newBuilder.append("entity A{} entity E extends ");
    _append.assertText("A", "E");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:packtpub-xtext-book-examples    文件:EntitiesContentAssistTest.java   
@Test
public void testAttributeTypes() {
  try {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    ContentAssistProcessorTestBuilder _append = _newBuilder.append("entity E { ");
    _append.assertText("E", "boolean", "int", "string", "}");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:packtpub-xtext-book-examples    文件:ExpressionsContentAssistTest.java   
@Test
public void testVariableReference() {
  try {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    ContentAssistProcessorTestBuilder _append = _newBuilder.append("i = 10 1+");
    _append.assertText("!", "\"Value\"", "(", "+", "1", "false", "i", "true");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:packtpub-xtext-book-examples    文件:ExpressionsContentAssistTest.java   
@Test
public void testForwardVariableReference() {
  try {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    ContentAssistProcessorTestBuilder _append = _newBuilder.append(" i = 10 ");
    _append.assertTextAtCursorPosition(" ", 
      "!", "\"Value\"", "(", "1", "Name", "false", "true");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:packtpub-xtext-book-examples    文件:ExpressionsContentAssistTest.java   
@Test
public void testForwardVariableReference2() {
  try {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    ContentAssistProcessorTestBuilder _append = _newBuilder.append("k= 0 j=1 1+  i = 10 ");
    _append.assertTextAtCursorPosition("+", 1, 
      "!", "\"Value\"", "(", "+", "1", "false", "j", "k", "true");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:packtpub-xtext-book-examples    文件:HelloContentAssistTest.java   
@Test
public void testEmptyProgram() {
  try {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    ContentAssistProcessorTestBuilder _append = _newBuilder.append("");
    _append.assertText("Hello");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:packtpub-xtext-book-examples    文件:HelloContentAssistTest.java   
@Test
public void testAfterName() {
  try {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    ContentAssistProcessorTestBuilder _append = _newBuilder.append("Hello test ");
    _append.assertText("!");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:dsl-devkit    文件:AbstractCheckContentAssistBugTest.java   
/**
 * Creates a new content assist processor test builder.
 *
 * @return the content assist processor test builder
 * @throws Exception
 *           the exception
 */
protected ContentAssistProcessorTestBuilder newBuilder() throws Exception {
  return new ContentAssistProcessorTestBuilder(getInjector(), this);
}