Merge branch 'master' into nodeDescriptor_names_ext
authorEgor.Ushakov <egor.ushakov@jetbrains.com>
Mon, 24 Aug 2015 08:03:42 +0000 (11:03 +0300)
committerEgor.Ushakov <egor.ushakov@jetbrains.com>
Mon, 24 Aug 2015 08:03:42 +0000 (11:03 +0300)
java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/FieldDescriptorImpl.java
java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/FieldOuterLocalNameAdjuster.java [new file with mode: 0644]
java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/LocalVariableDescriptorImpl.java
java/debugger/openapi/src/com/intellij/debugger/ui/tree/NodeDescriptorNameAdjuster.java [new file with mode: 0644]
resources/src/META-INF/IdeaPlugin.xml

index e88bd2e2a7ec880d1a42eeca3b49a2659e90762a..9c9c07f09d38b46c1ff37c1509ce06a9d8bdc1bc 100644 (file)
@@ -26,6 +26,7 @@ import com.intellij.debugger.impl.PositionUtil;
 import com.intellij.debugger.settings.NodeRendererSettings;
 import com.intellij.debugger.ui.tree.FieldDescriptor;
 import com.intellij.debugger.ui.tree.NodeDescriptor;
+import com.intellij.debugger.ui.tree.NodeDescriptorNameAdjuster;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.JavaPsiFacade;
@@ -107,8 +108,9 @@ public class FieldDescriptorImpl extends ValueDescriptorImpl implements FieldDes
   @Override
   public String getName() {
     final String fieldName = myField.name();
-    if (isOuterLocalVariableValue() && NodeRendererSettings.getInstance().getClassRenderer().SHOW_VAL_FIELDS_AS_LOCAL_VARIABLES) {
-      return StringUtil.trimStart(fieldName, OUTER_LOCAL_VAR_FIELD_PREFIX);
+    NodeDescriptorNameAdjuster nameAdjuster = NodeDescriptorNameAdjuster.findFor(this);
+    if (nameAdjuster != null) {
+      return nameAdjuster.fixName(fieldName, this);
     }
     return fieldName;
   }
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/FieldOuterLocalNameAdjuster.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/FieldOuterLocalNameAdjuster.java
new file mode 100644 (file)
index 0000000..fa938bc
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2000-2015 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.debugger.ui.impl.watch;
+
+import com.intellij.debugger.settings.NodeRendererSettings;
+import com.intellij.debugger.ui.tree.NodeDescriptor;
+import com.intellij.debugger.ui.tree.NodeDescriptorNameAdjuster;
+import com.intellij.openapi.util.text.StringUtil;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author Nikolay.Tropin
+ */
+public class FieldOuterLocalNameAdjuster extends NodeDescriptorNameAdjuster {
+
+  @Override
+  public boolean shouldApply(@NotNull NodeDescriptor descriptor) {
+    if (descriptor instanceof FieldDescriptorImpl && NodeRendererSettings.getInstance().getClassRenderer().SHOW_VAL_FIELDS_AS_LOCAL_VARIABLES) {
+      return ((FieldDescriptorImpl)descriptor).isOuterLocalVariableValue();
+    }
+    return false;
+  }
+
+  @Override
+  public String fixName(String name, @NotNull NodeDescriptor descriptor) {
+    return StringUtil.trimStart(name, FieldDescriptorImpl.OUTER_LOCAL_VAR_FIELD_PREFIX);
+  }
+}
index 6e10830ea1ec004024ad31fb3b8497ae6749408d..dc2602ca6e4f6332a443284b49e91a574533196c 100644 (file)
@@ -25,6 +25,7 @@ import com.intellij.debugger.jdi.LocalVariableProxyImpl;
 import com.intellij.debugger.jdi.StackFrameProxyImpl;
 import com.intellij.debugger.ui.tree.LocalVariableDescriptor;
 import com.intellij.debugger.ui.tree.NodeDescriptor;
+import com.intellij.debugger.ui.tree.NodeDescriptorNameAdjuster;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.JavaPsiFacade;
 import com.intellij.psi.PsiElementFactory;
@@ -92,7 +93,12 @@ public class LocalVariableDescriptorImpl extends ValueDescriptorImpl implements
 
   @Override
   public String getName() {
-    return myLocalVariable.name();
+    String varName = myLocalVariable.name();
+    NodeDescriptorNameAdjuster nameAdjuster = NodeDescriptorNameAdjuster.findFor(this);
+    if (nameAdjuster != null) {
+      return nameAdjuster.fixName(varName, this);
+    }
+    return varName;
   }
 
   @Nullable
diff --git a/java/debugger/openapi/src/com/intellij/debugger/ui/tree/NodeDescriptorNameAdjuster.java b/java/debugger/openapi/src/com/intellij/debugger/ui/tree/NodeDescriptorNameAdjuster.java
new file mode 100644 (file)
index 0000000..416f8ae
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2000-2015 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.debugger.ui.tree;
+
+import com.intellij.openapi.extensions.ExtensionPointName;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author Nikolay.Tropin
+ */
+public abstract class NodeDescriptorNameAdjuster {
+  public static ExtensionPointName<NodeDescriptorNameAdjuster> EP_NAME = ExtensionPointName.create("com.intellij.debugger.nodeNameAdjuster");
+
+  public abstract boolean shouldApply(@NotNull NodeDescriptor descriptor);
+
+  public abstract String fixName(String name, @NotNull NodeDescriptor descriptor);
+
+  public static NodeDescriptorNameAdjuster findFor(@NotNull NodeDescriptor descriptor) {
+    for (NodeDescriptorNameAdjuster adjuster:EP_NAME.getExtensions()) {
+      if (adjuster.shouldApply(descriptor)) return adjuster;
+    }
+    return null;
+  }
+}
index 172c3c1fcfafd9fff635f6ebe9b3de2ce2b5323f..59182565c9bad16d922935042e98d9889a29d618 100644 (file)
     <extensionPoint name="debugger.sourcePositionHighlighter"
                     interface="com.intellij.debugger.engine.SourcePositionHighlighter"/>
 
+    <extensionPoint name="debugger.nodeNameAdjuster"
+                    interface="com.intellij.debugger.ui.tree.NodeDescriptorNameAdjuster"/>
+
+
     <extensionPoint name="allOverridingMethodsSearch" interface="com.intellij.util.QueryExecutor"/>
     <extensionPoint name="annotatedElementsSearch" interface="com.intellij.util.QueryExecutor"/>
     <extensionPoint name="annotatedPackagesSearch" interface="com.intellij.util.QueryExecutor"/>
     <debugger.nodeRenderer implementation="com.intellij.debugger.ui.tree.render.FileObjectRenderer"/>
     <debugger.nodeRenderer implementation="com.intellij.debugger.ui.tree.render.StackTraceElementObjectRenderer"/>
 
+    <debugger.nodeNameAdjuster implementation="com.intellij.debugger.ui.impl.watch.FieldOuterLocalNameAdjuster"/>
+
     <applicationService serviceInterface="com.intellij.remoteServer.runtime.deployment.debug.JavaDebuggerLauncher"
                         serviceImplementation="com.intellij.remoteServer.impl.runtime.deployment.debug.JavaDebuggerLauncherImpl"/>