Java 类org.eclipse.xtext.formatting.INodeModelFormatter 实例源码

项目:dsl-devkit    文件:FormatFragment.java   
/** {@inheritDoc} */
@Override
public Set<Binding> getGuiceBindingsRt(final Grammar grammar) {
  final BindFactory bindFactory = new BindFactory();
  bindFactory.addTypeToType(IFormatter.class.getName(), FormatGeneratorUtil.getFormatterName(grammar, ""));
  bindFactory.addTypeToType(INodeModelFormatter.class.getName(), RegionNodeModelFormatter.class.getName());
  bindFactory.addTypeToType(INodeModelStreamer.class.getName(), DirectNodeModelStreamer.class.getName());
  return bindFactory.getBindings();
}
项目:dsl-devkit    文件:FormatterFragment.java   
@Override
public Set<Binding> getGuiceBindingsRt(final Grammar grammar) {
  final Set<Binding> bindings = super.getGuiceBindingsRt(grammar);
  BindFactory bindFactory = new BindFactory();
  bindings.addAll(bindFactory.addTypeToType(INodeModelFormatter.class.getName(), RegionNodeModelFormatter.class.getName()).getBindings());
  bindings.addAll(bindFactory.addTypeToType(INodeModelStreamer.class.getName(), DirectNodeModelStreamer.class.getName()).getBindings());
  return bindings;
}
项目:packtpub-xtext-book-examples    文件:EntitiesFormatterTest.java   
public void assertFormattedAs(final CharSequence input, final CharSequence expected) {
  try {
    String _string = expected.toString();
    Model _parse = this._parseHelper.parse(input);
    Resource _eResource = _parse.eResource();
    IParseResult _parseResult = ((XtextResource) _eResource).getParseResult();
    ICompositeNode _rootNode = _parseResult.getRootNode();
    int _length = input.length();
    INodeModelFormatter.IFormattedRegion _format = this._iNodeModelFormatter.format(_rootNode, 0, _length);
    String _formattedText = _format.getFormattedText();
    Assert.assertEquals(_string, _formattedText);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:xtext-extras    文件:AbstractXtextTests.java   
protected INodeModelFormatter getNodeModelFormatter() {
    return getInjector().getInstance(INodeModelFormatter.class);
}
项目:xtext-core    文件:DefaultRuntimeModule.java   
public Class<? extends INodeModelFormatter> bindINodeModelFormatter() {
    return DefaultNodeModelFormatter.class;
}
项目:xtext-core    文件:AbstractXtextTests.java   
protected INodeModelFormatter getNodeModelFormatter() {
    return getInjector().getInstance(INodeModelFormatter.class);
}
项目:dsl-devkit    文件:AbstractFormatterTest.java   
protected void assertFormattedNM(final String expected, final String model, final int offset, final int length) throws IOException {
  ICompositeNode node = NodeModelUtils.getNode(getModel(model)).getRootNode();
  IFormattedRegion r = getXtextTestUtil().get(INodeModelFormatter.class).format(node, offset, length);
  String actual = model.substring(0, r.getOffset()) + r.getFormattedText() + model.substring(r.getLength() + r.getOffset());
  Assert.assertEquals(expected, actual);
}
项目:dsl-devkit    文件:AbstractFormattingTest.java   
/**
 * Test formatting based on the NodeModel.
 *
 * @param model
 *          the model to check
 * @param input
 *          String representing a serialized model
 * @param expected
 *          Expected formatted String
 * @param offset
 *          Offset from which to start formatting
 * @param length
 *          Length of region to format
 */
private void assertFormattedNodeModel(final EObject model, final String input, final String expected, final int offset, final int length) {
  ICompositeNode node = NodeModelUtils.getNode(model).getRootNode();
  IFormattedRegion region = getXtextTestUtil().get(INodeModelFormatter.class).format(node, offset, length);
  String actual = input.substring(0, offset) + region.getFormattedText() + input.substring(length + offset);
  Assert.assertEquals(expected.replaceAll(CR_LF, LF), actual.replaceAll(CR_LF, LF));
}