org.eclipse.xtext.formatting.INodeModelStreamer Java Examples
The following examples show how to use
org.eclipse.xtext.formatting.INodeModelStreamer.
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: DotNodeModelStreamer.java From gef with Eclipse Public License 2.0 | 5 votes |
private void writeHTMLStringSemantic(AbstractRule rule, DotFormattingConfigBasedStream out, ICompositeNode node) throws IOException { Injector htmlLabelInjector = new DotHtmlLabelStandaloneSetup() .createInjectorAndDoEMFRegistration(); IFormatter dotHtmlLabelFormatter = htmlLabelInjector .getInstance(IFormatter.class); ITokenStream htmlLabelOut = new TokenStringBuffer(); // TODO: calculate initial indentation properly ITokenStream fmt = dotHtmlLabelFormatter.createFormatterStream("\t\t", htmlLabelOut, false); INodeModelStreamer dothtmlLabelNodeModelStreamer = htmlLabelInjector .getInstance(INodeModelStreamer.class); IParser dotHtmlLabelParser = htmlLabelInjector .getInstance(IParser.class); // cut off the leading and the trailing white spaces String trimmedNodeText = node.getText().trim(); String htmlLabelText = trimmedNodeText.substring(1, trimmedNodeText.length() - 1); IParseResult parseResult = dotHtmlLabelParser .parse(new StringReader(htmlLabelText)); ICompositeNode htmlLabelRootNode = parseResult.getRootNode(); dothtmlLabelNodeModelStreamer.feedTokenStream(fmt, htmlLabelRootNode, 0, htmlLabelText.length()); out.writeSemantic(null, "<"); out.addNewLine(); out.addLineEntry(node.getGrammarElement(), htmlLabelOut.toString(), false); out.addNewLine(); out.writeSemantic(null, ">"); }
Example #2
Source File: FormatFragment.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** {@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(); }
Example #3
Source File: FormatterFragment.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@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; }
Example #4
Source File: DotRuntimeModule.java From gef with Eclipse Public License 2.0 | 4 votes |
public Class<? extends INodeModelStreamer> bindINodeModelStreamer() { return DotNodeModelStreamer.class; }
Example #5
Source File: FormatterTest.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
void setNodeModelStreamer(INodeModelStreamer streamer) { nodeModelStreamer = streamer; }