本文整理汇总了Java中com.intellij.compiler.impl.javaCompiler.ModuleChunk类的典型用法代码示例。如果您正苦于以下问题:Java ModuleChunk类的具体用法?Java ModuleChunk怎么用?Java ModuleChunk使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ModuleChunk类属于com.intellij.compiler.impl.javaCompiler包,在下文中一共展示了ModuleChunk类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createStartupCommand
import com.intellij.compiler.impl.javaCompiler.ModuleChunk; //导入依赖的package包/类
@NotNull
public String[] createStartupCommand(final ModuleChunk chunk, final CompileContext context, final String outputPath)
throws IOException {
final ArrayList<String> commandLine = new ArrayList<String>();
final IOException[] ex = {null};
ApplicationManager.getApplication().runReadAction(new Runnable() {
public void run() {
try {
createStartupCommand(chunk, commandLine, outputPath, true);
}
catch (IOException e) {
ex[0] = e;
}
}
});
if (ex[0] != null) {
throw ex[0];
}
return ArrayUtil.toStringArray(commandLine);
}
示例2: createStartupCommand
import com.intellij.compiler.impl.javaCompiler.ModuleChunk; //导入依赖的package包/类
@NotNull
public String[] createStartupCommand(final ModuleChunk chunk, final CompileContext context, final String outputPath)
throws IOException {
final ArrayList<String> commandLine = new ArrayList<String>();
final IOException[] ex = {null};
ApplicationManager.getApplication().runReadAction(new Runnable() {
public void run() {
try {
_createStartupCommand(chunk, commandLine, outputPath);
}
catch (IOException e) {
ex[0] = e;
}
}
});
if (ex[0] != null) {
throw ex[0];
}
return ArrayUtil.toStringArray(commandLine);
}
示例3: addTargetCommandLineSwitch
import com.intellij.compiler.impl.javaCompiler.ModuleChunk; //导入依赖的package包/类
public static void addTargetCommandLineSwitch(final ModuleChunk chunk, final List<String> commandLine) {
String optionValue = null;
CompilerConfiguration config = null;
final Module[] modules = chunk.getModules();
for (Module module : modules) {
if (config == null) {
config = CompilerConfiguration.getInstance(module.getProject());
}
final String moduleTarget = config.getBytecodeTargetLevel(module);
if (moduleTarget == null) {
continue;
}
if (optionValue == null) {
optionValue = moduleTarget;
}
else {
if (moduleTarget.compareTo(optionValue) < 0) {
optionValue = moduleTarget; // use the lower possible target among modules that form the chunk
}
}
}
if (optionValue != null) {
commandLine.add("-target");
commandLine.add(optionValue);
}
}
示例4: addCommandLineOptions
import com.intellij.compiler.impl.javaCompiler.ModuleChunk; //导入依赖的package包/类
public static void addCommandLineOptions(@NotNull ModuleChunk chunk,
@NonNls List<String> commandLine,
@NotNull String outputPath,
@NotNull Sdk jdk,
boolean isAnnotationProcessingMode) throws IOException {
LanguageLevel languageLevel = chunk.getLanguageLevel();
CompilerUtil.addSourceCommandLineSwitch(jdk, languageLevel, commandLine);
commandLine.add("-verbose");
final String bootCp = chunk.getCompilationBootClasspath();
final String classPath = chunk.getCompilationClasspath();
commandLine.add("-bootclasspath");
addClassPathValue(commandLine, bootCp);
commandLine.add("-classpath");
addClassPathValue(commandLine, classPath);
if (isAnnotationProcessingMode) {
commandLine.add("-s");
commandLine.add(outputPath.replace('/', File.separatorChar));
final String moduleOutputPath = CompilerPaths.getModuleOutputPath(chunk.getModules()[0], false);
if (moduleOutputPath != null) {
commandLine.add("-d");
commandLine.add(moduleOutputPath.replace('/', File.separatorChar));
}
}
else {
commandLine.add("-d");
commandLine.add(outputPath.replace('/', File.separatorChar));
}
}
示例5: getJdkForStartupCommand
import com.intellij.compiler.impl.javaCompiler.ModuleChunk; //导入依赖的package包/类
private Sdk getJdkForStartupCommand(final ModuleChunk chunk) {
final Sdk jdk = chunk.getJdk();
if (ApplicationManager.getApplication().isUnitTestMode() && JavacConfiguration.getOptions(myProject, JavacConfiguration.class).isTestsUseExternalCompiler()) {
final String jdkHomePath = CompilerConfigurationImpl.getTestsExternalCompilerHome();
if (jdkHomePath == null) {
throw new IllegalArgumentException("[TEST-MODE] Cannot determine home directory for JDK to use javac from");
}
// when running under Mock JDK use VM executable from the JDK on which the tests run
return new MockJdkWrapper(jdkHomePath, jdk);
}
return jdk;
}
示例6: compile
import com.intellij.compiler.impl.javaCompiler.ModuleChunk; //导入依赖的package包/类
private static void compile(List<String> commandLine, ModuleChunk chunk, String outputDir, CompAPIDriver myCompAPIDriver) {
List<VirtualFile> filesToCompile = chunk.getFilesToCompile();
List<File> paths = new ArrayList<File>(filesToCompile.size());
for (VirtualFile file : filesToCompile) {
paths.add(new File(file.getPresentableUrl()));
}
myCompAPIDriver.compile(commandLine, paths, outputDir);
}
示例7: MyProcess
import com.intellij.compiler.impl.javaCompiler.ModuleChunk; //导入依赖的package包/类
private MyProcess(List<String> commandLine, ModuleChunk chunk, String outputDir, CompileContext compileContext) {
myCommandLine = commandLine;
myChunk = chunk;
myOutputDir = outputDir;
myCompileContext = compileContext;
myCompAPIDriver = new CompAPIDriver(findEncodingValue(commandLine));
}
示例8: setupSourceVersion
import com.intellij.compiler.impl.javaCompiler.ModuleChunk; //导入依赖的package包/类
@SuppressWarnings({"HardCodedStringLiteral"})
private static void setupSourceVersion(final ModuleChunk chunk, final ArrayList<String> commandLine) {
final Sdk jdk = chunk.getJdk();
final String versionString = jdk.getVersionString();
final LanguageLevel applicableLanguageLevel = CompilerUtil.getApplicableLanguageLevel(versionString, chunk.getLanguageLevel());
if (applicableLanguageLevel.equals(LanguageLevel.JDK_1_5)) {
commandLine.add("-source");
commandLine.add("1.4"); // -source 1.5 not supported yet by jikes, so use the highest possible version
}
else if (applicableLanguageLevel.equals(LanguageLevel.JDK_1_4)) {
commandLine.add("-source");
commandLine.add("1.4");
}
}
示例9: getOptionsString
import com.intellij.compiler.impl.javaCompiler.ModuleChunk; //导入依赖的package包/类
public String getOptionsString(final ModuleChunk chunk) {
final StringBuilder options = new StringBuilder();
for (String option : getOptions(chunk)) {
if (options.length() > 0) {
options.append(" ");
}
options.append(option);
}
return options.toString();
}
示例10: addAdditionalSettings
import com.intellij.compiler.impl.javaCompiler.ModuleChunk; //导入依赖的package包/类
public static List<String> addAdditionalSettings(List<String> commandLine, JpsJavaCompilerOptions javacOptions, boolean isAnnotationProcessing,
JavaSdkVersion version, ModuleChunk chunk, boolean annotationProcessorsEnabled) {
final List<String> additionalOptions = new ArrayList<String>();
StringTokenizer tokenizer = new StringTokenizer(new JavacSettingsBuilder(javacOptions).getOptionsString(chunk), " ");
if (isAnnotationProcessing) {
final AnnotationProcessingConfiguration config = CompilerConfiguration.getInstance(chunk.getProject()).getAnnotationProcessingConfiguration(chunk.getModules()[0]);
additionalOptions.add("-Xprefer:source");
additionalOptions.add("-implicit:none");
additionalOptions.add("-proc:only");
if (!config.isObtainProcessorsFromClasspath()) {
final String processorPath = config.getProcessorPath();
additionalOptions.add("-processorpath");
additionalOptions.add(FileUtil.toSystemDependentName(processorPath));
}
final Set<String> processors = config.getProcessors();
if (!processors.isEmpty()) {
additionalOptions.add("-processor");
additionalOptions.add(StringUtil.join(processors, ","));
}
for (Map.Entry<String, String> entry : config.getProcessorOptions().entrySet()) {
additionalOptions.add("-A" + entry.getKey() + "=" +entry.getValue());
}
}
else {
if (annotationProcessorsEnabled) {
// Unless explicitly specified by user, disable annotation processing by default for 'java compilation' mode
// This is needed to suppress unwanted side-effects from auto-discovered processors from compilation classpath
additionalOptions.add("-proc:none");
}
}
while (tokenizer.hasMoreTokens()) {
@NonNls String token = tokenizer.nextToken();
if (version == JavaSdkVersion.JDK_1_0 && "-deprecation".equals(token)) {
continue; // not supported for this version
}
if (!version.isAtLeast(JavaSdkVersion.JDK_1_5) && "-Xlint".equals(token)) {
continue; // not supported in these versions
}
if (isAnnotationProcessing) {
if (token.startsWith("-proc:")) {
continue;
}
if (token.startsWith("-implicit:")) {
continue;
}
}
else { // compiling java
if (annotationProcessorsEnabled) {
// in this mode we have -proc:none already added above, so user's settings should be ignored
if (token.startsWith("-proc:")) {
continue;
}
}
}
if (token.startsWith("-J-")) {
commandLine.add(token.substring("-J".length()));
}
else {
additionalOptions.add(token);
}
}
return additionalOptions;
}
示例11: _createStartupCommand
import com.intellij.compiler.impl.javaCompiler.ModuleChunk; //导入依赖的package包/类
private void _createStartupCommand(final ModuleChunk chunk, final ArrayList<String> commandLine, @NotNull final String outputPath) throws IOException {
myTempFile = FileUtil.createTempFile("jikes", ".tmp");
myTempFile.deleteOnExit();
final List<VirtualFile> files = chunk.getFilesToCompile();
PrintWriter writer = new PrintWriter(new FileWriter(myTempFile));
try {
for (VirtualFile file : files) {
writer.println(file.getPath());
}
}
finally {
writer.close();
}
String compilerPath = getCompilerPath();
LOG.assertTrue(compilerPath != null, "No path to compiler configured");
commandLine.add(compilerPath);
//noinspection HardCodedStringLiteral
commandLine.add("-verbose");
//noinspection HardCodedStringLiteral
commandLine.add("-classpath");
// must include output path to classpath, otherwise javac will compile all dependent files no matter were they compiled before or not
commandLine.add(chunk.getCompilationBootClasspath() + File.pathSeparator + chunk.getCompilationClasspath());
setupSourceVersion(chunk, commandLine);
//noinspection HardCodedStringLiteral
commandLine.add("-sourcepath");
String sourcePath = chunk.getSourcePath();
if (sourcePath.length() > 0) {
commandLine.add(sourcePath);
}
else {
commandLine.add("\"\"");
}
//noinspection HardCodedStringLiteral
commandLine.add("-d");
commandLine.add(outputPath.replace('/', File.separatorChar));
JikesSettingsBuilder jikesSettings = new JikesSettingsBuilder(JikesConfiguration.getOptions(myProject));
StringTokenizer tokenizer = new StringTokenizer(jikesSettings.getOptionsString(chunk), " ");
while (tokenizer.hasMoreTokens()) {
commandLine.add(tokenizer.nextToken());
}
commandLine.add("@" + myTempFile.getAbsolutePath());
}
示例12: addAdditionalSettings
import com.intellij.compiler.impl.javaCompiler.ModuleChunk; //导入依赖的package包/类
public static List<String> addAdditionalSettings(List<String> commandLine, JpsJavaCompilerOptions javacOptions, boolean isAnnotationProcessing,
JavaSdkVersion version, ModuleChunk chunk, boolean annotationProcessorsEnabled) {
final List<String> additionalOptions = new ArrayList<String>();
StringTokenizer tokenizer = new StringTokenizer(new JavacSettingsBuilder(javacOptions).getOptionsString(chunk), " ");
if (!version.isAtLeast(JavaSdkVersion.JDK_1_6)) {
isAnnotationProcessing = false; // makes no sense for these versions
annotationProcessorsEnabled = false;
}
if (isAnnotationProcessing) {
final AnnotationProcessingConfiguration config = CompilerConfiguration.getInstance(chunk.getProject()).getAnnotationProcessingConfiguration(chunk.getModules()[0]);
additionalOptions.add("-Xprefer:source");
additionalOptions.add("-implicit:none");
additionalOptions.add("-proc:only");
if (!config.isObtainProcessorsFromClasspath()) {
final String processorPath = config.getProcessorPath();
additionalOptions.add("-processorpath");
additionalOptions.add(FileUtil.toSystemDependentName(processorPath));
}
final Set<String> processors = config.getProcessors();
if (!processors.isEmpty()) {
additionalOptions.add("-processor");
additionalOptions.add(StringUtil.join(processors, ","));
}
for (Map.Entry<String, String> entry : config.getProcessorOptions().entrySet()) {
additionalOptions.add("-A" + entry.getKey() + "=" +entry.getValue());
}
}
else {
if (annotationProcessorsEnabled) {
// Unless explicitly specified by user, disable annotation processing by default for 'java compilation' mode
// This is needed to suppress unwanted side-effects from auto-discovered processors from compilation classpath
additionalOptions.add("-proc:none");
}
}
while (tokenizer.hasMoreTokens()) {
@NonNls String token = tokenizer.nextToken();
if (version == JavaSdkVersion.JDK_1_0 && "-deprecation".equals(token)) {
continue; // not supported for this version
}
if (!version.isAtLeast(JavaSdkVersion.JDK_1_5) && "-Xlint".equals(token)) {
continue; // not supported in these versions
}
if (isAnnotationProcessing) {
if (token.startsWith("-proc:")) {
continue;
}
if (token.startsWith("-implicit:")) {
continue;
}
}
else { // compiling java
if (annotationProcessorsEnabled) {
// in this mode we have -proc:none already added above, so user's settings should be ignored
if (token.startsWith("-proc:")) {
continue;
}
}
}
if (token.startsWith("-J-")) {
commandLine.add(token.substring("-J".length()));
}
else {
additionalOptions.add(token);
}
}
return additionalOptions;
}
示例13: addCommandLineOptions
import com.intellij.compiler.impl.javaCompiler.ModuleChunk; //导入依赖的package包/类
public static void addCommandLineOptions(ModuleChunk chunk, @NonNls List<String> commandLine, String outputPath, Sdk jdk,
boolean version1_0,
boolean version1_1,
List<File> tempFiles, boolean addSourcePath, boolean useTempFile,
boolean isAnnotationProcessingMode) throws IOException {
LanguageLevel languageLevel = chunk.getLanguageLevel();
CompilerUtil.addSourceCommandLineSwitch(jdk, languageLevel, commandLine);
CompilerUtil.addTargetCommandLineSwitch(chunk, commandLine);
commandLine.add("-verbose");
final String cp = chunk.getCompilationClasspath();
final String bootCp = chunk.getCompilationBootClasspath();
final String classPath;
if (version1_0 || version1_1) {
classPath = bootCp + File.pathSeparator + cp;
}
else {
classPath = cp;
commandLine.add("-bootclasspath");
addClassPathValue(jdk, false, commandLine, bootCp, "javac_bootcp", tempFiles, useTempFile);
}
commandLine.add("-classpath");
addClassPathValue(jdk, version1_0, commandLine, classPath, "javac_cp", tempFiles, useTempFile);
if (!version1_1 && !version1_0 && addSourcePath) {
commandLine.add("-sourcepath");
// this way we tell the compiler that the sourcepath is "empty". However, javac thinks that sourcepath is 'new File("")'
// this may cause problems if we have java code in IDEA working directory
if (isAnnotationProcessingMode) {
final int currentSourcesMode = chunk.getSourcesFilter();
commandLine.add(chunk.getSourcePath(currentSourcesMode == ModuleChunk.TEST_SOURCES? ModuleChunk.ALL_SOURCES : currentSourcesMode));
}
else {
commandLine.add("\"\"");
}
}
if (isAnnotationProcessingMode) {
commandLine.add("-s");
commandLine.add(outputPath.replace('/', File.separatorChar));
final String moduleOutputPath = CompilerPaths.getModuleOutputPath(chunk.getModules()[0], false);
if (moduleOutputPath != null) {
commandLine.add("-d");
commandLine.add(moduleOutputPath.replace('/', File.separatorChar));
}
}
else {
commandLine.add("-d");
commandLine.add(outputPath.replace('/', File.separatorChar));
}
}
示例14: createChunk
import com.intellij.compiler.impl.javaCompiler.ModuleChunk; //导入依赖的package包/类
private static ModuleChunk createChunk(Module module, CompileContext context) {
return new ModuleChunk((CompileContextEx)context, new Chunk<Module>(module), Collections.<Module, List<VirtualFile>>emptyMap());
}
示例15: createStartupCommand
import com.intellij.compiler.impl.javaCompiler.ModuleChunk; //导入依赖的package包/类
private void createStartupCommand(final ModuleChunk chunk, @NonNls final List<String> commandLine, final String outputPath,
JpsJavaCompilerOptions javacOptions, final boolean annotationProcessorsEnabled) throws IOException {
final Sdk jdk = getJdkForStartupCommand(chunk);
final String versionString = jdk.getVersionString();
JavaSdkVersion version = JavaSdk.getInstance().getVersion(jdk);
if (versionString == null || version == null || !(jdk.getSdkType() instanceof JavaSdkType)) {
throw new IllegalArgumentException(CompilerBundle.message("javac.error.unknown.jdk.version", jdk.getName()));
}
JavaSdkType sdkType = (JavaSdkType)jdk.getSdkType();
final String toolsJarPath = sdkType.getToolsPath(jdk);
if (toolsJarPath == null) {
throw new IllegalArgumentException(CompilerBundle.message("javac.error.tools.jar.missing", jdk.getName()));
}
final String vmExePath = sdkType.getVMExecutablePath(jdk);
commandLine.add(vmExePath);
commandLine.add("-Xmx" + javacOptions.MAXIMUM_HEAP_SIZE + "m");
final List<String> additionalOptions =
addAdditionalSettings(commandLine, javacOptions, myAnnotationProcessorMode, version, chunk, annotationProcessorsEnabled);
CompilerUtil.addLocaleOptions(commandLine, false);
commandLine.add("-classpath");
commandLine.add(sdkType.getToolsPath(jdk) + File.pathSeparator + PathUtil.getJarPathForClass(Matcher.class));
commandLine.add("com.google.errorprone.ErrorProneCompiler");
addCommandLineOptions(chunk, commandLine, outputPath, jdk, myAnnotationProcessorMode);
commandLine.addAll(additionalOptions);
final List<VirtualFile> files = chunk.getFilesToCompile();
for (final VirtualFile file : files) {
commandLine.add(file.getPath());
}
}