mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (duplicates; warnings; formatting)
This commit is contained in:
@@ -1,38 +1,25 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.compiler.ant;
|
||||
|
||||
import com.intellij.compiler.CompilerConfiguration;
|
||||
import com.intellij.compiler.CompilerEncodingService;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.module.EffectiveLanguageLevelUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.CompilerModuleExtension;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Module chunk consists of interdependent modules.
|
||||
@@ -40,21 +27,13 @@ import java.util.Arrays;
|
||||
* @author Eugene Zhuravlev
|
||||
*/
|
||||
public class ModuleChunk {
|
||||
/**
|
||||
* Modules in the chunk
|
||||
*/
|
||||
/* Modules in the chunk */
|
||||
private final Module[] myModules;
|
||||
/**
|
||||
* A array of custom compilation providers.
|
||||
*/
|
||||
/* An array of custom compilation providers. */
|
||||
private final ChunkCustomCompilerExtension[] myCustomCompilers;
|
||||
/**
|
||||
* The main module in the chunck (guessed by heuristic or selected by user)
|
||||
*/
|
||||
/* The main module in the chunk (guessed by heuristic or selected by user) */
|
||||
private Module myMainModule;
|
||||
/**
|
||||
* Chucnk dependendencies
|
||||
*/
|
||||
/* Chunk dependencies */
|
||||
private ModuleChunk[] myDependentChunks;
|
||||
private File myBaseDir = null;
|
||||
|
||||
@@ -82,12 +61,14 @@ public class ModuleChunk {
|
||||
|
||||
@Nullable
|
||||
public String getOutputDirUrl() {
|
||||
return CompilerModuleExtension.getInstance(myMainModule).getCompilerOutputUrl();
|
||||
CompilerModuleExtension extension = CompilerModuleExtension.getInstance(myMainModule);
|
||||
return extension != null ? extension.getCompilerOutputUrl() : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTestsOutputDirUrl() {
|
||||
return CompilerModuleExtension.getInstance(myMainModule).getCompilerOutputUrlForTests();
|
||||
CompilerModuleExtension extension = CompilerModuleExtension.getInstance(myMainModule);
|
||||
return extension != null ? extension.getCompilerOutputUrlForTests() : null;
|
||||
}
|
||||
|
||||
public boolean isJdkInherited() {
|
||||
@@ -108,10 +89,7 @@ public class ModuleChunk {
|
||||
}
|
||||
|
||||
public File getBaseDir() {
|
||||
if (myBaseDir != null) {
|
||||
return myBaseDir;
|
||||
}
|
||||
return new File(myMainModule.getModuleFilePath()).getParentFile();
|
||||
return myBaseDir != null ? myBaseDir : new File(myMainModule.getModuleFilePath()).getParentFile();
|
||||
}
|
||||
|
||||
public void setBaseDir(File baseDir) {
|
||||
@@ -127,50 +105,31 @@ public class ModuleChunk {
|
||||
}
|
||||
|
||||
public String getChunkSpecificCompileOptions() {
|
||||
final StringBuilder options = new StringBuilder();
|
||||
final Charset encoding = CompilerEncodingService.getInstance(getProject()).getPreferredModuleEncoding(myMainModule);
|
||||
List<String> options = new ArrayList<>();
|
||||
|
||||
Charset encoding = CompilerEncodingService.getInstance(getProject()).getPreferredModuleEncoding(myMainModule);
|
||||
if (encoding != null) {
|
||||
appendOption(options, "-encoding", encoding.name());
|
||||
options.add("-encoding");
|
||||
options.add(encoding.name());
|
||||
}
|
||||
|
||||
final String languageLevel = getLanguageLevelOption(ApplicationManager.getApplication().runReadAction(new Computable<LanguageLevel>() {
|
||||
@Override
|
||||
public LanguageLevel compute() {
|
||||
return EffectiveLanguageLevelUtil.getEffectiveLanguageLevel(myMainModule);
|
||||
}
|
||||
}));
|
||||
appendOption(options, "-source", languageLevel);
|
||||
LanguageLevel languageLevel = ReadAction.compute(() -> EffectiveLanguageLevelUtil.getEffectiveLanguageLevel(myMainModule));
|
||||
String sourceVersion = languageLevel.getCompilerComplianceDefaultOption();
|
||||
options.add("-source");
|
||||
options.add(sourceVersion);
|
||||
|
||||
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;
|
||||
bytecodeTarget = sourceVersion;
|
||||
}
|
||||
appendOption(options, "-target", bytecodeTarget);
|
||||
options.add("-target");
|
||||
options.add(bytecodeTarget);
|
||||
|
||||
return options.toString();
|
||||
return StringUtil.join(options, " ");
|
||||
}
|
||||
|
||||
|
||||
public boolean contains(final Module module) {
|
||||
for (Module chunkModule : myModules) {
|
||||
if (chunkModule.equals(module)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void appendOption(StringBuilder options, @NotNull final String name, @Nullable String value) {
|
||||
if (!StringUtil.isEmpty(value)) {
|
||||
if (options.length() > 0) {
|
||||
options.append(" ");
|
||||
}
|
||||
options.append(name).append(" ").append(value);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getLanguageLevelOption(LanguageLevel level) {
|
||||
return level != null ? level.getCompilerComplianceDefaultOption() : null;
|
||||
return ArrayUtil.contains(module, myModules);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user