mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
no use of IDEA's OutputItem in GroovyOSProcessHandler
This commit is contained in:
@@ -41,7 +41,7 @@ public class GroovyCompilerWrapper {
|
||||
List compiledFiles = new ArrayList();
|
||||
try {
|
||||
unit.compile(forStubs ? Phases.CONVERSION : Phases.ALL);
|
||||
addCompiledFiles(unit, compiledFiles, forStubs, collector);
|
||||
addCompiledFiles(unit, compiledFiles, forStubs);
|
||||
}
|
||||
catch (CompilationFailedException e) {
|
||||
processCompilationException(e, collector, forStubs);
|
||||
@@ -64,7 +64,9 @@ public class GroovyCompilerWrapper {
|
||||
return compiledFiles;
|
||||
}
|
||||
|
||||
private static void addCompiledFiles(CompilationUnit compilationUnit, final List compiledFiles, final boolean forStubs, final List collector) throws IOException {
|
||||
private static void addCompiledFiles(CompilationUnit compilationUnit,
|
||||
final List compiledFiles,
|
||||
final boolean forStubs) throws IOException {
|
||||
File targetDirectory = compilationUnit.getConfiguration().getTargetDirectory();
|
||||
|
||||
final String outputPath = targetDirectory.getCanonicalPath().replace(File.separatorChar, '/');
|
||||
@@ -76,7 +78,7 @@ public class GroovyCompilerWrapper {
|
||||
final String stubPath = outputPath + "/" + topLevel.replace('.', '/') + ".java";
|
||||
String fileName = source.getName();
|
||||
if (new File(stubPath).exists()) {
|
||||
compiledFiles.add(new OutputItemImpl(outputPath, stubPath, fileName));
|
||||
compiledFiles.add(new OutputItem(stubPath, fileName));
|
||||
}
|
||||
/*
|
||||
else {
|
||||
@@ -113,7 +115,7 @@ public class GroovyCompilerWrapper {
|
||||
String className = (String)tailIter.next();
|
||||
if (className.equals(topLevel) || className.startsWith(nested)) {
|
||||
tailIter.remove();
|
||||
compiledFiles.add(new OutputItemImpl(outputPath, outputPath + "/" + className.replace('.', '/') + ".class", fileName));
|
||||
compiledFiles.add(new OutputItem(outputPath + "/" + className.replace('.', '/') + ".class", fileName));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@@ -210,22 +212,11 @@ public class GroovyCompilerWrapper {
|
||||
addMessageWithoutLocation(collector, message.getMessage(), true);
|
||||
}
|
||||
|
||||
public interface OutputItem {
|
||||
String getOutputPath();
|
||||
|
||||
String getSourceFile();
|
||||
|
||||
String getOutputRootDirectory();
|
||||
}
|
||||
|
||||
public static class OutputItemImpl implements OutputItem {
|
||||
|
||||
public static class OutputItem {
|
||||
private final String myOutputPath;
|
||||
private final String myOutputDir;
|
||||
private final String mySourceFileName;
|
||||
|
||||
public OutputItemImpl(String outputDir, String outputPath, String sourceFileName) {
|
||||
myOutputDir = outputDir;
|
||||
public OutputItem(String outputPath, String sourceFileName) {
|
||||
myOutputPath = outputPath;
|
||||
mySourceFileName = sourceFileName;
|
||||
}
|
||||
@@ -234,10 +225,6 @@ public class GroovyCompilerWrapper {
|
||||
return myOutputPath;
|
||||
}
|
||||
|
||||
public String getOutputRootDirectory() {
|
||||
return myOutputDir;
|
||||
}
|
||||
|
||||
public String getSourceFile() {
|
||||
return mySourceFileName;
|
||||
}
|
||||
|
||||
@@ -302,8 +302,6 @@ public class GroovycRunner {
|
||||
System.out.print(compiledOutputItem.getOutputPath());
|
||||
System.out.print(SEPARATOR);
|
||||
System.out.print(compiledOutputItem.getSourceFile());
|
||||
System.out.print(SEPARATOR);
|
||||
System.out.print(compiledOutputItem.getOutputRootDirectory());
|
||||
System.out.print(COMPILED_END);
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.compiler.CompilerConfiguration;
|
||||
import com.intellij.compiler.impl.CompilerUtil;
|
||||
import com.intellij.compiler.impl.FileSetCompileScope;
|
||||
import com.intellij.compiler.impl.javaCompiler.ModuleChunk;
|
||||
import com.intellij.compiler.impl.javaCompiler.OutputItemImpl;
|
||||
import com.intellij.compiler.make.CacheCorruptedException;
|
||||
import com.intellij.compiler.make.DependencyCache;
|
||||
import com.intellij.execution.ExecutionException;
|
||||
@@ -69,6 +70,7 @@ import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.groovy.compiler.rt.CompilerMessage;
|
||||
import org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper;
|
||||
import org.jetbrains.groovy.compiler.rt.GroovycRunner;
|
||||
import org.jetbrains.plugins.groovy.GroovyFileType;
|
||||
import org.jetbrains.plugins.groovy.config.GroovyConfigUtils;
|
||||
@@ -224,14 +226,14 @@ public abstract class GroovyCompilerBase implements TranslatingCompiler {
|
||||
compileContext.addMessage(CompilerMessageCategory.ERROR, "Internal groovyc error: code " + exitCode, null, -1, -1);
|
||||
}
|
||||
|
||||
List<OutputItem> outputItems = processHandler.getSuccessfullyCompiled();
|
||||
List<GroovyCompilerWrapper.OutputItem> outputItems = processHandler.getSuccessfullyCompiled();
|
||||
ArrayList<OutputItem> items = new ArrayList<OutputItem>();
|
||||
if (forStubs) {
|
||||
List<String> outputPaths = new ArrayList<String>();
|
||||
for (final OutputItem outputItem : outputItems) {
|
||||
for (final GroovyCompilerWrapper.OutputItem outputItem : outputItems) {
|
||||
outputPaths.add(outputItem.getOutputPath());
|
||||
}
|
||||
addStubsToCompileScope(outputPaths, compileContext, module);
|
||||
outputItems = Collections.emptyList();
|
||||
}
|
||||
else {
|
||||
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
|
||||
@@ -240,10 +242,18 @@ public abstract class GroovyCompilerBase implements TranslatingCompiler {
|
||||
}
|
||||
|
||||
final DependencyCache dependencyCache = ((CompileContextEx)compileContext).getDependencyCache();
|
||||
for (OutputItem outputItem : outputItems) {
|
||||
if (indicator != null) {
|
||||
indicator.setText2(outputItem.getSourceFile().getName());
|
||||
for (GroovyCompilerWrapper.OutputItem outputItem : outputItems) {
|
||||
final VirtualFile sourceVirtualFile = LocalFileSystem.getInstance().findFileByIoFile(new File(outputItem.getSourceFile()));
|
||||
if (sourceVirtualFile == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (indicator != null) {
|
||||
indicator.setText2(sourceVirtualFile.getName());
|
||||
}
|
||||
|
||||
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(outputItem.getOutputPath()));
|
||||
items.add(new OutputItemImpl(outputItem.getOutputPath(), sourceVirtualFile));
|
||||
|
||||
final String path = outputItem.getOutputPath();
|
||||
final File classFile = new File(path);
|
||||
@@ -264,7 +274,7 @@ public abstract class GroovyCompilerBase implements TranslatingCompiler {
|
||||
}
|
||||
}
|
||||
|
||||
sink.add(outputDir.getPath(), outputItems, VfsUtil.toVirtualFileArray(toRecompile));
|
||||
sink.add(outputDir.getPath(), items, VfsUtil.toVirtualFileArray(toRecompile));
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
LOG.error(e);
|
||||
|
||||
+9
-21
@@ -19,26 +19,27 @@ package org.jetbrains.plugins.groovy.compiler;
|
||||
import com.intellij.execution.process.OSProcessHandler;
|
||||
import com.intellij.execution.process.ProcessOutputTypes;
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.compiler.TranslatingCompiler;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.groovy.compiler.rt.CompilerMessage;
|
||||
import org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper;
|
||||
import org.jetbrains.groovy.compiler.rt.GroovycRunner;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author: Dmitry.Krasilschikov
|
||||
* @date: 16.04.2007
|
||||
*/
|
||||
public class GroovycOSProcessHandler extends OSProcessHandler {
|
||||
private final List<TranslatingCompiler.OutputItem> myCompiledItems = new ArrayList<TranslatingCompiler.OutputItem>();
|
||||
private final List<GroovyCompilerWrapper.OutputItem> myCompiledItems = new ArrayList<GroovyCompilerWrapper.OutputItem>();
|
||||
private final Set<File> toRecompileFiles = new HashSet<File>();
|
||||
private final List<CompilerMessage> compilerMessages = new ArrayList<CompilerMessage>();
|
||||
private final StringBuffer stdErr = new StringBuffer();
|
||||
@@ -102,7 +103,6 @@ public class GroovycOSProcessHandler extends OSProcessHandler {
|
||||
String outputPath = list.get(0);
|
||||
String sourceFile = list.get(1);
|
||||
|
||||
LocalFileSystem.getInstance().refreshAndFindFileByPath(outputPath);
|
||||
ContainerUtil.addIfNotNull(getOutputItem(outputPath, sourceFile), myCompiledItems);
|
||||
|
||||
}
|
||||
@@ -169,23 +169,11 @@ public class GroovycOSProcessHandler extends OSProcessHandler {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static TranslatingCompiler.OutputItem getOutputItem(final String outputPath, final String sourceFile) {
|
||||
|
||||
final VirtualFile sourceVirtualFile = LocalFileSystem.getInstance().findFileByIoFile(new File(sourceFile));
|
||||
if (sourceVirtualFile == null) return null; //the source might already have been deleted
|
||||
|
||||
return new TranslatingCompiler.OutputItem() {
|
||||
public String getOutputPath() {
|
||||
return outputPath;
|
||||
}
|
||||
|
||||
public VirtualFile getSourceFile() {
|
||||
return sourceVirtualFile;
|
||||
}
|
||||
};
|
||||
private static GroovyCompilerWrapper.OutputItem getOutputItem(final String outputPath, final String sourceFile) {
|
||||
return new GroovyCompilerWrapper.OutputItem(outputPath, sourceFile);
|
||||
}
|
||||
|
||||
public List<TranslatingCompiler.OutputItem> getSuccessfullyCompiled() {
|
||||
public List<GroovyCompilerWrapper.OutputItem> getSuccessfullyCompiled() {
|
||||
return myCompiledItems;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user