notnullification (IDEA-57345)
authornik <Nikolay.Chashnikov@jetbrains.com>
Tue, 10 Aug 2010 11:26:55 +0000 (15:26 +0400)
committernik <Nikolay.Chashnikov@jetbrains.com>
Tue, 10 Aug 2010 11:27:47 +0000 (15:27 +0400)
java/compiler/impl/src/com/intellij/compiler/impl/GenericCompilerRunner.java
java/compiler/impl/src/com/intellij/compiler/impl/generic/GenericCompilerCache.java
java/compiler/impl/src/com/intellij/openapi/compiler/generic/GenericCompilerCacheState.java [moved from java/compiler/impl/src/com/intellij/openapi/compiler/generic/GenericCompilerItemState.java with 73% similarity]
java/compiler/impl/src/com/intellij/openapi/compiler/generic/GenericCompilerInstance.java
java/compiler/impl/src/com/intellij/openapi/compiler/generic/GenericCompilerProcessingItem.java [new file with mode: 0644]
java/compiler/impl/src/com/intellij/openapi/compiler/generic/SingleTargetCompilerInstance.java
java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactsCompilerInstance.java

index d684757dc81c29a6268d8377f72bed7f57ca2829..d5ff51d84c487afe2ec5c372972855050fa37655 100644 (file)
@@ -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>();
index 10152880e5f119bd73669144ff09b7f9f2189b44..9217bde65a71755053a44873187239b6c8ed5c51 100644 (file)
@@ -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;
     }
similarity index 73%
rename from java/compiler/impl/src/com/intellij/openapi/compiler/generic/GenericCompilerItemState.java
rename to java/compiler/impl/src/com/intellij/openapi/compiler/generic/GenericCompilerCacheState.java
index 6166117fb79df80f5cfeb5b95d36c48b23ab97a7..bfc44686893b84c48d70b6b856139cdfcd580851 100644 (file)
  */
 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;
   }
index c13da612ac8eaba4348861d35fe948fece975e2d..c00f57341309b044cbcb7742e0f710a102bf18b1 100644 (file)
@@ -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<?,?,?>> {
diff --git a/java/compiler/impl/src/com/intellij/openapi/compiler/generic/GenericCompilerProcessingItem.java b/java/compiler/impl/src/com/intellij/openapi/compiler/generic/GenericCompilerProcessingItem.java
new file mode 100644 (file)
index 0000000..e62a5b3
--- /dev/null
@@ -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;
+  }
+}
index 2472911574988355871ae4e75150f9a1ed3a4b23..f2e4dd3ca71e1039e68e2d28e447ee3e81b770af 100644 (file)
@@ -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) {
   }
 }
index 777e0ead9582d988f9fbee1e332c70e594346d9c..acf03b898c3fac3785593092550d41f7d03a5980 100644 (file)
@@ -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());
       }