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

项目:xtext-extras    文件:GrammarAccessUtil.java   
private static ISerializer getSerializer(final String delimiter) {
    ISerializer result = xtextSerializerByLineDelimiter.get(delimiter);
    if (result != null) {
        return result;
    }
    final ILineSeparatorInformation lineSeparatorInformation = new ILineSeparatorInformation() {
        @Override
        public String getLineSeparator() {
            return delimiter;
        }
    };
    Injector injector = Guice.createInjector(new LineSeparatorModule(lineSeparatorInformation));
    result = injector.getInstance(ISerializer.class);
    xtextSerializerByLineDelimiter.put(delimiter, result);
    return result;
}
项目:xtext-core    文件:XtextFormatterTest.java   
@Override
public void setUp() throws Exception {
    super.setUp();
    with(new XtextStandaloneSetup() {
        @Override
        public Injector createInjector() {
            return Guice.createInjector(new org.eclipse.xtext.XtextRuntimeModule() {
                @SuppressWarnings("unused")
                public Class<? extends ILineSeparatorInformation> bindILineSeparatorInformation() {
                    return FormatterTestLineSeparatorInformation.class;
                }
            });
        }
    });
    get(FormatterTestLineSeparatorInformation.class).setLineSeparator("\n");
}
项目:n4js    文件:NewlineAwareXcoreStandaloneSetup.java   
@Override
public Injector createInjector() {
    return Guice.createInjector(new XcoreStandaloneRuntimeModule() {
        @SuppressWarnings("unused")
        public Class<? extends ILineSeparatorInformation> bindILineSeparatorInformation() {
            return UnixLineSeparator.class;
        }

        @SuppressWarnings("unused")
        public Class<? extends XcoreResourceSetInitializer> bindXcoreResourceSetInitializer() {
            return CreateResourceGuardedResourceSetInitializer.class;
        }
    });
}
项目:xtext-extras    文件:DebugAntlrGeneratorFragment.java   
/**
 * @since 2.7
 */
protected void prettyPrint(String absoluteGrammarFileName, Charset encoding) {
    try {
        String content = readFileIntoString(absoluteGrammarFileName, encoding);
        final ILineSeparatorInformation lineSeparatorInformation = new ILineSeparatorInformation() {
            @Override
            public String getLineSeparator() {
                return DebugAntlrGeneratorFragment.this.getLineDelimiter();
            }
        };
        Injector injector = new SimpleAntlrStandaloneSetup() {
            @Override
            public Injector createInjector() {
                return Guice.createInjector(new SimpleAntlrRuntimeModule() {
                    @Override
                    public void configure(Binder binder) {
                        super.configure(binder);
                        binder.bind(ILineSeparatorInformation.class).toInstance(lineSeparatorInformation);
                    }
                });
            }
        }.createInjectorAndDoEMFRegistration();
        XtextResource resource = injector.getInstance(XtextResource.class);
        resource.setURI(URI.createFileURI(absoluteGrammarFileName));
        resource.load(new StringInputStream(content, encoding.name()),
                Collections.singletonMap(XtextResource.OPTION_ENCODING, encoding.name()));
        if (!resource.getErrors().isEmpty()) {
            String errors = Joiner.on(getLineDelimiter()).join(resource.getErrors());
            throw new GeneratorWarning("Non fatal problem: Debug grammar could not be formatted due to:" + getLineDelimiter() + errors);
        }
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream(content.length());
        resource.save(outputStream, SaveOptions.newBuilder().format().getOptions().toOptionsMap());
        String toBeWritten = new NewlineNormalizer(getLineDelimiter()).normalizeLineDelimiters(
                new String(outputStream.toByteArray(), encoding.name()));
        writeStringIntoFile(absoluteGrammarFileName, toBeWritten, encoding);
    } catch(IOException e) {
        throw new GeneratorWarning(e.getMessage());
    }
}
项目:xtext-core    文件:GrammarAccessExtensions.java   
private ISerializer getSerializer() {
  final String delimiter = this.codeConfig.getLineDelimiter();
  ISerializer result = this.xtextSerializerByLineDelimiter.get(delimiter);
  if ((result != null)) {
    return result;
  }
  final ILineSeparatorInformation _function = () -> {
    return delimiter;
  };
  GrammarAccessExtensions.LineSeparatorModule _lineSeparatorModule = new GrammarAccessExtensions.LineSeparatorModule(_function);
  final Injector injector = Guice.createInjector(_lineSeparatorModule);
  result = injector.<ISerializer>getInstance(ISerializer.class);
  this.xtextSerializerByLineDelimiter.put(delimiter, result);
  return result;
}
项目:bts    文件:PreferenceStoreWhitespaceInformationProvider.java   
public ILineSeparatorInformation getLineSeparatorInformation(URI uri) {
    final String lineSeparator = getLineSeparatorPreference(uri);
    return new ILineSeparatorInformation() {
        public String getLineSeparator() {
            return lineSeparator;
        }
    };
}
项目:xtext-extras    文件:GrammarAccessUtil.java   
protected LineSeparatorModule(ILineSeparatorInformation lineSeparatorInformation) {
    this.lineSeparatorInformation = lineSeparatorInformation;
}
项目:xtext-extras    文件:GrammarAccessUtil.java   
public ILineSeparatorInformation bindILineSeparatorInformation() {
    return lineSeparatorInformation;
}
项目:xtext-core    文件:FormattingConfig2.java   
public FormattingConfig2(IGrammarAccess grammarAccess, IHiddenTokenHelper hiddenTokenHelper,
        IIndentationInformation indentInfo, ILineSeparatorInformation lineSeparatorInfo) {
    super(grammarAccess, hiddenTokenHelper, indentInfo);
    this.lineSeparatorInfo = lineSeparatorInfo;
}
项目:xtext-core    文件:FormattingConfig2.java   
public ILineSeparatorInformation getLineSeparatorInfo() {
    return lineSeparatorInfo;
}
项目:xtext-core    文件:AbstractDeclarativeFormatter.java   
/**
 * @since 2.3
 */
protected ILineSeparatorInformation getLineSeparatorInfo() {
    return whitespaceInformationProvider.getLineSeparatorInformation(contextResourceURI);
}
项目:xtext-core    文件:GrammarAccessExtensions.java   
public ILineSeparatorInformation bindILineSeparatorInformation() {
  return this.lineSeparatorInformation;
}
项目:xtext-core    文件:GrammarAccessExtensions.java   
public LineSeparatorModule(final ILineSeparatorInformation lineSeparatorInformation) {
  super();
  this.lineSeparatorInformation = lineSeparatorInformation;
}
项目:xtext-core    文件:DefaultGeneratorModule.java   
public void configureLineSeparatorInformation(final Binder binder) {
  final ILineSeparatorInformation _function = () -> {
    return this.code.getLineDelimiter();
  };
  binder.<ILineSeparatorInformation>bind(ILineSeparatorInformation.class).toInstance(_function);
}
项目:xtext-core    文件:FormatterTestLanguageRuntimeModule.java   
public Class<? extends ILineSeparatorInformation> bindILineSeparatorInformation() {
    return FormatterTestLineSeparatorInformation.class;
}
项目:dsl-devkit    文件:ExtendedFormattingConfig.java   
/**
 * Instantiates a new AcfFormattingConfig.
 *
 * @param grammarAccess
 *          the grammar access
 * @param hiddenTokenHelper
 *          the hidden token helper
 * @param indentInfo
 *          the indent info
 * @param lineSeparatorInfo
 *          the line separator info
 */
public ExtendedFormattingConfig(final IGrammarAccess grammarAccess, final IHiddenTokenHelper hiddenTokenHelper, final IIndentationInformation indentInfo, final ILineSeparatorInformation lineSeparatorInfo) {
  super(grammarAccess, hiddenTokenHelper, indentInfo, lineSeparatorInfo);
}