mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -24,7 +24,7 @@ package com.intellij.compiler.impl;
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.analysis.AnalysisScope;
|
||||
import com.intellij.compiler.*;
|
||||
import com.intellij.compiler.impl.newApi.NewCompiler;
|
||||
import com.intellij.openapi.compiler.generic.GenericCompiler;
|
||||
import com.intellij.compiler.make.CacheCorruptedException;
|
||||
import com.intellij.compiler.make.CacheUtils;
|
||||
import com.intellij.compiler.make.DependencyCache;
|
||||
@@ -725,7 +725,7 @@ public class CompileDriver {
|
||||
boolean didSomething = false;
|
||||
|
||||
final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
|
||||
NewCompilerRunner runner = new NewCompilerRunner(context, compilerManager, forceCompile, onlyCheckStatus);
|
||||
GenericCompilerRunner runner = new GenericCompilerRunner(context, compilerManager, forceCompile, onlyCheckStatus);
|
||||
try {
|
||||
didSomething |= generateSources(compilerManager, context, forceCompile, onlyCheckStatus);
|
||||
|
||||
@@ -747,23 +747,23 @@ public class CompileDriver {
|
||||
|
||||
didSomething |= invokeFileProcessingCompilers(compilerManager, context, ClassInstrumentingCompiler.class,
|
||||
FILE_PROCESSING_COMPILER_ADAPTER_FACTORY, isRebuild, false, onlyCheckStatus);
|
||||
didSomething |= runner.invokeCompilers(NewCompiler.CompileOrderPlace.CLASS_INSTRUMENTING);
|
||||
didSomething |= runner.invokeCompilers(GenericCompiler.CompileOrderPlace.CLASS_INSTRUMENTING);
|
||||
|
||||
// explicitly passing forceCompile = false because in scopes that is narrower than ProjectScope it is impossible
|
||||
// to understand whether the class to be processed is in scope or not. Otherwise compiler may process its items even if
|
||||
// there were changes in completely independent files.
|
||||
didSomething |= invokeFileProcessingCompilers(compilerManager, context, ClassPostProcessingCompiler.class,
|
||||
FILE_PROCESSING_COMPILER_ADAPTER_FACTORY, isRebuild, false, onlyCheckStatus);
|
||||
didSomething |= runner.invokeCompilers(NewCompiler.CompileOrderPlace.CLASS_POST_PROCESSING);
|
||||
didSomething |= runner.invokeCompilers(GenericCompiler.CompileOrderPlace.CLASS_POST_PROCESSING);
|
||||
|
||||
didSomething |= invokeFileProcessingCompilers(compilerManager, context, PackagingCompiler.class,
|
||||
FILE_PACKAGING_COMPILER_ADAPTER_FACTORY,
|
||||
isRebuild, false, onlyCheckStatus);
|
||||
didSomething |= runner.invokeCompilers(NewCompiler.CompileOrderPlace.PACKAGING);
|
||||
didSomething |= runner.invokeCompilers(GenericCompiler.CompileOrderPlace.PACKAGING);
|
||||
|
||||
didSomething |= invokeFileProcessingCompilers(compilerManager, context, Validator.class, FILE_PROCESSING_COMPILER_ADAPTER_FACTORY,
|
||||
forceCompile, true, onlyCheckStatus);
|
||||
didSomething |= runner.invokeCompilers(NewCompiler.CompileOrderPlace.VALIDATING);
|
||||
didSomething |= runner.invokeCompilers(GenericCompiler.CompileOrderPlace.VALIDATING);
|
||||
}
|
||||
catch (ExitException e) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package com.intellij.compiler.impl;
|
||||
|
||||
import com.intellij.compiler.impl.newApi.NewCompiler;
|
||||
import com.intellij.compiler.impl.newApi.NewCompilerCache;
|
||||
import com.intellij.compiler.impl.generic.GenericCompilerCache;
|
||||
import com.intellij.openapi.compiler.generic.GenericCompiler;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.compiler.*;
|
||||
import com.intellij.openapi.compiler.Compiler;
|
||||
@@ -44,7 +44,7 @@ import java.util.Map;
|
||||
public class CompilerCacheManager implements ProjectComponent {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.impl.CompilerCacheManager");
|
||||
private final Map<Compiler, Object> myCompilerToCacheMap = new HashMap<Compiler, Object>();
|
||||
private final Map<NewCompiler<?,?,?>, NewCompilerCache<?,?,?>> myNewCachesMap = new HashMap<NewCompiler<?,?,?>, NewCompilerCache<?,?,?>>();
|
||||
private final Map<GenericCompiler<?,?,?>, GenericCompilerCache<?,?,?>> myGenericCachesMap = new HashMap<GenericCompiler<?,?,?>, GenericCompilerCache<?,?,?>>();
|
||||
private final List<Disposable> myCacheDisposables = new ArrayList<Disposable>();
|
||||
private final File myCachesRoot;
|
||||
private final Runnable myShutdownTask = new Runnable() {
|
||||
@@ -90,22 +90,23 @@ public class CompilerCacheManager implements ProjectComponent {
|
||||
return dir;
|
||||
}
|
||||
|
||||
public synchronized <Key, SourceState, OutputState> NewCompilerCache<Key, SourceState, OutputState>
|
||||
getNewCompilerCache(NewCompiler<Key, SourceState, OutputState> compiler) throws IOException {
|
||||
NewCompilerCache<?,?,?> cache = myNewCachesMap.get(compiler);
|
||||
public synchronized <Key, SourceState, OutputState> GenericCompilerCache<Key, SourceState, OutputState>
|
||||
getGenericCompilerCache(GenericCompiler<Key, SourceState, OutputState> compiler) throws IOException {
|
||||
GenericCompilerCache<?,?,?> cache = myGenericCachesMap.get(compiler);
|
||||
if (cache == null) {
|
||||
final NewCompilerCache<?,?,?> newCache = new NewCompilerCache<Key, SourceState, OutputState>(compiler, NewCompilerRunner.getNewCompilerCacheDir(myProject, compiler));
|
||||
myNewCachesMap.put(compiler, newCache);
|
||||
final GenericCompilerCache<?,?,?> genericCache = new GenericCompilerCache<Key, SourceState, OutputState>(compiler, GenericCompilerRunner
|
||||
.getGenericCompilerCacheDir(myProject, compiler));
|
||||
myGenericCachesMap.put(compiler, genericCache);
|
||||
myCacheDisposables.add(new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
newCache.close();
|
||||
genericCache.close();
|
||||
}
|
||||
});
|
||||
cache = newCache;
|
||||
cache = genericCache;
|
||||
}
|
||||
//noinspection unchecked
|
||||
return (NewCompilerCache<Key, SourceState, OutputState>)cache;
|
||||
return (GenericCompilerCache<Key, SourceState, OutputState>)cache;
|
||||
}
|
||||
|
||||
public synchronized FileProcessingCompilerStateCache getFileProcessingCompilerCache(FileProcessingCompiler compiler) throws IOException {
|
||||
@@ -172,7 +173,7 @@ public class CompilerCacheManager implements ProjectComponent {
|
||||
}
|
||||
}
|
||||
myCacheDisposables.clear();
|
||||
myNewCachesMap.clear();
|
||||
myGenericCachesMap.clear();
|
||||
myCompilerToCacheMap.clear();
|
||||
}
|
||||
|
||||
|
||||
+29
-26
@@ -16,7 +16,9 @@
|
||||
package com.intellij.compiler.impl;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.intellij.compiler.impl.newApi.*;
|
||||
import com.intellij.compiler.impl.generic.GenericCompilerCache;
|
||||
import com.intellij.compiler.impl.generic.GenericCompilerPersistentData;
|
||||
import com.intellij.openapi.compiler.generic.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.application.Result;
|
||||
@@ -41,26 +43,26 @@ import java.util.*;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class NewCompilerRunner {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.impl.NewCompilerRunner");
|
||||
public class GenericCompilerRunner {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.impl.GenericCompilerRunner");
|
||||
private CompileContext myContext;
|
||||
private final boolean myForceCompile;
|
||||
private final boolean myOnlyCheckStatus;
|
||||
private final NewCompiler<?,?,?>[] myCompilers;
|
||||
private final GenericCompiler<?,?,?>[] myCompilers;
|
||||
private final Project myProject;
|
||||
|
||||
public NewCompilerRunner(CompileContext context, CompilerManager compilerManager, boolean forceCompile, boolean onlyCheckStatus) {
|
||||
public GenericCompilerRunner(CompileContext context, CompilerManager compilerManager, boolean forceCompile, boolean onlyCheckStatus) {
|
||||
myContext = context;
|
||||
myForceCompile = forceCompile;
|
||||
myOnlyCheckStatus = onlyCheckStatus;
|
||||
myCompilers = compilerManager.getCompilers(NewCompiler.class);
|
||||
myCompilers = compilerManager.getCompilers(GenericCompiler.class);
|
||||
myProject = myContext.getProject();
|
||||
}
|
||||
|
||||
public boolean invokeCompilers(NewCompiler.CompileOrderPlace place) throws CompileDriver.ExitException {
|
||||
public boolean invokeCompilers(GenericCompiler.CompileOrderPlace place) throws CompileDriver.ExitException {
|
||||
boolean didSomething = false;
|
||||
try {
|
||||
for (NewCompiler<?,?,?> compiler : myCompilers) {
|
||||
for (GenericCompiler<?,?,?> compiler : myCompilers) {
|
||||
if (compiler.getOrderPlace().equals(place)) {
|
||||
didSomething = invokeCompiler(compiler);
|
||||
}
|
||||
@@ -84,14 +86,15 @@ public class NewCompilerRunner {
|
||||
return didSomething;
|
||||
}
|
||||
|
||||
private <Key, SourceState, OutputState> boolean invokeCompiler(NewCompiler<Key, SourceState, OutputState> compiler) throws IOException, CompileDriver.ExitException {
|
||||
private <Key, SourceState, OutputState> boolean invokeCompiler(GenericCompiler<Key, SourceState, OutputState> compiler) throws IOException, CompileDriver.ExitException {
|
||||
return invokeCompiler(compiler, compiler.createInstance(myContext));
|
||||
}
|
||||
|
||||
private <T extends BuildTarget, Item extends CompileItem<Key, SourceState, OutputState>, Key, SourceState, OutputState>
|
||||
boolean invokeCompiler(NewCompiler<Key, SourceState, OutputState> compiler, CompilerInstance<T, Item, Key, SourceState, OutputState> instance) throws IOException, CompileDriver.ExitException {
|
||||
NewCompilerCache<Key, SourceState, OutputState> cache = CompilerCacheManager.getInstance(myProject).getNewCompilerCache(compiler);
|
||||
NewCompilerPersistentData data = new NewCompilerPersistentData(getNewCompilerCacheDir(myProject, compiler), compiler.getVersion());
|
||||
boolean invokeCompiler(GenericCompiler<Key, SourceState, OutputState> compiler, GenericCompilerInstance<T, Item, Key, SourceState, OutputState> instance) throws IOException, CompileDriver.ExitException {
|
||||
GenericCompilerCache<Key, SourceState, OutputState> cache = CompilerCacheManager.getInstance(myProject).getGenericCompilerCache(compiler);
|
||||
GenericCompilerPersistentData
|
||||
data = new GenericCompilerPersistentData(getGenericCompilerCacheDir(myProject, compiler), compiler.getVersion());
|
||||
if (data.isVersionChanged()) {
|
||||
LOG.info("Clearing cache for " + compiler.getDescription());
|
||||
cache.wipe();
|
||||
@@ -109,10 +112,10 @@ public class NewCompilerRunner {
|
||||
}
|
||||
List<Key> keys = new ArrayList<Key>();
|
||||
cache.processSources(id, new CommonProcessors.CollectProcessor<Key>(keys));
|
||||
List<NewCompilerItemState<Key, SourceState, OutputState>> obsoleteSources = new ArrayList<NewCompilerItemState<Key,SourceState,OutputState>>();
|
||||
List<GenericCompilerItemState<Key, SourceState, OutputState>> obsoleteSources = new ArrayList<GenericCompilerItemState<Key,SourceState,OutputState>>();
|
||||
for (Key key : keys) {
|
||||
final NewCompilerCache.PersistentStateData<SourceState, OutputState> state = cache.getState(id, key);
|
||||
obsoleteSources.add(new NewCompilerItemState<Key,SourceState,OutputState>(key, state.mySourceState, state.myOutputState));
|
||||
final GenericCompilerCache.PersistentStateData<SourceState, OutputState> state = cache.getState(id, key);
|
||||
obsoleteSources.add(new GenericCompilerItemState<Key,SourceState,OutputState>(key, state.mySourceState, state.myOutputState));
|
||||
}
|
||||
instance.processObsoleteTarget(target, obsoleteSources);
|
||||
if (myContext.getMessageCount(CompilerMessageCategory.ERROR) > 0) {
|
||||
@@ -134,20 +137,20 @@ public class NewCompilerRunner {
|
||||
return didSomething;
|
||||
}
|
||||
|
||||
public static File getNewCompilerCacheDir(Project project, NewCompiler<?,?,?> compiler) {
|
||||
public static File getGenericCompilerCacheDir(Project project, GenericCompiler<?,?,?> compiler) {
|
||||
return new File(CompilerPaths.getCacheStoreDirectory(project), compiler.getId());
|
||||
}
|
||||
|
||||
private <T extends BuildTarget, Item extends CompileItem<Key, SourceState, OutputState>, Key, SourceState, OutputState>
|
||||
boolean processTarget(T target, final int targetId, final NewCompiler<Key, SourceState, OutputState> compiler, final CompilerInstance<T, Item, Key, SourceState, OutputState> instance,
|
||||
final NewCompilerCache<Key, SourceState, OutputState> cache) throws IOException, CompileDriver.ExitException {
|
||||
boolean processTarget(T target, final int targetId, final GenericCompiler<Key, SourceState, OutputState> compiler, final GenericCompilerInstance<T, Item, Key, SourceState, OutputState> instance,
|
||||
final GenericCompilerCache<Key, SourceState, OutputState> cache) throws IOException, CompileDriver.ExitException {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Processing target '" + target + "' (id=" + targetId + ")");
|
||||
}
|
||||
final List<Item> items = instance.getItems(target);
|
||||
if (myContext.getMessageCount(CompilerMessageCategory.ERROR) > 0) return true;
|
||||
|
||||
final List<NewCompilerItemState<Item, SourceState, OutputState>> toProcess = new ArrayList<NewCompilerItemState<Item,SourceState,OutputState>>();
|
||||
final List<GenericCompilerItemState<Item, SourceState, OutputState>> toProcess = new ArrayList<GenericCompilerItemState<Item,SourceState,OutputState>>();
|
||||
final THashSet<Key> keySet = new THashSet<Key>(new SourceItemHashingStrategy<Key>(compiler));
|
||||
final Ref<IOException> exception = Ref.create(null);
|
||||
DumbService.getInstance(myProject).waitForSmartMode();
|
||||
@@ -159,13 +162,13 @@ public class NewCompilerRunner {
|
||||
for (Item item : items) {
|
||||
final Key key = item.getKey();
|
||||
keySet.add(key);
|
||||
final NewCompilerCache.PersistentStateData<SourceState, OutputState> data = cache.getState(targetId, key);
|
||||
final GenericCompilerCache.PersistentStateData<SourceState, OutputState> data = cache.getState(targetId, key);
|
||||
SourceState sourceState = data != null ? data.mySourceState : null;
|
||||
final OutputState outputState = data != null ? data.myOutputState : null;
|
||||
if (myForceCompile || sourceState == null || !item.isSourceUpToDate(sourceState)
|
||||
|| outputState == null || !item.isOutputUpToDate(outputState)) {
|
||||
sourceStates.put(item, item.computeSourceState());
|
||||
toProcess.add(new NewCompilerItemState<Item, SourceState, OutputState>(item, sourceState, outputState));
|
||||
toProcess.add(new GenericCompilerItemState<Item, SourceState, OutputState>(item, sourceState, outputState));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -201,15 +204,15 @@ public class NewCompilerRunner {
|
||||
throw new CompileDriver.ExitException(CompileDriver.ExitStatus.CANCELLED);
|
||||
}
|
||||
|
||||
List<NewCompilerItemState<Key, SourceState, OutputState>> obsoleteItems = new ArrayList<NewCompilerItemState<Key,SourceState,OutputState>>();
|
||||
List<GenericCompilerItemState<Key, SourceState, OutputState>> obsoleteItems = new ArrayList<GenericCompilerItemState<Key,SourceState,OutputState>>();
|
||||
for (Key key : toRemove) {
|
||||
final NewCompilerCache.PersistentStateData<SourceState, OutputState> data = cache.getState(targetId, key);
|
||||
obsoleteItems.add(new NewCompilerItemState<Key,SourceState,OutputState>(key, data.mySourceState, data.myOutputState));
|
||||
final GenericCompilerCache.PersistentStateData<SourceState, OutputState> data = cache.getState(targetId, key);
|
||||
obsoleteItems.add(new GenericCompilerItemState<Key,SourceState,OutputState>(key, data.mySourceState, data.myOutputState));
|
||||
}
|
||||
|
||||
final List<Item> processedItems = new ArrayList<Item>();
|
||||
final List<File> toRefresh = new ArrayList<File>();
|
||||
instance.processItems(target, toProcess, obsoleteItems, new CompilerInstance.OutputConsumer<Item>() {
|
||||
instance.processItems(target, toProcess, obsoleteItems, new GenericCompilerInstance.OutputConsumer<Item>() {
|
||||
@Override
|
||||
public void addFileToRefresh(@NotNull File file) {
|
||||
toRefresh.add(file);
|
||||
@@ -248,7 +251,7 @@ public class NewCompilerRunner {
|
||||
private class SourceItemHashingStrategy<S> implements TObjectHashingStrategy<S> {
|
||||
private KeyDescriptor<S> myKeyDescriptor;
|
||||
|
||||
public SourceItemHashingStrategy(NewCompiler<S, ?, ?> compiler) {
|
||||
public SourceItemHashingStrategy(GenericCompiler<S, ?, ?> compiler) {
|
||||
myKeyDescriptor = compiler.getItemKeyDescriptor();
|
||||
}
|
||||
|
||||
+7
-6
@@ -13,8 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.compiler.impl.newApi;
|
||||
package com.intellij.compiler.impl.generic;
|
||||
|
||||
import com.intellij.openapi.compiler.generic.GenericCompiler;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.io.DataExternalizer;
|
||||
@@ -29,13 +30,13 @@ import java.io.IOException;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class NewCompilerCache<Key, SourceState, OutputState> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.impl.newApi.NewCompilerCache");
|
||||
public class GenericCompilerCache<Key, SourceState, OutputState> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.impl.generic.GenericCompilerCache");
|
||||
private PersistentHashMap<KeyAndTargetData<Key>, PersistentStateData<SourceState, OutputState>> myPersistentMap;
|
||||
private File myCacheFile;
|
||||
private final NewCompiler<Key, SourceState, OutputState> myCompiler;
|
||||
private final GenericCompiler<Key, SourceState, OutputState> myCompiler;
|
||||
|
||||
public NewCompilerCache(NewCompiler<Key, SourceState, OutputState> compiler, final File compilerCacheDir) throws IOException {
|
||||
public GenericCompilerCache(GenericCompiler<Key, SourceState, OutputState> compiler, final File compilerCacheDir) throws IOException {
|
||||
myCompiler = compiler;
|
||||
myCacheFile = new File(compilerCacheDir, "timestamps");
|
||||
createMap();
|
||||
@@ -147,7 +148,7 @@ public class NewCompilerCache<Key, SourceState, OutputState> {
|
||||
private DataExternalizer<SourceState> mySourceStateExternalizer;
|
||||
private DataExternalizer<OutputState> myOutputStateExternalizer;
|
||||
|
||||
public PersistentStateDataExternalizer(NewCompiler<Key,SourceState,OutputState> compiler) {
|
||||
public PersistentStateDataExternalizer(GenericCompiler<Key,SourceState,OutputState> compiler) {
|
||||
mySourceStateExternalizer = compiler.getSourceStateExternalizer();
|
||||
myOutputStateExternalizer = compiler.getOutputStateExternalizer();
|
||||
}
|
||||
+4
-4
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.compiler.impl.newApi;
|
||||
package com.intellij.compiler.impl.generic;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.io.IOUtil;
|
||||
@@ -28,8 +28,8 @@ import java.util.Set;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class NewCompilerPersistentData {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.impl.newApi.NewCompilerPersistentData");
|
||||
public class GenericCompilerPersistentData {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.impl.generic.GenericCompilerPersistentData");
|
||||
private static final int VERSION = 1;
|
||||
private File myFile;
|
||||
private Map<String, Integer> myTarget2Id = new HashMap<String, Integer>();
|
||||
@@ -37,7 +37,7 @@ public class NewCompilerPersistentData {
|
||||
private boolean myVersionChanged;
|
||||
private final int myCompilerVersion;
|
||||
|
||||
public NewCompilerPersistentData(File cacheStoreDirectory, int compilerVersion) throws IOException {
|
||||
public GenericCompilerPersistentData(File cacheStoreDirectory, int compilerVersion) throws IOException {
|
||||
myCompilerVersion = compilerVersion;
|
||||
myFile = new File(cacheStoreDirectory, "info");
|
||||
if (!myFile.exists()) {
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.
|
||||
*/
|
||||
package com.intellij.compiler.impl.newApi;
|
||||
|
||||
import com.intellij.util.io.DataExternalizer;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class VirtualFileStateExternalizer implements DataExternalizer<VirtualFilePersistentState> {
|
||||
public static VirtualFileStateExternalizer INSTANCE = new VirtualFileStateExternalizer();
|
||||
|
||||
@Override
|
||||
public void save(DataOutput out, VirtualFilePersistentState value) throws IOException {
|
||||
out.writeLong(value.getSourceTimestamp());
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFilePersistentState read(DataInput in) throws IOException {
|
||||
return new VirtualFilePersistentState(in.readLong());
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.compiler.impl.newApi;
|
||||
package com.intellij.openapi.compiler.generic;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.compiler.impl.newApi;
|
||||
package com.intellij.openapi.compiler.generic;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.compiler.impl.newApi;
|
||||
package com.intellij.openapi.compiler.generic;
|
||||
|
||||
import com.intellij.util.io.DataExternalizer;
|
||||
|
||||
+4
-4
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.compiler.impl.newApi;
|
||||
package com.intellij.openapi.compiler.generic;
|
||||
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.compiler.Compiler;
|
||||
@@ -24,12 +24,12 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class NewCompiler<Key, SourceState, OutputState> implements Compiler {
|
||||
public abstract class GenericCompiler<Key, SourceState, OutputState> implements Compiler {
|
||||
private final String myId;
|
||||
private final int myVersion;
|
||||
private final CompileOrderPlace myOrderPlace;
|
||||
|
||||
protected NewCompiler(@NotNull String id, int version, @NotNull CompileOrderPlace orderPlace) {
|
||||
protected GenericCompiler(@NotNull String id, int version, @NotNull CompileOrderPlace orderPlace) {
|
||||
myId = id;
|
||||
myVersion = version;
|
||||
myOrderPlace = orderPlace;
|
||||
@@ -43,7 +43,7 @@ public abstract class NewCompiler<Key, SourceState, OutputState> implements Comp
|
||||
public abstract DataExternalizer<OutputState> getOutputStateExternalizer();
|
||||
|
||||
@NotNull
|
||||
public abstract CompilerInstance<?, ? extends CompileItem<Key, SourceState, OutputState>, Key, SourceState, OutputState> createInstance(@NotNull CompileContext context);
|
||||
public abstract GenericCompilerInstance<?, ? extends CompileItem<Key, SourceState, OutputState>, Key, SourceState, OutputState> createInstance(@NotNull CompileContext context);
|
||||
|
||||
public final String getId() {
|
||||
return myId;
|
||||
+5
-5
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.compiler.impl.newApi;
|
||||
package com.intellij.openapi.compiler.generic;
|
||||
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -25,10 +25,10 @@ import java.util.List;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class CompilerInstance<T extends BuildTarget, Item extends CompileItem<Key, SourceState, OutputState>, Key, SourceState, OutputState> {
|
||||
public abstract class GenericCompilerInstance<T extends BuildTarget, Item extends CompileItem<Key, SourceState, OutputState>, Key, SourceState, OutputState> {
|
||||
protected final CompileContext myContext;
|
||||
|
||||
protected CompilerInstance(CompileContext context) {
|
||||
protected GenericCompilerInstance(CompileContext context) {
|
||||
myContext = context;
|
||||
}
|
||||
|
||||
@@ -42,13 +42,13 @@ public abstract class CompilerInstance<T extends BuildTarget, Item extends Compi
|
||||
@NotNull
|
||||
public abstract List<T> getSelectedTargets();
|
||||
|
||||
public abstract void processObsoleteTarget(@NotNull String targetId, @NotNull List<NewCompilerItemState<Key, SourceState, OutputState>> obsoleteItems);
|
||||
public abstract void processObsoleteTarget(@NotNull String targetId, @NotNull List<GenericCompilerItemState<Key, SourceState, OutputState>> obsoleteItems);
|
||||
|
||||
|
||||
@NotNull
|
||||
public abstract List<Item> getItems(@NotNull T target);
|
||||
|
||||
public abstract void processItems(@NotNull T target, @NotNull List<NewCompilerItemState<Item, SourceState, OutputState>> changedItems, @NotNull List<NewCompilerItemState<Key, SourceState, OutputState>> obsoleteItems,
|
||||
public abstract void processItems(@NotNull T target, @NotNull List<GenericCompilerItemState<Item, SourceState, OutputState>> changedItems, @NotNull List<GenericCompilerItemState<Key, SourceState, OutputState>> obsoleteItems,
|
||||
@NotNull OutputConsumer<Item> consumer);
|
||||
|
||||
public interface OutputConsumer<Item extends CompileItem<?,?,?>> {
|
||||
+3
-3
@@ -13,17 +13,17 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.compiler.impl.newApi;
|
||||
package com.intellij.openapi.compiler.generic;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class NewCompilerItemState<Item, SourceState, OutputState> {
|
||||
public class GenericCompilerItemState<Item, SourceState, OutputState> {
|
||||
private final Item myItem;
|
||||
private final SourceState mySourceState;
|
||||
private final OutputState myOutputState;
|
||||
|
||||
public NewCompilerItemState(Item item, SourceState sourceState, OutputState outputState) {
|
||||
public GenericCompilerItemState(Item item, SourceState sourceState, OutputState outputState) {
|
||||
myItem = item;
|
||||
mySourceState = sourceState;
|
||||
myOutputState = outputState;
|
||||
+4
-3
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.compiler.impl.newApi;
|
||||
package com.intellij.openapi.compiler.generic;
|
||||
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -24,7 +24,8 @@ import java.util.List;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class SingleTargetCompilerInstance<Item extends CompileItem<K,S,O>, K,S, O> extends CompilerInstance<BuildTarget, Item, K, S, O> {
|
||||
public abstract class SingleTargetCompilerInstance<Item extends CompileItem<K,S,O>, K,S, O> extends
|
||||
GenericCompilerInstance<BuildTarget, Item, K, S, O> {
|
||||
protected SingleTargetCompilerInstance(CompileContext context) {
|
||||
super(context);
|
||||
}
|
||||
@@ -42,6 +43,6 @@ public abstract class SingleTargetCompilerInstance<Item extends CompileItem<K,S,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processObsoleteTarget(@NotNull String targetId, @NotNull List<NewCompilerItemState<K, S, O>> obsoleteItems) {
|
||||
public void processObsoleteTarget(@NotNull String targetId, @NotNull List<GenericCompilerItemState<K, S, O>> obsoleteItems) {
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.compiler.impl.newApi;
|
||||
package com.intellij.openapi.compiler.generic;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.io.EnumeratorStringDescriptor;
|
||||
+21
-1
@@ -13,12 +13,19 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.compiler.impl.newApi;
|
||||
package com.intellij.openapi.compiler.generic;
|
||||
|
||||
import com.intellij.util.io.DataExternalizer;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class VirtualFilePersistentState {
|
||||
public static DataExternalizer<VirtualFilePersistentState> EXTERNALIZER = new VirtualFileStateExternalizer();
|
||||
private final long mySourceTimestamp;
|
||||
|
||||
public VirtualFilePersistentState(long sourceTimestamp) {
|
||||
@@ -28,4 +35,17 @@ public class VirtualFilePersistentState {
|
||||
public final long getSourceTimestamp() {
|
||||
return mySourceTimestamp;
|
||||
}
|
||||
|
||||
private static class VirtualFileStateExternalizer implements DataExternalizer<VirtualFilePersistentState> {
|
||||
@Override
|
||||
public void save(DataOutput out, VirtualFilePersistentState value) throws IOException {
|
||||
out.writeLong(value.getSourceTimestamp());
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFilePersistentState read(DataInput in) throws IOException {
|
||||
return new VirtualFilePersistentState(in.readLong());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.compiler.impl.newApi;
|
||||
package com.intellij.openapi.compiler.generic;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.packaging.impl.compiler;
|
||||
|
||||
import com.intellij.compiler.impl.newApi.BuildTarget;
|
||||
import com.intellij.openapi.compiler.generic.BuildTarget;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.packaging.impl.compiler;
|
||||
|
||||
import com.intellij.compiler.impl.newApi.VirtualFileCompileItem;
|
||||
import com.intellij.openapi.compiler.generic.VirtualFileCompileItem;
|
||||
import com.intellij.compiler.impl.packagingCompiler.DestinationInfo;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.packaging.impl.compiler;
|
||||
|
||||
import com.intellij.compiler.impl.newApi.*;
|
||||
import com.intellij.openapi.compiler.generic.*;
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.compiler.CompileScope;
|
||||
import com.intellij.openapi.compiler.CompilerManager;
|
||||
@@ -32,12 +32,12 @@ import java.util.Set;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ArtifactsCompiler extends NewCompiler<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState> {
|
||||
public class ArtifactsCompiler extends GenericCompiler<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState> {
|
||||
static final Key<Set<String>> WRITTEN_PATHS_KEY = Key.create("artifacts_written_paths");
|
||||
static final Key<Set<Artifact>> AFFECTED_ARTIFACTS = Key.create("affected_artifacts");
|
||||
|
||||
public ArtifactsCompiler() {
|
||||
super("artifacts_compiler", 0, NewCompiler.CompileOrderPlace.PACKAGING);
|
||||
super("artifacts_compiler", 0, GenericCompiler.CompileOrderPlace.PACKAGING);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -55,7 +55,7 @@ public class ArtifactsCompiler extends NewCompiler<String, VirtualFilePersistent
|
||||
@NotNull
|
||||
@Override
|
||||
public DataExternalizer<VirtualFilePersistentState> getSourceStateExternalizer() {
|
||||
return VirtualFileStateExternalizer.INSTANCE;
|
||||
return VirtualFilePersistentState.EXTERNALIZER;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -66,7 +66,7 @@ public class ArtifactsCompiler extends NewCompiler<String, VirtualFilePersistent
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CompilerInstance<ArtifactBuildTarget, ? extends CompileItem<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState>, String, VirtualFilePersistentState, ArtifactPackagingItemOutputState> createInstance(
|
||||
public GenericCompilerInstance<ArtifactBuildTarget, ? extends CompileItem<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState>, String, VirtualFilePersistentState, ArtifactPackagingItemOutputState> createInstance(
|
||||
@NotNull CompileContext context) {
|
||||
return new ArtifactsCompilerInstance(context);
|
||||
}
|
||||
|
||||
+15
-15
@@ -17,9 +17,9 @@ package com.intellij.packaging.impl.compiler;
|
||||
|
||||
import com.intellij.compiler.CompilerManagerImpl;
|
||||
import com.intellij.compiler.impl.CompilerUtil;
|
||||
import com.intellij.compiler.impl.newApi.CompilerInstance;
|
||||
import com.intellij.compiler.impl.newApi.NewCompilerItemState;
|
||||
import com.intellij.compiler.impl.newApi.VirtualFilePersistentState;
|
||||
import com.intellij.openapi.compiler.generic.GenericCompilerInstance;
|
||||
import com.intellij.openapi.compiler.generic.GenericCompilerItemState;
|
||||
import com.intellij.openapi.compiler.generic.VirtualFilePersistentState;
|
||||
import com.intellij.compiler.impl.packagingCompiler.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
@@ -61,7 +61,7 @@ import java.util.*;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ArtifactsCompilerInstance extends CompilerInstance<ArtifactBuildTarget, ArtifactCompilerCompileItem,
|
||||
public class ArtifactsCompilerInstance extends GenericCompilerInstance<ArtifactBuildTarget, ArtifactCompilerCompileItem,
|
||||
String, VirtualFilePersistentState, ArtifactPackagingItemOutputState> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.packaging.impl.compiler.ArtifactsCompilerInstance");
|
||||
private ArtifactsProcessingItemsBuilderContext myBuilderContext;
|
||||
@@ -120,8 +120,8 @@ public class ArtifactsCompilerInstance extends CompilerInstance<ArtifactBuildTar
|
||||
|
||||
@Override
|
||||
public void processObsoleteTarget(@NotNull String targetId,
|
||||
@NotNull List<NewCompilerItemState<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> obsoleteItems) {
|
||||
deleteFiles(obsoleteItems, Collections.<NewCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState>>emptyList());
|
||||
@NotNull List<GenericCompilerItemState<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> obsoleteItems) {
|
||||
deleteFiles(obsoleteItems, Collections.<GenericCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState>>emptyList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -163,7 +163,7 @@ public class ArtifactsCompilerInstance extends CompilerInstance<ArtifactBuildTar
|
||||
rootElement.computeIncrementalCompilerInstructions(instructionCreator, resolvingContext, myBuilderContext, artifact.getArtifactType());
|
||||
}
|
||||
|
||||
private boolean doBuild(final List<NewCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> changedItems,
|
||||
private boolean doBuild(final List<GenericCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> changedItems,
|
||||
final Set<ArtifactCompilerCompileItem> processedItems,
|
||||
final @NotNull Set<String> writtenPaths, final Set<String> deletedJars) {
|
||||
final boolean testMode = ApplicationManager.getApplication().isUnitTestMode();
|
||||
@@ -182,7 +182,7 @@ public class ArtifactsCompilerInstance extends CompilerInstance<ArtifactBuildTar
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (final NewCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState> item : changedItems) {
|
||||
for (final GenericCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState> item : changedItems) {
|
||||
final ArtifactCompilerCompileItem sourceItem = item.getItem();
|
||||
myContext.getProgressIndicator().checkCanceled();
|
||||
|
||||
@@ -308,8 +308,8 @@ public class ArtifactsCompilerInstance extends CompilerInstance<ArtifactBuildTar
|
||||
|
||||
@Override
|
||||
public void processItems(@NotNull ArtifactBuildTarget target,
|
||||
@NotNull final List<NewCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> changedItems,
|
||||
@NotNull List<NewCompilerItemState<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> obsoleteItems,
|
||||
@NotNull final List<GenericCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> changedItems,
|
||||
@NotNull List<GenericCompilerItemState<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> obsoleteItems,
|
||||
@NotNull OutputConsumer<ArtifactCompilerCompileItem> consumer) {
|
||||
|
||||
final THashSet<String> deletedJars = deleteFiles(obsoleteItems, changedItems);
|
||||
@@ -337,8 +337,8 @@ public class ArtifactsCompilerInstance extends CompilerInstance<ArtifactBuildTar
|
||||
myContext.putUserData(ArtifactsCompiler.WRITTEN_PATHS_KEY, writtenPaths);
|
||||
}
|
||||
|
||||
private THashSet<String> deleteFiles(List<NewCompilerItemState<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> obsoleteItems,
|
||||
List<NewCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> changedItems) {
|
||||
private THashSet<String> deleteFiles(List<GenericCompilerItemState<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> obsoleteItems,
|
||||
List<GenericCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> changedItems) {
|
||||
myContext.getProgressIndicator().setText(CompilerBundle.message("packaging.compiler.message.deleting.outdated.files"));
|
||||
|
||||
final boolean testMode = ApplicationManager.getApplication().isUnitTestMode();
|
||||
@@ -349,7 +349,7 @@ public class ArtifactsCompilerInstance extends CompilerInstance<ArtifactBuildTar
|
||||
}
|
||||
|
||||
Set<String> pathToDelete = new THashSet<String>();
|
||||
for (NewCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState> item : changedItems) {
|
||||
for (GenericCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState> item : changedItems) {
|
||||
final ArtifactPackagingItemOutputState cached = item.getOutputState();
|
||||
if (cached != null) {
|
||||
for (Pair<String, Long> destination : cached.myDestinations) {
|
||||
@@ -357,12 +357,12 @@ public class ArtifactsCompilerInstance extends CompilerInstance<ArtifactBuildTar
|
||||
}
|
||||
}
|
||||
}
|
||||
for (NewCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState> item : changedItems) {
|
||||
for (GenericCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState> item : changedItems) {
|
||||
for (DestinationInfo destination : item.getItem().getDestinations()) {
|
||||
pathToDelete.remove(destination.getOutputPath());
|
||||
}
|
||||
}
|
||||
for (NewCompilerItemState<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState> item : obsoleteItems) {
|
||||
for (GenericCompilerItemState<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState> item : obsoleteItems) {
|
||||
for (Pair<String, Long> destination : item.getOutputState().myDestinations) {
|
||||
pathToDelete.add(destination.getFirst());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user