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


Java CompilerEncodingService类代码示例

本文整理汇总了Java中com.intellij.compiler.CompilerEncodingService的典型用法代码示例。如果您正苦于以下问题:Java CompilerEncodingService类的具体用法?Java CompilerEncodingService怎么用?Java CompilerEncodingService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getChunkSpecificCompileOptions

import com.intellij.compiler.CompilerEncodingService; //导入依赖的package包/类
public String getChunkSpecificCompileOptions() {
  final StringBuilder options = new StringBuilder();
  final Charset encoding = CompilerEncodingService.getInstance(getProject()).getPreferredModuleEncoding(myMainModule);
  if (encoding != null) {
    appendOption(options, "-encoding", encoding.name());
  }
  
  final String languageLevel = getLanguageLevelOption(ApplicationManager.getApplication().runReadAction(new Computable<LanguageLevel>() {
    @Override
    public LanguageLevel compute() {
      return EffectiveLanguageLevelUtil.getEffectiveLanguageLevel(myMainModule);
    }
  }));
  appendOption(options, "-source", languageLevel);
  
  String bytecodeTarget = CompilerConfiguration.getInstance(getProject()).getBytecodeTargetLevel(myMainModule);
  if (StringUtil.isEmpty(bytecodeTarget)) {
    // according to IDEA rule: if not specified explicitly, set target to be the same as source language level
    bytecodeTarget = languageLevel;
  }
  appendOption(options, "-target", bytecodeTarget);
  
  return options.toString();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ModuleChunk.java

示例2: getOptions

import com.intellij.compiler.CompilerEncodingService; //导入依赖的package包/类
public Collection<String> getOptions(Chunk<Module> chunk) {
  List<String> options = new ArrayList<String>();
  if (getOptions().DEBUGGING_INFO) {
    options.add("-g");
  }
  if (getOptions().DEPRECATION) {
    options.add("-deprecation");
  }
  if (getOptions().GENERATE_NO_WARNINGS) {
    options.add("-nowarn");
  }
  boolean isEncodingSet = false;
  final StringTokenizer tokenizer = new StringTokenizer(getOptions().ADDITIONAL_OPTIONS_STRING, " \t\r\n");
  while(tokenizer.hasMoreTokens()) {
    final String token = tokenizer.nextToken();
    if(!acceptUserOption(token)) {
      continue;
    }
    options.add(token);
    if ("-encoding".equals(token)) {
      isEncodingSet = true;
    }
  }
  if (!isEncodingSet && acceptEncoding()) {
    final Charset charset = CompilerEncodingService.getPreferredModuleEncoding(chunk);
    if (charset != null) {
      options.add("-encoding");
      options.add(charset.name());
    }
  }
  return options;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:33,代码来源:JavacSettingsBuilder.java

示例3: validateEncoding

import com.intellij.compiler.CompilerEncodingService; //导入依赖的package包/类
private void validateEncoding(ModuleChunk chunk, String chunkPresentableName)
{
	final CompilerEncodingService es = CompilerEncodingService.getInstance(myProject);
	Charset charset = null;
	for(Module module : chunk.getModules())
	{
		final Charset moduleCharset = es.getPreferredModuleEncoding(module);
		if(charset == null)
		{
			charset = moduleCharset;
		}
		else
		{
			if(!Comparing.equal(charset, moduleCharset))
			{
				// warn user
				final Charset chunkEncoding = CompilerEncodingService.getPreferredModuleEncoding(chunk);
				final StringBuilder message = new StringBuilder();
				message.append("Modules in chunk [");
				message.append(chunkPresentableName);
				message.append("] configured to use different encodings.\n");
				if(chunkEncoding != null)
				{
					message.append("\"").append(chunkEncoding.name()).append("\" encoding will be used to compile the chunk");
				}
				else
				{
					message.append("Default compiler encoding will be used to compile the chunk");
				}
				myCompileContext.addMessage(CompilerMessageCategory.INFORMATION, message.toString(), null, -1, -1);
				break;
			}
		}
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:36,代码来源:BackendCompilerWrapper.java


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