From 9142df3c73adc0187522cfdc28d700066a64ee07 Mon Sep 17 00:00:00 2001
From: nik
Date: Thu, 6 Mar 2014 12:51:55 +0400
Subject: [PATCH 001/172] classes from old build system API marked as
deprecated (to be removed in IDEA 14)
---
.../intellij/openapi/compiler/generic/GenericCompiler.java | 4 ++++
.../openapi/compiler/ClassInstrumentingCompiler.java | 4 ++++
.../openapi/compiler/ClassPostProcessingCompiler.java | 4 ++++
.../src/com/intellij/openapi/compiler/CompilerManager.java | 4 ++++
.../src/com/intellij/openapi/compiler/CopyingCompiler.java | 4 ++++
.../com/intellij/openapi/compiler/GeneratingCompiler.java | 4 ++++
.../openapi/compiler/JavaSourceTransformingCompiler.java | 4 ++++
.../com/intellij/openapi/compiler/PackagingCompiler.java | 4 ++++
.../openapi/compiler/SourceGeneratingCompiler.java | 4 ++++
.../com/intellij/openapi/compiler/TranslatingCompiler.java | 4 ++++
.../intellij/openapi/compiler/make/BuildInstruction.java | 5 +++++
.../openapi/compiler/make/BuildInstructionVisitor.java | 6 +++++-
.../intellij/openapi/compiler/make/BuildParticipant.java | 4 +++-
.../openapi/compiler/make/BuildParticipantProvider.java | 4 +++-
.../openapi/compiler/make/FileCopyInstruction.java | 7 +++++--
15 files changed, 61 insertions(+), 5 deletions(-)
diff --git a/java/compiler/impl/src/com/intellij/openapi/compiler/generic/GenericCompiler.java b/java/compiler/impl/src/com/intellij/openapi/compiler/generic/GenericCompiler.java
index b09c8e599626..87136283737b 100644
--- a/java/compiler/impl/src/com/intellij/openapi/compiler/generic/GenericCompiler.java
+++ b/java/compiler/impl/src/com/intellij/openapi/compiler/generic/GenericCompiler.java
@@ -25,6 +25,10 @@ import org.jetbrains.annotations.NotNull;
/**
* @author nik
+ *
+ * @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public abstract class GenericCompiler implements Compiler {
protected static final KeyDescriptor STRING_KEY_DESCRIPTOR = new EnumeratorStringDescriptor();
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/ClassInstrumentingCompiler.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/ClassInstrumentingCompiler.java
index cfcf3373fa3f..4e5143aee495 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/ClassInstrumentingCompiler.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/ClassInstrumentingCompiler.java
@@ -21,6 +21,10 @@ package com.intellij.openapi.compiler;
* This affects the order of compiler calls:
* The sequence in which compilers are called:
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
+ *
+ * @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface ClassInstrumentingCompiler extends FileProcessingCompiler {
}
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/ClassPostProcessingCompiler.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/ClassPostProcessingCompiler.java
index 203facd2b02d..c4c3e8b40cf1 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/ClassPostProcessingCompiler.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/ClassPostProcessingCompiler.java
@@ -21,6 +21,10 @@ package com.intellij.openapi.compiler;
* This affects the order of compiler calls:
* The sequence in which compilers are called:
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
+ *
+ * @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface ClassPostProcessingCompiler extends FileProcessingCompiler {
}
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerManager.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerManager.java
index 4456665ef4bd..03d9be241ffb 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerManager.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerManager.java
@@ -63,6 +63,10 @@ public abstract class CompilerManager {
* @param compiler compiler implementation
* @param inputTypes a set of filetypes that compiler accepts as input
* @param outputTypes a set of filetypes that compiler can generate
+ *
+ * @deprecated this method is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public abstract void addTranslatingCompiler(@NotNull TranslatingCompiler compiler, Set inputTypes, Set outputTypes);
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/CopyingCompiler.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/CopyingCompiler.java
index 7d80c21daedf..758524e92426 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/CopyingCompiler.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/CopyingCompiler.java
@@ -32,6 +32,10 @@ import java.util.List;
/**
* Compiler which copies the compiled files to a different directory.
+ *
+ * @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public abstract class CopyingCompiler implements PackagingCompiler{
public abstract VirtualFile[] getFilesToCopy(CompileContext context);
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/GeneratingCompiler.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/GeneratingCompiler.java
index 962bcb218e5e..af1fb1eb8dd7 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/GeneratingCompiler.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/GeneratingCompiler.java
@@ -21,6 +21,10 @@ import com.intellij.openapi.vfs.VirtualFile;
/**
* A base interface for all compilers that generate new files. The generated files may be processed by other compilers.
* Actual implementation should implement one of its subinterfaces. Currently only {@link SourceGeneratingCompiler} is available.
+ *
+ * @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface GeneratingCompiler extends Compiler, ValidityStateFactory, IntermediateOutputCompiler {
/**
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/JavaSourceTransformingCompiler.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/JavaSourceTransformingCompiler.java
index 27a397569aad..1194efcccba3 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/JavaSourceTransformingCompiler.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/JavaSourceTransformingCompiler.java
@@ -19,6 +19,10 @@ import com.intellij.openapi.vfs.VirtualFile;
/**
* This compiler is called right before the java sources compiler.
+ *
+ * @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface JavaSourceTransformingCompiler extends Compiler {
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/PackagingCompiler.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/PackagingCompiler.java
index e7e1350b41b9..3055e0ff654f 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/PackagingCompiler.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/PackagingCompiler.java
@@ -23,6 +23,10 @@ import org.jetbrains.annotations.Nullable;
* This affects the order of compiler calls.
* The sequence in which compilers are called:
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
+ *
+ * @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface PackagingCompiler extends FileProcessingCompiler{
/**
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/SourceGeneratingCompiler.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/SourceGeneratingCompiler.java
index 4c0b646658f6..2fe36ba202ba 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/SourceGeneratingCompiler.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/SourceGeneratingCompiler.java
@@ -23,6 +23,10 @@ import com.intellij.openapi.vfs.VirtualFile;
* This affects the order of compiler calls.
* The sequence in which compilers are called:
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
+ *
+ * @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface SourceGeneratingCompiler extends GeneratingCompiler {
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/TranslatingCompiler.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/TranslatingCompiler.java
index 3c56f8d9f67d..c5ce012c9ce6 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/TranslatingCompiler.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/TranslatingCompiler.java
@@ -26,6 +26,10 @@ import java.util.Collection;
* This affects the order of compiler calls.
* The sequence in which compilers are called:
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
+ *
+ * @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface TranslatingCompiler extends Compiler {
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstruction.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstruction.java
index 148e1524e4a2..eed2e77c8030 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstruction.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstruction.java
@@ -15,6 +15,11 @@
*/
package com.intellij.openapi.compiler.make;
+/**
+ * @deprecated this class is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
+ */
public interface BuildInstruction {
String getOutputRelativePath();
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstructionVisitor.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstructionVisitor.java
index 6ae9b33e062b..0bd62be958f7 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstructionVisitor.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstructionVisitor.java
@@ -15,7 +15,11 @@
*/
package com.intellij.openapi.compiler.make;
-
+/**
+ * @deprecated this class is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
+ */
public abstract class BuildInstructionVisitor {
public boolean visitInstruction(BuildInstruction instruction) throws Exception {
return true;
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildParticipant.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildParticipant.java
index 48022b6bf272..977772418589 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildParticipant.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildParticipant.java
@@ -20,7 +20,9 @@ import com.intellij.packaging.artifacts.Artifact;
import org.jetbrains.annotations.Nullable;
/**
- * @deprecated use interfaces from {@link com.intellij.openapi.compiler.Compiler}'s hierarchy instead
+ * @deprecated this class is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public abstract class BuildParticipant {
public static final BuildParticipant[] EMPTY_ARRAY = new BuildParticipant[0];
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildParticipantProvider.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildParticipantProvider.java
index a0f46da79290..374e161549ad 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildParticipantProvider.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildParticipantProvider.java
@@ -24,7 +24,9 @@ import java.util.Collection;
/**
* @author nik
*
- * @deprecated use interfaces from {@link com.intellij.openapi.compiler.Compiler}'s hierarchy instead
+ * @deprecated this class is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public abstract class BuildParticipantProvider {
public static final ExtensionPointName EXTENSION_POINT_NAME = ExtensionPointName.create("com.intellij.compiler.buildParticipantProvider");
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/FileCopyInstruction.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/FileCopyInstruction.java
index 4109410aec00..c5636394cfe0 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/FileCopyInstruction.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/FileCopyInstruction.java
@@ -15,10 +15,13 @@
*/
package com.intellij.openapi.compiler.make;
-import org.jetbrains.annotations.Nullable;
-
import java.io.File;
+/**
+ * @deprecated this class is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
+ */
public interface FileCopyInstruction extends BuildInstruction {
File getFile();
From 2149ea34f33bc10ff0bd8014fe47832553eeaf20 Mon Sep 17 00:00:00 2001
From: Rustam Vishnyakov
Date: Thu, 6 Mar 2014 13:04:22 +0400
Subject: [PATCH 002/172] Fixed project leak
---
.../file/exclude/EnforcedPlainTextFileTypeManager.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/platform/lang-impl/src/com/intellij/openapi/file/exclude/EnforcedPlainTextFileTypeManager.java b/platform/lang-impl/src/com/intellij/openapi/file/exclude/EnforcedPlainTextFileTypeManager.java
index e8a18e423423..f40d069c83c1 100644
--- a/platform/lang-impl/src/com/intellij/openapi/file/exclude/EnforcedPlainTextFileTypeManager.java
+++ b/platform/lang-impl/src/com/intellij/openapi/file/exclude/EnforcedPlainTextFileTypeManager.java
@@ -28,7 +28,7 @@ import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
import com.intellij.openapi.util.EmptyRunnable;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileWithId;
-import com.intellij.util.containers.ConcurrentHashMap;
+import com.intellij.util.containers.ConcurrentWeakHashMap;
import com.intellij.util.indexing.FileBasedIndex;
import org.jetbrains.annotations.NotNull;
@@ -43,7 +43,7 @@ import java.util.Map;
* @author Rustam Vishnyakov
*/
public class EnforcedPlainTextFileTypeManager implements ProjectManagerListener {
- private final Map> myPlainTextFileSets = new ConcurrentHashMap>();
+ private final Map> myPlainTextFileSets = new ConcurrentWeakHashMap>();
private volatile boolean mySetsInitialized = false;
private static final Object LOCK = new Object();
From a70f8239c8de35f69fb0004373990fa128cc77e9 Mon Sep 17 00:00:00 2001
From: Anna Kozlova
Date: Wed, 5 Mar 2014 19:43:13 +0100
Subject: [PATCH 003/172] new inference: postpone argument types calculation
---
.../psi/infos/MethodCandidateInfo.java | 51 ++++++++++---------
.../JavaMethodsConflictResolver.java | 41 ++++++++++-----
.../processor/MethodCandidatesProcessor.java | 7 ++-
3 files changed, 62 insertions(+), 37 deletions(-)
diff --git a/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java b/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java
index 2afc76a5d060..2831025839e3 100644
--- a/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java
+++ b/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java
@@ -82,9 +82,11 @@ public class MethodCandidateInfo extends CandidateInfo{
@ApplicabilityLevelConstant
private int getApplicabilityLevelInner() {
- if (myArgumentTypes == null) return ApplicabilityLevel.NOT_APPLICABLE;
+ final PsiType[] argumentTypes = getArgumentTypes();
- int level = PsiUtil.getApplicabilityLevel(getElement(), getSubstitutor(), myArgumentTypes, myLanguageLevel);
+ if (argumentTypes == null) return ApplicabilityLevel.NOT_APPLICABLE;
+
+ int level = PsiUtil.getApplicabilityLevel(getElement(), getSubstitutor(), argumentTypes, myLanguageLevel);
if (level > ApplicabilityLevel.NOT_APPLICABLE && !isTypeArgumentsApplicable()) level = ApplicabilityLevel.NOT_APPLICABLE;
return level;
}
@@ -104,18 +106,17 @@ public class MethodCandidateInfo extends CandidateInfo{
return getApplicabilityLevel();
}
- if (myArgumentTypes == null) {
- return ApplicabilityLevel.NOT_APPLICABLE;
- }
-
@ApplicabilityLevelConstant int level;
Integer boxedLevel = ourOverloadGuard.doPreventingRecursion(myArgumentList, false, new Computable() {
@Override
public Integer compute() {
-
- final PsiMethod method = getElement();
- if (method != null && method.hasTypeParameters() || myArgumentList == null || !PsiUtil.isLanguageLevel8OrHigher(myArgumentList)) {
- return PsiUtil.getApplicabilityLevel(getElement(), getSubstitutor(false), myArgumentTypes, myLanguageLevel);
+ if (PsiUtil.isLanguageLevel8OrHigher(myArgumentList)) {
+ final PsiType[] argumentTypes = getArgumentTypes();
+ if (argumentTypes == null) {
+ return ApplicabilityLevel.NOT_APPLICABLE;
+ }
+
+ return PsiUtil.getApplicabilityLevel(getElement(), getSubstitutor(false), argumentTypes, myLanguageLevel);
}
return getApplicabilityLevelInner();
}
@@ -127,7 +128,17 @@ public class MethodCandidateInfo extends CandidateInfo{
}
public PsiSubstitutor getSiteSubstitutor() {
- return super.getSubstitutor();
+ PsiSubstitutor incompleteSubstitutor = super.getSubstitutor();
+ if (myTypeArguments != null) {
+ PsiMethod method = getElement();
+ if (method != null) {
+ PsiTypeParameter[] typeParams = method.getTypeParameters();
+ for (int i = 0; i < myTypeArguments.length && i < typeParams.length; i++) {
+ incompleteSubstitutor = incompleteSubstitutor.put(typeParams[i], myTypeArguments[i]);
+ }
+ }
+ }
+ return incompleteSubstitutor;
}
@NotNull
@@ -206,22 +217,10 @@ public class MethodCandidateInfo extends CandidateInfo{
return inferTypeArguments(policy, arguments, true);
}
else {
- return typeArgumentsSubstitutor();
+ return getSiteSubstitutor();
}
}
- public PsiSubstitutor typeArgumentsSubstitutor() {
- PsiSubstitutor incompleteSubstitutor = super.getSubstitutor();
- PsiMethod method = getElement();
- if (method != null) {
- PsiTypeParameter[] typeParams = method.getTypeParameters();
- for (int i = 0; i < myTypeArguments.length && i < typeParams.length; i++) {
- incompleteSubstitutor = incompleteSubstitutor.put(typeParams[i], myTypeArguments[i]);
- }
- }
- return incompleteSubstitutor;
- }
-
@NotNull
public PsiSubstitutor inferTypeArguments(@NotNull ParameterTypeInferencePolicy policy,
@NotNull PsiExpression[] arguments,
@@ -283,6 +282,10 @@ public class MethodCandidateInfo extends CandidateInfo{
}
}
+ public PsiType[] getArgumentTypes() {
+ return myArgumentTypes;
+ }
+
public static class ApplicabilityLevel {
public static final int NOT_APPLICABLE = 1;
public static final int VARARGS = 2;
diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
index 406abbf9ee7a..81cfc0ab4799 100644
--- a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
+++ b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
@@ -72,7 +72,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
if (conflicts.isEmpty()) return null;
if (conflicts.size() == 1) return conflicts.get(0);
- boolean atLeastOneMatch = checkParametersNumber(conflicts, getActualParameterTypes().length, true);
+ boolean atLeastOneMatch = checkParametersNumber(conflicts, getActualParametersLength(), true);
if (conflicts.size() == 1) return conflicts.get(0);
checkSameSignatures(conflicts);
@@ -81,7 +81,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
checkAccessStaticLevels(conflicts, true);
if (conflicts.size() == 1) return conflicts.get(0);
- checkParametersNumber(conflicts, getActualParameterTypes().length, false);
+ checkParametersNumber(conflicts, getActualParametersLength(), false);
if (conflicts.size() == 1) return conflicts.get(0);
final int applicabilityLevel = checkApplicability(conflicts);
@@ -97,7 +97,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
checkSpecifics(conflicts, applicabilityLevel, myLanguageLevel);
if (conflicts.size() == 1) return conflicts.get(0);
- checkPrimitiveVarargs(conflicts, getActualParameterTypes().length);
+ checkPrimitiveVarargs(conflicts, getActualParametersLength());
if (conflicts.size() == 1) return conflicts.get(0);
checkAccessStaticLevels(conflicts, false);
@@ -110,10 +110,19 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
private void checkLambdaApplicable(@NotNull List conflicts, @NotNull LanguageLevel languageLevel) {
if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) return;
- for (int i = 0; i < getActualParameterTypes().length; i++) {
- PsiType parameterType = getActualParameterTypes()[i];
- if (parameterType instanceof PsiLambdaExpressionType) {
- final PsiLambdaExpression lambdaExpression = ((PsiLambdaExpressionType)parameterType).getExpression();
+ for (int i = 0; i < getActualParametersLength(); i++) {
+
+ PsiExpression expression;
+ if (myArgumentsList instanceof PsiExpressionList) {
+ expression = ((PsiExpressionList)myArgumentsList).getExpressions()[i];
+ }
+ else {
+ final PsiType argType = getActualParameterTypes()[i];
+ expression = argType instanceof PsiLambdaExpressionType ? ((PsiLambdaExpressionType)argType).getExpression() : null;
+ }
+
+ if (expression instanceof PsiLambdaExpression) {
+ final PsiLambdaExpression lambdaExpression = (PsiLambdaExpression)expression;
for (Iterator iterator = conflicts.iterator(); iterator.hasNext(); ) {
ProgressManager.checkCanceled();
final CandidateInfo conflict = iterator.next();
@@ -411,6 +420,14 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return myActualParameterTypes;
}
+ private int getActualParametersLength() {
+ if (myActualParameterTypes == null) {
+ LOG.assertTrue(myArgumentsList instanceof PsiExpressionList, myArgumentsList);
+ return ((PsiExpressionList)myArgumentsList).getExpressions().length;
+ }
+ return myActualParameterTypes.length;
+ }
+
protected PsiType[] getArgumentTypes() {
return ((PsiExpressionList)myArgumentsList).getExpressionTypes();
}
@@ -500,8 +517,8 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
final PsiSubstitutor siteSubstitutor1 = info1.getSiteSubstitutor();
final PsiSubstitutor siteSubstitutor2 = info2.getSiteSubstitutor();
- final PsiType[] types2AtSite = typesAtSite(types2, siteSubstitutor2, typeParameters2);
- final PsiType[] types1AtSite = typesAtSite(types1, siteSubstitutor1, typeParameters1);
+ final PsiType[] types2AtSite = typesAtSite(types2, siteSubstitutor2);
+ final PsiType[] types1AtSite = typesAtSite(types1, siteSubstitutor1);
final PsiSubstitutor methodSubstitutor1 = calculateMethodSubstitutor(typeParameters1, method1, siteSubstitutor1, types1, types2AtSite,
languageLevel);
@@ -538,7 +555,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && myArgumentsList instanceof PsiExpressionList && (typeParameters1.length == 0 || typeParameters2.length == 0)) {
boolean toCompareFunctional = false;
- for (int i = 0; i < myActualParameterTypes.length; i++) {
+ for (int i = 0; i < getActualParametersLength(); i++) {
if (types1.length > 0 && LambdaUtil.isFunctionalType(types1[Math.min(i, types1.length - 1)]) &&
types2.length > 0 && LambdaUtil.isFunctionalType(types2[Math.min(i, types2.length - 1)])) {
types1AtSite[Math.min(i, types1.length - 1)] = PsiType.NULL;
@@ -555,7 +572,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
if (applicable12ignoreFunctionalType || applicable21ignoreFunctionalType) {
Specifics specifics = null;
- for (int i = 0; i < myActualParameterTypes.length; i++) {
+ for (int i = 0; i < getActualParametersLength(); i++) {
if (types1.length > 0 && types1AtSite[Math.min(i, types1.length - 1)] == PsiType.NULL &&
types2.length > 0 && types2AtSite[Math.min(i, types2.length - 1)] == PsiType.NULL) {
Specifics specific = isFunctionalTypeMoreSpecific(info1, info2, ((PsiExpressionList)myArgumentsList).getExpressions()[i], i);
@@ -642,7 +659,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return applicabilityLevel > MethodCandidateInfo.ApplicabilityLevel.NOT_APPLICABLE;
}
- private static PsiType[] typesAtSite(PsiType[] types1, PsiSubstitutor siteSubstitutor1, PsiTypeParameter[] typeParameters1) {
+ private static PsiType[] typesAtSite(PsiType[] types1, PsiSubstitutor siteSubstitutor1) {
final PsiType[] types = PsiType.createArray(types1.length);
for (int i = 0; i < types1.length; i++) {
types[i] = siteSubstitutor1.substitute(types1[i]);
diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodCandidatesProcessor.java b/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodCandidatesProcessor.java
index ad0e7358842c..8607ff43c60e 100644
--- a/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodCandidatesProcessor.java
+++ b/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodCandidatesProcessor.java
@@ -63,7 +63,12 @@ public class MethodCandidatesProcessor extends MethodsProcessor{
final boolean staticProblem, final boolean accessible) {
final PsiExpressionList argumentList = getArgumentList();
return new MethodCandidateInfo(method, substitutor, !accessible, staticProblem, argumentList, myCurrentFileContext,
- getExpressionTypes(argumentList), getTypeArguments(), getLanguageLevel());
+ null, getTypeArguments(), getLanguageLevel()) {
+ @Override
+ public PsiType[] getArgumentTypes() {
+ return getExpressionTypes(argumentList);
+ }
+ };
}
protected PsiType[] getExpressionTypes(PsiExpressionList argumentList) {
From 5029b3fc552374f34e3568450aaca8a2d6e14204 Mon Sep 17 00:00:00 2001
From: Anna Kozlova
Date: Wed, 5 Mar 2014 19:52:17 +0100
Subject: [PATCH 004/172] new inference: do not prefer specifics based on void
return type for both void and value compatible lambdas
---
.../resolve/graphInference/InferenceSession.java | 12 ++++++------
.../lambda/highlighting/AmbiguityRawGenerics.java | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
index 53911011bc17..62a588d4b940 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
@@ -995,8 +995,9 @@ public class InferenceSession {
return true;
}
- if (sReturnType == PsiType.VOID && session != null) {
- return false;
+ final List returnExpressions = LambdaUtil.getReturnExpressions((PsiLambdaExpression)arg);
+ if (sReturnType == PsiType.VOID) {
+ return returnExpressions.isEmpty() && session == null;
}
if (LambdaUtil.isFunctionalType(sReturnType) && LambdaUtil.isFunctionalType(tReturnType) &&
@@ -1005,15 +1006,14 @@ public class InferenceSession {
//Otherwise, if R1 and R2 are functional interface types, and neither interface is a subinterface of the other,
//then these rules are applied recursively to R1 and R2, for each result expression in expi.
- final List returnExpressions = LambdaUtil.getReturnExpressions((PsiLambdaExpression)arg);
if (!isFunctionalTypeMoreSpecific(sReturnType, tReturnType, session, returnExpressions.toArray(new PsiExpression[returnExpressions.size()]))) {
return false;
}
} else {
- final boolean sPrimitive = sReturnType instanceof PsiPrimitiveType;
- final boolean tPrimitive = tReturnType instanceof PsiPrimitiveType;
+ final boolean sPrimitive = sReturnType instanceof PsiPrimitiveType && sReturnType != PsiType.VOID;
+ final boolean tPrimitive = tReturnType instanceof PsiPrimitiveType && tReturnType != PsiType.VOID;
if (sPrimitive ^ tPrimitive) {
- for (PsiExpression returnExpression : LambdaUtil.getReturnExpressions((PsiLambdaExpression)arg)) {
+ for (PsiExpression returnExpression : returnExpressions) {
if (!PsiPolyExpressionUtil.isPolyExpression(returnExpression)) {
final PsiType returnExpressionType = returnExpression.getType();
if (sPrimitive) {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityRawGenerics.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityRawGenerics.java
index 6c664dd9e65a..595787704437 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityRawGenerics.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityRawGenerics.java
@@ -22,6 +22,6 @@ class AmbiguityRawGenerics {
void foo(I3 s) { }
void bar() {
- foo(()-> { throw new RuntimeException(); });
+ foo(()-> { throw new RuntimeException(); });
}
}
\ No newline at end of file
From 46112ee3ec9ea901b9fdd18efd80985b4f0ab8cd Mon Sep 17 00:00:00 2001
From: Anna Kozlova
Date: Wed, 5 Mar 2014 20:00:05 +0100
Subject: [PATCH 005/172] new inference: cache lambda functional type during
expression constraints reduction (IDEA-121315)
---
.../src/com/intellij/psi/LambdaUtil.java | 8 +++++++
.../graphInference/InferenceSession.java | 18 +++++++++------
.../InputOutputConstraintFormula.java | 10 ++++++---
.../lambda/newLambda/IDEA121315.java | 22 +++++++++++++++++++
.../lambda/NewLambdaHighlightingTest.java | 4 ++++
5 files changed, 52 insertions(+), 10 deletions(-)
create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA121315.java
diff --git a/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java b/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java
index 54bd0241e64e..e1a9469765d3 100644
--- a/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java
@@ -33,6 +33,7 @@ import java.util.*;
* Date: 7/17/12
*/
public class LambdaUtil {
+ public static ThreadLocal
*
- * @author Kirill Likhodedov
*/
public abstract class GithubTest extends UsefulTestCase {
@@ -77,7 +76,7 @@ public abstract class GithubTest extends UsefulTestCase {
@NotNull private GitHttpAuthTestService myHttpAuthService;
@NotNull protected TestDialogManager myDialogManager;
- @NotNull protected TestNotificator myNotificator;
+ @NotNull protected TestVcsNotifier myVcsNotifier;
@NotNull private IdeaProjectTestFixture myProjectFixture;
@@ -104,7 +103,7 @@ public abstract class GithubTest extends UsefulTestCase {
}
protected void checkNotification(@NotNull NotificationType type, @Nullable String title, @Nullable String content) {
- Notification actualNotification = myNotificator.getLastNotification();
+ Notification actualNotification = myVcsNotifier.getLastNotification();
assertNotNull("No notification was shown", actualNotification);
if (title != null) {
@@ -213,7 +212,7 @@ public abstract class GithubTest extends UsefulTestCase {
myGitHubSettings.setAuthData(myAuth, false);
myDialogManager = (TestDialogManager)ServiceManager.getService(DialogManager.class);
- myNotificator = (TestNotificator)ServiceManager.getService(myProject, Notificator.class);
+ myVcsNotifier = (TestVcsNotifier)ServiceManager.getService(myProject, VcsNotifier.class);
myHttpAuthService = (GitHttpAuthTestService)ServiceManager.getService(GitHttpAuthService.class);
myGitRepositoryManager = GitUtil.getRepositoryManager(myProject);
@@ -240,7 +239,7 @@ public abstract class GithubTest extends UsefulTestCase {
finally {
myHttpAuthService.cleanup();
myDialogManager.cleanup();
- myNotificator.cleanup();
+ myVcsNotifier.cleanup();
myProjectFixture.tearDown();
super.tearDown();
diff --git a/plugins/hg4idea/resources/org/zmlx/hg4idea/HgVcsMessages.properties b/plugins/hg4idea/resources/org/zmlx/hg4idea/HgVcsMessages.properties
index 5f5a1679709f..af459be969f5 100644
--- a/plugins/hg4idea/resources/org/zmlx/hg4idea/HgVcsMessages.properties
+++ b/plugins/hg4idea/resources/org/zmlx/hg4idea/HgVcsMessages.properties
@@ -48,7 +48,7 @@ hg4idea.clone.test.success=Connection Successful
hg4idea.configuration.title=Mercurial Configuration
hg4idea.configuration.executable.title=Mercurial executable
hg4idea.configuration.description=Specify the full path to hg executable
-hg4idea.configuration.executable.error=\"{0}\" doesn''t appear to be a valid hg executable
+hg4idea.configuration.executable.error=\"{0}\" doesn't appear to be a valid hg executable
hg4idea.configuration.test.label=Test
hg4idea.configuration.test=&Test
hg4idea.unable.to.run.hg=Unable to run hg: {0}
@@ -80,7 +80,7 @@ hg4idea.init.already.under.hg.option.create.repo.here=Create new repository here
hg4idea.init.created.notification.title=Mercurial repository created
hg4idea.init.created.notification.description=Repository was created in {0}
hg4idea.init.error.title=Error creating Mercurial repository
-hg4idea.init.error.description=Couldn''t create a Mercurial repository in {0}
+hg4idea.init.error.description=Couldn't create a Mercurial repository in {0}
hg4idea.move.progress=Moving files in the VCS...
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java
index 17d4f364a154..2e9321253b7e 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java
@@ -21,6 +21,7 @@ import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vcs.VcsNotifier;
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
@@ -90,12 +91,10 @@ public class HgPusher {
String successTitle = "Pushed successfully";
String successDescription = String.format("Pushed %d %s [%s]", commitsNum, StringUtil.pluralize("commit", commitsNum),
repo.getPresentableName());
- new HgCommandResultNotifier(project).notifySuccess(successTitle, successDescription);
- }
- else if (result.getExitValue() == NOTHING_TO_PUSH_EXIT_VALUE) {
- new HgCommandResultNotifier(project).notifySuccess("", "Nothing to push");
- }
- else {
+ VcsNotifier.getInstance(project).notifySuccess(successTitle, successDescription);
+ } else if (result.getExitValue() == NOTHING_TO_PUSH_EXIT_VALUE) {
+ VcsNotifier.getInstance(project).notifySuccess("Nothing to push");
+ } else {
new HgCommandResultNotifier(project).notifyError(result, "Push failed",
"Failed to push to [" + repo.getPresentableName() + "]");
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgVcs.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgVcs.java
index 0c6ac2aa227d..8745a6b738b5 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgVcs.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgVcs.java
@@ -18,6 +18,7 @@ import com.intellij.notification.NotificationListener;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.application.ModalityState;
+import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.diff.impl.patch.formove.FilePathComparator;
import com.intellij.openapi.editor.markup.TextAttributes;
@@ -38,6 +39,7 @@ import com.intellij.openapi.vcs.diff.DiffProvider;
import com.intellij.openapi.vcs.history.VcsHistoryProvider;
import com.intellij.openapi.vcs.merge.MergeProvider;
import com.intellij.openapi.vcs.rollback.RollbackEnvironment;
+import com.intellij.openapi.vcs.roots.VcsRootDetector;
import com.intellij.openapi.vcs.update.UpdateEnvironment;
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
import com.intellij.openapi.vfs.VfsUtilCore;
@@ -48,12 +50,12 @@ import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.zmlx.hg4idea.action.HgCommandResultNotifier;
import org.zmlx.hg4idea.provider.*;
import org.zmlx.hg4idea.provider.annotate.HgAnnotationProvider;
import org.zmlx.hg4idea.provider.commit.HgCheckinEnvironment;
import org.zmlx.hg4idea.provider.commit.HgCommitAndPushExecutor;
import org.zmlx.hg4idea.provider.update.HgUpdateEnvironment;
+import org.zmlx.hg4idea.roots.HgIntegrationEnabler;
import org.zmlx.hg4idea.status.HgRemoteStatusUpdater;
import org.zmlx.hg4idea.status.ui.HgHideableWidget;
import org.zmlx.hg4idea.status.ui.HgIncomingOutgoingWidget;
@@ -63,6 +65,7 @@ import org.zmlx.hg4idea.util.HgVersion;
import javax.swing.event.HyperlinkEvent;
import java.io.File;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -401,6 +404,17 @@ public class HgVcs extends AbstractVcs {
return VcsType.distributed;
}
+ @Override
+ @CalledInAwt
+ public void enableIntegration() {
+ ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
+ public void run() {
+ Collection roots = ServiceManager.getService(myProject, VcsRootDetector.class).detect();
+ new HgIntegrationEnabler(HgVcs.this).enable(roots);
+ }
+ });
+ }
+
@Override
public CheckoutProvider getCheckoutProvider() {
return new HgCheckoutProvider();
@@ -412,7 +426,7 @@ public class HgVcs extends AbstractVcs {
*/
public void checkVersion() {
final String executable = getGlobalSettings().getHgExecutable();
- HgCommandResultNotifier errorNotification = new HgCommandResultNotifier(myProject);
+ VcsNotifier vcsNotifier = VcsNotifier.getInstance(myProject);
final String SETTINGS_LINK = "settings";
final String UPDATE_LINK = "update";
NotificationListener linkAdapter = new NotificationListener.Adapter() {
@@ -436,14 +450,14 @@ public class HgVcs extends AbstractVcs {
String message = String.format("The configured version of Hg is not supported: %s. " +
"The minimal supported version is %s. Please update.",
myVersion, HgVersion.MIN);
- errorNotification.notifyError(null, "Unsupported Hg version", message, linkAdapter);
+ vcsNotifier.notifyError("Unsupported Hg version", message, linkAdapter);
}
else if (myVersion.hasUnsupportedExtensions()) {
String unsupportedExtensionsAsString = myVersion.getUnsupportedExtensions().toString();
LOG.warn("Unsupported Hg extensions: " + unsupportedExtensionsAsString);
String message = String.format("Some hg extensions %s are not found or not supported by your hg version and will be ignored.\n" +
"Please, update your hgrc or Mercurial.ini file", unsupportedExtensionsAsString);
- errorNotification.notifyWarning("Unsupported Hg version", message);
+ vcsNotifier.notifyWarning("Unsupported Hg version", message);
}
}
catch (Exception e) {
@@ -452,13 +466,15 @@ public class HgVcs extends AbstractVcs {
// so parse(output) throw ParseException, but hg and git executable seems to be valid in this case
final String reason = (e.getCause() != null ? e.getCause() : e).getMessage();
String message = HgVcsMessages.message("hg4idea.unable.to.run.hg", executable);
- errorNotification.notifyError(null, message,
- String.format(
- reason +
- " Please check your hg executable path in settings "),
- linkAdapter);
+ vcsNotifier.notifyError(message,
+ String.format(
+ reason +
+ " Please check your hg executable path in settings "
+ ),
+ linkAdapter
+ );
}
}
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgCommandResultNotifier.java b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgCommandResultNotifier.java
index 73d5506396c7..45cfd6cfb6d1 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgCommandResultNotifier.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgCommandResultNotifier.java
@@ -12,14 +12,11 @@
// limitations under the License.
package org.zmlx.hg4idea.action;
-import com.intellij.notification.NotificationDisplayType;
-import com.intellij.notification.NotificationGroup;
import com.intellij.notification.NotificationListener;
-import com.intellij.notification.NotificationType;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager;
+import com.intellij.openapi.vcs.VcsNotifier;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -31,23 +28,11 @@ public final class HgCommandResultNotifier {
private final Project myProject;
private static final Logger LOG = Logger.getInstance(HgCommandResultNotifier.class);
- public static final NotificationGroup NOTIFICATION_GROUP = NotificationGroup.toolWindowGroup(
- "Mercurial Messages", ChangesViewContentManager.TOOLWINDOW_ID, true);
- public static final NotificationGroup IMPORTANT_ERROR_NOTIFICATION = new NotificationGroup(
- "Mercurial Important Messages", NotificationDisplayType.STICKY_BALLOON, true);
public HgCommandResultNotifier(Project project) {
myProject = project;
}
- public void notifySuccess(@NotNull String title, @NotNull String successDescription) {
- NOTIFICATION_GROUP.createNotification(title, successDescription, NotificationType.INFORMATION, null).notify(myProject);
- }
-
- public void notifyWarning(@NotNull String title, @NotNull String warningDescription) {
- NOTIFICATION_GROUP.createNotification(title, warningDescription, NotificationType.WARNING, null).notify(myProject);
- }
-
public void notifyError(@Nullable HgCommandResult result, @NotNull String failureTitle, @NotNull String failureDescription) {
notifyError(result, failureTitle, failureDescription, null);
}
@@ -75,8 +60,6 @@ public final class HgCommandResultNotifier {
errorMessage = XmlStringUtil.wrapInHtml(failureDescription + " " + StringUtil.join(err, " "));
}
}
- IMPORTANT_ERROR_NOTIFICATION
- .createNotification(failureTitle, errorMessage, NotificationType.ERROR, listener)
- .notify(myProject);
+ VcsNotifier.getInstance(myProject).notifyError(failureTitle, errorMessage, listener);
}
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgCommonBranchActions.java b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgCommonBranchActions.java
index 992a26c6ab5e..a8972f86939a 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgCommonBranchActions.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgCommonBranchActions.java
@@ -22,6 +22,7 @@ import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.VcsException;
+import com.intellij.openapi.vcs.VcsNotifier;
import com.intellij.openapi.vcs.update.UpdatedFiles;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
@@ -73,7 +74,6 @@ public class HgCommonBranchActions extends ActionGroup {
final HgMergeCommand hgMergeCommand = new HgMergeCommand(myProject, mySelectedRepository.getRoot());
hgMergeCommand.setRevision(myBranchName);//there is no difference between branch or revision or bookmark as parameter to merge,
// we need just a string
- final HgCommandResultNotifier notifier = new HgCommandResultNotifier(myProject);
new Task.Backgroundable(myProject, "Merging changes...") {
@Override
public void run(@NotNull ProgressIndicator indicator) {
@@ -84,11 +84,12 @@ public class HgCommonBranchActions extends ActionGroup {
}
catch (VcsException exception) {
+ assert myProject != null; // myProject couldn't be null, see annotation for Merge action
if (exception.isWarning()) {
- notifier.notifyWarning("Warning during merge", exception.getMessage());
+ VcsNotifier.getInstance(myProject).notifyWarning("Warning during merge", exception.getMessage());
}
else {
- notifier.notifyError(null, "Exception during merge", exception.getMessage());
+ VcsNotifier.getInstance(myProject).notifyError("Exception during merge", exception.getMessage());
}
}
catch (Exception e1) {
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgInit.java b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgInit.java
index 27346660015b..7d329a3f3652 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgInit.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgInit.java
@@ -2,12 +2,12 @@ package org.zmlx.hg4idea.action;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.VcsDirectoryMapping;
+import com.intellij.openapi.vcs.VcsNotifier;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.Nullable;
@@ -116,15 +116,17 @@ public class HgInit extends DumbAwareAction {
public void process(@Nullable HgCommandResult result) {
if (!HgErrorUtil.hasErrorsInCommandExecution(result)) {
updateDirectoryMappings(mapRoot);
- new HgCommandResultNotifier(myProject.isDefault() ? null : myProject)
- .notifySuccess(HgVcsMessages.message("hg4idea.init.created.notification.title"),
- HgVcsMessages.message("hg4idea.init.created.notification.description", selectedRoot.getPresentableUrl()));
+ VcsNotifier.getInstance(myProject).notifySuccess(HgVcsMessages.message("hg4idea.init.created.notification.title"),
+ HgVcsMessages.message("hg4idea.init.created.notification.description",
+ selectedRoot.getPresentableUrl())
+ );
}
else {
new HgCommandResultNotifier(myProject.isDefault() ? null : myProject)
.notifyError(result, HgVcsMessages.message("hg4idea.init.error.title"), HgVcsMessages.message("hg4idea.init.error.description",
selectedRoot
- .getPresentableUrl()));
+ .getPresentableUrl()
+ ));
}
}
});
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgMerge.java b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgMerge.java
index 87c907d76d59..1743e7e5b56e 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgMerge.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgMerge.java
@@ -19,6 +19,7 @@ import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.VcsException;
+import com.intellij.openapi.vcs.VcsNotifier;
import com.intellij.openapi.vcs.update.UpdatedFiles;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
@@ -62,7 +63,6 @@ public class HgMerge extends HgAbstractGlobalAction {
private static void executeMerge(@NotNull final Project project, @NotNull VirtualFile repo, @NotNull String targetValue)
throws HgCommandException {
UpdatedFiles updatedFiles = UpdatedFiles.create();
- HgCommandResultNotifier notifier = new HgCommandResultNotifier(project);
HgMergeCommand hgMergeCommand = new HgMergeCommand(project, repo);
hgMergeCommand.setRevision(targetValue);
@@ -73,10 +73,10 @@ public class HgMerge extends HgAbstractGlobalAction {
}
catch (VcsException e) {
if (e.isWarning()) {
- notifier.notifyWarning("Warning during merge", e.getMessage());
+ VcsNotifier.getInstance(project).notifyWarning("Warning during merge", e.getMessage());
}
else {
- notifier.notifyError(null, "Exception during merge", e.getMessage());
+ VcsNotifier.getInstance(project).notifyError("Exception during merge", e.getMessage());
}
}
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/roots/HgIntegrationEnabler.java b/plugins/hg4idea/src/org/zmlx/hg4idea/roots/HgIntegrationEnabler.java
new file mode 100644
index 000000000000..853c4d00ddc6
--- /dev/null
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/roots/HgIntegrationEnabler.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2000-2014 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 org.zmlx.hg4idea.roots;
+
+import com.intellij.openapi.vcs.VcsNotifier;
+import com.intellij.openapi.vcs.roots.VcsIntegrationEnabler;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.zmlx.hg4idea.HgVcs;
+import org.zmlx.hg4idea.HgVcsMessages;
+import org.zmlx.hg4idea.command.HgInitCommand;
+import org.zmlx.hg4idea.execution.HgCommandResult;
+import org.zmlx.hg4idea.execution.HgCommandResultHandler;
+import org.zmlx.hg4idea.util.HgErrorUtil;
+
+public class HgIntegrationEnabler extends VcsIntegrationEnabler {
+
+ public HgIntegrationEnabler(@NotNull HgVcs vcs) {
+ super(vcs);
+ }
+
+ @Override
+ protected boolean initOrNotifyError(@NotNull final VirtualFile projectDir) {
+ final boolean[] success = new boolean[1];
+ new HgInitCommand(myProject).execute(projectDir, new HgCommandResultHandler() {
+ @Override
+ public void process(@Nullable HgCommandResult result) {
+ VcsNotifier notification = VcsNotifier.getInstance(myProject);
+ if (!HgErrorUtil.hasErrorsInCommandExecution(result)) {
+ success[0] = true;
+ notification.notifySuccess(HgVcsMessages.message("hg4idea.init.created.notification.title"),
+ HgVcsMessages
+ .message("hg4idea.init.created.notification.description", projectDir.getPresentableUrl())
+ );
+ }
+ else {
+ success[0] = false;
+ String errors = result != null ? result.getRawError() : "";
+ notification.notifyError(
+ HgVcsMessages.message("hg4idea.init.error.description", projectDir.getPresentableUrl()), errors);
+ }
+ }
+ });
+ return success[0];
+ }
+}
From dbe037223ee360033cbd1828c3c7087a0614f453 Mon Sep 17 00:00:00 2001
From: nik
Date: Thu, 6 Mar 2014 17:14:24 +0400
Subject: [PATCH 036/172] memory leak fixed
---
.../impl/src/com/intellij/debugger/ui/impl/VariablesPanel.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/VariablesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/VariablesPanel.java
index 71e5ff878d70..8518230d495a 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/VariablesPanel.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/VariablesPanel.java
@@ -60,6 +60,7 @@ public class VariablesPanel extends DebuggerTreePanel implements DataProvider {
myCards.add(frameTree, TREE);
myXTree = new MyXVariablesView(project);
+ registerDisposable(myXTree);
myCards.add(myXTree.getTree(), X_TREE);
add(ScrollPaneFactory.createScrollPane(myCards), BorderLayout.CENTER);
From 400d1ff3308122966702eaddfe228df82dcba785 Mon Sep 17 00:00:00 2001
From: Konstantin Bulenkov
Date: Thu, 6 Mar 2014 14:24:06 +0100
Subject: [PATCH 037/172] one big comparator for ratings, downloads, updates
and status
---
.../ide/plugins/PluginManagerColumnInfo.java | 97 ++++++++-----------
1 file changed, 41 insertions(+), 56 deletions(-)
diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerColumnInfo.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerColumnInfo.java
index 591798ae8b70..90150d42aad0 100644
--- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerColumnInfo.java
+++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerColumnInfo.java
@@ -97,15 +97,15 @@ class PluginManagerColumnInfo extends ColumnInfo {
}
protected boolean isSortByName() {
- return COLUMN_NAME == columnIdx;
+ return !isSortByDate() && !isSortByDownloads() && !isSortByStatus();
}
protected boolean isSortByDownloads() {
- return columnIdx == COLUMN_DOWNLOADS;
+ return myModel.isSortByDownloads();
}
protected boolean isSortByDate() {
- return columnIdx == COLUMN_DATE;
+ return myModel.isSortByUpdated();
}
protected boolean isSortByStatus() {
@@ -167,76 +167,61 @@ class PluginManagerColumnInfo extends ColumnInfo {
}
protected Comparator getColumnComparator() {
- if (isSortByName()) {
- return new Comparator() {
- public int compare(IdeaPluginDescriptor o1, IdeaPluginDescriptor o2) {
- return StringUtil.compare(o1.getName(), o2.getName(), true);
- }
- };
- }
- if (columnIdx == COLUMN_RATE) {
- return new Comparator() {
- @Override
- public int compare(IdeaPluginDescriptor o1, IdeaPluginDescriptor o2) {
+ return new Comparator() {
+ public int compare(IdeaPluginDescriptor o1, IdeaPluginDescriptor o2) {
+ if (myModel.isSortByRating()) {
final String rating1 = ((PluginNode)o1).getRating();
final String rating2 = ((PluginNode)o2).getRating();
- return Comparing.compare(rating1, rating2);
+ final int compare = Comparing.compare(rating2, rating1);
+ if (compare != 0) {
+ return compare;
+ }
}
- };
- }
- if (isSortByDownloads()) {
- return new Comparator() {
- public int compare(IdeaPluginDescriptor o1, IdeaPluginDescriptor o2) {
+
+ if (isSortByDate()) {
+ long date1 = (o1 instanceof PluginNode) ? ((PluginNode)o1).getDate() : ((IdeaPluginDescriptorImpl)o1).getDate();
+ long date2 = (o2 instanceof PluginNode) ? ((PluginNode)o2).getDate() : ((IdeaPluginDescriptorImpl)o2).getDate();
+ date1 /= 60 * 1000;
+ date2 /= 60 * 1000;
+ if (date2 != date1) {
+ return date2 - date1 > 0L ? 1 : -1;
+ }
+ }
+
+ if (isSortByDownloads()) {
String count1 = o1.getDownloads();
String count2 = o2.getDownloads();
if (count1 != null && count2 != null) {
- return Long.valueOf(count1).compareTo(Long.valueOf(count2));
- }
- else if (count1 != null) {
- return -1;
+ final Long result = Long.valueOf(count2);
+ if (result != 0) {
+ return result.compareTo(Long.valueOf(count1));
+ }
}
else {
- return 1;
+ return count1 != null ? -1 : 1;
}
}
- };
- }
- if (isSortByDate()) {
- return new Comparator() {
- public int compare(IdeaPluginDescriptor o1, IdeaPluginDescriptor o2) {
- long date1 = (o1 instanceof PluginNode) ? ((PluginNode)o1).getDate() : ((IdeaPluginDescriptorImpl)o1).getDate();
- long date2 = (o2 instanceof PluginNode) ? ((PluginNode)o2).getDate() : ((IdeaPluginDescriptorImpl)o2).getDate();
- if (date1 < date2) {
- return -1;
- }
- else if (date1 > date2) return 1;
- return 0;
- }
- };
- }
- return new Comparator() {
- @Override
- public int compare(IdeaPluginDescriptor o1, IdeaPluginDescriptor o2) {
- return StringUtil.compare(o1.getCategory(), o2.getCategory(), true);
+
+ return StringUtil.compare(o1.getName(), o2.getName(), true);
}
};
}
- @SuppressWarnings({"HardCodedStringLiteral"})
- public static String getFormattedSize(String size) {
- if (size.equals("-1")) {
- return IdeBundle.message("plugin.info.unknown");
- }
- else if (size.length() >= 4) {
- if (size.length() < 7) {
- size = String.format("%.1f", (float)Integer.parseInt(size) / kByte) + " K";
+ @SuppressWarnings({"HardCodedStringLiteral"})
+ public static String getFormattedSize (String size){
+ if (size.equals("-1")) {
+ return IdeBundle.message("plugin.info.unknown");
}
- else {
- size = String.format("%.1f", (float)Integer.parseInt(size) / mgByte) + " M";
+ else if (size.length() >= 4) {
+ if (size.length() < 7) {
+ size = String.format("%.1f", (float)Integer.parseInt(size) / kByte) + " K";
+ }
+ else {
+ size = String.format("%.1f", (float)Integer.parseInt(size) / mgByte) + " M";
+ }
}
+ return size;
}
- return size;
- }
public static int getRealNodeState(PluginNode node) {
if (node.getStatus() == PluginNode.STATUS_DOWNLOADED) return PluginNode.STATUS_DOWNLOADED;
From 82a4f0d0e64ce1b1e8e0538d348754c38d0533df Mon Sep 17 00:00:00 2001
From: Max Medvedev
Date: Wed, 5 Mar 2014 14:01:58 +0400
Subject: [PATCH 038/172] IDEA-121318 optimizing whether place is child of
import statement. Actually place can be a child of an import statement only
if it is a GrCodeReferenceElement.
---
.../toplevel/imports/GrImportStatementImpl.java | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java
index 761cbeb31b6c..03e8016f08bf 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -25,7 +25,6 @@ import com.intellij.psi.stubs.IStubElementType;
import com.intellij.psi.util.CachedValueProvider;
import com.intellij.psi.util.CachedValuesManager;
import com.intellij.psi.util.PsiModificationTracker;
-import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -78,7 +77,7 @@ public class GrImportStatementImpl extends GrStubElementBase
Date: Thu, 6 Mar 2014 13:02:35 +0400
Subject: [PATCH 039/172] IDEA-121662 Unify Groovy and Java Intention behavior
---
.../annotator/GrReferenceHighlighter.java | 31 +++++++++----------
.../GroovyStaticImportMethodFix.java | 8 ++---
.../GrUnresolvedAccessInspection.java | 31 ++++++++++++-------
.../GroovyHighlightingTest.groovy | 11 +++++++
4 files changed, 48 insertions(+), 33 deletions(-)
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GrReferenceHighlighter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GrReferenceHighlighter.java
index 4d23980e30ac..78ae905b5850 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GrReferenceHighlighter.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GrReferenceHighlighter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -67,29 +67,26 @@ public class GrReferenceHighlighter extends TextEditorHighlightingPass {
final TextAttributesKey attribute = GrHighlightUtil.getDeclarationHighlightingAttribute(variable, null);
if (attribute != null) {
final PsiElement nameElement = variable.getNameIdentifierGroovy();
- assert myInfos != null;
- HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(nameElement);
- HighlightInfo info = builder.needsUpdateOnTyping(false).textAttributes(attribute).create();
- if (info != null) {
- myInfos.add(info);
- }
+ addInfo(attribute, nameElement);
}
}
}
-
private void visit(GrReferenceElement element) {
ProgressManager.checkCanceled();
final PsiElement resolved = element.resolve();
final TextAttributesKey attribute = GrHighlightUtil.getDeclarationHighlightingAttribute(resolved, element);
if (attribute != null) {
final PsiElement refNameElement = GrHighlightUtil.getElementToHighlight(element);
- assert myInfos != null;
- HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(refNameElement);
- HighlightInfo info = builder.needsUpdateOnTyping(false).textAttributes(attribute).create();
- if (info != null) {
- myInfos.add(info);
- }
+ addInfo(attribute, refNameElement);
+ }
+ }
+
+ private void addInfo(TextAttributesKey attribute, PsiElement nameElement) {
+ assert myInfos != null;
+ HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(nameElement).needsUpdateOnTyping(false).textAttributes(attribute).create();
+ if (info != null) {
+ myInfos.add(info);
}
}
};
@@ -100,10 +97,10 @@ public class GrReferenceHighlighter extends TextEditorHighlightingPass {
final int size = myInfos.size();
super.visitReferenceExpression(referenceExpression);
if (size == myInfos.size()) {
- HighlightInfo info = GrUnresolvedAccessInspection.checkReferenceExpression(referenceExpression);
- if (info != null) {
+ List infos = GrUnresolvedAccessInspection.checkReferenceExpression(referenceExpression);
+ if (infos != null) {
assert myInfos != null;
- myInfos.add(info);
+ myInfos.addAll(infos);
}
}
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyStaticImportMethodFix.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyStaticImportMethodFix.java
index d5b5132f0b9e..8b17f9c4d047 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyStaticImportMethodFix.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyStaticImportMethodFix.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -31,6 +31,7 @@ import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiShortNamesCache;
import com.intellij.psi.util.PsiFormatUtil;
+import com.intellij.psi.util.PsiFormatUtilBase;
import com.intellij.psi.util.proximity.PsiProximityComparator;
import com.intellij.ui.components.JBList;
import com.intellij.util.IncorrectOperationException;
@@ -65,7 +66,7 @@ public class GroovyStaticImportMethodFix extends Intention {
public String getText() {
String text = "Static Import Method";
if (getCandidates().size() == 1) {
- final int options = PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_CONTAINING_CLASS | PsiFormatUtil.SHOW_FQ_NAME;
+ final int options = PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_CONTAINING_CLASS | PsiFormatUtilBase.SHOW_FQ_NAME;
text += " '" + PsiFormatUtil.formatMethod(getCandidates().get(0), PsiSubstitutor.EMPTY, options, 0) + "'";
}
else {
@@ -87,8 +88,7 @@ public class GroovyStaticImportMethodFix extends Intention {
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
myCandidates = null;
- return myMethodCall != null &&
- myMethodCall.getElement() != null &&
+ return myMethodCall.getElement() != null &&
myMethodCall.getElement().isValid() &&
getMethodExpression(myMethodCall.getElement()) != null &&
getMethodExpression(myMethodCall.getElement()).getQualifierExpression() == null &&
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java
index 7259fa7cff67..6b58f99d0ddc 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java
@@ -88,6 +88,9 @@ import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
import org.jetbrains.plugins.groovy.util.LightCacheKey;
import javax.swing.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import java.util.Map;
import static com.intellij.psi.PsiModifier.STATIC;
@@ -173,9 +176,9 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo
}
@Nullable
- public static HighlightInfo checkReferenceExpression(GrReferenceExpression ref) {
- HighlightInfo info = checkRefInner(ref);
- addEmptyIntentionIfNeeded(info);
+ public static List checkReferenceExpression(GrReferenceExpression ref) {
+ List info = checkRefInner(ref);
+ addEmptyIntentionIfNeeded(ContainerUtil.getFirstItem(info));
return info;
}
@@ -251,7 +254,7 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo
}
@Nullable
- private static HighlightInfo checkRefInner(GrReferenceExpression ref) {
+ private static List checkRefInner(GrReferenceExpression ref) {
PsiElement refNameElement = ref.getReferenceNameElement();
if (refNameElement == null) return null;
@@ -263,7 +266,7 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo
if (!isStaticOk(resolveResult)) {
String message = GroovyBundle.message("cannot.reference.non.static", ref.getReferenceName());
- return createAnnotationForRef(ref, inStaticContext, message);
+ return Collections.singletonList(createAnnotationForRef(ref, inStaticContext, message));
}
return null;
@@ -288,9 +291,11 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo
HighlightInfo info = createAnnotationForRef(ref, inStaticContext, GroovyBundle.message("cannot.resolve", ref.getReferenceName()));
if (info == null) return null;
+ ArrayList result = ContainerUtil.newArrayList();
+ result.add(info);
HighlightDisplayKey displayKey = HighlightDisplayKey.find(SHORT_NAME);
if (ref.getParent() instanceof GrMethodCall) {
- registerStaticImportFix(ref, info, displayKey);
+ ContainerUtil.addIfNotNull(result, registerStaticImportFix(ref, displayKey));
}
else {
registerCreateClassByTypeFix(ref, info, displayKey);
@@ -300,7 +305,7 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo
registerReferenceFixes(ref, info, inStaticContext, displayKey);
UnresolvedReferenceQuickFixProvider.registerReferenceFixes(ref, new QuickFixActionRegistrarAdapter(info, displayKey));
OrderEntryFix.registerFixes(new QuickFixActionRegistrarAdapter(info, displayKey), ref);
- return info;
+ return result;
}
return null;
@@ -534,14 +539,16 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo
return HighlightInfo.newHighlightInfo(highlightInfoType).range(refNameElement).descriptionAndTooltip(message).create();
}
- private static void registerStaticImportFix(@NotNull GrReferenceExpression referenceExpression,
- @Nullable HighlightInfo info,
- @Nullable final HighlightDisplayKey key) {
+ private static HighlightInfo registerStaticImportFix(@NotNull GrReferenceExpression referenceExpression,
+ @Nullable final HighlightDisplayKey key) {
final String referenceName = referenceExpression.getReferenceName();
- if (StringUtil.isEmpty(referenceName)) return;
- if (referenceExpression.getQualifier() != null) return;
+ if (StringUtil.isEmpty(referenceName)) return null;
+ if (referenceExpression.getQualifier() != null) return null;
+ HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(
+ referenceExpression.getParent()).createUnconditionally();
QuickFixAction.registerQuickFixAction(info, new GroovyStaticImportMethodFix((GrMethodCall)referenceExpression.getParent()), key);
+ return info;
}
private static void registerReferenceFixes(GrReferenceExpression refExpr,
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy
index 0405449ee0f5..0b6f00de9d2e 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy
@@ -1789,4 +1789,15 @@ public class Bar3 { }
''')
}
+ void testImportStaticFix() {
+ myFixture.configureByText('a.groovy', '''
+class A {
+ static void foo(String s){}
+}
+
+foo()
+''')
+
+ myFixture.getAvailableIntention("Static Import Method 'A.foo'")
+ }
}
\ No newline at end of file
From 2bc747efa3fe7f839208df1cdf5ed95bc36d52dc Mon Sep 17 00:00:00 2001
From: Max Medvedev
Date: Thu, 6 Mar 2014 13:11:15 +0400
Subject: [PATCH 040/172] Groovy: import static intention should be available
on argument list
---
.../style/ImportStaticIntention.java | 88 ++++++++++++-------
1 file changed, 56 insertions(+), 32 deletions(-)
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/ImportStaticIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/ImportStaticIntention.java
index c5bea4a6709a..7bccfea8a963 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/ImportStaticIntention.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/ImportStaticIntention.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -23,13 +23,17 @@ import com.intellij.psi.search.LocalSearchScope;
import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.codeStyle.GrReferenceAdjuster;
import org.jetbrains.plugins.groovy.intentions.base.Intention;
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
import org.jetbrains.plugins.groovy.lang.psi.GrQualifiedReference;
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
import org.jetbrains.plugins.groovy.lang.psi.GroovyRecursiveElementVisitor;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList;
@@ -41,27 +45,19 @@ public class ImportStaticIntention extends Intention {
private static final Key TEMP_REFERENT_USER_DATA = new Key("TEMP_REFERENT_USER_DATA");
@Override
- protected void processIntention(@NotNull PsiElement element, final Project project, final Editor editor)
- throws IncorrectOperationException {
- final PsiElement resolved;
- final String name;
- final GroovyFile file;
- final GrImportStatement importStatement;
- boolean isAnythingShortened;
- if (!(element instanceof GrReferenceExpression)) return;
- final GrReferenceExpression ref = (GrReferenceExpression)element;
- resolved = ref.resolve();
+ protected void processIntention(@NotNull PsiElement element, final Project project, final Editor editor) throws IncorrectOperationException {
+ final PsiElement resolved = resolve(element);
if (!(resolved instanceof PsiMember)) return;
final PsiClass containingClass = ((PsiMember)resolved).getContainingClass();
if (containingClass == null) return;
final String qname = containingClass.getQualifiedName();
- name = ((PsiMember)resolved).getName();
+ final String name = ((PsiMember)resolved).getName();
if (name == null) return;
final PsiFile containingFile = element.getContainingFile();
if (!(containingFile instanceof GroovyFile)) return;
- file = (GroovyFile)containingFile;
+ final GroovyFile file = (GroovyFile)containingFile;
file.accept(new GroovyRecursiveElementVisitor() {
@Override
public void visitReferenceExpression(GrReferenceExpression expression) {
@@ -77,17 +73,9 @@ public class ImportStaticIntention extends Intention {
final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(project);
final GrImportStatement tempImport = factory.createImportStatementFromText(qname + "." + name, true, false, null);
- importStatement = file.addImport(tempImport);
-
- isAnythingShortened = false;
- for (PsiReference reference : ReferencesSearch.search(resolved, new LocalSearchScope(containingFile))) {
- final PsiElement refElement = reference.getElement();
- if (refElement instanceof GrQualifiedReference>) {
- isAnythingShortened |=
- org.jetbrains.plugins.groovy.codeStyle.GrReferenceAdjuster.shortenReference((GrQualifiedReference>)refElement);
- }
- }
+ final GrImportStatement importStatement = file.addImport(tempImport);
+ boolean isAnythingShortened = shortenUsages(resolved, containingFile);
if (!isAnythingShortened) {
importStatement.delete();
return;
@@ -111,7 +99,7 @@ public class ImportStaticIntention extends Intention {
if (qualifier instanceof GrReferenceExpression) {
PsiElement aClass = ((GrReferenceExpression)qualifier).resolve();
if (aClass == ((PsiMember)resolved).getContainingClass()) {
- org.jetbrains.plugins.groovy.codeStyle.GrReferenceAdjuster.shortenReference(expression);
+ GrReferenceAdjuster.shortenReference(expression);
}
}
}
@@ -129,6 +117,18 @@ public class ImportStaticIntention extends Intention {
});
}
+ private static boolean shortenUsages(PsiElement resolved, PsiFile containingFile) {
+ boolean isAnythingShortened = false;
+ for (PsiReference reference : ReferencesSearch.search(resolved, new LocalSearchScope(containingFile))) {
+ final PsiElement refElement = reference.getElement();
+ if (refElement instanceof GrQualifiedReference>) {
+ boolean shortened = GrReferenceAdjuster.shortenReference((GrQualifiedReference>)refElement);
+ isAnythingShortened |= shortened;
+ }
+ }
+ return isAnythingShortened;
+ }
+
@Override
protected boolean isStopElement(PsiElement element) {
return super.isStopElement(element) || element instanceof GrReferenceExpression;
@@ -140,15 +140,39 @@ public class ImportStaticIntention extends Intention {
return new PsiElementPredicate() {
@Override
public boolean satisfiedBy(PsiElement element) {
- if (!(element instanceof GrReferenceExpression)) return false;
- final GrReferenceExpression ref = (GrReferenceExpression)element;
- if (ref.getQualifier() == null) return false;
- final PsiElement resolved = ref.resolve();
- if (resolved == null) return false;
- return resolved instanceof PsiMember && !(resolved instanceof PsiClass) &&
- ((PsiMember)resolved).hasModifierProperty(PsiModifier.STATIC) &&
- ((PsiMember)resolved).getContainingClass() != null;
+ final PsiElement resolved = resolve(element);
+
+ if (resolved == null) return false;
+ return resolved instanceof PsiMember && !(resolved instanceof PsiClass) &&
+ ((PsiMember)resolved).hasModifierProperty(PsiModifier.STATIC) &&
+ ((PsiMember)resolved).getContainingClass() != null;
}
};
}
+
+ @Nullable
+ private static PsiElement resolve(PsiElement element) {
+ GrReferenceExpression ref = findRef(element);
+
+ if (ref == null || ref.getQualifier() == null) return null;
+ return ref.resolve();
+ }
+
+ @Nullable
+ private static GrReferenceExpression findRef(PsiElement element) {
+ if ((element instanceof GrReferenceExpression)) {
+ return (GrReferenceExpression)element;
+
+ }
+ else if (element instanceof GrArgumentList) {
+ PsiElement parent = element.getParent();
+ if (parent instanceof GrMethodCall) {
+ GrExpression invoked = ((GrMethodCall)parent).getInvokedExpression();
+ if (invoked instanceof GrReferenceExpression) {
+ return ((GrReferenceExpression)invoked);
+ }
+ }
+ }
+ return null;
+ }
}
From 812d0d6201c9399666ec05a3d5ca0cfe5ccd9b5e Mon Sep 17 00:00:00 2001
From: Max Medvedev
Date: Thu, 6 Mar 2014 17:23:10 +0400
Subject: [PATCH 041/172] Groovy: remove redundant GrDefaultAnnotationValue
psi.
---
.../groovy/annotator/GroovyAnnotator.java | 10 ++--
.../processors/GroovyIndentProcessor.java | 15 +++---
.../processors/GroovySpacingProcessor.java | 3 +-
.../groovy/lang/parser/GroovyPsiCreator.java | 4 +-
.../declaration/VariableDefinitions.java | 5 +-
.../groovy/lang/psi/GroovyElementVisitor.java | 4 --
.../statements/GrDefaultAnnotationValue.java | 30 ------------
.../typedef/members/GrAnnotationMethod.java | 7 +--
.../GroovyExpectedTypesProvider.java | 6 +--
.../GrDefaultAnnotationValueImpl.java | 47 -------------------
.../members/GrAnnotationMethodImpl.java | 8 ++--
.../convertToJava/ClassItemGeneratorImpl.java | 12 ++---
.../parsing/groovy/types/ann_def3.test | 15 +++---
.../parsing/groovy/types/default1.test | 17 ++++---
.../parsing/groovy/types/default2.test | 9 ++--
15 files changed, 51 insertions(+), 141 deletions(-)
delete mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrDefaultAnnotationValue.java
delete mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrDefaultAnnotationValueImpl.java
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java
index 4f7ebf4bbcd4..a53647ea40ec 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java
@@ -1493,13 +1493,13 @@ public class GroovyAnnotator extends GroovyElementVisitor {
}
@Override
- public void visitDefaultAnnotationValue(GrDefaultAnnotationValue defaultAnnotationValue) {
- final GrAnnotationMemberValue value = defaultAnnotationValue.getDefaultValue();
+ public void visitAnnotationMethod(GrAnnotationMethod annotationMethod) {
+ super.visitAnnotationMethod(annotationMethod);
+
+ final GrAnnotationMemberValue value = annotationMethod.getDefaultValue();
if (value == null) return;
- final PsiElement parent = defaultAnnotationValue.getParent();
- assert parent instanceof GrAnnotationMethod;
- final PsiType type = ((GrAnnotationMethod)parent).getReturnType();
+ final PsiType type = annotationMethod.getReturnType();
Map errors = ContainerUtil.newHashMap();
CustomAnnotationChecker.checkAnnotationValueByType(errors, value, type, false);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java
index c81df59cd7fa..b004679e8fb9 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java
@@ -36,10 +36,7 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrThrowsClause;
-import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
-import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationArgumentList;
-import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationArrayInitializer;
-import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationNameValuePair;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.*;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.*;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
@@ -55,6 +52,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrExtendsCla
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrImplementsClause;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAnnotationMethod;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList;
@@ -407,8 +405,13 @@ public class GroovyIndentProcessor extends GroovyElementVisitor {
}
@Override
- public void visitDefaultAnnotationValue(GrDefaultAnnotationValue defaultAnnotationValue) {
- myResult = Indent.getContinuationIndent();
+ public void visitAnnotationMethod(GrAnnotationMethod annotationMethod) {
+ if (myChild instanceof GrAnnotationMemberValue) {
+ myResult = Indent.getContinuationIndent();
+ }
+ else {
+ super.visitAnnotationMethod(annotationMethod);
+ }
}
@Override
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java
index e64154c3a14b..fd2e9bd42516 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java
@@ -69,6 +69,7 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
import static org.jetbrains.plugins.groovy.GroovyFileType.GROOVY_LANGUAGE;
import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.*;
import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.GROOVY_DOC_COMMENT;
+import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.kDEFAULT;
import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.kIN;
import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.mCOMMA;
import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.mELVIS;
@@ -684,7 +685,7 @@ public class GroovySpacingProcessor extends GroovyElementVisitor {
@Override
public void visitAnnotationMethod(GrAnnotationMethod annotationMethod) {
- if (myType2 == DEFAULT_ANNOTATION_VALUE) {
+ if (myType2 == kDEFAULT) {
createSpaceInCode(true);
}
else {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyPsiCreator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyPsiCreator.java
index a071bd23a3f5..a7f0524baddd 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyPsiCreator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyPsiCreator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -104,8 +104,6 @@ public class GroovyPsiCreator implements GroovyElementTypes {
if (elem == ANNOTATION_ARRAY_INITIALIZER) return new GrAnnotationArrayInitializerImpl(node);
if (elem == ANNOTATION_MEMBER_VALUE_PAIR) return new GrAnnotationNameValuePairImpl(node);
- if (elem == DEFAULT_ANNOTATION_VALUE) return new GrDefaultAnnotationValueImpl(node);
-
//throws
if (elem == THROW_CLAUSE) return new GrThrowsClauseImpl(node);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/declaration/VariableDefinitions.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/declaration/VariableDefinitions.java
index 80d0ee6c32a7..fa4db282a732 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/declaration/VariableDefinitions.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/declaration/VariableDefinitions.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -152,15 +152,12 @@ public class VariableDefinitions implements GroovyElementTypes {
}
if (isAnnotationMember && builder.getTokenType() == kDEFAULT) {
- PsiBuilder.Marker defaultValueMarker = builder.mark();
ParserUtils.getToken(builder, kDEFAULT);
ParserUtils.getToken(builder, mNLS);
if (!AnnotationArguments.parseAnnotationMemberValueInitializer(builder, parser)) {
builder.error(GroovyBundle.message("annotation.initializer.expected"));
}
-
- defaultValueMarker.done(DEFAULT_ANNOTATION_VALUE);
}
if (ParserUtils.lookAhead(builder, mNLS, kTHROWS) || ParserUtils.lookAhead(builder, mNLS, mLCURLY)) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyElementVisitor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyElementVisitor.java
index c548b56eafdd..bf65baa23c6e 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyElementVisitor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyElementVisitor.java
@@ -296,10 +296,6 @@ public abstract class GroovyElementVisitor {
visitMethod(annotationMethod);
}
- public void visitDefaultAnnotationValue(GrDefaultAnnotationValue defaultAnnotationValue) {
- visitElement(defaultAnnotationValue);
- }
-
public void visitMethod(GrMethod method) {
visitElement(method);
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrDefaultAnnotationValue.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrDefaultAnnotationValue.java
deleted file mode 100644
index 84bd256cc2d0..000000000000
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrDefaultAnnotationValue.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2000-2009 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 org.jetbrains.plugins.groovy.lang.psi.api.statements;
-
-import com.intellij.psi.PsiAnnotationMemberValue;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
-import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationMemberValue;
-
-/**
- * User: Dmitry.Krasilschikov
- * Date: 04.06.2007
- */
-public interface GrDefaultAnnotationValue extends GroovyPsiElement, PsiAnnotationMemberValue {
- @Nullable
- GrAnnotationMemberValue getDefaultValue();
-}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/typedef/members/GrAnnotationMethod.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/typedef/members/GrAnnotationMethod.java
index be21a511ea31..255abd0339e3 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/typedef/members/GrAnnotationMethod.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/typedef/members/GrAnnotationMethod.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -17,13 +17,14 @@ package org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members;
import com.intellij.psi.PsiAnnotationMethod;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrDefaultAnnotationValue;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationMemberValue;
/**
* User: Dmitry.Krasilschikov
* Date: 04.06.2007
*/
public interface GrAnnotationMethod extends GrMethod, PsiAnnotationMethod {
+
@Nullable
- GrDefaultAnnotationValue getDefaultValue();
+ GrAnnotationMemberValue getDefaultValue();
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/expectedTypes/GroovyExpectedTypesProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/expectedTypes/GroovyExpectedTypesProvider.java
index 1d541a0b83c2..bc48bb2a043a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/expectedTypes/GroovyExpectedTypesProvider.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/expectedTypes/GroovyExpectedTypesProvider.java
@@ -205,9 +205,7 @@ public class GroovyExpectedTypesProvider {
}
@Override
- public void visitDefaultAnnotationValue(GrDefaultAnnotationValue defaultAnnotationValue) {
- final GrAnnotationMethod method = ((GrAnnotationMethod)defaultAnnotationValue.getParent());
-
+ public void visitAnnotationMethod(GrAnnotationMethod method) {
PsiType type = method.getReturnType();
if (type != null && isAcceptableAnnotationValueType(type)) {
myResult = createSimpleSubTypeResult(type);
@@ -216,7 +214,7 @@ public class GroovyExpectedTypesProvider {
@Override
public void visitAnnotationArrayInitializer(GrAnnotationArrayInitializer arrayInitializer) {
- final GrAnnotationNameValuePair nameValuePair = PsiTreeUtil.getParentOfType(arrayInitializer, GrAnnotationNameValuePair.class, true, GrDefaultAnnotationValue.class);
+ final GrAnnotationNameValuePair nameValuePair = PsiTreeUtil.getParentOfType(arrayInitializer, GrAnnotationNameValuePair.class, true, GrAnnotationMethod.class);
if (nameValuePair != null) {
final PsiClass annot = ResolveUtil.resolveAnnotation(arrayInitializer);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrDefaultAnnotationValueImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrDefaultAnnotationValueImpl.java
deleted file mode 100644
index cb878623a383..000000000000
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrDefaultAnnotationValueImpl.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2000-2009 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 org.jetbrains.plugins.groovy.lang.psi.impl.statements;
-
-import com.intellij.lang.ASTNode;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
-import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationMemberValue;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrDefaultAnnotationValue;
-import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl;
-
-/**
- * User: Dmitry.Krasilschikov
- * Date: 04.06.2007
- */
-public class GrDefaultAnnotationValueImpl extends GroovyPsiElementImpl implements GrDefaultAnnotationValue {
-
- public GrDefaultAnnotationValueImpl(@NotNull ASTNode node) {
- super(node);
- }
-
- public void accept(GroovyElementVisitor visitor) {
- visitor.visitDefaultAnnotationValue(this);
- }
-
- public String toString() {
- return "Default annotation value";
- }
-
- @Override
- public GrAnnotationMemberValue getDefaultValue() {
- return findChildByClass(GrAnnotationMemberValue.class);
- }
-}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/members/GrAnnotationMethodImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/members/GrAnnotationMethodImpl.java
index 2286e4a59b6b..69f345555c84 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/members/GrAnnotationMethodImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/members/GrAnnotationMethodImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.extensions.NamedArgumentDescriptor;
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrDefaultAnnotationValue;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationMemberValue;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAnnotationMethod;
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrMethodStub;
@@ -54,7 +54,7 @@ public class GrAnnotationMethodImpl extends GrMethodBaseImpl implements GrAnnota
}
@Override
- public GrDefaultAnnotationValue getDefaultValue() {
- return findChildByClass(GrDefaultAnnotationValue.class);
+ public GrAnnotationMemberValue getDefaultValue() {
+ return findChildByClass(GrAnnotationMemberValue.class);
}
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ClassItemGeneratorImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ClassItemGeneratorImpl.java
index bf29ed895839..aa3c11df8022 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ClassItemGeneratorImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ClassItemGeneratorImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -32,7 +32,6 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationMemberValue;
import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrClosureSignature;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrDefaultAnnotationValue;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
@@ -139,13 +138,10 @@ public class ClassItemGeneratorImpl implements ClassItemGenerator {
GenerationUtil.writeParameterList(builder, method.getParameterList().getParameters(), classNameProvider, context);
if (method instanceof GrAnnotationMethod) {
- GrDefaultAnnotationValue defaultAnnotationValue = ((GrAnnotationMethod)method).getDefaultValue();
- if (defaultAnnotationValue!=null) {
+ GrAnnotationMemberValue defaultValue = ((GrAnnotationMethod)method).getDefaultValue();
+ if (defaultValue != null) {
builder.append("default ");
- GrAnnotationMemberValue defaultValue = defaultAnnotationValue.getDefaultValue();
- if (defaultValue != null) {
- defaultValue.accept(new AnnotationGenerator(builder, context));
- }
+ defaultValue.accept(new AnnotationGenerator(builder, context));
}
}
diff --git a/plugins/groovy/testdata/parsing/groovy/types/ann_def3.test b/plugins/groovy/testdata/parsing/groovy/types/ann_def3.test
index 026b3d40209c..4c35706139e2 100644
--- a/plugins/groovy/testdata/parsing/groovy/types/ann_def3.test
+++ b/plugins/groovy/testdata/parsing/groovy/types/ann_def3.test
@@ -31,14 +31,13 @@ Groovy script
PsiElement())(')')
PsiWhiteSpace(' ')
- Default annotation value
- PsiElement(default)('default')
- PsiWhiteSpace(' ')
- Annotation array initializer
- PsiElement([)('[')
- Literal
- PsiElement(Integer)('8')
- PsiElement(])(']')
+ PsiElement(default)('default')
+ PsiWhiteSpace(' ')
+ Annotation array initializer
+ PsiElement([)('[')
+ Literal
+ PsiElement(Integer)('8')
+ PsiElement(])(']')
Throw clause
PsiElement(;)(';')
diff --git a/plugins/groovy/testdata/parsing/groovy/types/default1.test b/plugins/groovy/testdata/parsing/groovy/types/default1.test
index 94cc6ece5f07..46d59f6653be 100644
--- a/plugins/groovy/testdata/parsing/groovy/types/default1.test
+++ b/plugins/groovy/testdata/parsing/groovy/types/default1.test
@@ -34,15 +34,14 @@ Groovy script
PsiElement())(')')
PsiWhiteSpace(' ')
- Default annotation value
- PsiElement(default)('default')
- PsiWhiteSpace(' ')
- Annotation
- PsiElement(@)('@')
- Reference element
- PsiElement(identifier)('Bar')
- Annotation arguments
-
+ PsiElement(default)('default')
+ PsiWhiteSpace(' ')
+ Annotation
+ PsiElement(@)('@')
+ Reference element
+ PsiElement(identifier)('Bar')
+ Annotation arguments
+
Throw clause
PsiWhiteSpace(' ')
diff --git a/plugins/groovy/testdata/parsing/groovy/types/default2.test b/plugins/groovy/testdata/parsing/groovy/types/default2.test
index 05a31b6762d9..026bb8c470df 100644
--- a/plugins/groovy/testdata/parsing/groovy/types/default2.test
+++ b/plugins/groovy/testdata/parsing/groovy/types/default2.test
@@ -34,11 +34,10 @@ Groovy script
PsiElement())(')')
PsiWhiteSpace(' ')
- Default annotation value
- PsiElement(default)('default')
- PsiWhiteSpace(' ')
- Literal
- PsiElement(Integer)('5')
+ PsiElement(default)('default')
+ PsiWhiteSpace(' ')
+ Literal
+ PsiElement(Integer)('5')
Throw clause
PsiElement(new line)('\n')
From 1766d0603b160cebe9c2abb7c59c523a1640d03d Mon Sep 17 00:00:00 2001
From: Max Medvedev
Date: Thu, 6 Mar 2014 17:30:45 +0400
Subject: [PATCH 042/172] Groovy: fix parameter info
---
.../GroovyAnnotationAttributeInfoHandler.java | 5 ++---
.../GroovyTypeParameterInfoHandler.java | 17 ++++++++---------
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyAnnotationAttributeInfoHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyAnnotationAttributeInfoHandler.java
index 8d6705087992..35030c19110a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyAnnotationAttributeInfoHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyAnnotationAttributeInfoHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -18,7 +18,6 @@ package org.jetbrains.plugins.groovy.lang.parameterInfo;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.lang.parameterInfo.*;
import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.PsiTreeUtil;
@@ -197,6 +196,6 @@ public class GroovyAnnotationAttributeInfoHandler implements ParameterInfoHandle
}
- context.setupUIComponentPresentation(StringUtil.escapeXml(buffer.toString()), highlightStartOffset, highlightEndOffset, false, p.isDeprecated(), false, context.getDefaultParameterColor());
+ context.setupUIComponentPresentation(buffer.toString(), highlightStartOffset, highlightEndOffset, false, p.isDeprecated(), false, context.getDefaultParameterColor());
}
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyTypeParameterInfoHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyTypeParameterInfoHandler.java
index 4924d0175b33..2e54bef62d8e 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyTypeParameterInfoHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyTypeParameterInfoHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -34,7 +34,6 @@ import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList;
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
-import java.util.Arrays;
import java.util.Set;
/**
@@ -156,13 +155,13 @@ public class GroovyTypeParameterInfoHandler implements ParameterInfoHandlerWithT
buffer.append(p.getName());
int highlightEndOffset = buffer.length();
buffer.append(" extends ");
- buffer.append(StringUtil.join(Arrays.asList(p.getSuperTypes()), new Function() {
- @Override
- public String fun(final PsiClassType t) {
- return t.getPresentableText();
- }
- }, ", "));
+ buffer.append(StringUtil.join(p.getSuperTypes(), new Function() {
+ @Override
+ public String fun(final PsiClassType t) {
+ return t.getPresentableText();
+ }
+ }, ", "));
- context.setupUIComponentPresentation(StringUtil.escapeXml(buffer.toString()), 0, highlightEndOffset, false, false, false, context.getDefaultParameterColor());
+ context.setupUIComponentPresentation(buffer.toString(), 0, highlightEndOffset, false, false, false, context.getDefaultParameterColor());
}
}
From 5a54361be1c3091d866a958d082e82501fc401d1 Mon Sep 17 00:00:00 2001
From: Sergey Evdokimov
Date: Thu, 6 Mar 2014 17:37:54 +0400
Subject: [PATCH 043/172] IDEA-116134 Inherited maven resource filtering is not
applied
---
.../jps/incremental/fs/FilesDelta.java | 7 ++---
.../maven/compiler/ResourceFilteringTest.java | 27 +++++++++++++++++++
2 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/fs/FilesDelta.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/fs/FilesDelta.java
index 689db8ac814f..334ba15f4a88 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/incremental/fs/FilesDelta.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/fs/FilesDelta.java
@@ -30,17 +30,14 @@ import java.io.DataInput;
import java.io.DataOutput;
import java.io.File;
import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/** @noinspection SynchronizationOnLocalVariableOrMethodParameter*/
final class FilesDelta {
private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.incremental.fs.FilesDelta");
private final Set myDeletedPaths = Collections.synchronizedSet(new THashSet(FileUtil.PATH_HASHING_STRATEGY));
- private final Map> myFilesToRecompile = Collections.synchronizedMap(new HashMap>());
+ private final Map> myFilesToRecompile = Collections.synchronizedMap(new LinkedHashMap>());
public void save(DataOutput out) throws IOException {
out.writeInt(myDeletedPaths.size());
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java
index 1a27f94ff708..db4c1a213eae 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java
@@ -998,4 +998,31 @@ public abstract class ResourceFilteringTest extends MavenCompilingTestCase {
assertNotNull(myProjectPom.getParent().findFileByRelativePath("target/classes/file.xyz"));
}
+
+ public void testTwoResourcesMapping() throws Exception {
+ createProjectSubFile("resources/file.properties", "value=${project.version}\n");
+
+ importProject("test" +
+ "project" +
+ "1" +
+ "" +
+
+ "" +
+ " " +
+ " " +
+ " resources" +
+ " false" +
+ " " +
+ " " +
+ " resources" +
+ " true" +
+ " " +
+ " " +
+ "");
+
+ compileModules("project");
+
+ assertResult("target/classes/file.properties", "value=1\n");
+ }
+
}
From 675fa42c8050fbd2f82ac7637a07d844b8c21fb4 Mon Sep 17 00:00:00 2001
From: Max Medvedev
Date: Thu, 6 Mar 2014 17:44:13 +0400
Subject: [PATCH 044/172] fix tests. Rebinding for 'def' reference should do
nothing because it references to an inferred variable's type or to a variable
itself.
---
.../psi/impl/statements/GrVariableDeclarationImpl.java | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrVariableDeclarationImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrVariableDeclarationImpl.java
index 6e312234decb..e1ef4491d27b 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrVariableDeclarationImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrVariableDeclarationImpl.java
@@ -242,6 +242,11 @@ public class GrVariableDeclarationImpl extends GrStubElementBase impl
public Object[] getVariants() {
return EMPTY_ARRAY;
}
+
+ @Override
+ public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
+ return getElement();
+ }
};
}
else {
@@ -257,6 +262,11 @@ public class GrVariableDeclarationImpl extends GrStubElementBase impl
public Object[] getVariants() {
return EMPTY_ARRAY;
}
+
+ @Override
+ public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
+ return getElement();
+ }
};
}
}
From e14e9137aa95c2a5baa707660310978a1b0fa66c Mon Sep 17 00:00:00 2001
From: "Egor.Ushakov"
Date: Thu, 6 Mar 2014 17:54:52 +0400
Subject: [PATCH 045/172] IDEA-121739 Debugger doesn't stop on breakpoints in
some anonymous classes
---
.../debugger/engine/PositionManagerImpl.java | 34 +++++++++++++++++--
1 file changed, 31 insertions(+), 3 deletions(-)
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java
index cd6944c31952..b3e371d7e327 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java
@@ -29,7 +29,6 @@ import com.intellij.openapi.util.NullableComputable;
import com.intellij.openapi.util.Ref;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.sun.jdi.AbsentInformationException;
import com.sun.jdi.Location;
@@ -258,14 +257,43 @@ public class PositionManagerImpl implements PositionManager {
private static int getNestingDepth(PsiClass aClass) {
int depth = 0;
- PsiClass enclosing = PsiTreeUtil.getParentOfType(aClass, PsiClass.class, true);
+ PsiClass enclosing = getEnclosingClass(aClass);
while (enclosing != null) {
depth++;
- enclosing = PsiTreeUtil.getParentOfType(enclosing, PsiClass.class, true);
+ enclosing = getEnclosingClass(enclosing);
}
return depth;
}
+ /**
+ * See IDEA-121739
+ * Anonymous classes inside other anonymous class parameters list should belong to parent class
+ * Inner in = new Inner(new Inner2(){}) {};
+ * Parent of Inner2 sub class here is not Inner sub class
+ */
+ private static PsiClass getEnclosingClass(PsiElement element) {
+ if (element == null) {
+ return null;
+ }
+
+ element = element.getParent();
+ PsiElement previous = null;
+
+ while (element != null) {
+ if (PsiClass.class.isInstance(element) && !(previous instanceof PsiExpressionList)) {
+ //noinspection unchecked
+ return (PsiClass)element;
+ }
+ if (element instanceof PsiFile) {
+ return null;
+ }
+ previous = element;
+ element = element.getParent();
+ }
+
+ return null;
+ }
+
@Nullable
private ReferenceType findNested(final ReferenceType fromClass, final int currentDepth, final PsiClass classToFind, final int requiredDepth, final SourcePosition position) {
final VirtualMachineProxyImpl vmProxy = myDebugProcess.getVirtualMachineProxy();
From fce20a5d464638920bfea6215a3f35a1c12f35d0 Mon Sep 17 00:00:00 2001
From: "Egor.Ushakov"
Date: Thu, 6 Mar 2014 18:00:17 +0400
Subject: [PATCH 046/172] IDEA-121764 Debugger does not show null values
---
.../src/com/intellij/debugger/engine/DebugProcessImpl.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java
index b660d5f1ed6e..07bfe319d62f 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java
@@ -72,12 +72,12 @@ import com.intellij.util.EventDispatcher;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.containers.HashMap;
import com.sun.jdi.*;
import com.sun.jdi.connect.*;
import com.sun.jdi.request.EventRequest;
import com.sun.jdi.request.EventRequestManager;
import com.sun.jdi.request.StepRequest;
-import gnu.trove.THashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -119,7 +119,10 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
private Map myArguments;
private final List myRenderers = new ArrayList();
- private final Map myNodeRenderersMap = new THashMap();
+
+ // we use null key here
+ private final Map myNodeRenderersMap = new HashMap();
+
private final NodeRendererSettingsListener mySettingsListener = new NodeRendererSettingsListener() {
@Override
public void renderersChanged() {
From 039520b4ad6bf200811b0c050b6fbfb1f5749fff Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Tue, 11 Feb 2014 20:05:40 +0400
Subject: [PATCH 047/172] Graph Black Box refactoring initial step
---
.../com/intellij/vcs/log/GraphBlackBox.java | 86 +++++++++++++++++++
1 file changed, 86 insertions(+)
create mode 100644 platform/vcs-log/graph/src/com/intellij/vcs/log/GraphBlackBox.java
diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/GraphBlackBox.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/GraphBlackBox.java
new file mode 100644
index 000000000000..ac34bd338fc4
--- /dev/null
+++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/GraphBlackBox.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2000-2014 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.vcs.log;
+
+import com.intellij.openapi.util.Condition;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.awt.*;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * The only point of interaction with the Graph.
+ */
+public interface GraphBlackBox {
+
+ void paint(Graphics2D g, int visibleRow);
+
+ @Nullable
+ GraphChangeEvent performAction(@NotNull GraphAction action);
+
+ @NotNull
+ List getAllCommits();
+
+ @NotNull
+ List getVisibleCommits();
+
+ void setVisibleBranches(@Nullable Collection heads);
+
+ void setFilter(Condition visibilityPredicate);
+
+ GraphInfoProvider getInfoProvider();
+
+ interface GraphInfoProvider {
+ int getOneOfHeads(int commit); // this is fast
+ Set getContainingBranches(int commitIndex); // this requires graph iteration => can take some time
+ RowInfo getRowInfo(int visibleRow);
+ }
+
+ /**
+ * Some information about row highlighting etc.
+ */
+ interface RowInfo {
+
+ }
+
+ interface GraphAction {
+ }
+
+ class ClickGraphAction implements GraphAction {
+ int visibleRow;
+ Point relativePoint;
+ }
+
+ class HoverGraphAction implements GraphAction {
+ int visibleRow;
+ Point relativePoint;
+ }
+
+ class LinearBranchesExpansionAction implements GraphAction {
+ boolean expanded; // or collapsed
+ }
+
+ class LongEdgesAction implements GraphAction {
+ boolean show;
+ }
+
+ interface GraphChangeEvent {
+ }
+
+}
From 81488e4ad118f62caa5b2d29a1921226f229aae1 Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Thu, 13 Feb 2014 16:01:20 +0400
Subject: [PATCH 048/172] some javadocs & GraphInfoProvider extraction
---
.../vcs/log/graph}/GraphBlackBox.java | 40 +++++++++++--------
.../vcs/log/graph/GraphInfoProvider.java | 38 ++++++++++++++++++
2 files changed, 61 insertions(+), 17 deletions(-)
rename platform/vcs-log/{graph/src/com/intellij/vcs/log => api/src/com/intellij/vcs/log/graph}/GraphBlackBox.java (62%)
create mode 100644 platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java
diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/GraphBlackBox.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
similarity index 62%
rename from platform/vcs-log/graph/src/com/intellij/vcs/log/GraphBlackBox.java
rename to platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
index ac34bd338fc4..c714727d4601 100644
--- a/platform/vcs-log/graph/src/com/intellij/vcs/log/GraphBlackBox.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
@@ -13,52 +13,58 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.intellij.vcs.log;
+package com.intellij.vcs.log.graph;
import com.intellij.openapi.util.Condition;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.awt.*;
+import java.awt.Graphics2D;
+import java.awt.Point;
import java.util.Collection;
import java.util.List;
-import java.util.Set;
/**
* The only point of interaction with the Graph.
+ *
+ * Any access to the methods of this class must be performed from the EDT.
*/
public interface GraphBlackBox {
void paint(Graphics2D g, int visibleRow);
+ /**
+ * Performs some user action on the graph, which can be a click, hover, drag, changing view parameters, etc.
+ * Changes are applied to the graph immediately, and the method returns the result of such action.
+ * In some cases the action might take significant time (say, 1 second) - clients of this method take care of it themselves: by showing
+ * some modal progress or else.
+ */
@Nullable
GraphChangeEvent performAction(@NotNull GraphAction action);
+ /**
+ * Returns all commits in the graph without considering commits visibility.
+ * @see #getVisibleCommits()
+ */
@NotNull
List getAllCommits();
+ /**
+ * Returns those commits of the graph which is current visible, according to filters currently set up on the graph.
+ * @see #getAllCommits()
+ * @see #setFilter(Condition)
+ * @see #setVisibleBranches(Collection)
+ */
@NotNull
List getVisibleCommits();
void setVisibleBranches(@Nullable Collection heads);
- void setFilter(Condition visibilityPredicate);
+ void setFilter(@NotNull Condition visibilityPredicate);
+ @NotNull
GraphInfoProvider getInfoProvider();
- interface GraphInfoProvider {
- int getOneOfHeads(int commit); // this is fast
- Set getContainingBranches(int commitIndex); // this requires graph iteration => can take some time
- RowInfo getRowInfo(int visibleRow);
- }
-
- /**
- * Some information about row highlighting etc.
- */
- interface RowInfo {
-
- }
-
interface GraphAction {
}
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java
new file mode 100644
index 000000000000..03e4e8ca9992
--- /dev/null
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2000-2014 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.vcs.log.graph;
+
+import java.util.Set;
+
+/**
+ * Use this provider to get information from the Graph.
+ * An instance of GraphInfoProvider is obtained via {@link GraphBlackBox#getInfoProvider()}.
+ */
+public interface GraphInfoProvider {
+
+ int getOneOfHeads(int commit); // this is fast
+
+ Set getContainingBranches(int commitIndex); // this requires graph iteration => can take some time
+
+ RowInfo getRowInfo(int visibleRow);
+
+ /**
+ * Some information about row highlighting etc. TBD
+ */
+ interface RowInfo {
+ }
+
+}
From 8661db58fff6bb42ef78ad81faa565fdbd743173 Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Thu, 13 Feb 2014 16:01:46 +0400
Subject: [PATCH 049/172] GraphColorManager
---
.../vcs/log/graph/GraphColorManager.java | 35 +++++++++++++++++++
1 file changed, 35 insertions(+)
create mode 100644 platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphColorManager.java
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphColorManager.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphColorManager.java
new file mode 100644
index 000000000000..2b137140340e
--- /dev/null
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphColorManager.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2000-2014 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.vcs.log.graph;
+
+import com.intellij.ui.JBColor;
+import org.jetbrains.annotations.NotNull;
+
+public interface GraphColorManager {
+
+ @NotNull
+ JBColor getColorOfBranch(int headCommit);
+
+ /**
+ * Returns 1, 0 or -1 if branch identified by commit {@code head1} is "more powerful", "equally powerful" or "less powerful"
+ * than the branch identified by commit {@code head2}.
+ *
+ * If branch1 is more powerful than branch2, it means that its color will be reused by the subgraph below the point when these branches
+ * were diverged.
+ */
+ int compareHeads(int head1, int head2);
+
+}
From e8525931a4a5d8092bfdc6c95466780d1115dbad Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Thu, 13 Feb 2014 16:03:49 +0400
Subject: [PATCH 050/172] remove unused methods
---
.../com/intellij/vcs/log/data/DataPack.java | 89 +------------------
.../intellij/vcs/log/data/VcsLogFilterer.java | 2 +-
.../src/com/intellij/vcs/log/ui/VcsLogUI.java | 10 ---
.../ui/render/AbstractPaddingCellRender.java | 23 +----
.../vcs/log/ui/tables/GraphTableModel.java | 20 +----
5 files changed, 8 insertions(+), 136 deletions(-)
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
index 3ddb036ef802..e22c8ff10112 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
@@ -4,14 +4,11 @@ import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.util.Consumer;
import com.intellij.util.Function;
import com.intellij.util.NotNullFunction;
-import com.intellij.util.containers.Predicate;
import com.intellij.vcs.log.GraphCommit;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.compressedlist.UpdateRequest;
import com.intellij.vcs.log.graph.Graph;
-import com.intellij.vcs.log.graph.elements.Edge;
-import com.intellij.vcs.log.graph.elements.GraphElement;
import com.intellij.vcs.log.graph.elements.Node;
import com.intellij.vcs.log.graph.mutable.GraphBuilder;
import com.intellij.vcs.log.graph.mutable.MutableGraph;
@@ -22,7 +19,8 @@ import com.intellij.vcs.log.printmodel.impl.GraphPrintCellModelImpl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.*;
+import java.util.Collection;
+import java.util.List;
/**
* @author erokhins
@@ -92,29 +90,6 @@ public class DataPack {
return myPrintCellModel;
}
- public boolean isSameBranch(@NotNull Node nodeA, @NotNull Node nodeB) {
- Node up, down;
- if (nodeA.getRowIndex() > nodeB.getRowIndex()) {
- up = nodeB;
- down = nodeA;
- } else {
- up = nodeA;
- down = nodeB;
- }
- return getGraphModel().getFragmentManager().getUpNodes(down).contains(up);
- }
-
- @NotNull
- public Set getUpRefNodes(@NotNull GraphElement graphElement) {
- Set nodes = new HashSet();
- for (Node node : getGraphModel().getFragmentManager().getUpNodes(graphElement)) {
- if (getRefsModel().isBranchRef(node.getCommitIndex())) {
- nodes.add(node);
- }
- }
- return nodes;
- }
-
@Nullable
public Node getNode(int rowIndex) {
return getGraphModel().getGraph().getCommitNodeInRow(rowIndex);
@@ -150,64 +125,4 @@ public class DataPack {
return null;
}
- @Nullable
- public Node getCommonParent(Node a, Node b) {
- List commitDiff = getCommitsDownToCommon(a, b);
- return commitDiff.isEmpty() ? null : commitDiff.get(commitDiff.size() - 1);
- }
-
- public boolean isAncestorOf(Node ancestor, Node child) {
- return ancestor != child && getGraphModel().getFragmentManager().getUpNodes(ancestor).contains(child);
- }
-
- @Nullable
- public Node getCommonParent(Node a, Node b, Node c) {
- return null;
- }
-
- public List getCommitsDownToCommon(Node newBase, Node head) {
- final List all = getAllAncestors(newBase, new Predicate() {
- @Override
- public boolean apply(@Nullable Node input) {
- return false;
- }
- });
- return getAllAncestors(head, new Predicate() {
- @Override
- public boolean apply(@Nullable Node input) {
- return all.contains(input);
- }
- });
- }
-
- private List getAllAncestors(Node a, Predicate stop) {
- Set all = new LinkedHashSet();
- Queue queue = new ArrayDeque();
- queue.add(a);
- while (!queue.isEmpty()) {
- Node aNode = queue.remove();
- all.add(aNode);
- if (stop.apply(aNode)) {
- return new ArrayList(all);
- }
- for (Edge edge : aNode.getDownEdges()) {
- queue.add(edge.getDownNode());
- }
- }
- return new ArrayList(all);
- }
-
- public List getCommitsInBranchAboveBase(Node base, Node branchHead) {
- List result = new ArrayList();
- Node node = branchHead;
- while (node != base) {
- result.add(node);
- // TODO: multiple edges must not appear
- // TODO: if there are no edges, we are in the wrong branch
- node = node.getDownEdges().get(0).getDownNode();
- }
- //Collections.reverse(result);
- return result;
- }
-
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java
index e3b22ce32e0b..ab9e2f043382 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java
@@ -72,7 +72,7 @@ public class VcsLogFilterer {
model = new NoGraphTableModel(myUI, filteredCommits, dataPack.getRefsModel(), LoadMoreStage.INITIAL);
}
else {
- model = new GraphTableModel(myLogDataHolder, myUI);
+ model = new GraphTableModel(myLogDataHolder);
}
updateUi(model);
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java
index cda36e4307b2..c8dbdd411ad0 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java
@@ -142,16 +142,6 @@ public class VcsLogUI {
});
}
- public void addToSelection(final Hash hash) {
- UIUtil.invokeLaterIfNeeded(new Runnable() {
- @Override
- public void run() {
- int row = myLogDataHolder.getDataPack().getRowByHash(hash);
- myMainFrame.getGraphTable().getSelectionModel().addSelectionInterval(row, row);
- }
- });
- }
-
public void showAll() {
runUnderModalProgress("Expanding linear branches...", new Runnable() {
@Override
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/AbstractPaddingCellRender.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/AbstractPaddingCellRender.java
index d75ca1d6624f..c2c046d5cf18 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/AbstractPaddingCellRender.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/AbstractPaddingCellRender.java
@@ -6,22 +6,20 @@ import com.intellij.openapi.vcs.changes.issueLinks.IssueLinkRenderer;
import com.intellij.ui.ColoredTableCellRenderer;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcs.log.VcsRef;
-import com.intellij.vcs.log.graph.render.GraphCommitCell;
-import com.intellij.vcs.log.printmodel.SpecialPrintElement;
import com.intellij.vcs.log.ui.VcsLogColorManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import javax.swing.*;
-import java.awt.*;
+import javax.swing.JTable;
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
import java.util.Collection;
import java.util.List;
import java.util.Map;
public abstract class AbstractPaddingCellRender extends ColoredTableCellRenderer {
- public static final Color MARKED_BACKGROUND = new Color(200, 255, 250);
-
@NotNull protected final RefPainter myRefPainter;
@NotNull private final IssueLinkRenderer myIssueLinkRenderer;
@Nullable private Object myValue;
@@ -38,19 +36,6 @@ public abstract class AbstractPaddingCellRender extends ColoredTableCellRenderer
protected abstract void additionPaint(Graphics g, Object value);
- public static boolean isMarked(@Nullable Object value) {
- if (!(value instanceof GraphCommitCell)) {
- return false;
- }
- GraphCommitCell cell = (GraphCommitCell)value;
- for (SpecialPrintElement printElement : cell.getPrintCell().getSpecialPrintElements()) {
- if (printElement.getType() == SpecialPrintElement.Type.COMMIT_NODE && printElement.isMarked()) {
- return true;
- }
- }
- return false;
- }
-
@Override
protected void customizeCellRenderer(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (value == null) {
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java
index 2b48965e2686..3c64f64cf616 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java
@@ -1,6 +1,5 @@
package com.intellij.vcs.log.ui.tables;
-import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.vcs.log.Hash;
@@ -13,7 +12,6 @@ import com.intellij.vcs.log.data.VcsLogDataHolder;
import com.intellij.vcs.log.graph.elements.Node;
import com.intellij.vcs.log.graph.render.GraphCommitCell;
import com.intellij.vcs.log.printmodel.GraphPrintCell;
-import com.intellij.vcs.log.ui.VcsLogUI;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -26,15 +24,11 @@ import java.util.List;
*/
public class GraphTableModel extends AbstractVcsLogTableModel {
- private static final Logger LOG = Logger.getInstance(GraphTableModel.class);
-
@NotNull private final DataPack myDataPack;
@NotNull private final VcsLogDataHolder myDataHolder;
- @NotNull private final VcsLogUI myUi;
- public GraphTableModel(@NotNull VcsLogDataHolder dataHolder, @NotNull VcsLogUI ui) {
+ public GraphTableModel(@NotNull VcsLogDataHolder dataHolder) {
myDataHolder = dataHolder;
- myUi = ui;
myDataPack = dataHolder.getDataPack();
}
@@ -79,16 +73,6 @@ public class GraphTableModel extends AbstractVcsLogTableModel refs = Collections.emptyList();
- Hash hash = null;
if (details != null) {
- hash = details.getHash();
message = details.getSubject();
refs = (List)myDataPack.getRefsModel().refsToCommit(details.getHash());
}
From 89dd596eae6b292db6845a1485473ead002134e8 Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Thu, 13 Feb 2014 16:36:12 +0400
Subject: [PATCH 051/172] Transition to GraphFacade, step 1:
getVisibleCommits(), getRoot()
---
.../intellij/vcs/log/graph/GraphBlackBox.java | 10 ++
.../vcs/log/graph/GraphInfoProvider.java | 1 +
.../com/intellij/vcs/log/data/DataPack.java | 40 +----
.../intellij/vcs/log/data/VcsLogFilterer.java | 21 +--
.../vcs/log/graph/GraphFacadeImpl.java | 161 ++++++++++++++++++
.../vcs/log/ui/tables/GraphTableModel.java | 40 ++++-
6 files changed, 221 insertions(+), 52 deletions(-)
create mode 100644 platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
index c714727d4601..c69cdcbd38cd 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
@@ -58,6 +58,16 @@ public interface GraphBlackBox {
@NotNull
List getVisibleCommits();
+ /**
+ * A shorthand to getVisibleCommits().get(visibleRow), but may be faster.
+ */
+ int getCommitAtRow(int visibleRow);
+
+ /**
+ * A shorthand to {@code getVisibleCommits().size()}, but is faster.
+ */
+ int getVisibleCommitCount();
+
void setVisibleBranches(@Nullable Collection heads);
void setFilter(@NotNull Condition visibilityPredicate);
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java
index 03e4e8ca9992..d0f49c527ec3 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java
@@ -33,6 +33,7 @@ public interface GraphInfoProvider {
* Some information about row highlighting etc. TBD
*/
interface RowInfo {
+ int getOneOfHeads();
}
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
index e22c8ff10112..d71c06c5e5e6 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
@@ -8,7 +8,8 @@ import com.intellij.vcs.log.GraphCommit;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.compressedlist.UpdateRequest;
-import com.intellij.vcs.log.graph.Graph;
+import com.intellij.vcs.log.graph.GraphBlackBox;
+import com.intellij.vcs.log.graph.GraphFacadeImpl;
import com.intellij.vcs.log.graph.elements.Node;
import com.intellij.vcs.log.graph.mutable.GraphBuilder;
import com.intellij.vcs.log.graph.mutable.MutableGraph;
@@ -32,6 +33,7 @@ public class DataPack {
@NotNull private final GraphPrintCellModel myPrintCellModel;
private final NotNullFunction myHashGetter;
private final NotNullFunction myIndexGetter;
+ @NotNull private final GraphFacadeImpl myGraphFacade;
@NotNull
public static DataPack build(@NotNull List extends GraphCommit> commits, @NotNull Collection allRefs, @NotNull ProgressIndicator indicator,
@@ -73,6 +75,12 @@ public class DataPack {
myPrintCellModel = printCellModel;
myHashGetter = hashGetter;
myIndexGetter = indexGetter;
+ myGraphFacade = new GraphFacadeImpl(graphModel, printCellModel);
+ }
+
+ @NotNull
+ public GraphBlackBox getGraphFacade() {
+ return myGraphFacade;
}
@NotNull
@@ -95,34 +103,4 @@ public class DataPack {
return getGraphModel().getGraph().getCommitNodeInRow(rowIndex);
}
- public int getRowByHash(Hash commitHash) {
- Node node = getNodeByHash(commitHash);
- return node == null ? -1 : node.getRowIndex();
- }
-
- @Nullable
- public Node getNodeByHash(Hash hash) {
- int index = myIndexGetter.fun(hash);
- Graph graph = getGraphModel().getGraph();
- for (int i = 0; i < graph.getNodeRows().size(); i++) {
- Node node = graph.getCommitNodeInRow(i);
- if (node != null && node.getCommitIndex() == index) {
- return node;
- }
- }
- return null;
- }
-
- @Nullable
- public Node getNodeByPartOfHash(@NotNull String hash) {
- Graph graph = getGraphModel().getGraph();
- for (int i = 0; i < graph.getNodeRows().size(); i++) {
- Node node = graph.getCommitNodeInRow(i);
- if (node != null && myHashGetter.fun(node.getCommitIndex()).asString().startsWith(hash.toLowerCase())) {
- return node;
- }
- }
- return null;
- }
-
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java
index ab9e2f043382..cf55e446ca46 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java
@@ -68,7 +68,7 @@ public class VcsLogFilterer {
// apply details filters, and use simple table without graph (we can't filter by details and keep the graph yet).
final AbstractVcsLogTableModel model;
if (!detailsFilters.isEmpty()) {
- List filteredCommits = filterByDetails(graphModel, detailsFilters);
+ List filteredCommits = filterByDetails(detailsFilters);
model = new NoGraphTableModel(myUI, filteredCommits, dataPack.getRefsModel(), LoadMoreStage.INITIAL);
}
else {
@@ -142,16 +142,13 @@ public class VcsLogFilterer {
}
@NotNull
- private List filterByDetails(@NotNull GraphModel graphModel, @NotNull List detailsFilters) {
+ private List filterByDetails(@NotNull List detailsFilters) {
List result = ContainerUtil.newArrayList();
int topCommits = myLogDataHolder.getSettings().getRecentCommitsCount();
- for (int i = 0; i < topCommits && i < graphModel.getGraph().getNodeRows().size(); i++) {
- Node node = graphModel.getGraph().getCommitNodeInRow(i);
- if (node == null) {
- // there can be nodes which contain no commits (IDEA-115442, branch filter case)
- continue;
- }
- final VcsFullCommitDetails details = getDetailsFromCache(node);
+ List visibleCommits = myLogDataHolder.getDataPack().getGraphFacade().getVisibleCommits();
+ for (int i = 0; i < topCommits && i < visibleCommits.size(); i++) {
+ int commitIndex = visibleCommits.get(i);
+ final VcsFullCommitDetails details = getDetailsFromCache(commitIndex);
if (details == null) {
// Details for recent commits should be available in the cache.
// However if they are not there for some reason, we stop filtering.
@@ -160,7 +157,7 @@ public class VcsLogFilterer {
// then we will return the list which incorrectly misses some matching commit in the middle.
// => Instead we rather will return a smaller list: this is not a problem,
// because the VCS will be requested for filtered details if there are not enough of them.
- LOG.debug("No details found for a recent commit " + myLogDataHolder.getHash(node.getCommitIndex()));
+ LOG.debug("No details found for a recent commit " + myLogDataHolder.getHash(commitIndex));
break;
}
boolean allFiltersMatch = !ContainerUtil.exists(detailsFilters, new Condition() {
@@ -177,12 +174,12 @@ public class VcsLogFilterer {
}
@Nullable
- private VcsFullCommitDetails getDetailsFromCache(@NotNull final Node node) {
+ private VcsFullCommitDetails getDetailsFromCache(final int commitIndex) {
final Ref ref = Ref.create();
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
- ref.set(myLogDataHolder.getCommitDetailsGetter().getCommitDataIfAvailable(myLogDataHolder.getHash(node.getCommitIndex())));
+ ref.set(myLogDataHolder.getCommitDetailsGetter().getCommitDataIfAvailable(myLogDataHolder.getHash(commitIndex)));
}
});
return ref.get();
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
new file mode 100644
index 000000000000..1ee4c70f64b9
--- /dev/null
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2000-2014 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.vcs.log.graph;
+
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.util.Condition;
+import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.vcs.log.graph.elements.Node;
+import com.intellij.vcs.log.graph.elements.NodeRow;
+import com.intellij.vcs.log.graphmodel.GraphModel;
+import com.intellij.vcs.log.printmodel.GraphPrintCellModel;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.awt.*;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+public class GraphFacadeImpl implements GraphBlackBox {
+
+ private static final Logger LOG = Logger.getInstance(GraphFacadeImpl.class);
+ private final GraphModel myGraphModel;
+ private final GraphPrintCellModel myPrintCellModel;
+
+ public GraphFacadeImpl(GraphModel graphModel, GraphPrintCellModel printCellModel) {
+ myGraphModel = graphModel;
+ myPrintCellModel = printCellModel;
+ }
+
+ @Override
+ public void paint(Graphics2D g, int visibleRow) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Nullable
+ @Override
+ public GraphChangeEvent performAction(@NotNull GraphAction action) {
+ throw new UnsupportedOperationException();
+ }
+
+ @NotNull
+ @Override
+ public List getAllCommits() {
+ throw new UnsupportedOperationException();
+ }
+
+ @NotNull
+ @Override
+ public List getVisibleCommits() {
+ List nodeRows = myGraphModel.getGraph().getNodeRows();
+ return ContainerUtil.map(nodeRows, new Function() {
+ @Override
+ public Integer fun(NodeRow nodeRow) {
+ return getCommit(nodeRow);
+ }
+ });
+ }
+
+ @Override
+ public int getCommitAtRow(int visibleRow) {
+ NodeRow row = myGraphModel.getGraph().getNodeRows().get(visibleRow);
+ return getCommit(row);
+ }
+
+ private static int getCommit(@NotNull NodeRow nodeRow) {
+ List nodes = nodeRow.getNodes();
+ if (nodes.size() < 1) {
+ LOG.error("No nodes for nodeRow: " + nodeRow);
+ return -1;
+ }
+ else {
+ if (nodes.size() > 1 && existsNotEndNode(nodes)) { // allowed for END_NODES, i.e. at the bottom of the partly loaded log
+ LOG.error("Too many nodes for nodeRow: " + nodeRow);
+ }
+ return nodes.get(0).getCommitIndex();
+ }
+ }
+
+ @Override
+ public int getVisibleCommitCount() {
+ return myGraphModel.getGraph().getNodeRows().size();
+ }
+
+ private static boolean existsNotEndNode(@NotNull List nodes) {
+ return ContainerUtil.exists(nodes, new Condition() {
+ @Override
+ public boolean value(Node node) {
+ return node.getType() != Node.NodeType.END_COMMIT_NODE;
+ }
+ });
+ }
+
+ @Override
+ public void setVisibleBranches(@Nullable Collection heads) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setFilter(@NotNull Condition visibilityPredicate) {
+ throw new UnsupportedOperationException();
+ }
+
+ @NotNull
+ @Override
+ public GraphInfoProvider getInfoProvider() {
+ return new GraphInfoProviderImpl();
+ }
+
+ private class GraphInfoProviderImpl implements GraphInfoProvider {
+
+ @Override
+ public int getOneOfHeads(int commit) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Set getContainingBranches(int commitIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public RowInfo getRowInfo(int visibleRow) {
+ return new RowInfoImpl(visibleRow);
+ }
+
+ }
+
+ private class RowInfoImpl implements GraphInfoProvider.RowInfo {
+ private final int myVisibleRow;
+
+ public RowInfoImpl(int visibleRow) {
+ myVisibleRow = visibleRow;
+ }
+
+ @Override
+ public int getOneOfHeads() {
+ Node node = myGraphModel.getGraph().getCommitNodeInRow(myVisibleRow);
+ assert node != null : "node is null for row " + myVisibleRow;
+ while (!node.getUpEdges().isEmpty()) {
+ node = node.getUpEdges().get(0).getUpNode();
+ }
+ return node.getCommitIndex();
+ }
+ }
+
+}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java
index 3c64f64cf616..faab9d0fae9f 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java
@@ -1,7 +1,10 @@
package com.intellij.vcs.log.ui.tables;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.util.Condition;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsFullCommitDetails;
import com.intellij.vcs.log.VcsRef;
@@ -16,6 +19,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -24,6 +28,8 @@ import java.util.List;
*/
public class GraphTableModel extends AbstractVcsLogTableModel {
+ private static final Logger LOG = Logger.getInstance(GraphTableModel.class);
+
@NotNull private final DataPack myDataPack;
@NotNull private final VcsLogDataHolder myDataHolder;
@@ -34,7 +40,7 @@ public class GraphTableModel extends AbstractVcsLogTableModel refs = myDataPack.getRefsModel().refsToCommit(head);
+ if (refs.isEmpty()) {
+ LOG.error("No references pointing to head " + head + " identified for commit at row " + rowIndex);
+ return FAKE_ROOT;
+ }
+ return refs.iterator().next().getRoot();
}
@NotNull
@@ -102,19 +113,30 @@ public class GraphTableModel extends AbstractVcsLogTableModel() {
+ @Override
+ public boolean value(Integer integer) {
+ return integer == commitIndex;
+ }
+ });
}
@Override
- public int getRowOfCommitByPartOfHash(@NotNull String hash) {
- Node node = myDataPack.getNodeByPartOfHash(hash);
- return node != null ? node.getRowIndex() : -1;
+ public int getRowOfCommitByPartOfHash(@NotNull String partialHash) {
+ final String pHash = partialHash.toLowerCase();
+ return ContainerUtil.indexOf(myDataPack.getGraphFacade().getVisibleCommits(), new Condition() {
+ @Override
+ public boolean value(Integer integer) {
+ Hash hash = myDataHolder.getHash(integer);
+ return hash.toString().toLowerCase().startsWith(pHash);
+ }
+ });
}
}
From 9311f2fea8d6c777d30afb865b456d2e735dc163 Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Fri, 14 Feb 2014 18:00:09 +0400
Subject: [PATCH 052/172] Transition to GraphFacade, step 2: setVisibleBranches
---
.../intellij/vcs/log/VcsLogBranchFilter.java | 5 ++-
.../vcs/log/VcsLogFilterCollection.java | 3 --
.../intellij/vcs/log/VcsLogGraphFilter.java | 10 -----
.../vcs/log/data/VcsLogBranchFilterImpl.java | 14 +++---
.../intellij/vcs/log/data/VcsLogFilterer.java | 43 +++----------------
.../vcs/log/graph/GraphFacadeImpl.java | 16 ++++++-
.../log/impl/VcsLogFilterCollectionImpl.java | 9 +---
7 files changed, 33 insertions(+), 67 deletions(-)
delete mode 100644 platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogGraphFilter.java
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogBranchFilter.java b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogBranchFilter.java
index 1c0ddec718d8..dfa78da2fab3 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogBranchFilter.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogBranchFilter.java
@@ -22,9 +22,12 @@ import java.util.Collection;
/**
* Tells to filter by some branch name.
*/
-public interface VcsLogBranchFilter extends VcsLogGraphFilter {
+public interface VcsLogBranchFilter extends VcsLogFilter {
@NotNull
Collection getBranchNames();
+ @NotNull
+ Collection getMatchingHeads();
+
}
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogFilterCollection.java b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogFilterCollection.java
index a1c10ec313eb..19cfbdf486eb 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogFilterCollection.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogFilterCollection.java
@@ -47,9 +47,6 @@ public interface VcsLogFilterCollection {
*/
boolean isEmpty();
- @NotNull
- List getGraphFilters();
-
@NotNull
List getDetailsFilters();
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogGraphFilter.java b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogGraphFilter.java
deleted file mode 100644
index 4475b5da40c6..000000000000
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogGraphFilter.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.intellij.vcs.log;
-
-/**
- * Filter that is able to work on graph.
- */
-public interface VcsLogGraphFilter extends VcsLogFilter {
-
- boolean matches(int hash);
-
-}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogBranchFilterImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogBranchFilterImpl.java
index 8872406fb88d..f16a44094002 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogBranchFilterImpl.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogBranchFilterImpl.java
@@ -3,13 +3,12 @@ package com.intellij.vcs.log.data;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcs.log.VcsLogBranchFilter;
-import com.intellij.vcs.log.VcsLogGraphFilter;
import com.intellij.vcs.log.VcsRef;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
-public class VcsLogBranchFilterImpl implements VcsLogBranchFilter, VcsLogGraphFilter {
+public class VcsLogBranchFilterImpl implements VcsLogBranchFilter {
@NotNull private final Collection myMatchingHeads;
@NotNull private final Collection myBranchNames;
@@ -27,11 +26,6 @@ public class VcsLogBranchFilterImpl implements VcsLogBranchFilter, VcsLogGraphFi
});
}
- @Override
- public boolean matches(int hash) {
- return myMatchingHeads.contains(hash);
- }
-
@Override
public String toString() {
return "on: " + myBranchNames;
@@ -43,4 +37,10 @@ public class VcsLogBranchFilterImpl implements VcsLogBranchFilter, VcsLogGraphFi
return myBranchNames;
}
+ @Override
+ @NotNull
+ public Collection getMatchingHeads() {
+ return myMatchingHeads;
+ }
+
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java
index cf55e446ca46..4e53587c7a42 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java
@@ -6,12 +6,12 @@ import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.EmptyRunnable;
import com.intellij.openapi.util.Ref;
import com.intellij.util.Consumer;
-import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
-import com.intellij.vcs.log.*;
-import com.intellij.vcs.log.graph.elements.Node;
-import com.intellij.vcs.log.graphmodel.GraphModel;
+import com.intellij.vcs.log.VcsFullCommitDetails;
+import com.intellij.vcs.log.VcsLogBranchFilter;
+import com.intellij.vcs.log.VcsLogDetailsFilter;
+import com.intellij.vcs.log.VcsLogFilterCollection;
import com.intellij.vcs.log.ui.VcsLogUI;
import com.intellij.vcs.log.ui.tables.AbstractVcsLogTableModel;
import com.intellij.vcs.log.ui.tables.GraphTableModel;
@@ -27,13 +27,6 @@ public class VcsLogFilterer {
private static final int LOAD_MORE_COMMITS_FIRST_STEP_LIMIT = 200;
- private static final Function ALL_NODES_VISIBLE = new Function() {
- @Override
- public Boolean fun(Node node) {
- return true;
- }
- };
-
@NotNull private final VcsLogDataHolder myLogDataHolder;
@NotNull private final VcsLogUI myUI;
@@ -44,8 +37,6 @@ public class VcsLogFilterer {
public void applyFiltersAndUpdateUi(@NotNull VcsLogFilterCollection filters) {
DataPack dataPack = myLogDataHolder.getDataPack();
- final GraphModel graphModel = dataPack.getGraphModel();
- List graphFilters = filters.getGraphFilters();
List detailsFilters = filters.getDetailsFilters();
// it is important to apply graph filters first:
@@ -53,17 +44,7 @@ public class VcsLogFilterer {
// (e.g. won't be able to find out if a commit belongs to the branch selected by user).
// hide invisible nodes from the graph
- if (!graphFilters.isEmpty()) {
- applyGraphFilters(graphModel, graphFilters);
- }
- else {
- myUI.getTable().executeWithoutRepaint(new Runnable() {
- @Override
- public void run() {
- graphModel.setVisibleBranchesNodes(ALL_NODES_VISIBLE);
- }
- });
- }
+ applyGraphFilters(filters.getBranchFilter());
// apply details filters, and use simple table without graph (we can't filter by details and keep the graph yet).
final AbstractVcsLogTableModel model;
@@ -122,21 +103,11 @@ public class VcsLogFilterer {
return newLoadMoreStage;
}
- private void applyGraphFilters(final GraphModel graphModel, final List onGraphFilters) {
+ private void applyGraphFilters(@Nullable final VcsLogBranchFilter branchFilter) {
myUI.getTable().executeWithoutRepaint(new Runnable() {
@Override
public void run() {
- graphModel.setVisibleBranchesNodes(new Function() {
- @Override
- public Boolean fun(final Node node) {
- return !ContainerUtil.exists(onGraphFilters, new Condition() {
- @Override
- public boolean value(VcsLogGraphFilter filter) {
- return !filter.matches(node.getCommitIndex());
- }
- });
- }
- });
+ myLogDataHolder.getDataPack().getGraphFacade().setVisibleBranches(branchFilter != null ? branchFilter.getMatchingHeads() : null);
}
});
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
index 1ee4c70f64b9..77c574549fca 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
@@ -34,6 +34,13 @@ import java.util.Set;
public class GraphFacadeImpl implements GraphBlackBox {
private static final Logger LOG = Logger.getInstance(GraphFacadeImpl.class);
+ private static final Function ALL_NODES_VISIBLE = new Function() {
+ @Override
+ public Boolean fun(Node node) {
+ return true;
+ }
+ };
+
private final GraphModel myGraphModel;
private final GraphPrintCellModel myPrintCellModel;
@@ -106,8 +113,13 @@ public class GraphFacadeImpl implements GraphBlackBox {
}
@Override
- public void setVisibleBranches(@Nullable Collection heads) {
- throw new UnsupportedOperationException();
+ public void setVisibleBranches(@Nullable final Collection heads) {
+ myGraphModel.setVisibleBranchesNodes(heads == null ? ALL_NODES_VISIBLE : new Function() {
+ @Override
+ public Boolean fun(final Node node) {
+ return heads.contains(node.getCommitIndex());
+ }
+ });
}
@Override
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogFilterCollectionImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogFilterCollectionImpl.java
index 4920a4ecb59f..285e3ce91079 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogFilterCollectionImpl.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogFilterCollectionImpl.java
@@ -21,7 +21,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
public class VcsLogFilterCollectionImpl implements VcsLogFilterCollection {
@@ -76,13 +75,7 @@ public class VcsLogFilterCollectionImpl implements VcsLogFilterCollection {
@Override
public boolean isEmpty() {
- return getGraphFilters().isEmpty() && getDetailsFilters().isEmpty();
- }
-
- @NotNull
- @Override
- public List getGraphFilters() {
- return ContainerUtil.skipNulls(Collections.singletonList(myBranchFilter));
+ return myBranchFilter == null && getDetailsFilters().isEmpty();
}
@NotNull
From a74518c9735494743d3e86fba0afc02ce84ea2f8 Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Fri, 14 Feb 2014 18:15:36 +0400
Subject: [PATCH 053/172] Transition to GraphFacade, step 3: expansion actions
Dumb performAction() implementation with instanceofs and else.
Actions are also located in the api, maybe it will change in future.
---
.../intellij/vcs/log/graph/GraphAction.java | 19 ++++++++++
.../intellij/vcs/log/graph/GraphBlackBox.java | 11 ------
.../vcs/log/graph/GraphInfoProvider.java | 3 ++
.../graph/LinearBranchesExpansionAction.java | 32 ++++++++++++++++
.../vcs/log/graph/LongEdgesAction.java | 37 +++++++++++++++++++
.../vcs/log/graph/GraphFacadeImpl.java | 19 +++++++++-
.../src/com/intellij/vcs/log/ui/VcsLogUI.java | 10 +++--
7 files changed, 115 insertions(+), 16 deletions(-)
create mode 100644 platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphAction.java
create mode 100644 platform/vcs-log/api/src/com/intellij/vcs/log/graph/LinearBranchesExpansionAction.java
create mode 100644 platform/vcs-log/api/src/com/intellij/vcs/log/graph/LongEdgesAction.java
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphAction.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphAction.java
new file mode 100644
index 000000000000..a08aaaf928c7
--- /dev/null
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphAction.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2000-2014 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.vcs.log.graph;
+
+public interface GraphAction {
+}
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
index c69cdcbd38cd..c6911ee46686 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
@@ -75,9 +75,6 @@ public interface GraphBlackBox {
@NotNull
GraphInfoProvider getInfoProvider();
- interface GraphAction {
- }
-
class ClickGraphAction implements GraphAction {
int visibleRow;
Point relativePoint;
@@ -88,14 +85,6 @@ public interface GraphBlackBox {
Point relativePoint;
}
- class LinearBranchesExpansionAction implements GraphAction {
- boolean expanded; // or collapsed
- }
-
- class LongEdgesAction implements GraphAction {
- boolean show;
- }
-
interface GraphChangeEvent {
}
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java
index d0f49c527ec3..b221d85eb85a 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java
@@ -29,6 +29,9 @@ public interface GraphInfoProvider {
RowInfo getRowInfo(int visibleRow);
+ // TODO probably this can be removed and identified from the outside
+ boolean areLongEdgesHidden();
+
/**
* Some information about row highlighting etc. TBD
*/
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/LinearBranchesExpansionAction.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/LinearBranchesExpansionAction.java
new file mode 100644
index 000000000000..dbfd046cf0b6
--- /dev/null
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/LinearBranchesExpansionAction.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2000-2014 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.vcs.log.graph;
+
+public class LinearBranchesExpansionAction implements GraphAction {
+
+ public static LinearBranchesExpansionAction EXPAND = new LinearBranchesExpansionAction(true);
+ public static LinearBranchesExpansionAction COLLAPSE = new LinearBranchesExpansionAction(false);
+
+ private final boolean myExpand;
+
+ private LinearBranchesExpansionAction(boolean expand) {
+ myExpand = expand;
+ }
+
+ public boolean shouldExpand() {
+ return myExpand;
+ }
+}
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/LongEdgesAction.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/LongEdgesAction.java
new file mode 100644
index 000000000000..4824f0b13c65
--- /dev/null
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/LongEdgesAction.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2000-2014 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.vcs.log.graph;
+
+public class LongEdgesAction implements GraphAction {
+
+ private static LongEdgesAction SHOW = new LongEdgesAction(true);
+ private static LongEdgesAction HIDE = new LongEdgesAction(false);
+
+ private final boolean myShowLongEdges;
+
+ public static LongEdgesAction valueOf(boolean showLongEdges) {
+ return showLongEdges ? SHOW : HIDE;
+ }
+
+ private LongEdgesAction(boolean show) {
+ myShowLongEdges = show;
+ }
+
+ public boolean shouldShowLongEdges() {
+ return myShowLongEdges;
+ }
+
+}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
index 77c574549fca..228d48cef01b 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
@@ -21,6 +21,7 @@ import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcs.log.graph.elements.Node;
import com.intellij.vcs.log.graph.elements.NodeRow;
+import com.intellij.vcs.log.graphmodel.FragmentManager;
import com.intellij.vcs.log.graphmodel.GraphModel;
import com.intellij.vcs.log.printmodel.GraphPrintCellModel;
import org.jetbrains.annotations.NotNull;
@@ -57,7 +58,19 @@ public class GraphFacadeImpl implements GraphBlackBox {
@Nullable
@Override
public GraphChangeEvent performAction(@NotNull GraphAction action) {
- throw new UnsupportedOperationException();
+ if (action instanceof LinearBranchesExpansionAction) {
+ FragmentManager fragmentManager = myGraphModel.getFragmentManager();
+ if (((LinearBranchesExpansionAction)action).shouldExpand()) {
+ fragmentManager.showAll();
+ }
+ else {
+ fragmentManager.hideAll();
+ }
+ }
+ else if (action instanceof LongEdgesAction) {
+ myPrintCellModel.setLongEdgeVisibility(((LongEdgesAction)action).shouldShowLongEdges());
+ }
+ return null;
}
@NotNull
@@ -150,6 +163,10 @@ public class GraphFacadeImpl implements GraphBlackBox {
return new RowInfoImpl(visibleRow);
}
+ @Override
+ public boolean areLongEdgesHidden() {
+ return myPrintCellModel.areLongEdgesHidden();
+ }
}
private class RowInfoImpl implements GraphInfoProvider.RowInfo {
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java
index c8dbdd411ad0..acc34d09935d 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java
@@ -17,6 +17,8 @@ import com.intellij.vcs.log.data.DataPack;
import com.intellij.vcs.log.data.VcsLogDataHolder;
import com.intellij.vcs.log.data.VcsLogFilterer;
import com.intellij.vcs.log.data.VcsLogUiProperties;
+import com.intellij.vcs.log.graph.LinearBranchesExpansionAction;
+import com.intellij.vcs.log.graph.LongEdgesAction;
import com.intellij.vcs.log.graph.elements.GraphElement;
import com.intellij.vcs.log.graph.elements.Node;
import com.intellij.vcs.log.graphmodel.FragmentManager;
@@ -146,7 +148,7 @@ public class VcsLogUI {
runUnderModalProgress("Expanding linear branches...", new Runnable() {
@Override
public void run() {
- myLogDataHolder.getDataPack().getGraphModel().getFragmentManager().showAll();
+ myLogDataHolder.getDataPack().getGraphFacade().performAction(LinearBranchesExpansionAction.EXPAND);
updateUI();
jumpToRow(0);
}
@@ -157,7 +159,7 @@ public class VcsLogUI {
runUnderModalProgress("Collapsing linear branches...", new Runnable() {
@Override
public void run() {
- myLogDataHolder.getDataPack().getGraphModel().getFragmentManager().hideAll();
+ myLogDataHolder.getDataPack().getGraphFacade().performAction(LinearBranchesExpansionAction.COLLAPSE);
updateUI();
jumpToRow(0);
}
@@ -165,12 +167,12 @@ public class VcsLogUI {
}
public void setLongEdgeVisibility(boolean visibility) {
- myLogDataHolder.getDataPack().getPrintCellModel().setLongEdgeVisibility(visibility);
+ myLogDataHolder.getDataPack().getGraphFacade().performAction(LongEdgesAction.valueOf(visibility));
updateUI();
}
public boolean areLongEdgesHidden() {
- return myLogDataHolder.getDataPack().getPrintCellModel().areLongEdgesHidden();
+ return myLogDataHolder.getDataPack().getGraphFacade().getInfoProvider().areLongEdgesHidden();
}
public void over(@Nullable GraphElement graphElement) {
From cd4728b0bc5901f13008c986ccff3b1b1f46ae06 Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Fri, 14 Feb 2014 18:23:49 +0400
Subject: [PATCH 054/172] Transition to GraphFacade, step 4: click to row
+ no need to call click from jumpToRow: it will be called from
selectionChanged() anyway
---
.../vcs/log/graph/ClickGraphAction.java | 35 +++++++++++++++++++
.../intellij/vcs/log/graph/GraphBlackBox.java | 5 ---
.../com/intellij/vcs/log/data/DataPack.java | 7 ----
.../vcs/log/graph/GraphFacadeImpl.java | 8 +++++
.../src/com/intellij/vcs/log/ui/VcsLogUI.java | 10 ++----
5 files changed, 45 insertions(+), 20 deletions(-)
create mode 100644 platform/vcs-log/api/src/com/intellij/vcs/log/graph/ClickGraphAction.java
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/ClickGraphAction.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/ClickGraphAction.java
new file mode 100644
index 000000000000..55880ee799bf
--- /dev/null
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/ClickGraphAction.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2000-2014 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.vcs.log.graph;
+
+import org.jetbrains.annotations.Nullable;
+
+import java.awt.*;
+
+public class ClickGraphAction implements GraphAction {
+
+ private final int myVisibleRow;
+ @Nullable private final Point myRelativePoint;
+
+ public ClickGraphAction(int visibleRow, @Nullable Point relativePoint) {
+ myVisibleRow = visibleRow;
+ myRelativePoint = relativePoint;
+ }
+
+ public int getRow() {
+ return myVisibleRow;
+ }
+}
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
index c6911ee46686..409e366096e4 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
@@ -75,11 +75,6 @@ public interface GraphBlackBox {
@NotNull
GraphInfoProvider getInfoProvider();
- class ClickGraphAction implements GraphAction {
- int visibleRow;
- Point relativePoint;
- }
-
class HoverGraphAction implements GraphAction {
int visibleRow;
Point relativePoint;
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
index d71c06c5e5e6..d4bfbc729907 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
@@ -18,7 +18,6 @@ import com.intellij.vcs.log.graphmodel.impl.GraphModelImpl;
import com.intellij.vcs.log.printmodel.GraphPrintCellModel;
import com.intellij.vcs.log.printmodel.impl.GraphPrintCellModelImpl;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.List;
@@ -97,10 +96,4 @@ public class DataPack {
public GraphPrintCellModel getPrintCellModel() {
return myPrintCellModel;
}
-
- @Nullable
- public Node getNode(int rowIndex) {
- return getGraphModel().getGraph().getCommitNodeInRow(rowIndex);
- }
-
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
index 228d48cef01b..1661d13552a1 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
@@ -70,6 +70,14 @@ public class GraphFacadeImpl implements GraphBlackBox {
else if (action instanceof LongEdgesAction) {
myPrintCellModel.setLongEdgeVisibility(((LongEdgesAction)action).shouldShowLongEdges());
}
+ else if (action instanceof ClickGraphAction) {
+ myPrintCellModel.getCommitSelectController().deselectAll();
+ Node node = myGraphModel.getGraph().getCommitNodeInRow(((ClickGraphAction)action).getRow());
+ if (node != null) {
+ FragmentManager fragmentController = myGraphModel.getFragmentManager();
+ myPrintCellModel.getCommitSelectController().select(fragmentController.allCommitsCurrentBranch(node));
+ }
+ }
return null;
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java
index acc34d09935d..e514ea8bb82e 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java
@@ -17,10 +17,10 @@ import com.intellij.vcs.log.data.DataPack;
import com.intellij.vcs.log.data.VcsLogDataHolder;
import com.intellij.vcs.log.data.VcsLogFilterer;
import com.intellij.vcs.log.data.VcsLogUiProperties;
+import com.intellij.vcs.log.graph.ClickGraphAction;
import com.intellij.vcs.log.graph.LinearBranchesExpansionAction;
import com.intellij.vcs.log.graph.LongEdgesAction;
import com.intellij.vcs.log.graph.elements.GraphElement;
-import com.intellij.vcs.log.graph.elements.Node;
import com.intellij.vcs.log.graphmodel.FragmentManager;
import com.intellij.vcs.log.graphmodel.GraphFragment;
import com.intellij.vcs.log.impl.VcsLogImpl;
@@ -84,7 +84,6 @@ public class VcsLogUI {
@Override
public void run() {
myMainFrame.getGraphTable().jumpToRow(rowIndex);
- click(rowIndex);
}
});
}
@@ -219,12 +218,7 @@ public class VcsLogUI {
public void click(int rowIndex) {
DataPack dataPack = myLogDataHolder.getDataPack();
- dataPack.getPrintCellModel().getCommitSelectController().deselectAll();
- Node node = dataPack.getNode(rowIndex);
- if (node != null) {
- FragmentManager fragmentController = dataPack.getGraphModel().getFragmentManager();
- dataPack.getPrintCellModel().getCommitSelectController().select(fragmentController.allCommitsCurrentBranch(node));
- }
+ dataPack.getGraphFacade().performAction(new ClickGraphAction(rowIndex, null));
updateUI();
}
From bb8b89790b0ad86159cde73b580d59b79d06cd5e Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Mon, 17 Feb 2014 18:15:53 +0400
Subject: [PATCH 055/172] optimize getOneOfHeads: store it in Branch instead of
the VirtualFile.
---
.../intellij/vcs/log/graph/elements/Branch.java | 17 +++++++----------
.../vcs/log/graph/mutable/GraphBuilder.java | 15 +++++++--------
.../intellij/vcs/log/graph/GraphTestUtils.java | 3 +--
.../intellij/vcs/log/graph/GraphFacadeImpl.java | 5 +----
4 files changed, 16 insertions(+), 24 deletions(-)
diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/elements/Branch.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/elements/Branch.java
index de249613a219..86ae08b9d66e 100644
--- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/elements/Branch.java
+++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/elements/Branch.java
@@ -1,7 +1,6 @@
package com.intellij.vcs.log.graph.elements;
import com.intellij.openapi.util.Condition;
-import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcs.log.VcsRef;
import org.jetbrains.annotations.NotNull;
@@ -16,13 +15,12 @@ public final class Branch {
private final int upCommitHash;
private final int downCommitHash;
@Nullable private final VcsRef myColoredRef;
- @NotNull private final VirtualFile myRepositoryRoot;
+ private final int myOneOfHeads;
- public Branch(int upCommitHash, int downCommitHash, @NotNull Collection refs,
- @NotNull VirtualFile repositoryRoot) {
+ public Branch(int upCommitHash, int downCommitHash, @NotNull Collection refs, int oneOfHeads) {
this.upCommitHash = upCommitHash;
this.downCommitHash = downCommitHash;
- myRepositoryRoot = repositoryRoot;
+ myOneOfHeads = oneOfHeads;
myColoredRef = findRefForBranchColor(refs);
}
@@ -36,8 +34,8 @@ public final class Branch {
});
}
- public Branch(int commit, @NotNull Collection refs, @NotNull VirtualFile repositoryRoot) {
- this(commit, commit, refs, repositoryRoot);
+ public Branch(int commit, @NotNull Collection refs, int oneOfHeads) {
+ this(commit, commit, refs, oneOfHeads);
}
public int getUpCommitHash() {
@@ -79,9 +77,8 @@ public final class Branch {
}
}
- @NotNull
- public VirtualFile getRepositoryRoot() {
- return myRepositoryRoot;
+ public int getOneOfHeads() {
+ return myOneOfHeads;
}
}
diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/mutable/GraphBuilder.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/mutable/GraphBuilder.java
index b07d876a1e9a..65b8ec6e36b1 100644
--- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/mutable/GraphBuilder.java
+++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/mutable/GraphBuilder.java
@@ -1,8 +1,6 @@
package com.intellij.vcs.log.graph.mutable;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.vfs.newvfs.impl.NullVirtualFile;
import com.intellij.util.containers.MultiMap;
import com.intellij.vcs.log.GraphCommit;
import com.intellij.vcs.log.VcsRef;
@@ -14,7 +12,8 @@ import org.jetbrains.annotations.NotNull;
import java.util.*;
-import static com.intellij.vcs.log.graph.elements.Node.NodeType.*;
+import static com.intellij.vcs.log.graph.elements.Node.NodeType.COMMIT_NODE;
+import static com.intellij.vcs.log.graph.elements.Node.NodeType.END_COMMIT_NODE;
/**
* @author erokhins
@@ -90,16 +89,16 @@ public class GraphBuilder {
@NotNull
protected Branch createBranch(int commitHash, @NotNull Collection refs) {
- VirtualFile repositoryRoot;
+ int oneOfHeads;
if (refs.isEmpty()) {
// should never happen, but fallback gently.
LOG.error("Ref should exist for this node. Hash: " + commitHash);
- repositoryRoot = NullVirtualFile.INSTANCE;
+ oneOfHeads = -1;
}
else {
- repositoryRoot = refs.iterator().next().getRoot();
+ oneOfHeads = refs.iterator().next().getCommitIndex();
}
- return new Branch(commitHash, refs, repositoryRoot);
+ return new Branch(commitHash, refs, oneOfHeads);
}
private void addParent(MutableNode node, int parentHash, Branch branch) {
@@ -126,7 +125,7 @@ public class GraphBuilder {
else {
for (int parentHash : parents) {
Collection refs = findRefForHash(node.getCommitIndex());
- addParent(node, parentHash, new Branch(node.getCommitIndex(), parentHash, refs, branch.getRepositoryRoot()));
+ addParent(node, parentHash, new Branch(node.getCommitIndex(), parentHash, refs, branch.getOneOfHeads()));
}
}
}
diff --git a/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/GraphTestUtils.java b/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/GraphTestUtils.java
index a8c716628125..1f0922df699f 100644
--- a/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/GraphTestUtils.java
+++ b/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/GraphTestUtils.java
@@ -1,6 +1,5 @@
package com.intellij.vcs.log.graph;
-import com.intellij.openapi.vfs.newvfs.impl.StubVirtualFile;
import com.intellij.vcs.log.GraphCommit;
import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.graph.elements.Branch;
@@ -60,7 +59,7 @@ public class GraphTestUtils {
@NotNull
public static Branch createBranchWithFakeRoot(int commitHash, @NotNull Collection refs) {
- return new Branch(commitHash, refs, new StubVirtualFile());
+ return new Branch(commitHash, refs, -1);
}
// "1 20 3" -> {1,20,3}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
index 1661d13552a1..60f81980f892 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
@@ -188,10 +188,7 @@ public class GraphFacadeImpl implements GraphBlackBox {
public int getOneOfHeads() {
Node node = myGraphModel.getGraph().getCommitNodeInRow(myVisibleRow);
assert node != null : "node is null for row " + myVisibleRow;
- while (!node.getUpEdges().isEmpty()) {
- node = node.getUpEdges().get(0).getUpNode();
- }
- return node.getCommitIndex();
+ return node.getBranch().getOneOfHeads();
}
}
From 411a76f91e0455cdd64d9668752efa50907e3886 Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Mon, 17 Feb 2014 18:22:27 +0400
Subject: [PATCH 056/172] javadocs
---
.../intellij/vcs/log/graph/GraphBlackBox.java | 27 ++++++++++++++-----
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
index 409e366096e4..7e01f82500ec 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
@@ -19,8 +19,7 @@ import com.intellij.openapi.util.Condition;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.awt.Graphics2D;
-import java.awt.Point;
+import java.awt.*;
import java.util.Collection;
import java.util.List;
@@ -31,6 +30,9 @@ import java.util.List;
*/
public interface GraphBlackBox {
+ /**
+ * Paints the given row in the given Graphics.
+ */
void paint(Graphics2D g, int visibleRow);
/**
@@ -68,18 +70,29 @@ public interface GraphBlackBox {
*/
int getVisibleCommitCount();
+ /**
+ * Set branches which should be visible in the log, all others will be hidden.
+ * Pass {@code null} to show all branches, i.e. reset this branch filter.
+ *
+ * @param heads branches represented by commit indices of commits they point to; or {@code null} if all branches should be shown.
+ * @see #setFilter(Condition)
+ */
void setVisibleBranches(@Nullable Collection heads);
+ /**
+ * Set filter to the commits displayed by the log.
+ *
+ * @param visibilityPredicate check if the given commit should be shown or not.
+ * @see #setVisibleBranches(Collection)
+ */
void setFilter(@NotNull Condition visibilityPredicate);
+ /**
+ * Returns the provider of some information about the graph.
+ */
@NotNull
GraphInfoProvider getInfoProvider();
- class HoverGraphAction implements GraphAction {
- int visibleRow;
- Point relativePoint;
- }
-
interface GraphChangeEvent {
}
From d1b69d196b1375b21122ecb8adee5dc802ccf7a6 Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Mon, 17 Feb 2014 18:34:09 +0400
Subject: [PATCH 057/172] remove getVisibleCommits since we've got
getVisibleCommitCount & getCommitAtRow
Add a utility method
---
.../intellij/vcs/log/graph/GraphBlackBox.java | 11 +-------
.../intellij/vcs/log/data/VcsLogFilterer.java | 3 ++-
.../vcs/log/graph/GraphFacadeImpl.java | 12 ---------
.../com/intellij/vcs/log/impl/VcsLogUtil.java | 25 +++++++++++++------
.../vcs/log/ui/tables/GraphTableModel.java | 5 ++--
5 files changed, 24 insertions(+), 32 deletions(-)
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
index 7e01f82500ec..bfae28771726 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
@@ -46,20 +46,11 @@ public interface GraphBlackBox {
/**
* Returns all commits in the graph without considering commits visibility.
- * @see #getVisibleCommits()
+ * To get visible commits use {@link #getVisibleCommitCount} & {@link #getCommitAtRow}.
*/
@NotNull
List getAllCommits();
- /**
- * Returns those commits of the graph which is current visible, according to filters currently set up on the graph.
- * @see #getAllCommits()
- * @see #setFilter(Condition)
- * @see #setVisibleBranches(Collection)
- */
- @NotNull
- List getVisibleCommits();
-
/**
* A shorthand to getVisibleCommits().get(visibleRow), but may be faster.
*/
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java
index 4e53587c7a42..9272a7a94087 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java
@@ -12,6 +12,7 @@ import com.intellij.vcs.log.VcsFullCommitDetails;
import com.intellij.vcs.log.VcsLogBranchFilter;
import com.intellij.vcs.log.VcsLogDetailsFilter;
import com.intellij.vcs.log.VcsLogFilterCollection;
+import com.intellij.vcs.log.impl.VcsLogUtil;
import com.intellij.vcs.log.ui.VcsLogUI;
import com.intellij.vcs.log.ui.tables.AbstractVcsLogTableModel;
import com.intellij.vcs.log.ui.tables.GraphTableModel;
@@ -116,7 +117,7 @@ public class VcsLogFilterer {
private List filterByDetails(@NotNull List detailsFilters) {
List result = ContainerUtil.newArrayList();
int topCommits = myLogDataHolder.getSettings().getRecentCommitsCount();
- List visibleCommits = myLogDataHolder.getDataPack().getGraphFacade().getVisibleCommits();
+ List visibleCommits = VcsLogUtil.getVisibleCommits(myLogDataHolder.getDataPack().getGraphFacade());
for (int i = 0; i < topCommits && i < visibleCommits.size(); i++) {
int commitIndex = visibleCommits.get(i);
final VcsFullCommitDetails details = getDetailsFromCache(commitIndex);
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
index 60f81980f892..9a95cbabd9e0 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
@@ -87,18 +87,6 @@ public class GraphFacadeImpl implements GraphBlackBox {
throw new UnsupportedOperationException();
}
- @NotNull
- @Override
- public List getVisibleCommits() {
- List nodeRows = myGraphModel.getGraph().getNodeRows();
- return ContainerUtil.map(nodeRows, new Function() {
- @Override
- public Integer fun(NodeRow nodeRow) {
- return getCommit(nodeRow);
- }
- });
- }
-
@Override
public int getCommitAtRow(int visibleRow) {
NodeRow row = myGraphModel.getGraph().getNodeRows().get(visibleRow);
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogUtil.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogUtil.java
index a8f1585e936c..d0dce9e0f694 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogUtil.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogUtil.java
@@ -18,16 +18,11 @@ package com.intellij.vcs.log.impl;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.MultiMap;
import com.intellij.vcs.log.VcsRef;
+import com.intellij.vcs.log.graph.GraphBlackBox;
import org.jetbrains.annotations.NotNull;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Map;
-import java.util.TreeMap;
+import java.util.*;
-/**
- * @author Kirill Likhodedov
- */
public class VcsLogUtil {
@NotNull
public static MultiMap groupRefsByRoot(@NotNull Collection refs) {
@@ -47,4 +42,20 @@ public class VcsLogUtil {
}
return map;
}
+
+ @NotNull
+ public static List getVisibleCommits(@NotNull final GraphBlackBox facade) {
+ return new AbstractList() {
+ @Override
+ public Integer get(int index) {
+ return facade.getCommitAtRow(index);
+ }
+
+ @Override
+ public int size() {
+ return facade.getVisibleCommitCount();
+ }
+ };
+ }
+
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java
index faab9d0fae9f..fb176a8a2f4d 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java
@@ -14,6 +14,7 @@ import com.intellij.vcs.log.data.LoadingDetails;
import com.intellij.vcs.log.data.VcsLogDataHolder;
import com.intellij.vcs.log.graph.elements.Node;
import com.intellij.vcs.log.graph.render.GraphCommitCell;
+import com.intellij.vcs.log.impl.VcsLogUtil;
import com.intellij.vcs.log.printmodel.GraphPrintCell;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -119,7 +120,7 @@ public class GraphTableModel extends AbstractVcsLogTableModel() {
+ return ContainerUtil.indexOf(VcsLogUtil.getVisibleCommits(myDataPack.getGraphFacade()), new Condition() {
@Override
public boolean value(Integer integer) {
return integer == commitIndex;
@@ -130,7 +131,7 @@ public class GraphTableModel extends AbstractVcsLogTableModel() {
+ return ContainerUtil.indexOf(VcsLogUtil.getVisibleCommits(myDataPack.getGraphFacade()), new Condition() {
@Override
public boolean value(Integer integer) {
Hash hash = myDataHolder.getHash(integer);
From 055f10b93782c0eb066be8ee95c989caba56372d Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Mon, 17 Feb 2014 18:46:53 +0400
Subject: [PATCH 058/172] optimize search commit by part of hash
iterate over persisted hashes to get the Hash from string
---
.../vcs/log/data/VcsLogDataHolder.java | 17 +++++++++++++++++
.../intellij/vcs/log/data/VcsLogHashMap.java | 19 +++++++++++++++++++
.../vcs/log/ui/tables/GraphTableModel.java | 10 ++--------
3 files changed, 38 insertions(+), 8 deletions(-)
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java
index f5fc5f495173..f4bfa2a2c127 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java
@@ -586,6 +586,23 @@ public class VcsLogDataHolder implements Disposable {
return myContainingBranchesGetter;
}
+ @Nullable
+ public Hash findHashByString(@NotNull String string) {
+ final String pHash = string.toLowerCase();
+ try {
+ return myHashMap.findHash(new Condition() {
+ @Override
+ public boolean value(@NotNull Hash hash) {
+ return hash.toString().toLowerCase().startsWith(pHash);
+ }
+ });
+ }
+ catch (IOException e) {
+ LOG.error(e);
+ return null;
+ }
+ }
+
private static class RecentCommitsInfo {
List firstBlockCommits;
Collection newRefs;
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogHashMap.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogHashMap.java
index a3a520376909..e62d22c8b22f 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogHashMap.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogHashMap.java
@@ -19,7 +19,10 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.ThrowableComputable;
+import com.intellij.util.CommonProcessors;
import com.intellij.util.io.IOUtil;
import com.intellij.util.io.KeyDescriptor;
import com.intellij.util.io.Page;
@@ -77,6 +80,22 @@ class VcsLogHashMap implements Disposable {
}
}
+ @Nullable
+ Hash findHash(@NotNull final Condition condition) throws IOException {
+ final Ref hashRef = Ref.create();
+ myPersistentEnumerator.iterateData(new CommonProcessors.FindProcessor() {
+ @Override
+ protected boolean accept(Hash hash) {
+ boolean matches = condition.value(hash);
+ if (matches) {
+ hashRef.set(hash);
+ }
+ return matches;
+ }
+ });
+ return hashRef.get();
+ }
+
private static class MyHashKeyDescriptor implements KeyDescriptor {
@Override
public void save(@NotNull DataOutput out, Hash value) throws IOException {
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java
index fb176a8a2f4d..f2585cabed50 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java
@@ -130,14 +130,8 @@ public class GraphTableModel extends AbstractVcsLogTableModel() {
- @Override
- public boolean value(Integer integer) {
- Hash hash = myDataHolder.getHash(integer);
- return hash.toString().toLowerCase().startsWith(pHash);
- }
- });
+ Hash hash = myDataHolder.findHashByString(partialHash);
+ return hash != null ? getRowOfCommit(hash) : -1;
}
}
From f9b9890888bb4441e8f1950bd3c67d4e2185dbeb Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Wed, 19 Feb 2014 15:53:18 +0400
Subject: [PATCH 059/172] rename to GraphFacade
---
.../vcs/log/graph/{GraphBlackBox.java => GraphFacade.java} | 2 +-
.../api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java | 2 +-
.../vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java | 4 ++--
.../impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java | 2 +-
.../impl/src/com/intellij/vcs/log/impl/VcsLogUtil.java | 4 ++--
5 files changed, 7 insertions(+), 7 deletions(-)
rename platform/vcs-log/api/src/com/intellij/vcs/log/graph/{GraphBlackBox.java => GraphFacade.java} (98%)
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphFacade.java
similarity index 98%
rename from platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
rename to platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphFacade.java
index bfae28771726..ac70e25c84d5 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphBlackBox.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphFacade.java
@@ -28,7 +28,7 @@ import java.util.List;
*
* Any access to the methods of this class must be performed from the EDT.
*/
-public interface GraphBlackBox {
+public interface GraphFacade {
/**
* Paints the given row in the given Graphics.
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java
index b221d85eb85a..8bbd1e0adaa6 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java
@@ -19,7 +19,7 @@ import java.util.Set;
/**
* Use this provider to get information from the Graph.
- * An instance of GraphInfoProvider is obtained via {@link GraphBlackBox#getInfoProvider()}.
+ * An instance of GraphInfoProvider is obtained via {@link GraphFacade#getInfoProvider()}.
*/
public interface GraphInfoProvider {
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
index d4bfbc729907..546a213f7d43 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
@@ -8,7 +8,7 @@ import com.intellij.vcs.log.GraphCommit;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.compressedlist.UpdateRequest;
-import com.intellij.vcs.log.graph.GraphBlackBox;
+import com.intellij.vcs.log.graph.GraphFacade;
import com.intellij.vcs.log.graph.GraphFacadeImpl;
import com.intellij.vcs.log.graph.elements.Node;
import com.intellij.vcs.log.graph.mutable.GraphBuilder;
@@ -78,7 +78,7 @@ public class DataPack {
}
@NotNull
- public GraphBlackBox getGraphFacade() {
+ public GraphFacade getGraphFacade() {
return myGraphFacade;
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
index 9a95cbabd9e0..8cf748299a74 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
@@ -32,7 +32,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Set;
-public class GraphFacadeImpl implements GraphBlackBox {
+public class GraphFacadeImpl implements GraphFacade {
private static final Logger LOG = Logger.getInstance(GraphFacadeImpl.class);
private static final Function ALL_NODES_VISIBLE = new Function() {
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogUtil.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogUtil.java
index d0dce9e0f694..30fba91e8028 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogUtil.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogUtil.java
@@ -18,7 +18,7 @@ package com.intellij.vcs.log.impl;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.MultiMap;
import com.intellij.vcs.log.VcsRef;
-import com.intellij.vcs.log.graph.GraphBlackBox;
+import com.intellij.vcs.log.graph.GraphFacade;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -44,7 +44,7 @@ public class VcsLogUtil {
}
@NotNull
- public static List getVisibleCommits(@NotNull final GraphBlackBox facade) {
+ public static List getVisibleCommits(@NotNull final GraphFacade facade) {
return new AbstractList() {
@Override
public Integer get(int index) {
From 54a50ae36b691630e11b32b4cea6dbb32b0abcfd Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Wed, 19 Feb 2014 16:48:20 +0400
Subject: [PATCH 060/172] GraphAnswer interface
---
.../vcs/log/graph/GraphActionRequest.java | 24 +++++++++++
.../intellij/vcs/log/graph/GraphAnswer.java | 40 +++++++++++++++++++
.../intellij/vcs/log/graph/GraphChange.java | 24 +++++++++++
.../intellij/vcs/log/graph/GraphFacade.java | 5 +--
.../vcs/log/graph/JumpToRowActionRequest.java | 30 ++++++++++++++
.../vcs/log/graph/GraphFacadeImpl.java | 2 +-
6 files changed, 120 insertions(+), 5 deletions(-)
create mode 100644 platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphActionRequest.java
create mode 100644 platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphAnswer.java
create mode 100644 platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphChange.java
create mode 100644 platform/vcs-log/api/src/com/intellij/vcs/log/graph/JumpToRowActionRequest.java
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphActionRequest.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphActionRequest.java
new file mode 100644
index 000000000000..a963da2a5ae5
--- /dev/null
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphActionRequest.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2014 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.vcs.log.graph;
+
+/**
+ * Action which should be executed by the code which called {@link GraphFacade#performAction(com.intellij.vcs.log.graph.GraphAction)}.
+ * E.g. when user clicks to the arrow to go to the parent/child commit, the table should jump to concrete row.
+ */
+public interface GraphActionRequest {
+
+}
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphAnswer.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphAnswer.java
new file mode 100644
index 000000000000..57c985155e89
--- /dev/null
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphAnswer.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2000-2014 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.vcs.log.graph;
+
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * The graph returns an instance of the GraphAnswer as a reaction to {@link #performAction(com.intellij.vcs.log.graph.GraphAction)}.
+ */
+public interface GraphAnswer {
+
+ /**
+ * Tells how graph was changed after performing action
+ * {@code null} means that graph didn't change (e.g. when user clicks on the arrow to go to the parent/child commit).
+ */
+ @Nullable
+ GraphChange getGraphChange();
+
+ /**
+ * Tells which action should be execute by the client code.
+ * {@code null} means that the graph doesn't expect the client code to execute anything special
+ * (although of course it can react somehow on the returned {@link #getGraphChange() GraphChange}.
+ */
+ @Nullable
+ GraphActionRequest getActionRequest();
+
+}
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphChange.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphChange.java
new file mode 100644
index 000000000000..41cdaa1f14a6
--- /dev/null
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphChange.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2014 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.vcs.log.graph;
+
+/**
+ * Describes how graph was changed after {@link GraphFacade#performAction(GraphAction) executing some action on it}
+ * (e.g. a linear branch was collapsed).
+ */
+public interface GraphChange {
+
+}
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphFacade.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphFacade.java
index ac70e25c84d5..ddd88d49d533 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphFacade.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphFacade.java
@@ -42,7 +42,7 @@ public interface GraphFacade {
* some modal progress or else.
*/
@Nullable
- GraphChangeEvent performAction(@NotNull GraphAction action);
+ GraphAnswer performAction(@NotNull GraphAction action);
/**
* Returns all commits in the graph without considering commits visibility.
@@ -84,7 +84,4 @@ public interface GraphFacade {
@NotNull
GraphInfoProvider getInfoProvider();
- interface GraphChangeEvent {
- }
-
}
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/JumpToRowActionRequest.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/JumpToRowActionRequest.java
new file mode 100644
index 000000000000..5b2518b26f8a
--- /dev/null
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/JumpToRowActionRequest.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2014 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.vcs.log.graph;
+
+public class JumpToRowActionRequest implements GraphActionRequest {
+
+ private final int myRow;
+
+ public JumpToRowActionRequest(int row) {
+ myRow = row;
+ }
+
+ public int getRow() {
+ return myRow;
+ }
+
+}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
index 8cf748299a74..f26dfa1ced1e 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
@@ -57,7 +57,7 @@ public class GraphFacadeImpl implements GraphFacade {
@Nullable
@Override
- public GraphChangeEvent performAction(@NotNull GraphAction action) {
+ public GraphAnswer performAction(@NotNull GraphAction action) {
if (action instanceof LinearBranchesExpansionAction) {
FragmentManager fragmentManager = myGraphModel.getFragmentManager();
if (((LinearBranchesExpansionAction)action).shouldExpand()) {
From 98b80a1983b3252d5bdb74735ead50d4f1bbf6fa Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Wed, 19 Feb 2014 18:56:57 +0400
Subject: [PATCH 061/172] rename & check link listener first
---
.../intellij/vcs/log/ui/frame/VcsLogGraphTable.java | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java
index 3532137577d3..dfab8be58eaa 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java
@@ -272,10 +272,10 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
private class MyMouseAdapter extends MouseAdapter {
private final Cursor DEFAULT_CURSOR = new Cursor(Cursor.DEFAULT_CURSOR);
private final Cursor HAND_CURSOR = new Cursor(Cursor.HAND_CURSOR);
- private final TableLinkMouseListener myTableListener;
+ private final TableLinkMouseListener myLinkListener;
MyMouseAdapter() {
- myTableListener = new TableLinkMouseListener();
+ myLinkListener = new TableLinkMouseListener();
}
@Nullable
@@ -313,6 +313,10 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
@Override
public void mouseClicked(MouseEvent e) {
+ if (myLinkListener.onClick(e, e.getClickCount())) {
+ return;
+ }
+
if (e.getClickCount() == 1) {
Node jumpToNode = arrowToNode(e);
if (jumpToNode != null) {
@@ -325,7 +329,6 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
myUI.click(PositionUtil.getRowIndex(e));
}
}
- myTableListener.onClick(e, e.getClickCount());
}
@Override
@@ -346,7 +349,7 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
}
private boolean isAboveLink(MouseEvent e) {
- return myTableListener.getTagAt(e) != null;
+ return myLinkListener.getTagAt(e) != null;
}
@Override
From a00646d58e48dc656d8c9d74bbdffd45eb229ac4 Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Thu, 20 Feb 2014 16:55:21 +0400
Subject: [PATCH 062/172] GraphColorManager: more methods + javadocs
---
.../vcs/log/graph/GraphColorManager.java | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphColorManager.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphColorManager.java
index 2b137140340e..caa82f2b93aa 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphColorManager.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphColorManager.java
@@ -20,9 +20,26 @@ import org.jetbrains.annotations.NotNull;
public interface GraphColorManager {
+ /**
+ * Returns the color which should be used to draw the given branch.
+ * @param headCommit branch head commit index.
+ */
@NotNull
JBColor getColorOfBranch(int headCommit);
+ /**
+ * Returns the color which should be used to draw a not-main fragment of a branch
+ * (e.g. there was master, then I've checked out a feature, made some commits and merged back to master - these my commits form such
+ * a fragment which is the same branch in terms of VCS, but is a separate branch in terms of graph,
+ * and therefore we may want to color it separately.
+ *
+ * @param headCommit commit of the branch head which the fragment belongs to.
+ * @param magicIndex some magic index identifying the fragment (we don't know which one - it is some Graph internal thing).
+ * @return the color which should be used to draw this fragment.
+ */
+ @NotNull
+ JBColor getColorOfFragment(int headCommit, int magicIndex);
+
/**
* Returns 1, 0 or -1 if branch identified by commit {@code head1} is "more powerful", "equally powerful" or "less powerful"
* than the branch identified by commit {@code head2}.
From c152a2901b09f28d0d0c81ffce6d145d39fe67b7 Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Thu, 20 Feb 2014 18:08:43 +0400
Subject: [PATCH 063/172] Move clicks & hovers to the GraphFacade
* Remove root column stuff from the GraphCellPainter.
Calculate multi-root offset from VcsLogGraphTable and pass the
relative point shifted by this offset.
Painting was not modified => it is broken for multi-roots,
the painting change will follow.
* GraphPrintCell is temporary passed to the actions.
+ Modify GraphInfoProvider interface (was lazy to split commits).
---
.../vcs/log/graph/GraphInfoProvider.java | 5 +-
.../log/graph/render/GraphCellPainter.java | 2 -
.../vcs/log/graph/render/PositionUtil.java | 27 +--
.../graph/render/SimpleGraphCellPainter.java | 23 +--
.../log/graph/ChangeCursorActionRequest.java | 33 ++++
.../vcs/log/graph/ClickGraphAction.java | 15 +-
.../vcs/log/graph/GraphFacadeImpl.java | 179 ++++++++++++++++--
.../vcs/log/graph/MouseOverAction.java | 49 +++++
.../src/com/intellij/vcs/log/ui/VcsLogUI.java | 51 +----
.../vcs/log/ui/frame/VcsLogGraphTable.java | 148 ++++++---------
10 files changed, 339 insertions(+), 193 deletions(-)
create mode 100644 platform/vcs-log/impl/src/com/intellij/vcs/log/graph/ChangeCursorActionRequest.java
rename platform/vcs-log/{api => impl}/src/com/intellij/vcs/log/graph/ClickGraphAction.java (74%)
create mode 100644 platform/vcs-log/impl/src/com/intellij/vcs/log/graph/MouseOverAction.java
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java
index 8bbd1e0adaa6..bf4b612c77d9 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphInfoProvider.java
@@ -23,13 +23,10 @@ import java.util.Set;
*/
public interface GraphInfoProvider {
- int getOneOfHeads(int commit); // this is fast
-
- Set getContainingBranches(int commitIndex); // this requires graph iteration => can take some time
+ Set getContainingBranches(int visibleRow); // this requires graph iteration => can take some time
RowInfo getRowInfo(int visibleRow);
- // TODO probably this can be removed and identified from the outside
boolean areLongEdgesHidden();
/**
diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/GraphCellPainter.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/GraphCellPainter.java
index b2fe9d65e966..8c1e32e3e645 100644
--- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/GraphCellPainter.java
+++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/GraphCellPainter.java
@@ -6,7 +6,6 @@ import com.intellij.vcs.log.printmodel.SpecialPrintElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import javax.swing.table.TableColumn;
import java.awt.*;
/**
@@ -22,6 +21,5 @@ public interface GraphCellPainter {
@Nullable
SpecialPrintElement mouseOverArrow(@NotNull GraphPrintCell row, int x, int y);
- void setRootColumn(TableColumn column);
}
diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/PositionUtil.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/PositionUtil.java
index 025577f7ae72..aab27f879849 100644
--- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/PositionUtil.java
+++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/PositionUtil.java
@@ -4,9 +4,10 @@ import com.intellij.vcs.log.graph.elements.Node;
import com.intellij.vcs.log.printmodel.GraphPrintCell;
import com.intellij.vcs.log.printmodel.ShortEdge;
import com.intellij.vcs.log.printmodel.SpecialPrintElement;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.awt.event.MouseEvent;
+import java.awt.*;
import static com.intellij.vcs.log.graph.render.PrintParameters.*;
@@ -15,38 +16,38 @@ public class PositionUtil {
return (float)Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
- public static boolean overUpEdge(ShortEdge edge, int x, int y, int offset) {
+ public static boolean overUpEdge(ShortEdge edge, int x, int y) {
float thick = THICK_LINE;
- int x1 = WIDTH_NODE * edge.getDownPosition() + WIDTH_NODE / 2 + offset;
+ int x1 = WIDTH_NODE * edge.getDownPosition() + WIDTH_NODE / 2;
int y1 = HEIGHT_CELL / 2;
- int x2 = WIDTH_NODE * edge.getUpPosition() + WIDTH_NODE / 2 + offset;
+ int x2 = WIDTH_NODE * edge.getUpPosition() + WIDTH_NODE / 2;
int y2 = -HEIGHT_CELL / 2;
//return true;
return (distance(x1, y1, x, y) + distance(x2, y2, x, y) < distance(x1, y1, x2, y2) + thick);
}
- public static boolean overDownEdge(ShortEdge edge, int x, int y, int offset) {
+ public static boolean overDownEdge(ShortEdge edge, int x, int y) {
float thick = THICK_LINE;
- int x1 = WIDTH_NODE * edge.getUpPosition() + WIDTH_NODE / 2 + offset;
+ int x1 = WIDTH_NODE * edge.getUpPosition() + WIDTH_NODE / 2;
int y1 = HEIGHT_CELL / 2;
- int x2 = WIDTH_NODE * edge.getDownPosition() + WIDTH_NODE / 2 + offset;
+ int x2 = WIDTH_NODE * edge.getDownPosition() + WIDTH_NODE / 2;
int y2 = HEIGHT_CELL + HEIGHT_CELL / 2;
return distance(x1, y1, x, y) + distance(x2, y2, x, y) < distance(x1, y1, x2, y2) + thick;
}
- public static boolean overNode(int position, int x, int y, int xOffset) {
- int x0 = WIDTH_NODE * position + WIDTH_NODE / 2 + xOffset;
+ public static boolean overNode(int position, int x, int y) {
+ int x0 = WIDTH_NODE * position + WIDTH_NODE / 2;
int y0 = HEIGHT_CELL / 2;
int r = CIRCLE_RADIUS;
return distance(x0, y0, x, y) <= r;
}
- public static int getYInsideRow(MouseEvent e) {
- return e.getY() - getRowIndex(e) * HEIGHT_CELL;
+ public static int getYInsideRow(@NotNull Point point) {
+ return point.y - getRowIndex(point) * HEIGHT_CELL;
}
- public static int getRowIndex(MouseEvent e) {
- return e.getY() / HEIGHT_CELL;
+ public static int getRowIndex(@NotNull Point point) {
+ return point.y / HEIGHT_CELL;
}
@Nullable
diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/SimpleGraphCellPainter.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/SimpleGraphCellPainter.java
index 4c9c1cff271c..41ad959e436e 100644
--- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/SimpleGraphCellPainter.java
+++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/SimpleGraphCellPainter.java
@@ -10,7 +10,6 @@ import com.intellij.vcs.log.printmodel.SpecialPrintElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import javax.swing.table.TableColumn;
import java.awt.*;
import java.awt.geom.Ellipse2D;
@@ -20,8 +19,6 @@ import java.awt.geom.Ellipse2D;
public class SimpleGraphCellPainter implements GraphCellPainter {
private static final Color MARK_COLOR = JBColor.BLACK;
- private final boolean myMultiRoot;
- private TableColumn myRootColumn;
private Graphics2D g2;
@@ -30,10 +27,6 @@ public class SimpleGraphCellPainter implements GraphCellPainter {
private final Stroke selectUsual = new BasicStroke(PrintParameters.SELECT_THICK_LINE, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL);
private final Stroke selectHide = new BasicStroke(PrintParameters.SELECT_THICK_LINE, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL, 0, new float[]{7}, 0);
- public SimpleGraphCellPainter(boolean multiRoot) {
- myMultiRoot = multiRoot;
- }
-
private void paintUpLine(int from, int to, Color color) {
int x1 = PrintParameters.WIDTH_NODE * from + PrintParameters.WIDTH_NODE / 2;
int y1 = PrintParameters.HEIGHT_CELL / 2;
@@ -217,18 +210,18 @@ public class SimpleGraphCellPainter implements GraphCellPainter {
public GraphElement mouseOver(@NotNull GraphPrintCell row, int x, int y) {
for (SpecialPrintElement printElement : row.getSpecialPrintElements()) {
if (printElement.getType() == SpecialPrintElement.Type.COMMIT_NODE) {
- if (PositionUtil.overNode(printElement.getPosition(), x, y, getXOffset())) {
+ if (PositionUtil.overNode(printElement.getPosition(), x, y)) {
return printElement.getGraphElement();
}
}
}
for (ShortEdge edge : row.getUpEdges()) {
- if (PositionUtil.overUpEdge(edge, x, y, getXOffset())) {
+ if (PositionUtil.overUpEdge(edge, x, y)) {
return edge.getEdge();
}
}
for (ShortEdge edge : row.getDownEdges()) {
- if (PositionUtil.overDownEdge(edge, x, y, getXOffset())) {
+ if (PositionUtil.overDownEdge(edge, x, y)) {
return edge.getEdge();
}
}
@@ -236,16 +229,12 @@ public class SimpleGraphCellPainter implements GraphCellPainter {
return null;
}
- private int getXOffset() {
- return myMultiRoot && myRootColumn != null ? myRootColumn.getWidth() : 0;
- }
-
@Nullable
@Override
public SpecialPrintElement mouseOverArrow(@NotNull GraphPrintCell row, int x, int y) {
for (SpecialPrintElement printElement : row.getSpecialPrintElements()) {
if (printElement.getType() != SpecialPrintElement.Type.COMMIT_NODE) {
- if (PositionUtil.overNode(printElement.getPosition(), x, y, getXOffset())) {
+ if (PositionUtil.overNode(printElement.getPosition(), x, y)) {
return printElement;
}
}
@@ -253,8 +242,4 @@ public class SimpleGraphCellPainter implements GraphCellPainter {
return null;
}
- @Override
- public void setRootColumn(TableColumn column) {
- myRootColumn = column;
- }
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/ChangeCursorActionRequest.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/ChangeCursorActionRequest.java
new file mode 100644
index 000000000000..ec7908295875
--- /dev/null
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/ChangeCursorActionRequest.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2000-2014 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.vcs.log.graph;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.awt.*;
+
+public class ChangeCursorActionRequest implements GraphActionRequest {
+ @NotNull private final Cursor myCursor;
+
+ public ChangeCursorActionRequest(@NotNull Cursor cursor) {
+ myCursor = cursor;
+ }
+
+ @NotNull
+ public Cursor getCursor() {
+ return myCursor;
+ }
+}
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/ClickGraphAction.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/ClickGraphAction.java
similarity index 74%
rename from platform/vcs-log/api/src/com/intellij/vcs/log/graph/ClickGraphAction.java
rename to platform/vcs-log/impl/src/com/intellij/vcs/log/graph/ClickGraphAction.java
index 55880ee799bf..732fd00dc746 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/ClickGraphAction.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/ClickGraphAction.java
@@ -15,6 +15,7 @@
*/
package com.intellij.vcs.log.graph;
+import com.intellij.vcs.log.printmodel.GraphPrintCell;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
@@ -23,13 +24,25 @@ public class ClickGraphAction implements GraphAction {
private final int myVisibleRow;
@Nullable private final Point myRelativePoint;
+ @Nullable private final GraphPrintCell myPrintCell;
- public ClickGraphAction(int visibleRow, @Nullable Point relativePoint) {
+ public ClickGraphAction(int visibleRow, @Nullable Point relativePoint, @Nullable GraphPrintCell printCell) {
myVisibleRow = visibleRow;
myRelativePoint = relativePoint;
+ myPrintCell = printCell;
}
public int getRow() {
return myVisibleRow;
}
+
+ @Nullable
+ public Point getRelativePoint() {
+ return myRelativePoint;
+ }
+
+ @Nullable
+ public GraphPrintCell getPrintCell() {
+ return myPrintCell;
+ }
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
index f26dfa1ced1e..5fc3f9154a9a 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
@@ -19,11 +19,19 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Condition;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
+import com.intellij.vcs.log.compressedlist.UpdateRequest;
+import com.intellij.vcs.log.graph.elements.Edge;
+import com.intellij.vcs.log.graph.elements.GraphElement;
import com.intellij.vcs.log.graph.elements.Node;
import com.intellij.vcs.log.graph.elements.NodeRow;
+import com.intellij.vcs.log.graph.render.SimpleGraphCellPainter;
import com.intellij.vcs.log.graphmodel.FragmentManager;
+import com.intellij.vcs.log.graphmodel.GraphFragment;
import com.intellij.vcs.log.graphmodel.GraphModel;
+import com.intellij.vcs.log.printmodel.GraphPrintCell;
import com.intellij.vcs.log.printmodel.GraphPrintCellModel;
+import com.intellij.vcs.log.printmodel.SelectController;
+import com.intellij.vcs.log.printmodel.SpecialPrintElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -42,12 +50,16 @@ public class GraphFacadeImpl implements GraphFacade {
}
};
- private final GraphModel myGraphModel;
- private final GraphPrintCellModel myPrintCellModel;
+ @NotNull private final GraphModel myGraphModel;
+ @NotNull private final GraphPrintCellModel myPrintCellModel;
+ @NotNull private final SimpleGraphCellPainter myGraphPainter;
- public GraphFacadeImpl(GraphModel graphModel, GraphPrintCellModel printCellModel) {
+ @Nullable private GraphElement prevGraphElement;
+
+ public GraphFacadeImpl(@NotNull GraphModel graphModel, @NotNull GraphPrintCellModel printCellModel) {
myGraphModel = graphModel;
myPrintCellModel = printCellModel;
+ myGraphPainter = new SimpleGraphCellPainter();
}
@Override
@@ -71,22 +83,124 @@ public class GraphFacadeImpl implements GraphFacade {
myPrintCellModel.setLongEdgeVisibility(((LongEdgesAction)action).shouldShowLongEdges());
}
else if (action instanceof ClickGraphAction) {
- myPrintCellModel.getCommitSelectController().deselectAll();
- Node node = myGraphModel.getGraph().getCommitNodeInRow(((ClickGraphAction)action).getRow());
- if (node != null) {
- FragmentManager fragmentController = myGraphModel.getFragmentManager();
- myPrintCellModel.getCommitSelectController().select(fragmentController.allCommitsCurrentBranch(node));
- }
+ return handleClick((ClickGraphAction)action);
+ }
+ else if (action instanceof MouseOverAction) {
+ return handleMouseOver((MouseOverAction)action);
}
return null;
}
+ @Nullable
+ private GraphAnswer handleMouseOver(MouseOverAction action) {
+ Node jumpToNode = arrowToNode(action.getRelativePoint(), action.getPrintCell());
+ if (jumpToNode != null) {
+ over(null);
+ return new ChangeCursorAnswer(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+ }
+ else {
+ over(overCell(action.getRelativePoint(), action.getPrintCell()));
+ return new ChangeCursorAnswer(Cursor.getDefaultCursor());
+ }
+ }
+
+ @Nullable
+ private GraphAnswer handleClick(@NotNull ClickGraphAction action) {
+ if (action.getRelativePoint() == null) {
+ return handleRowSelection(action.getRow());
+ }
+ else {
+ return handleMouseClick(action.getRow(), action.getRelativePoint(), action.getPrintCell());
+ }
+ }
+
+ @Nullable
+ private GraphAnswer handleRowSelection(int row) {
+ myPrintCellModel.getCommitSelectController().deselectAll();
+ Node node = myGraphModel.getGraph().getCommitNodeInRow(row);
+ if (node != null) {
+ FragmentManager fragmentController = myGraphModel.getFragmentManager();
+ myPrintCellModel.getCommitSelectController().select(fragmentController.allCommitsCurrentBranch(node));
+ }
+ return null;
+ }
+
+ @Nullable
+ private GraphAnswer handleMouseClick(int row, @NotNull Point point, @Nullable GraphPrintCell printCell) {
+ Node jumpToNode = arrowToNode(point, printCell);
+ if (jumpToNode != null) {
+ return new JumpToRowAnswer(jumpToNode.getRowIndex());
+ }
+ GraphElement graphElement = overCell(point, printCell);
+ myPrintCellModel.getSelectController().deselectAll();
+ if (graphElement == null) {
+ return handleRowSelection(row);
+ }
+ else {
+ return click(graphElement);
+ }
+ }
+
+ @Nullable
+ private Node arrowToNode(@NotNull Point point, @Nullable GraphPrintCell row) {
+ if (row == null) {
+ return null;
+ }
+ SpecialPrintElement printElement = myGraphPainter.mouseOverArrow(row, point.x, point.y);
+ if (printElement == null) {
+ return null;
+ }
+ Edge edge = printElement.getGraphElement().getEdge();
+ if (edge == null) {
+ return null;
+ }
+ return printElement.getType() == SpecialPrintElement.Type.DOWN_ARROW ? edge.getDownNode() : edge.getUpNode();
+ }
+
+ @Nullable
+ public GraphAnswer click(@Nullable GraphElement graphElement) {
+ FragmentManager fragmentController = myGraphModel.getFragmentManager();
+ if (graphElement == null) {
+ return null;
+ }
+ final GraphFragment fragment = fragmentController.relateFragment(graphElement);
+ if (fragment == null) {
+ return null;
+ }
+
+ UpdateRequest updateRequest = fragmentController.changeVisibility(fragment);
+ return new JumpToRowAnswer(updateRequest.from());
+ }
+
+ public void over(@Nullable GraphElement graphElement) {
+ SelectController selectController = myPrintCellModel.getSelectController();
+ FragmentManager fragmentManager = myGraphModel.getFragmentManager();
+ if (graphElement == prevGraphElement) {
+ return;
+ }
+ else {
+ prevGraphElement = graphElement;
+ }
+ selectController.deselectAll();
+ if (graphElement != null) {
+ GraphFragment graphFragment = fragmentManager.relateFragment(graphElement);
+ selectController.select(graphFragment);
+ }
+ }
+
@NotNull
@Override
public List getAllCommits() {
throw new UnsupportedOperationException();
}
+ @Nullable
+ private GraphElement overCell(@NotNull Point point, @Nullable GraphPrintCell row) {
+ int y = point.y;
+ int x = point.x;
+ return row != null ? myGraphPainter.mouseOver(row, x, y) : null;
+ }
+
@Override
public int getCommitAtRow(int visibleRow) {
NodeRow row = myGraphModel.getGraph().getNodeRows().get(visibleRow);
@@ -145,12 +259,7 @@ public class GraphFacadeImpl implements GraphFacade {
private class GraphInfoProviderImpl implements GraphInfoProvider {
@Override
- public int getOneOfHeads(int commit) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Set getContainingBranches(int commitIndex) {
+ public Set getContainingBranches(int visibleRow) {
throw new UnsupportedOperationException();
}
@@ -180,4 +289,44 @@ public class GraphFacadeImpl implements GraphFacade {
}
}
+ private static class JumpToRowAnswer implements GraphAnswer {
+ private final int myRow;
+
+ public JumpToRowAnswer(int row) {
+ myRow = row;
+ }
+
+ @Nullable
+ @Override
+ public GraphChange getGraphChange() {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public GraphActionRequest getActionRequest() {
+ return new JumpToRowActionRequest(myRow);
+ }
+
+ }
+
+ private static class ChangeCursorAnswer implements GraphAnswer {
+ private final Cursor myCursor;
+
+ public ChangeCursorAnswer(@NotNull Cursor cursor) {
+ myCursor = cursor;
+ }
+
+ @Nullable
+ @Override
+ public GraphChange getGraphChange() {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public GraphActionRequest getActionRequest() {
+ return new ChangeCursorActionRequest(myCursor);
+ }
+ }
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/MouseOverAction.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/MouseOverAction.java
new file mode 100644
index 000000000000..eb98fc6d4fe6
--- /dev/null
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/MouseOverAction.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2000-2014 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.vcs.log.graph;
+
+import com.intellij.vcs.log.printmodel.GraphPrintCell;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.awt.*;
+
+public class MouseOverAction implements GraphAction {
+
+ private final int myVisibleRow;
+ @NotNull private final Point myRelativePoint;
+ @Nullable private final GraphPrintCell myPrintCell;
+
+ public MouseOverAction(int visibleRow, @NotNull Point relativePoint, @Nullable GraphPrintCell printCell) {
+ myVisibleRow = visibleRow;
+ myRelativePoint = relativePoint;
+ myPrintCell = printCell;
+ }
+
+ public int getRow() {
+ return myVisibleRow;
+ }
+
+ @NotNull
+ public Point getRelativePoint() {
+ return myRelativePoint;
+ }
+
+ @Nullable
+ public GraphPrintCell getPrintCell() {
+ return myPrintCell;
+ }
+}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java
index e514ea8bb82e..55eda106cbed 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java
@@ -12,7 +12,6 @@ import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsLog;
import com.intellij.vcs.log.VcsLogFilterCollection;
import com.intellij.vcs.log.VcsLogSettings;
-import com.intellij.vcs.log.compressedlist.UpdateRequest;
import com.intellij.vcs.log.data.DataPack;
import com.intellij.vcs.log.data.VcsLogDataHolder;
import com.intellij.vcs.log.data.VcsLogFilterer;
@@ -20,11 +19,7 @@ import com.intellij.vcs.log.data.VcsLogUiProperties;
import com.intellij.vcs.log.graph.ClickGraphAction;
import com.intellij.vcs.log.graph.LinearBranchesExpansionAction;
import com.intellij.vcs.log.graph.LongEdgesAction;
-import com.intellij.vcs.log.graph.elements.GraphElement;
-import com.intellij.vcs.log.graphmodel.FragmentManager;
-import com.intellij.vcs.log.graphmodel.GraphFragment;
import com.intellij.vcs.log.impl.VcsLogImpl;
-import com.intellij.vcs.log.printmodel.SelectController;
import com.intellij.vcs.log.ui.frame.MainFrame;
import com.intellij.vcs.log.ui.frame.VcsLogGraphTable;
import com.intellij.vcs.log.ui.tables.AbstractVcsLogTableModel;
@@ -54,8 +49,6 @@ public class VcsLogUI {
@NotNull private final VcsLogFilterer myFilterer;
@NotNull private final VcsLog myLog;
- @Nullable private GraphElement prevGraphElement;
-
public VcsLogUI(@NotNull VcsLogDataHolder logDataHolder, @NotNull Project project, @NotNull VcsLogSettings settings,
@NotNull VcsLogColorManager manager, @NotNull VcsLogUiProperties uiProperties) {
myLogDataHolder = logDataHolder;
@@ -174,51 +167,9 @@ public class VcsLogUI {
return myLogDataHolder.getDataPack().getGraphFacade().getInfoProvider().areLongEdgesHidden();
}
- public void over(@Nullable GraphElement graphElement) {
- SelectController selectController = myLogDataHolder.getDataPack().getPrintCellModel().getSelectController();
- FragmentManager fragmentManager = myLogDataHolder.getDataPack().getGraphModel().getFragmentManager();
- if (graphElement == prevGraphElement) {
- return;
- }
- else {
- prevGraphElement = graphElement;
- }
- selectController.deselectAll();
- if (graphElement == null) {
- updateUI();
- }
- else {
- GraphFragment graphFragment = fragmentManager.relateFragment(graphElement);
- selectController.select(graphFragment);
- updateUI();
- }
- }
-
- public void click(@Nullable GraphElement graphElement) {
- SelectController selectController = myLogDataHolder.getDataPack().getPrintCellModel().getSelectController();
- final FragmentManager fragmentController = myLogDataHolder.getDataPack().getGraphModel().getFragmentManager();
- selectController.deselectAll();
- if (graphElement == null) {
- return;
- }
- final GraphFragment fragment = fragmentController.relateFragment(graphElement);
- if (fragment == null) {
- return;
- }
-
- myMainFrame.getGraphTable().executeWithoutRepaint(new Runnable() {
- @Override
- public void run() {
- UpdateRequest updateRequest = fragmentController.changeVisibility(fragment);
- jumpToRow(updateRequest.from());
- }
- });
- updateUI();
- }
-
public void click(int rowIndex) {
DataPack dataPack = myLogDataHolder.getDataPack();
- dataPack.getGraphFacade().performAction(new ClickGraphAction(rowIndex, null));
+ dataPack.getGraphFacade().performAction(new ClickGraphAction(rowIndex, null, null));
updateUI();
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java
index dfab8be58eaa..0214d7dcf30e 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java
@@ -12,17 +12,18 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.JBColor;
import com.intellij.ui.PopupHandler;
import com.intellij.ui.table.JBTable;
+import com.intellij.util.PairFunction;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.text.DateFormatUtil;
import com.intellij.util.ui.UIUtil;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.data.VcsLogDataHolder;
-import com.intellij.vcs.log.graph.elements.Edge;
-import com.intellij.vcs.log.graph.elements.GraphElement;
-import com.intellij.vcs.log.graph.elements.Node;
-import com.intellij.vcs.log.graph.render.*;
+import com.intellij.vcs.log.graph.*;
+import com.intellij.vcs.log.graph.render.CommitCell;
+import com.intellij.vcs.log.graph.render.GraphCommitCell;
+import com.intellij.vcs.log.graph.render.PositionUtil;
+import com.intellij.vcs.log.graph.render.SimpleGraphCellPainter;
import com.intellij.vcs.log.printmodel.GraphPrintCell;
-import com.intellij.vcs.log.printmodel.SpecialPrintElement;
import com.intellij.vcs.log.ui.VcsLogUI;
import com.intellij.vcs.log.ui.render.CommitCellRender;
import com.intellij.vcs.log.ui.render.GraphCommitCellRender;
@@ -31,7 +32,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import javax.swing.event.*;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
import javax.swing.table.*;
import java.awt.*;
import java.awt.datatransfer.StringSelection;
@@ -53,7 +55,7 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
private static final int MAX_DEFAULT_AUTHOR_COLUMN_WIDTH = 200;
@NotNull private final VcsLogUI myUI;
- @NotNull private final GraphCellPainter myGraphPainter;
+ private final VcsLogDataHolder myLogDataHolder;
private boolean myColumnsSizeInitialized = false;
private volatile boolean myRepaintFreezed;
@@ -61,11 +63,10 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
public VcsLogGraphTable(@NotNull VcsLogUI UI, final VcsLogDataHolder logDataHolder) {
super();
myUI = UI;
-
- myGraphPainter = new SimpleGraphCellPainter(logDataHolder.isMultiRoot());
+ myLogDataHolder = logDataHolder;
setDefaultRenderer(VirtualFile.class, new RootCellRenderer(myUI));
- setDefaultRenderer(GraphCommitCell.class, new GraphCommitCellRender(myGraphPainter, logDataHolder, myUI.getColorManager()));
+ setDefaultRenderer(GraphCommitCell.class, new GraphCommitCellRender(new SimpleGraphCellPainter(), logDataHolder, myUI.getColorManager()));
setDefaultRenderer(CommitCell.class, new CommitCellRender(myUI.getColorManager(), logDataHolder.getProject()));
setDefaultRenderer(String.class, new StringCellRenderer());
@@ -88,31 +89,6 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
addMouseListener(mouseAdapter);
PopupHandler.installPopupHandler(this, VcsLogUI.POPUP_ACTION_GROUP, VcsLogUI.VCS_LOG_TABLE_PLACE);
-
- getColumnModel().addColumnModelListener(new TableColumnModelListener() {
- @Override
- public void columnAdded(TableColumnModelEvent e) {
- if (e.getToIndex() == AbstractVcsLogTableModel.ROOT_COLUMN) {
- myGraphPainter.setRootColumn(getColumnModel().getColumn(AbstractVcsLogTableModel.ROOT_COLUMN));
- }
- }
-
- @Override
- public void columnRemoved(TableColumnModelEvent e) {
- }
-
- @Override
- public void columnMoved(TableColumnModelEvent e) {
- }
-
- @Override
- public void columnMarginChanged(ChangeEvent e) {
- }
-
- @Override
- public void columnSelectionChanged(ListSelectionEvent e) {
- }
- });
}
@Override
@@ -270,47 +246,12 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
}
private class MyMouseAdapter extends MouseAdapter {
- private final Cursor DEFAULT_CURSOR = new Cursor(Cursor.DEFAULT_CURSOR);
- private final Cursor HAND_CURSOR = new Cursor(Cursor.HAND_CURSOR);
private final TableLinkMouseListener myLinkListener;
MyMouseAdapter() {
myLinkListener = new TableLinkMouseListener();
}
- @Nullable
- private GraphPrintCell getGraphPrintCell(MouseEvent e) {
- int rowIndex = PositionUtil.getRowIndex(e);
- return getGraphPrintCellForRow(getModel(), rowIndex);
- }
-
- @Nullable
- private GraphElement overCell(MouseEvent e) {
- int y = PositionUtil.getYInsideRow(e);
- int x = e.getX();
- GraphPrintCell row = getGraphPrintCell(e);
- return row != null ? myGraphPainter.mouseOver(row, x, y) : null;
- }
-
- @Nullable
- private Node arrowToNode(MouseEvent e) {
- int y = PositionUtil.getYInsideRow(e);
- int x = e.getX();
- GraphPrintCell row = getGraphPrintCell(e);
- if (row == null) {
- return null;
- }
- SpecialPrintElement printElement = myGraphPainter.mouseOverArrow(row, x, y);
- if (printElement == null) {
- return null;
- }
- Edge edge = printElement.getGraphElement().getEdge();
- if (edge == null) {
- return null;
- }
- return printElement.getType() == SpecialPrintElement.Type.DOWN_ARROW ? edge.getDownNode() : edge.getUpNode();
- }
-
@Override
public void mouseClicked(MouseEvent e) {
if (myLinkListener.onClick(e, e.getClickCount())) {
@@ -318,34 +259,36 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
}
if (e.getClickCount() == 1) {
- Node jumpToNode = arrowToNode(e);
- if (jumpToNode != null) {
- jumpToRow(jumpToNode.getRowIndex());
- return;
- }
- GraphElement graphElement = overCell(e);
- myUI.click(graphElement);
- if (graphElement == null) {
- myUI.click(PositionUtil.getRowIndex(e));
- }
+ performAction(e, new PairFunction() {
+ @Override
+ public GraphAction fun(Integer row, Point point) {
+ return new ClickGraphAction(row, point, getGraphPrintCellForRow(getModel(), row));
+ }
+ });
}
}
@Override
public void mouseMoved(MouseEvent e) {
- Node jumpToNode = arrowToNode(e);
- if (jumpToNode != null || isAboveLink(e)) {
- setCursor(HAND_CURSOR);
+ if (isAboveLink(e)) {
+ setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
else {
- setCursor(DEFAULT_CURSOR);
+ performAction(e, new PairFunction() {
+ @Override
+ public GraphAction fun(Integer row, Point point) {
+ return new MouseOverAction(row, point, getGraphPrintCellForRow(getModel(), row));
+ }
+ });
}
+ }
- if (jumpToNode == null) {
- myUI.over(overCell(e));
- } else {
- myUI.over(null);
- }
+ private void performAction(@NotNull MouseEvent e, @NotNull PairFunction actionConstructor) {
+ int row = PositionUtil.getRowIndex(e.getPoint());
+ Point point = calcPoint4Graph(e.getPoint());
+ GraphFacade graphFacade = myLogDataHolder.getDataPack().getGraphFacade();
+ GraphAnswer answer = graphFacade.performAction(actionConstructor.fun(row, point));
+ handleAnswer(answer);
}
private boolean isAboveLink(MouseEvent e) {
@@ -363,6 +306,33 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
}
}
+ private void handleAnswer(@Nullable GraphAnswer answer) {
+ setCursor(Cursor.getDefaultCursor());
+ myUI.updateUI();
+
+ if (answer == null) {
+ return;
+ }
+ GraphActionRequest actionRequest = answer.getActionRequest();
+ if (actionRequest instanceof JumpToRowActionRequest) {
+ int row = ((JumpToRowActionRequest)actionRequest).getRow();
+ jumpToRow(row);
+ }
+ else if (actionRequest instanceof ChangeCursorActionRequest) {
+ setCursor(((ChangeCursorActionRequest)actionRequest).getCursor());
+ }
+ }
+
+ @NotNull
+ private Point calcPoint4Graph(@NotNull Point clickPoint) {
+ return new Point(clickPoint.x - getXOffset(), PositionUtil.getYInsideRow(clickPoint));
+ }
+
+ private int getXOffset() {
+ TableColumn rootColumn = getColumnModel().getColumn(AbstractVcsLogTableModel.ROOT_COLUMN);
+ return myLogDataHolder.isMultiRoot() ? rootColumn.getWidth() : 0;
+ }
+
private static class RootCellRenderer extends JPanel implements TableCellRenderer {
private static final Logger LOG = Logger.getInstance(RootCellRenderer.class);
From 99d52e8d0e34f6a126b08b7a0fd90773765f4086 Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Sat, 22 Feb 2014 11:23:38 +0400
Subject: [PATCH 064/172] [log] Delegate graph painting to the GraphFacade
* Remove the GraphPrintCell from the GraphCommitCell & actions: the
graph facade is be able to get the print cell by row
from the print cell model.
* Move graph painting to GraphFacadeImpl.
Paint on an image; return the image and the width for text padding.
* Rewrite AbstractPaddingCellRender & descendants: move refs painting
to the parent, since it is used in both renderers.
prepare the image in getCellRenderer, use it in paint().
---
.../intellij/vcs/log/graph/GraphFacade.java | 6 +-
.../com/intellij/vcs/log/graph/PaintInfo.java | 37 ++++++++
.../vcs/log/graph/render/GraphCommitCell.java | 10 +--
.../vcs/log/graph/ClickGraphAction.java | 9 +-
.../vcs/log/graph/GraphFacadeImpl.java | 53 ++++++++++--
.../vcs/log/graph/MouseOverAction.java | 10 +--
.../src/com/intellij/vcs/log/ui/VcsLogUI.java | 2 +-
.../vcs/log/ui/frame/VcsLogGraphTable.java | 31 ++-----
.../ui/render/AbstractPaddingCellRender.java | 75 ++++++++++++-----
.../vcs/log/ui/render/CommitCellRender.java | 43 ++--------
.../log/ui/render/GraphCommitCellRender.java | 84 +++----------------
.../vcs/log/ui/render/RefPainter.java | 6 +-
.../vcs/log/ui/tables/GraphTableModel.java | 7 +-
13 files changed, 172 insertions(+), 201 deletions(-)
create mode 100644 platform/vcs-log/api/src/com/intellij/vcs/log/graph/PaintInfo.java
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphFacade.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphFacade.java
index ddd88d49d533..f0f9b121fca3 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphFacade.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/GraphFacade.java
@@ -19,7 +19,6 @@ import com.intellij.openapi.util.Condition;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.awt.*;
import java.util.Collection;
import java.util.List;
@@ -31,9 +30,10 @@ import java.util.List;
public interface GraphFacade {
/**
- * Paints the given row in the given Graphics.
+ * Paints the given row.
*/
- void paint(Graphics2D g, int visibleRow);
+ @NotNull
+ PaintInfo paint(int visibleRow);
/**
* Performs some user action on the graph, which can be a click, hover, drag, changing view parameters, etc.
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/graph/PaintInfo.java b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/PaintInfo.java
new file mode 100644
index 000000000000..42e56042756e
--- /dev/null
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/graph/PaintInfo.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2000-2014 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.vcs.log.graph;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.awt.*;
+
+public interface PaintInfo {
+
+ /**
+ * Returns the image to actually paint.
+ */
+ @NotNull
+ Image getImage();
+
+ /**
+ * Returns the "interesting" width of the painted image, i.e. the width which the text in the table should be offset by.
+ * It can be smaller than the width of {@link #getImage() the image}, because we allow the text to cover part of the graph
+ * (some diagonal edges, etc.)
+ */
+ int getWidth();
+
+}
diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/GraphCommitCell.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/GraphCommitCell.java
index ae7d35130f25..f09ceb6ff3b2 100644
--- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/GraphCommitCell.java
+++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/GraphCommitCell.java
@@ -1,7 +1,6 @@
package com.intellij.vcs.log.graph.render;
import com.intellij.vcs.log.VcsRef;
-import com.intellij.vcs.log.printmodel.GraphPrintCell;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
@@ -12,15 +11,8 @@ import java.util.Collection;
*/
public class GraphCommitCell extends CommitCell {
- private final GraphPrintCell row;
-
- public GraphCommitCell(@NotNull GraphPrintCell row, @NotNull String text,
- @NotNull Collection refsToThisCommit) {
+ public GraphCommitCell(@NotNull String text, @NotNull Collection refsToThisCommit) {
super(text, refsToThisCommit);
- this.row = row;
}
- public GraphPrintCell getPrintCell() {
- return row;
- }
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/ClickGraphAction.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/ClickGraphAction.java
index 732fd00dc746..fc037f701855 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/ClickGraphAction.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/ClickGraphAction.java
@@ -15,7 +15,6 @@
*/
package com.intellij.vcs.log.graph;
-import com.intellij.vcs.log.printmodel.GraphPrintCell;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
@@ -24,12 +23,10 @@ public class ClickGraphAction implements GraphAction {
private final int myVisibleRow;
@Nullable private final Point myRelativePoint;
- @Nullable private final GraphPrintCell myPrintCell;
- public ClickGraphAction(int visibleRow, @Nullable Point relativePoint, @Nullable GraphPrintCell printCell) {
+ public ClickGraphAction(int visibleRow, @Nullable Point relativePoint) {
myVisibleRow = visibleRow;
myRelativePoint = relativePoint;
- myPrintCell = printCell;
}
public int getRow() {
@@ -41,8 +38,4 @@ public class ClickGraphAction implements GraphAction {
return myRelativePoint;
}
- @Nullable
- public GraphPrintCell getPrintCell() {
- return myPrintCell;
- }
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
index 5fc3f9154a9a..cf806f2b65cd 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
@@ -19,6 +19,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Condition;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.ui.UIUtil;
import com.intellij.vcs.log.compressedlist.UpdateRequest;
import com.intellij.vcs.log.graph.elements.Edge;
import com.intellij.vcs.log.graph.elements.GraphElement;
@@ -36,10 +37,14 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
+import java.awt.image.BufferedImage;
import java.util.Collection;
import java.util.List;
import java.util.Set;
+import static com.intellij.vcs.log.graph.render.PrintParameters.HEIGHT_CELL;
+import static com.intellij.vcs.log.graph.render.PrintParameters.WIDTH_NODE;
+
public class GraphFacadeImpl implements GraphFacade {
private static final Logger LOG = Logger.getInstance(GraphFacadeImpl.class);
@@ -50,6 +55,9 @@ public class GraphFacadeImpl implements GraphFacade {
}
};
+ // In case of diagonal edges, one node can be at most 3 "arrows" + 2 nodes at the left from another - that is enough for sure
+ private static final int IMAGE_WIDTH_RESERVE = 5 * WIDTH_NODE;
+
@NotNull private final GraphModel myGraphModel;
@NotNull private final GraphPrintCellModel myPrintCellModel;
@NotNull private final SimpleGraphCellPainter myGraphPainter;
@@ -62,9 +70,20 @@ public class GraphFacadeImpl implements GraphFacade {
myGraphPainter = new SimpleGraphCellPainter();
}
+ @NotNull
@Override
- public void paint(Graphics2D g, int visibleRow) {
- throw new UnsupportedOperationException();
+ public PaintInfo paint(int visibleRow) {
+ GraphPrintCell cell = myPrintCellModel.getGraphPrintCell(visibleRow);
+ int imageWidth = calcImageWidth(cell);
+ int bufferWidth = imageWidth + IMAGE_WIDTH_RESERVE;
+ BufferedImage image = UIUtil.createImage(bufferWidth, HEIGHT_CELL, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2 = image.createGraphics();
+ myGraphPainter.draw(g2, cell);
+ return new PaintInfoImpl(image, imageWidth);
+ }
+
+ private static int calcImageWidth(@NotNull GraphPrintCell cell) {
+ return cell.countCell() * WIDTH_NODE;
}
@Nullable
@@ -93,13 +112,14 @@ public class GraphFacadeImpl implements GraphFacade {
@Nullable
private GraphAnswer handleMouseOver(MouseOverAction action) {
- Node jumpToNode = arrowToNode(action.getRelativePoint(), action.getPrintCell());
+ GraphPrintCell printCell = myPrintCellModel.getGraphPrintCell(action.getRow());
+ Node jumpToNode = arrowToNode(action.getRelativePoint(), printCell);
if (jumpToNode != null) {
over(null);
return new ChangeCursorAnswer(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
else {
- over(overCell(action.getRelativePoint(), action.getPrintCell()));
+ over(overCell(action.getRelativePoint(), printCell));
return new ChangeCursorAnswer(Cursor.getDefaultCursor());
}
}
@@ -110,7 +130,8 @@ public class GraphFacadeImpl implements GraphFacade {
return handleRowSelection(action.getRow());
}
else {
- return handleMouseClick(action.getRow(), action.getRelativePoint(), action.getPrintCell());
+ GraphPrintCell printCell = myPrintCellModel.getGraphPrintCell(action.getRow());
+ return handleMouseClick(action.getRow(), action.getRelativePoint(), printCell);
}
}
@@ -329,4 +350,26 @@ public class GraphFacadeImpl implements GraphFacade {
return new ChangeCursorActionRequest(myCursor);
}
}
+
+ private static class PaintInfoImpl implements PaintInfo {
+
+ private final Image myImage;
+ private final int myWidth;
+
+ public PaintInfoImpl(Image image, int width) {
+ myImage = image;
+ myWidth = width;
+ }
+
+ @NotNull
+ @Override
+ public Image getImage() {
+ return myImage;
+ }
+
+ @Override
+ public int getWidth() {
+ return myWidth;
+ }
+ }
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/MouseOverAction.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/MouseOverAction.java
index eb98fc6d4fe6..ca619c6e55f3 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/MouseOverAction.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/MouseOverAction.java
@@ -15,9 +15,7 @@
*/
package com.intellij.vcs.log.graph;
-import com.intellij.vcs.log.printmodel.GraphPrintCell;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import java.awt.*;
@@ -25,12 +23,10 @@ public class MouseOverAction implements GraphAction {
private final int myVisibleRow;
@NotNull private final Point myRelativePoint;
- @Nullable private final GraphPrintCell myPrintCell;
- public MouseOverAction(int visibleRow, @NotNull Point relativePoint, @Nullable GraphPrintCell printCell) {
+ public MouseOverAction(int visibleRow, @NotNull Point relativePoint) {
myVisibleRow = visibleRow;
myRelativePoint = relativePoint;
- myPrintCell = printCell;
}
public int getRow() {
@@ -42,8 +38,4 @@ public class MouseOverAction implements GraphAction {
return myRelativePoint;
}
- @Nullable
- public GraphPrintCell getPrintCell() {
- return myPrintCell;
- }
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java
index 55eda106cbed..b37d59715d03 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java
@@ -169,7 +169,7 @@ public class VcsLogUI {
public void click(int rowIndex) {
DataPack dataPack = myLogDataHolder.getDataPack();
- dataPack.getGraphFacade().performAction(new ClickGraphAction(rowIndex, null, null));
+ dataPack.getGraphFacade().performAction(new ClickGraphAction(rowIndex, null));
updateUI();
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java
index 0214d7dcf30e..d8c327f87ee9 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java
@@ -22,8 +22,6 @@ import com.intellij.vcs.log.graph.*;
import com.intellij.vcs.log.graph.render.CommitCell;
import com.intellij.vcs.log.graph.render.GraphCommitCell;
import com.intellij.vcs.log.graph.render.PositionUtil;
-import com.intellij.vcs.log.graph.render.SimpleGraphCellPainter;
-import com.intellij.vcs.log.printmodel.GraphPrintCell;
import com.intellij.vcs.log.ui.VcsLogUI;
import com.intellij.vcs.log.ui.render.CommitCellRender;
import com.intellij.vcs.log.ui.render.GraphCommitCellRender;
@@ -66,8 +64,9 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
myLogDataHolder = logDataHolder;
setDefaultRenderer(VirtualFile.class, new RootCellRenderer(myUI));
- setDefaultRenderer(GraphCommitCell.class, new GraphCommitCellRender(new SimpleGraphCellPainter(), logDataHolder, myUI.getColorManager()));
- setDefaultRenderer(CommitCell.class, new CommitCellRender(myUI.getColorManager(), logDataHolder.getProject()));
+ setDefaultRenderer(GraphCommitCell.class, new GraphCommitCellRender(myUI.getColorManager(), logDataHolder,
+ logDataHolder.getDataPack().getGraphFacade()));
+ setDefaultRenderer(CommitCell.class, new CommitCellRender(myUI.getColorManager(), logDataHolder));
setDefaultRenderer(String.class, new StringCellRenderer());
setRowHeight(HEIGHT_CELL);
@@ -181,19 +180,6 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
}
}
- @Nullable
- public GraphPrintCell getGraphPrintCellForRow(TableModel model, int rowIndex) {
- if (rowIndex >= model.getRowCount()) {
- return null;
- }
- Object commitValue = model.getValueAt(rowIndex, AbstractVcsLogTableModel.COMMIT_COLUMN);
- if (commitValue instanceof GraphCommitCell) {
- GraphCommitCell commitCell = (GraphCommitCell)commitValue;
- return commitCell.getPrintCell();
- }
- return null;
- }
-
@Nullable
public List getSelectedChanges() {
TableModel model = getModel();
@@ -262,7 +248,7 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
performAction(e, new PairFunction() {
@Override
public GraphAction fun(Integer row, Point point) {
- return new ClickGraphAction(row, point, getGraphPrintCellForRow(getModel(), row));
+ return new ClickGraphAction(row, point);
}
});
}
@@ -277,7 +263,7 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
performAction(e, new PairFunction() {
@Override
public GraphAction fun(Integer row, Point point) {
- return new MouseOverAction(row, point, getGraphPrintCellForRow(getModel(), row));
+ return new MouseOverAction(row, point);
}
});
}
@@ -335,8 +321,6 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
private static class RootCellRenderer extends JPanel implements TableCellRenderer {
- private static final Logger LOG = Logger.getInstance(RootCellRenderer.class);
-
@NotNull private final VcsLogUI myUi;
@NotNull private Color myColor = UIUtil.getTableBackground();
@@ -369,10 +353,7 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component rendererComponent = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
- Object commit = getValueAt(row, AbstractVcsLogTableModel.COMMIT_COLUMN);
- if (commit instanceof GraphCommitCell) {
- setBackground(isSelected ? table.getSelectionBackground() : JBColor.WHITE);
- }
+ setBackground(isSelected ? table.getSelectionBackground() : JBColor.WHITE);
return rendererComponent;
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/AbstractPaddingCellRender.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/AbstractPaddingCellRender.java
index c2c046d5cf18..31ab0de0031f 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/AbstractPaddingCellRender.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/AbstractPaddingCellRender.java
@@ -1,56 +1,80 @@
package com.intellij.vcs.log.ui.render;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.vcs.changes.issueLinks.IssueLinkRenderer;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.ColoredTableCellRenderer;
import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.ui.UIUtil;
import com.intellij.vcs.log.VcsRef;
+import com.intellij.vcs.log.data.VcsLogDataHolder;
+import com.intellij.vcs.log.graph.PaintInfo;
+import com.intellij.vcs.log.graph.render.CommitCell;
import com.intellij.vcs.log.ui.VcsLogColorManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import javax.swing.JTable;
-import java.awt.Color;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
+import javax.swing.*;
+import java.awt.*;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
public abstract class AbstractPaddingCellRender extends ColoredTableCellRenderer {
- @NotNull protected final RefPainter myRefPainter;
- @NotNull private final IssueLinkRenderer myIssueLinkRenderer;
- @Nullable private Object myValue;
+ @NotNull private final VcsLogDataHolder myDataHolder;
- protected AbstractPaddingCellRender(@NotNull Project project, VcsLogColorManager colorManager) {
+ @NotNull private final RefPainter myRefPainter;
+ @NotNull private final IssueLinkRenderer myIssueLinkRenderer;
+
+ @Nullable private PaintInfo myGraphImage;
+ @Nullable private Collection myRefs;
+
+ protected AbstractPaddingCellRender(@NotNull VcsLogColorManager colorManager, @NotNull VcsLogDataHolder dataHolder) {
+ myDataHolder = dataHolder;
myRefPainter = new RefPainter(colorManager, false);
- myIssueLinkRenderer = new IssueLinkRenderer(project, this);
+ myIssueLinkRenderer = new IssueLinkRenderer(dataHolder.getProject(), this);
}
- protected abstract int getLeftPadding(JTable table, Object value);
-
- @NotNull
- protected abstract String getCellText(@Nullable Object value);
-
- protected abstract void additionPaint(Graphics g, Object value);
+ @Nullable
+ protected abstract PaintInfo getGraphImage(int row);
@Override
protected void customizeCellRenderer(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (value == null) {
return;
}
- myValue = value;
+
+ CommitCell cell = getAssertCommitCell(value);
+ myGraphImage = getGraphImage(row);
+ myRefs = cell.getRefsToThisCommit();
+
+ int graphPadding = myGraphImage != null ? myGraphImage.getWidth() : 0;
+ int textPadding = graphPadding + calcRefsPadding(myRefs);
+
append("");
- appendFixedTextFragmentWidth(getLeftPadding(table, value));
- myIssueLinkRenderer.appendTextWithLinks(getCellText(value));
+ appendFixedTextFragmentWidth(textPadding);
+ myIssueLinkRenderer.appendTextWithLinks(cell.getText());
}
@Override
public void paint(Graphics g) {
super.paint(g);
- additionPaint(g, myValue);
+
+ if (myRefs != null) {
+ int graphPadding = myGraphImage != null ? myGraphImage.getWidth() : 0;
+ drawRefs((Graphics2D)g, myRefs, graphPadding);
+ }
+
+ if (myGraphImage != null) {
+ UIUtil.drawImage(g, myGraphImage.getImage(), 0, 0, null);
+ }
+ }
+
+ private static CommitCell getAssertCommitCell(Object value) {
+ assert value instanceof CommitCell : "Value of incorrect class was supplied: " + value;
+ return (CommitCell)value;
}
protected void drawRefs(@NotNull Graphics2D g2, @NotNull Collection refs, int padding) {
@@ -58,14 +82,19 @@ public abstract class AbstractPaddingCellRender extends ColoredTableCellRenderer
}
@NotNull
- private static Map collectLabelsForRefs(@NotNull Collection refs) {
+ private Map collectLabelsForRefs(@NotNull Collection refs) {
+ if (refs.isEmpty()) {
+ return Collections.emptyMap();
+ }
+ VirtualFile root = refs.iterator().next().getRoot(); // all refs are from the same commit => they have the same root
+ refs = myDataHolder.getLogProvider(root).getReferenceManager().sort(refs);
List branches = getBranches(refs);
Collection tags = ContainerUtil.subtract(refs, branches);
return getLabelsForRefs(branches, tags);
}
- protected int calcRefsPadding(@NotNull Collection refs, @NotNull Graphics2D g2) {
- return myRefPainter.padding(collectLabelsForRefs(refs).keySet(), g2);
+ protected int calcRefsPadding(@NotNull Collection refs) {
+ return myRefPainter.padding(collectLabelsForRefs(refs).keySet(), this.getFontMetrics(RefPainter.DEFAULT_FONT));
}
@NotNull
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/CommitCellRender.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/CommitCellRender.java
index 702af3f1a667..cb9040bc6e22 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/CommitCellRender.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/CommitCellRender.java
@@ -1,48 +1,21 @@
package com.intellij.vcs.log.ui.render;
-import com.intellij.openapi.project.Project;
-import com.intellij.vcs.log.graph.render.CommitCell;
+import com.intellij.vcs.log.data.VcsLogDataHolder;
+import com.intellij.vcs.log.graph.PaintInfo;
import com.intellij.vcs.log.ui.VcsLogColorManager;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
-import javax.swing.*;
-import java.awt.*;
-
-/**
- * @author erokhins
- */
public class CommitCellRender extends AbstractPaddingCellRender {
- public CommitCellRender(@NotNull VcsLogColorManager colorManager, Project project) {
- super(project, colorManager);
+ public CommitCellRender(@NotNull VcsLogColorManager colorManager, @NotNull VcsLogDataHolder dataHolder) {
+ super(colorManager, dataHolder);
}
+ @Nullable
@Override
- protected int getLeftPadding(JTable table, Object value) {
- CommitCell cell = getAssertCommitCell(value);
- return calcRefsPadding(cell.getRefsToThisCommit(), (Graphics2D)table.getGraphics());
- }
-
- private static CommitCell getAssertCommitCell(Object value) {
- assert value instanceof CommitCell : "Value of incorrect class was supplied: " + value;
- return (CommitCell)value;
- }
-
- @NotNull
- @Override
- protected String getCellText(Object value) {
- if (value == null) {
- return "";
- }
- CommitCell cell = getAssertCommitCell(value);
- return cell.getText();
- }
-
- @Override
- protected void additionPaint(Graphics g, Object value) {
- CommitCell cell = getAssertCommitCell(value);
- Graphics2D g2 = (Graphics2D)g;
- drawRefs(g2, cell.getRefsToThisCommit(), 0);
+ protected PaintInfo getGraphImage(int row) {
+ return null;
}
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRender.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRender.java
index 12c7600b770d..652f6583a3cd 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRender.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRender.java
@@ -15,91 +15,27 @@
*/
package com.intellij.vcs.log.ui.render;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.ui.UIUtil;
-import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.data.VcsLogDataHolder;
-import com.intellij.vcs.log.graph.render.GraphCellPainter;
-import com.intellij.vcs.log.graph.render.GraphCommitCell;
+import com.intellij.vcs.log.graph.GraphFacade;
+import com.intellij.vcs.log.graph.PaintInfo;
import com.intellij.vcs.log.ui.VcsLogColorManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import javax.swing.*;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.util.Collection;
-
-import static com.intellij.vcs.log.graph.render.PrintParameters.HEIGHT_CELL;
-import static com.intellij.vcs.log.graph.render.PrintParameters.WIDTH_NODE;
-
-/**
- * @author erokhins
- */
public class GraphCommitCellRender extends AbstractPaddingCellRender {
- // In case of diagonal edges, one node can be at most 3 "arrows" + 2 nodes at the left from another - that is enough for sure
- private static final int IMAGE_WIDTH_RESERVE = 5 * WIDTH_NODE;
+ @NotNull private final GraphFacade myGraphFacade;
- @NotNull private final GraphCellPainter graphPainter;
- @NotNull private final VcsLogDataHolder myDataHolder;
-
- public GraphCommitCellRender(@NotNull GraphCellPainter graphPainter, @NotNull VcsLogDataHolder logDataHolder,
- @NotNull VcsLogColorManager colorManager) {
- super(logDataHolder.getProject(), colorManager);
- this.graphPainter = graphPainter;
- myDataHolder = logDataHolder;
+ public GraphCommitCellRender(@NotNull VcsLogColorManager colorManager,
+ @NotNull VcsLogDataHolder dataHolder, @NotNull GraphFacade graphFacade) {
+ super(colorManager, dataHolder);
+ myGraphFacade = graphFacade;
}
+ @Nullable
@Override
- protected int getLeftPadding(JTable table, @Nullable Object value) {
- GraphCommitCell cell = (GraphCommitCell)value;
- if (cell == null) {
- return 0;
- }
- return calcPaddingBeforeText(cell, (Graphics2D)table.getGraphics());
+ protected PaintInfo getGraphImage(int row) {
+ return myGraphFacade.paint(row);
}
- private int calcPaddingBeforeText(GraphCommitCell cell, Graphics2D g) {
- int refPadding = calcRefsPadding(cell.getRefsToThisCommit(), g);
- int countCells = cell.getPrintCell().countCell();
- int graphPadding = countCells * WIDTH_NODE;
- return refPadding + graphPadding;
- }
-
- @NotNull
- protected String getCellText(@Nullable Object value) {
- GraphCommitCell cell = (GraphCommitCell)value;
- if (cell == null) {
- return "";
- }
- else {
- return cell.getText();
- }
- }
-
- @Override
- protected void additionPaint(Graphics g, @Nullable Object value) {
- GraphCommitCell cell = (GraphCommitCell)value;
- if (cell == null) {
- return;
- }
-
- int width = calcPaddingBeforeText(cell, (Graphics2D)g) + IMAGE_WIDTH_RESERVE;
- BufferedImage image = UIUtil.createImage(width, HEIGHT_CELL, BufferedImage.TYPE_INT_ARGB);
- Graphics2D g2 = image.createGraphics();
-
- graphPainter.draw(g2, cell.getPrintCell());
-
- int countCells = cell.getPrintCell().countCell();
- int padding = countCells * WIDTH_NODE;
- Collection refs = cell.getRefsToThisCommit();
- if (!refs.isEmpty()) {
- VirtualFile root = refs.iterator().next().getRoot(); // all refs are from the same commit => they have the same root
- refs = myDataHolder.getLogProvider(root).getReferenceManager().sort(refs);
- }
- drawRefs(g2, refs, padding);
-
- UIUtil.drawImage(g, image, 0, 0, null);
- }
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/RefPainter.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/RefPainter.java
index 004a9eda8c17..7d555429cb91 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/RefPainter.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/RefPainter.java
@@ -30,7 +30,7 @@ public class RefPainter {
private static final int ROUND_RADIUS = 5;
- private static final Font DEFAULT_FONT = new Font("Arial", Font.PLAIN, 12);
+ public static final Font DEFAULT_FONT = new Font("Arial", Font.PLAIN, 12);
private static final Color DEFAULT_FONT_COLOR = JBColor.BLACK;
@NotNull private final VcsLogColorManager myColorManager;
@@ -85,10 +85,10 @@ public class RefPainter {
g2.drawPolygon(polygon);
}
- public int padding(@NotNull Collection refs, @NotNull Graphics2D g2) {
+ public int padding(@NotNull Collection refs, FontMetrics fontMetrics) {
int p = 0;
for (String ref : refs) {
- XAndWidth xAndWidth = getXAndWidth(ref, 0, g2.getFontMetrics(DEFAULT_FONT));
+ XAndWidth xAndWidth = getXAndWidth(ref, 0, fontMetrics);
p += xAndWidth.x + xAndWidth.width + LABEL_PADDING;
}
if (p > 0) { // additional padding after all references looks better
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java
index f2585cabed50..7bc9b451edcc 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java
@@ -15,7 +15,6 @@ import com.intellij.vcs.log.data.VcsLogDataHolder;
import com.intellij.vcs.log.graph.elements.Node;
import com.intellij.vcs.log.graph.render.GraphCommitCell;
import com.intellij.vcs.log.impl.VcsLogUtil;
-import com.intellij.vcs.log.printmodel.GraphPrintCell;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -24,9 +23,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
-/**
- * @author Kirill Likhodedov
- */
public class GraphTableModel extends AbstractVcsLogTableModel {
private static final Logger LOG = Logger.getInstance(GraphTableModel.class);
@@ -95,14 +91,13 @@ public class GraphTableModel extends AbstractVcsLogTableModel refs = Collections.emptyList();
if (details != null) {
message = details.getSubject();
refs = (List)myDataPack.getRefsModel().refsToCommit(details.getHash());
}
- return new GraphCommitCell(graphPrintCell, message, refs);
+ return new GraphCommitCell(message, refs);
}
@NotNull
From bfcb3f44614062d6101bd1411d5e533e620af834 Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Sat, 22 Feb 2014 11:25:48 +0400
Subject: [PATCH 065/172] Override paintComponent() instead of paint().
As recommended by JDK javadocs.
---
.../intellij/vcs/log/ui/render/AbstractPaddingCellRender.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/AbstractPaddingCellRender.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/AbstractPaddingCellRender.java
index 31ab0de0031f..638cb686d48b 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/AbstractPaddingCellRender.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/AbstractPaddingCellRender.java
@@ -59,8 +59,8 @@ public abstract class AbstractPaddingCellRender extends ColoredTableCellRenderer
}
@Override
- public void paint(Graphics g) {
- super.paint(g);
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
if (myRefs != null) {
int graphPadding = myGraphImage != null ? myGraphImage.getWidth() : 0;
From 4e968e11151dde6cdbf43ce93b73a2a3bf180d19 Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Sat, 22 Feb 2014 11:30:28 +0400
Subject: [PATCH 066/172] [log] remove unused stuff from the DataPack.
---
.../com/intellij/vcs/log/data/DataPack.java | 31 ++++---------------
.../vcs/log/data/VcsLogDataHolder.java | 8 ++---
2 files changed, 9 insertions(+), 30 deletions(-)
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
index 546a213f7d43..16f5f12cedab 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
@@ -22,21 +22,16 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.List;
-/**
- * @author erokhins
- */
public class DataPack {
- @NotNull private final GraphModel myGraphModel;
@NotNull private final RefsModel myRefsModel;
- @NotNull private final GraphPrintCellModel myPrintCellModel;
- private final NotNullFunction myHashGetter;
- private final NotNullFunction myIndexGetter;
@NotNull private final GraphFacadeImpl myGraphFacade;
@NotNull
- public static DataPack build(@NotNull List extends GraphCommit> commits, @NotNull Collection allRefs, @NotNull ProgressIndicator indicator,
- NotNullFunction hashGetter, NotNullFunction indexGetter) {
+ public static DataPack build(@NotNull List extends GraphCommit> commits,
+ @NotNull Collection allRefs,
+ @NotNull ProgressIndicator indicator,
+ @NotNull NotNullFunction indexGetter) {
indicator.setText("Building graph...");
MutableGraph graph = GraphBuilder.build(commits, allRefs);
@@ -64,16 +59,11 @@ public class DataPack {
}
}
});
- return new DataPack(graphModel, refsModel, printCellModel, hashGetter, indexGetter);
+ return new DataPack(graphModel, refsModel, printCellModel);
}
- private DataPack(@NotNull GraphModel graphModel, @NotNull RefsModel refsModel, @NotNull GraphPrintCellModel printCellModel,
- NotNullFunction hashGetter, NotNullFunction indexGetter) {
- myGraphModel = graphModel;
+ private DataPack(@NotNull GraphModel graphModel, @NotNull RefsModel refsModel, @NotNull GraphPrintCellModel printCellModel) {
myRefsModel = refsModel;
- myPrintCellModel = printCellModel;
- myHashGetter = hashGetter;
- myIndexGetter = indexGetter;
myGraphFacade = new GraphFacadeImpl(graphModel, printCellModel);
}
@@ -87,13 +77,4 @@ public class DataPack {
return myRefsModel;
}
- @NotNull
- public GraphModel getGraphModel() {
- return myGraphModel;
- }
-
- @NotNull
- public GraphPrintCellModel getPrintCellModel() {
- return myPrintCellModel;
- }
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java
index f4bfa2a2c127..9e27f2aab39d 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java
@@ -342,7 +342,7 @@ public class VcsLogDataHolder implements Disposable {
// }
List extends TimedVcsCommit> compoundLog = myMultiRepoJoiner.join(myLogData.myLogsByRoot.values());
- DataPack fullDataPack = DataPack.build(convertToGraphCommits(compoundLog), myLogData.getAllRefs(), indicator, myHashGetter, myIndexGetter);
+ DataPack fullDataPack = DataPack.build(convertToGraphCommits(compoundLog), myLogData.getAllRefs(), indicator, myIndexGetter);
myLogData = new LogData(myLogData.getLogs(), myLogData.getRefs(), myLogData.getTopCommits(), fullDataPack, true);
myFullLogShowing = true;
invokeAndWait(new Runnable() {
@@ -401,8 +401,7 @@ public class VcsLogDataHolder implements Disposable {
List extends TimedVcsCommit> topPartOfTheLog = compoundLog.subList(0, topCommitCount);
List extends TimedVcsCommit> logToBuild = myFullLogShowing ? compoundLog : topPartOfTheLog; // keep looking at the full log after refresh
- DataPack dataPack = DataPack.build(convertToGraphCommits(logToBuild), collectAllRefs(refsByRoot), indicator,
- myHashGetter, myIndexGetter);
+ DataPack dataPack = DataPack.build(convertToGraphCommits(logToBuild), collectAllRefs(refsByRoot), indicator, myIndexGetter);
myLogData = new LogData(logsToBuild, refsByRoot, topPartOfTheLog, dataPack, true);
@@ -437,8 +436,7 @@ public class VcsLogDataHolder implements Disposable {
// even if the full log was already loaded (and possibly presented to the user),
// build only the data that was retrieved from the VCS:
// if it is not one of the initial refreshes, then it is filtering, and then the DataPack will change anyway.
- DataPack dataPack = DataPack.build(convertToGraphCommits(compoundLog), collectAllRefs(refsByRoot), indicator,
- myHashGetter, myIndexGetter);
+ DataPack dataPack = DataPack.build(convertToGraphCommits(compoundLog), collectAllRefs(refsByRoot), indicator, myIndexGetter);
if (myLogData != null && myLogData.isFullLogReady()) {
// reuse the skeleton, since it didn't change, because it is not a refresh
From 584e37d20b377efb107b93b3282d4c8b1f25a3e6 Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Sat, 22 Feb 2014 11:33:32 +0400
Subject: [PATCH 067/172] [log] Move GraphFacade implementation to
vcs-log-graph module
---
.../src/com/intellij/vcs/log/graph/ChangeCursorActionRequest.java | 0
.../src/com/intellij/vcs/log/graph/ClickGraphAction.java | 0
.../src/com/intellij/vcs/log/graph/GraphFacadeImpl.java | 0
.../src/com/intellij/vcs/log/graph/MouseOverAction.java | 0
4 files changed, 0 insertions(+), 0 deletions(-)
rename platform/vcs-log/{impl => graph}/src/com/intellij/vcs/log/graph/ChangeCursorActionRequest.java (100%)
rename platform/vcs-log/{impl => graph}/src/com/intellij/vcs/log/graph/ClickGraphAction.java (100%)
rename platform/vcs-log/{impl => graph}/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java (100%)
rename platform/vcs-log/{impl => graph}/src/com/intellij/vcs/log/graph/MouseOverAction.java (100%)
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/ChangeCursorActionRequest.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/ChangeCursorActionRequest.java
similarity index 100%
rename from platform/vcs-log/impl/src/com/intellij/vcs/log/graph/ChangeCursorActionRequest.java
rename to platform/vcs-log/graph/src/com/intellij/vcs/log/graph/ChangeCursorActionRequest.java
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/ClickGraphAction.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/ClickGraphAction.java
similarity index 100%
rename from platform/vcs-log/impl/src/com/intellij/vcs/log/graph/ClickGraphAction.java
rename to platform/vcs-log/graph/src/com/intellij/vcs/log/graph/ClickGraphAction.java
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
similarity index 100%
rename from platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
rename to platform/vcs-log/graph/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/MouseOverAction.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/MouseOverAction.java
similarity index 100%
rename from platform/vcs-log/impl/src/com/intellij/vcs/log/graph/MouseOverAction.java
rename to platform/vcs-log/graph/src/com/intellij/vcs/log/graph/MouseOverAction.java
From be34c3278735b31e6bff0ab7c7cc69a25bd18e5b Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Sat, 22 Feb 2014 11:55:50 +0400
Subject: [PATCH 068/172] [log] DataPack: create GraphFacadeImpl instance in
build
---
.../impl/src/com/intellij/vcs/log/data/DataPack.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
index 16f5f12cedab..00313ecf7105 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
@@ -25,7 +25,7 @@ import java.util.List;
public class DataPack {
@NotNull private final RefsModel myRefsModel;
- @NotNull private final GraphFacadeImpl myGraphFacade;
+ @NotNull private final GraphFacade myGraphFacade;
@NotNull
public static DataPack build(@NotNull List extends GraphCommit> commits,
@@ -59,12 +59,12 @@ public class DataPack {
}
}
});
- return new DataPack(graphModel, refsModel, printCellModel);
+ return new DataPack(refsModel, new GraphFacadeImpl(graphModel, printCellModel));
}
- private DataPack(@NotNull GraphModel graphModel, @NotNull RefsModel refsModel, @NotNull GraphPrintCellModel printCellModel) {
+ private DataPack(@NotNull RefsModel refsModel, @NotNull GraphFacade graphFacade) {
myRefsModel = refsModel;
- myGraphFacade = new GraphFacadeImpl(graphModel, printCellModel);
+ myGraphFacade = graphFacade;
}
@NotNull
From a61594329a34059f82c89d454680dd3b0bf970f9 Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Sat, 22 Feb 2014 12:04:56 +0400
Subject: [PATCH 069/172] [log] remove no more needed dependencies from
vcs-log-graph
---
platform/vcs-log/graph/vcs-log-graph.iml | 2 --
1 file changed, 2 deletions(-)
diff --git a/platform/vcs-log/graph/vcs-log-graph.iml b/platform/vcs-log/graph/vcs-log-graph.iml
index f3e768b40041..16c51609ce0d 100644
--- a/platform/vcs-log/graph/vcs-log-graph.iml
+++ b/platform/vcs-log/graph/vcs-log-graph.iml
@@ -9,8 +9,6 @@
-
-
From 691077d00bfe2009e0fdfbb1271993a2bd71e1bd Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Sun, 23 Feb 2014 12:05:43 +0400
Subject: [PATCH 070/172] GraphColorManager initial implementation
Close to current coloring scheme.
---
.../vcs/log/graph/GraphFacadeImpl.java | 5 +-
.../vcs/log/graph/render/ColorGenerator.java | 12 +-
.../graph/render/SimpleGraphCellPainter.java | 16 +--
.../com/intellij/vcs/log/data/DataPack.java | 24 +++-
.../vcs/log/data/VcsLogDataHolder.java | 9 +-
.../vcs/log/graph/GraphColorManagerImpl.java | 117 ++++++++++++++++++
6 files changed, 159 insertions(+), 24 deletions(-)
create mode 100644 platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphColorManagerImpl.java
diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
index cf806f2b65cd..9f630eacede7 100644
--- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
+++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/GraphFacadeImpl.java
@@ -60,13 +60,16 @@ public class GraphFacadeImpl implements GraphFacade {
@NotNull private final GraphModel myGraphModel;
@NotNull private final GraphPrintCellModel myPrintCellModel;
+ @NotNull private final GraphColorManager myColorManager;
@NotNull private final SimpleGraphCellPainter myGraphPainter;
@Nullable private GraphElement prevGraphElement;
- public GraphFacadeImpl(@NotNull GraphModel graphModel, @NotNull GraphPrintCellModel printCellModel) {
+ public GraphFacadeImpl(@NotNull GraphModel graphModel, @NotNull GraphPrintCellModel printCellModel,
+ @NotNull GraphColorManager colorManager) {
myGraphModel = graphModel;
myPrintCellModel = printCellModel;
+ myColorManager = colorManager;
myGraphPainter = new SimpleGraphCellPainter();
}
diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/ColorGenerator.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/ColorGenerator.java
index 8471d005d070..d87d920c6820 100644
--- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/ColorGenerator.java
+++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/ColorGenerator.java
@@ -1,7 +1,6 @@
package com.intellij.vcs.log.graph.render;
import com.intellij.util.containers.ContainerUtil;
-import com.intellij.vcs.log.graph.elements.Branch;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
@@ -15,12 +14,11 @@ public class ColorGenerator {
private static final Map ourColorMap = ContainerUtil.newHashMap();
@NotNull
- public static Color getColor(@NotNull Branch branch) {
- int indexColor = branch.getBranchNumber();
- Color color = ourColorMap.get(indexColor);
+ public static Color getColor(int branchNumber) {
+ Color color = ourColorMap.get(branchNumber);
if (color == null) {
- color = getColor(indexColor);
- ourColorMap.put(indexColor, color);
+ color = calcColor(branchNumber);
+ ourColorMap.put(branchNumber, color);
}
return color;
}
@@ -30,7 +28,7 @@ public class ColorGenerator {
}
@NotNull
- private static Color getColor(int indexColor) {
+ private static Color calcColor(int indexColor) {
int r = indexColor * 200 + 30;
int g = indexColor * 130 + 50;
int b = indexColor * 90 + 100;
diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/SimpleGraphCellPainter.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/SimpleGraphCellPainter.java
index 41ad959e436e..16e2a3115c91 100644
--- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/SimpleGraphCellPainter.java
+++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/render/SimpleGraphCellPainter.java
@@ -136,7 +136,7 @@ public class SimpleGraphCellPainter implements GraphCellPainter {
this.g2 = g2;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
for (final ShortEdge edge : row.getUpEdges()) {
- drawLogic(edge.isSelected(), edge.isMarked(), edge.isUsual(), ColorGenerator.getColor(edge.getEdge().getBranch()), new LitePrinter() {
+ drawLogic(edge.isSelected(), edge.isMarked(), edge.isUsual(), ColorGenerator.getColor(edge.getEdge().getBranch().getBranchNumber()), new LitePrinter() {
@Override
public void print(Color color) {
paintUpLine(edge.getDownPosition(), edge.getUpPosition(), color);
@@ -144,7 +144,7 @@ public class SimpleGraphCellPainter implements GraphCellPainter {
});
}
for (final ShortEdge edge : row.getDownEdges()) {
- drawLogic(edge.isSelected(), edge.isMarked(), edge.isUsual(), ColorGenerator.getColor(edge.getEdge().getBranch()), new LitePrinter() {
+ drawLogic(edge.isSelected(), edge.isMarked(), edge.isUsual(), ColorGenerator.getColor(edge.getEdge().getBranch().getBranchNumber()), new LitePrinter() {
@Override
public void print(Color color) {
paintDownLine(edge.getUpPosition(), edge.getDownPosition(), color);
@@ -160,16 +160,16 @@ public class SimpleGraphCellPainter implements GraphCellPainter {
assert node != null;
if (printElement.isSelected()) {
paintCircle(printElement.getPosition(), MARK_COLOR, true);
- paintCircle(printElement.getPosition(), ColorGenerator.getColor(node.getBranch()), false);
+ paintCircle(printElement.getPosition(), ColorGenerator.getColor(node.getBranch().getBranchNumber()), false);
} else {
- paintCircle(printElement.getPosition(), ColorGenerator.getColor(node.getBranch()), printElement.isMarked());
+ paintCircle(printElement.getPosition(), ColorGenerator.getColor(node.getBranch().getBranchNumber()), printElement.isMarked());
}
break;
case UP_ARROW:
edge = printElement.getGraphElement().getEdge();
assert edge != null;
drawLogic(printElement.isSelected(), printElement.isMarked(), edge.getType() == Edge.EdgeType.USUAL, ColorGenerator.getColor(
- edge.getBranch()), new LitePrinter() {
+ edge.getBranch().getBranchNumber()), new LitePrinter() {
@Override
public void print(Color color) {
paintShow(printElement.getPosition(), color);
@@ -180,7 +180,7 @@ public class SimpleGraphCellPainter implements GraphCellPainter {
edge = printElement.getGraphElement().getEdge();
assert edge != null;
drawLogic(printElement.isSelected(), printElement.isMarked(), edge.getType() == Edge.EdgeType.USUAL, ColorGenerator.getColor(
- edge.getBranch()), new LitePrinter() {
+ edge.getBranch().getBranchNumber()), new LitePrinter() {
@Override
public void print(Color color) {
paintHide(printElement.getPosition(), color);
@@ -197,9 +197,9 @@ public class SimpleGraphCellPainter implements GraphCellPainter {
Node node = printElement.getGraphElement().getNode();
assert node != null;
if (printElement.getDragAndDropSelect() > 0) {
- paintAbove(printElement.getPosition(), ColorGenerator.getColor(node.getBranch()));
+ paintAbove(printElement.getPosition(), ColorGenerator.getColor(node.getBranch().getBranchNumber()));
} else {
- paintBelow(printElement.getPosition(), ColorGenerator.getColor(node.getBranch()));
+ paintBelow(printElement.getPosition(), ColorGenerator.getColor(node.getBranch().getBranchNumber()));
}
}
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
index 00313ecf7105..19d5083d4ad4 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
@@ -1,13 +1,14 @@
package com.intellij.vcs.log.data;
import com.intellij.openapi.progress.ProgressIndicator;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Consumer;
import com.intellij.util.Function;
import com.intellij.util.NotNullFunction;
-import com.intellij.vcs.log.GraphCommit;
-import com.intellij.vcs.log.Hash;
-import com.intellij.vcs.log.VcsRef;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.vcs.log.*;
import com.intellij.vcs.log.compressedlist.UpdateRequest;
+import com.intellij.vcs.log.graph.GraphColorManagerImpl;
import com.intellij.vcs.log.graph.GraphFacade;
import com.intellij.vcs.log.graph.GraphFacadeImpl;
import com.intellij.vcs.log.graph.elements.Node;
@@ -21,6 +22,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
public class DataPack {
@@ -31,7 +33,9 @@ public class DataPack {
public static DataPack build(@NotNull List extends GraphCommit> commits,
@NotNull Collection allRefs,
@NotNull ProgressIndicator indicator,
- @NotNull NotNullFunction indexGetter) {
+ @NotNull NotNullFunction indexGetter,
+ @NotNull NotNullFunction hashGetter,
+ @NotNull Map logProviders) {
indicator.setText("Building graph...");
MutableGraph graph = GraphBuilder.build(commits, allRefs);
@@ -59,7 +63,17 @@ public class DataPack {
}
}
});
- return new DataPack(refsModel, new GraphFacadeImpl(graphModel, printCellModel));
+ GraphColorManagerImpl colorManager = new GraphColorManagerImpl(refsModel, hashGetter, getRefManagerMap(logProviders));
+ return new DataPack(refsModel, new GraphFacadeImpl(graphModel, printCellModel, colorManager));
+ }
+
+ @NotNull
+ private static Map getRefManagerMap(@NotNull Map logProviders) {
+ Map