/** * Creates a JavaCodeFormatter using the default formatter options and * optionally applying user provided options on top. * * @param overrideOptions user provided options to apply on top of defaults */ public JavaCodeFormatter(final Map<String, Object> overrideOptions) { Map formatterOptions = new HashMap<>(DEFAULT_FORMATTER_OPTIONS); if (overrideOptions != null) { formatterOptions.putAll(overrideOptions); } this.codeFormatter = ToolFactory.createCodeFormatter(formatterOptions, ToolFactory.M_FORMAT_EXISTING); }
private CodeFormatter getCodeFormatter() { if (fCodeFormatter == null) fCodeFormatter = ToolFactory.createCodeFormatter(null); return fCodeFormatter; }
/** * Creates and returns a new JDT code formatter. * * @deprecated In EMF 2.2, a {@link org.eclipse.emf.codegen.ecore.generator.GeneratorAdapter GeneratorAdapter} should be used to * implement code generation. {@link org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter AbstractGeneratorAdapter} provides * an equivalent to this method. This method will be removed after 2.2. */ @Deprecated public CodeFormatter createCodeFormatter() { return ToolFactory.createCodeFormatter(codeFormatterOptions); }
/** * Creates and returns a new JDT code formatter. * * @deprecated In EMF 2.2, a {@link org.eclipse.emf.codegen.ecore.generator.GeneratorAdapter GeneratorAdapter} should be used to * implement code generation. {@link org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter AbstractGeneratorAdapter} provides * an equivalent to this method. This method will be removed after 2.2. */ @Deprecated public CodeFormatter createCodeFormatter() { return ToolFactory.createCodeFormatter(codeFormatterOptions); }
/** * Creates a JavaCodeFormatter using the default formatter options and * optionally applying user provided options on top. * * @param overrideOptions user provided options to apply on top of defaults */ public JavaCodeFormatter(final Map<String, Object> overrideOptions) { Map formatterOptions = new HashMap<>(DEFAULT_FORMATTER_OPTIONS); if (overrideOptions != null) { formatterOptions.putAll(overrideOptions); } this.codeFormatter = ToolFactory.createCodeFormatter(formatterOptions, ToolFactory.M_FORMAT_EXISTING); }
/** * Creates a JavaCodeFormatter using the default formatter options and * optionally applying user provided options on top. * * @param overrideOptions user provided options to apply on top of defaults */ public JavaCodeFormatter(final Map<String, Object> overrideOptions) { Map formatterOptions = new HashMap<>(DEFAULT_FORMATTER_OPTIONS); if (overrideOptions != null) { formatterOptions.putAll(overrideOptions); } this.codeFormatter = ToolFactory.createCodeFormatter(formatterOptions, ToolFactory.M_FORMAT_EXISTING); }
/** * Creates a JavaCodeFormatter using the default formatter options and * optionally applying user provided options on top. * * @param overrideOptions user provided options to apply on top of defaults */ public JavaCodeFormatter(final Map<String, Object> overrideOptions) { Map formatterOptions = new HashMap<>(DEFAULT_FORMATTER_OPTIONS); if (overrideOptions != null) { formatterOptions.putAll(overrideOptions); } this.codeFormatter = ToolFactory.createCodeFormatter(formatterOptions, ToolFactory.M_FORMAT_EXISTING); }
public JavaFormatter(Properties settings) { if (settings == null) { // if no settings run with jdk 5 as default settings = new Properties(); settings.put(JavaCore.COMPILER_SOURCE, "1.5"); settings.put(JavaCore.COMPILER_COMPLIANCE, "1.5"); settings.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, "1.5"); } this.codeFormatter = ToolFactory.createCodeFormatter(settings); }
public JavaFormatter( Map<String, String> options, String compilerSources, String compilerCompliance, String compilerCodegenTargetPlatform, String lineEnding) { options.put(JavaCore.COMPILER_SOURCE, compilerSources); options.put(JavaCore.COMPILER_COMPLIANCE, compilerCompliance); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, compilerCodegenTargetPlatform); formatter = ToolFactory.createCodeFormatter(options); this.lineEnding = lineEnding; }
public JavaFormatter(Map<Object, Object> settings) { if(settings==null) { // if no settings run with jdk 5 as default settings = new HashMap<Object, Object>(); settings.put( JavaCore.COMPILER_SOURCE, "1.5"); settings.put( JavaCore.COMPILER_COMPLIANCE, "1.5"); settings.put( JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, "1.5"); } this.codeFormatter = ToolFactory.createCodeFormatter(settings); }
public Formatter(Map<Object, Object> settings) { if(settings==null) { // if no settings run with jdk 5 as default settings = new HashMap<Object, Object>(); settings.put( JavaCore.COMPILER_SOURCE, "1.5"); settings.put( JavaCore.COMPILER_COMPLIANCE, "1.5"); settings.put( JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, "1.5"); } this.codeFormatter = ToolFactory.createCodeFormatter(settings); }
public JavaFormatter( Map<String, String> options, String compilerSources, String compilerCompliance, String compilerCodegenTargetPlatform, LineEnding lineEnding) { options.put(JavaCore.COMPILER_SOURCE, compilerSources); options.put(JavaCore.COMPILER_COMPLIANCE, compilerCompliance); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, compilerCodegenTargetPlatform); formatter = ToolFactory.createCodeFormatter(new HashMap<>(options)); this.lineEnding = lineEnding; }
/** * Creates edits that describe how to format the given string. Returns <code>null</code> if the code could not be formatted for the given kind. * @throws IllegalArgumentException If the offset and length are not inside the string, a * IllegalArgumentException is thrown. */ public static TextEdit format2(int kind, String string, int offset, int length, int indentationLevel, String lineSeparator, Map options) { if (offset < 0 || length < 0 || offset + length > string.length()) { throw new IllegalArgumentException("offset or length outside of string. offset: " + offset + ", length: " + length + ", string size: " + string.length()); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ } return ToolFactory.createCodeFormatter(options).format(kind, string, offset, length, indentationLevel, lineSeparator); }
public static TextEdit reformat(int kind, String string, int offset, int length, int indentationLevel, String lineSeparator, Map options) { if (offset < 0 || length < 0 || offset + length > string.length()) { throw new IllegalArgumentException("offset or length outside of string. offset: " + offset + ", length: " + length + ", string size: " + string.length()); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ } return ToolFactory.createCodeFormatter(options, ToolFactory.M_FORMAT_EXISTING).format(kind, string, offset, length, indentationLevel, lineSeparator); }
/** * Create a {@link CodeFormatter} instance to be used by this mojo. * * @throws MojoExecutionException the mojo execution exception */ private void createCodeFormatter() throws MojoExecutionException { Map<String, String> options = getFormattingOptions(); this.formatter = ToolFactory.createCodeFormatter(options); }
public TextEdit formatString(int kind, String string, int offset, int length, int indentationLevel) { return ToolFactory.createCodeFormatter(this.options).format(kind, string, offset, length, indentationLevel, this.lineDelimiter); }
public TextEdit formatString(int kind, String string, int offset, int length, int indentationLevel) { return ToolFactory.createCodeFormatter(this.options).format(kind, string, offset, length, indentationLevel, this.lineDelimiter); }
public static String format(String source) { // TODO locate user's eclipse project settings, use those if we can. Properties options = readConfig("org.eclipse.jdt.core.prefs"); final CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(options); return ensureCorrectNewLines(formatFile(source, codeFormatter)); }
/** * Creates a string that represents the given number of indentation units. * The returned string can contain tabs and/or spaces depending on the core * formatter preferences. * * @param indentationUnits the number of indentation units to generate * @param project the project from which to get the formatter settings, * <code>null</code> if the workspace default should be used * @return the indent string */ public static String createIndentString(int indentationUnits, IJavaProject project) { Map options= project != null ? project.getOptions(true) : JavaCore.getOptions(); return ToolFactory.createCodeFormatter(options).createIndentationString(indentationUnits); }
public EclipseJdtCompiler(ClassLoader parentLoader) { this.byteCodeClassLoader = new ByteCodeClassLoader(parentLoader); this.formatter = ToolFactory .createCodeFormatter(getFormattingOptions()); this.compilerNameEnvironment = new NameEnvironment( this.byteCodeClassLoader); this.compilerRequester = new CompilerRequestor(); this.compiler = new Compiler(compilerNameEnvironment, DefaultErrorHandlingPolicies.proceedWithAllProblems(), getCompilerOptions(), compilerRequester, new DefaultProblemFactory(Locale.getDefault())); }