本文整理汇总了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();
}
示例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;
}
示例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;
}
}
}
}