mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
notnullification (IDEA-57345)
This commit is contained in:
@@ -117,10 +117,10 @@ public class GenericCompilerRunner {
|
||||
@Override
|
||||
public void run() throws IOException {
|
||||
cache.processSources(id, new CommonProcessors.CollectProcessor<Key>(keys));
|
||||
List<GenericCompilerItemState<Key, SourceState, OutputState>> obsoleteSources = new ArrayList<GenericCompilerItemState<Key,SourceState,OutputState>>();
|
||||
List<GenericCompilerCacheState<Key, SourceState, OutputState>> obsoleteSources = new ArrayList<GenericCompilerCacheState<Key,SourceState,OutputState>>();
|
||||
for (Key key : keys) {
|
||||
final GenericCompilerCache.PersistentStateData<SourceState, OutputState> state = cache.getState(id, key);
|
||||
obsoleteSources.add(new GenericCompilerItemState<Key,SourceState,OutputState>(key, state.mySourceState, state.myOutputState));
|
||||
obsoleteSources.add(new GenericCompilerCacheState<Key,SourceState,OutputState>(key, state.mySourceState, state.myOutputState));
|
||||
}
|
||||
instance.processObsoleteTarget(target, obsoleteSources);
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public class GenericCompilerRunner {
|
||||
final List<Item> items = instance.getItems(target);
|
||||
checkForErrorsOrCanceled();
|
||||
|
||||
final List<GenericCompilerItemState<Item, SourceState, OutputState>> toProcess = new ArrayList<GenericCompilerItemState<Item,SourceState,OutputState>>();
|
||||
final List<GenericCompilerProcessingItem<Item, SourceState, OutputState>> toProcess = new ArrayList<GenericCompilerProcessingItem<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();
|
||||
@@ -182,7 +182,7 @@ public class GenericCompilerRunner {
|
||||
if (myForceCompile || sourceState == null || !item.isSourceUpToDate(sourceState)
|
||||
|| outputState == null || !item.isOutputUpToDate(outputState)) {
|
||||
sourceStates.put(item, item.computeSourceState());
|
||||
toProcess.add(new GenericCompilerItemState<Item, SourceState, OutputState>(item, sourceState, outputState));
|
||||
toProcess.add(new GenericCompilerProcessingItem<Item,SourceState,OutputState>(item, sourceState, outputState));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -218,10 +218,10 @@ public class GenericCompilerRunner {
|
||||
throw new CompileDriver.ExitException(CompileDriver.ExitStatus.CANCELLED);
|
||||
}
|
||||
|
||||
List<GenericCompilerItemState<Key, SourceState, OutputState>> obsoleteItems = new ArrayList<GenericCompilerItemState<Key,SourceState,OutputState>>();
|
||||
List<GenericCompilerCacheState<Key, SourceState, OutputState>> obsoleteItems = new ArrayList<GenericCompilerCacheState<Key,SourceState,OutputState>>();
|
||||
for (Key key : toRemove) {
|
||||
final GenericCompilerCache.PersistentStateData<SourceState, OutputState> data = cache.getState(targetId, key);
|
||||
obsoleteItems.add(new GenericCompilerItemState<Key,SourceState,OutputState>(key, data.mySourceState, data.myOutputState));
|
||||
obsoleteItems.add(new GenericCompilerCacheState<Key,SourceState,OutputState>(key, data.mySourceState, data.myOutputState));
|
||||
}
|
||||
|
||||
final List<Item> processedItems = new ArrayList<Item>();
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.util.Processor;
|
||||
import com.intellij.util.io.DataExternalizer;
|
||||
import com.intellij.util.io.KeyDescriptor;
|
||||
import com.intellij.util.io.PersistentHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
@@ -87,7 +88,7 @@ public class GenericCompilerCache<Key, SourceState, OutputState> {
|
||||
});
|
||||
}
|
||||
|
||||
public void putState(int targetId, Key key, SourceState sourceState, OutputState outputState) throws IOException {
|
||||
public void putState(int targetId, @NotNull Key key, @NotNull SourceState sourceState, @NotNull OutputState outputState) throws IOException {
|
||||
myPersistentMap.put(getKeyAndTargetData(key, targetId), new PersistentStateData<SourceState,OutputState>(sourceState, outputState));
|
||||
}
|
||||
|
||||
@@ -106,7 +107,7 @@ public class GenericCompilerCache<Key, SourceState, OutputState> {
|
||||
public final SourceState mySourceState;
|
||||
public final OutputState myOutputState;
|
||||
|
||||
private PersistentStateData(SourceState sourceState, OutputState outputState) {
|
||||
private PersistentStateData(@NotNull SourceState sourceState, @NotNull OutputState outputState) {
|
||||
mySourceState = sourceState;
|
||||
myOutputState = outputState;
|
||||
}
|
||||
|
||||
+11
-6
@@ -15,28 +15,33 @@
|
||||
*/
|
||||
package com.intellij.openapi.compiler.generic;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class GenericCompilerItemState<Item, SourceState, OutputState> {
|
||||
private final Item myItem;
|
||||
public class GenericCompilerCacheState<Key, SourceState, OutputState> {
|
||||
private final Key myKey;
|
||||
private final SourceState mySourceState;
|
||||
private final OutputState myOutputState;
|
||||
|
||||
public GenericCompilerItemState(Item item, SourceState sourceState, OutputState outputState) {
|
||||
myItem = item;
|
||||
public GenericCompilerCacheState(@NotNull Key key, @NotNull SourceState sourceState, @NotNull OutputState outputState) {
|
||||
myKey = key;
|
||||
mySourceState = sourceState;
|
||||
myOutputState = outputState;
|
||||
}
|
||||
|
||||
public Item getItem() {
|
||||
return myItem;
|
||||
@NotNull
|
||||
public Key getKey() {
|
||||
return myKey;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public SourceState getSourceState() {
|
||||
return mySourceState;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public OutputState getOutputState() {
|
||||
return myOutputState;
|
||||
}
|
||||
+2
-2
@@ -42,13 +42,13 @@ public abstract class GenericCompilerInstance<T extends BuildTarget, Item extend
|
||||
@NotNull
|
||||
public abstract List<T> getSelectedTargets();
|
||||
|
||||
public abstract void processObsoleteTarget(@NotNull String targetId, @NotNull List<GenericCompilerItemState<Key, SourceState, OutputState>> obsoleteItems);
|
||||
public abstract void processObsoleteTarget(@NotNull String targetId, @NotNull List<GenericCompilerCacheState<Key, SourceState, OutputState>> obsoleteItems);
|
||||
|
||||
|
||||
@NotNull
|
||||
public abstract List<Item> getItems(@NotNull T target);
|
||||
|
||||
public abstract void processItems(@NotNull T target, @NotNull List<GenericCompilerItemState<Item, SourceState, OutputState>> changedItems, @NotNull List<GenericCompilerItemState<Key, SourceState, OutputState>> obsoleteItems,
|
||||
public abstract void processItems(@NotNull T target, @NotNull List<GenericCompilerProcessingItem<Item, SourceState, OutputState>> changedItems, @NotNull List<GenericCompilerCacheState<Key, SourceState, OutputState>> obsoleteItems,
|
||||
@NotNull OutputConsumer<Item> consumer);
|
||||
|
||||
public interface OutputConsumer<Item extends CompileItem<?,?,?>> {
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.openapi.compiler.generic;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class GenericCompilerProcessingItem<Item extends CompileItem<?, SourceState, OutputState>, SourceState, OutputState> {
|
||||
private final Item myItem;
|
||||
private final SourceState myCachedSourceState;
|
||||
private final OutputState myCachedOutputState;
|
||||
|
||||
public GenericCompilerProcessingItem(@NotNull Item item, @Nullable SourceState cachedSourceState, @Nullable OutputState cachedOutputState) {
|
||||
myItem = item;
|
||||
myCachedSourceState = cachedSourceState;
|
||||
myCachedOutputState = cachedOutputState;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Item getItem() {
|
||||
return myItem;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SourceState getCachedSourceState() {
|
||||
return myCachedSourceState;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public OutputState getCachedOutputState() {
|
||||
return myCachedOutputState;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -43,6 +43,6 @@ public abstract class SingleTargetCompilerInstance<Item extends CompileItem<K,S,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processObsoleteTarget(@NotNull String targetId, @NotNull List<GenericCompilerItemState<K, S, O>> obsoleteItems) {
|
||||
public void processObsoleteTarget(@NotNull String targetId, @NotNull List<GenericCompilerCacheState<K, S, O>> obsoleteItems) {
|
||||
}
|
||||
}
|
||||
|
||||
+14
-13
@@ -17,8 +17,9 @@ package com.intellij.packaging.impl.compiler;
|
||||
|
||||
import com.intellij.compiler.CompilerManagerImpl;
|
||||
import com.intellij.compiler.impl.CompilerUtil;
|
||||
import com.intellij.openapi.compiler.generic.GenericCompilerCacheState;
|
||||
import com.intellij.openapi.compiler.generic.GenericCompilerInstance;
|
||||
import com.intellij.openapi.compiler.generic.GenericCompilerItemState;
|
||||
import com.intellij.openapi.compiler.generic.GenericCompilerProcessingItem;
|
||||
import com.intellij.openapi.compiler.generic.VirtualFilePersistentState;
|
||||
import com.intellij.compiler.impl.packagingCompiler.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -120,8 +121,8 @@ public class ArtifactsCompilerInstance extends GenericCompilerInstance<ArtifactB
|
||||
|
||||
@Override
|
||||
public void processObsoleteTarget(@NotNull String targetId,
|
||||
@NotNull List<GenericCompilerItemState<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> obsoleteItems) {
|
||||
deleteFiles(obsoleteItems, Collections.<GenericCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState>>emptyList());
|
||||
@NotNull List<GenericCompilerCacheState<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> obsoleteItems) {
|
||||
deleteFiles(obsoleteItems, Collections.<GenericCompilerProcessingItem<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState>>emptyList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -163,7 +164,7 @@ public class ArtifactsCompilerInstance extends GenericCompilerInstance<ArtifactB
|
||||
rootElement.computeIncrementalCompilerInstructions(instructionCreator, resolvingContext, myBuilderContext, artifact.getArtifactType());
|
||||
}
|
||||
|
||||
private boolean doBuild(final List<GenericCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> changedItems,
|
||||
private boolean doBuild(final List<GenericCompilerProcessingItem<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 +183,7 @@ public class ArtifactsCompilerInstance extends GenericCompilerInstance<ArtifactB
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (final GenericCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState> item : changedItems) {
|
||||
for (final GenericCompilerProcessingItem<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState> item : changedItems) {
|
||||
final ArtifactCompilerCompileItem sourceItem = item.getItem();
|
||||
myContext.getProgressIndicator().checkCanceled();
|
||||
|
||||
@@ -308,8 +309,8 @@ public class ArtifactsCompilerInstance extends GenericCompilerInstance<ArtifactB
|
||||
|
||||
@Override
|
||||
public void processItems(@NotNull ArtifactBuildTarget target,
|
||||
@NotNull final List<GenericCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> changedItems,
|
||||
@NotNull List<GenericCompilerItemState<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> obsoleteItems,
|
||||
@NotNull final List<GenericCompilerProcessingItem<ArtifactCompilerCompileItem,VirtualFilePersistentState,ArtifactPackagingItemOutputState>> changedItems,
|
||||
@NotNull List<GenericCompilerCacheState<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> obsoleteItems,
|
||||
@NotNull OutputConsumer<ArtifactCompilerCompileItem> consumer) {
|
||||
|
||||
final THashSet<String> deletedJars = deleteFiles(obsoleteItems, changedItems);
|
||||
@@ -337,8 +338,8 @@ public class ArtifactsCompilerInstance extends GenericCompilerInstance<ArtifactB
|
||||
myContext.putUserData(ArtifactsCompiler.WRITTEN_PATHS_KEY, writtenPaths);
|
||||
}
|
||||
|
||||
private THashSet<String> deleteFiles(List<GenericCompilerItemState<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> obsoleteItems,
|
||||
List<GenericCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> changedItems) {
|
||||
private THashSet<String> deleteFiles(List<GenericCompilerCacheState<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> obsoleteItems,
|
||||
List<GenericCompilerProcessingItem<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> changedItems) {
|
||||
myContext.getProgressIndicator().setText(CompilerBundle.message("packaging.compiler.message.deleting.outdated.files"));
|
||||
|
||||
final boolean testMode = ApplicationManager.getApplication().isUnitTestMode();
|
||||
@@ -349,20 +350,20 @@ public class ArtifactsCompilerInstance extends GenericCompilerInstance<ArtifactB
|
||||
}
|
||||
|
||||
Set<String> pathToDelete = new THashSet<String>();
|
||||
for (GenericCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState> item : changedItems) {
|
||||
final ArtifactPackagingItemOutputState cached = item.getOutputState();
|
||||
for (GenericCompilerProcessingItem<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState> item : changedItems) {
|
||||
final ArtifactPackagingItemOutputState cached = item.getCachedOutputState();
|
||||
if (cached != null) {
|
||||
for (Pair<String, Long> destination : cached.myDestinations) {
|
||||
pathToDelete.add(destination.getFirst());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (GenericCompilerItemState<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState> item : changedItems) {
|
||||
for (GenericCompilerProcessingItem<ArtifactCompilerCompileItem, VirtualFilePersistentState, ArtifactPackagingItemOutputState> item : changedItems) {
|
||||
for (DestinationInfo destination : item.getItem().getDestinations()) {
|
||||
pathToDelete.remove(destination.getOutputPath());
|
||||
}
|
||||
}
|
||||
for (GenericCompilerItemState<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState> item : obsoleteItems) {
|
||||
for (GenericCompilerCacheState<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState> item : obsoleteItems) {
|
||||
for (Pair<String, Long> destination : item.getOutputState().myDestinations) {
|
||||
pathToDelete.add(destination.getFirst());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user