当前位置: 首页>>代码示例>>Java>>正文


Java DefaultCodeFormatterConstants.getEclipseDefaultSettings方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants.getEclipseDefaultSettings方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultCodeFormatterConstants.getEclipseDefaultSettings方法的具体用法?Java DefaultCodeFormatterConstants.getEclipseDefaultSettings怎么用?Java DefaultCodeFormatterConstants.getEclipseDefaultSettings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants的用法示例。


在下文中一共展示了DefaultCodeFormatterConstants.getEclipseDefaultSettings方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: formatUnitSourceCode

import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; //导入方法依赖的package包/类
/**
 * Format a Unit Source Code
 * 
 * @param testInterface
 * @param monitor
 * @throws CoreException 
 */
@SuppressWarnings("unchecked")
public static void formatUnitSourceCode(IFile file, IProgressMonitor monitor) throws CoreException {
	@SuppressWarnings("rawtypes")
	SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
	ICompilationUnit unit = JavaCore.createCompilationUnitFrom(file);
	subMonitor.split(50);
	ICompilationUnit workingCopy = unit.getWorkingCopy(monitor);

	Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();

	options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_7);
	options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_7);
	options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_7);

	options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS,
			DefaultCodeFormatterConstants.createAlignmentValue(true,
					DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE,
					DefaultCodeFormatterConstants.INDENT_ON_COLUMN));

	final CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(options);
	ISourceRange range = unit.getSourceRange();
	TextEdit formatEdit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT, unit.getSource(),
			range.getOffset(), range.getLength(), 0, null);
	subMonitor.split(30);
	if (formatEdit != null /* && formatEdit.hasChildren()*/) {
		workingCopy.applyTextEdit(formatEdit, monitor);
		workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null);
		workingCopy.commitWorkingCopy(true, null);
		workingCopy.discardWorkingCopy();
	}
	file.refreshLocal(IResource.DEPTH_INFINITE, subMonitor);
	subMonitor.split(20);
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:41,代码来源:JDTManager.java

示例2: getDefaultFormatSettings

import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; //导入方法依赖的package包/类
public static Map<String, String> getDefaultFormatSettings() {
  if (formatSettings != null && !formatSettings.isEmpty()) {
    return formatSettings;
  }

  formatSettings = new CheCodeFormatterOptions().getCheDefaultSettings();
  if (formatSettings != null && !formatSettings.isEmpty()) {
    return formatSettings;
  }
  return DefaultCodeFormatterConstants.getEclipseDefaultSettings();
}
 
开发者ID:eclipse,项目名称:che,代码行数:12,代码来源:CheCodeFormatterOptions.java

示例3: setFormatterSettings

import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "deprecation"})
public void setFormatterSettings(List<Setting> settings) {

    // // change the option to wrap each enum constant on a new line
    // options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS,
    // DefaultCodeFormatterConstants.createAlignmentValue(true,
    // DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE,
    // DefaultCodeFormatterConstants.INDENT_ON_COLUMN));
    //
    if (settings != null) {
        options = newHashMap();
        for (Setting s : settings) {
            options.put(s.getId(), s.getValue());
        }
    } else {
        options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();

        options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8);
        options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8);
        options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8);

        options.put(JavaCore.FORMATTER_LINE_SPLIT, "160");
        options.put(JavaCore.FORMATTER_TAB_CHAR, JavaCore.SPACE);
        options.put(JavaCore.FORMATTER_TAB_SIZE, "4");
    }

    // instanciate the default code formatter with the given options
    codeFormatter = ToolFactory.createCodeFormatter(options);
}
 
开发者ID:jaxio,项目名称:celerio,代码行数:30,代码来源:EclipseCodeFormatter.java

示例4: getEclipseSettings

import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; //导入方法依赖的package包/类
/**
 * @return Returns the settings for the new eclipse profile.
 */
public static Map<String, String> getEclipseSettings() {
	final Map<String, String> options= DefaultCodeFormatterConstants.getEclipseDefaultSettings();

	ProfileVersioner.setLatestCompliance(options);
	return options;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:FormatterProfileManager.java


注:本文中的org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants.getEclipseDefaultSettings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。