Merge branch 'daywalker/cmake_option_sorting'
authorVasily Pisar <vasily.pisar@jetbrains.com>
Thu, 29 Oct 2015 15:23:15 +0000 (18:23 +0300)
committerVasily Pisar <vasily.pisar@jetbrains.com>
Thu, 29 Oct 2015 15:23:15 +0000 (18:23 +0300)
18 files changed:
build/scripts/utils.gant
java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java
java/debugger/impl/src/com/intellij/debugger/engine/JavaValueModifier.java
java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/LocalVariableEvaluator.java
java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariablesUtil.java
java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/ArgumentValueDescriptorImpl.java
java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/ArrayElementDescriptorImpl.java
java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/EvaluationDescriptor.java
java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/FieldDescriptorImpl.java
java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/LocalVariableDescriptorImpl.java
java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/ValueDescriptorImpl.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/ImportHelperTest.java
platform/platform-tests/testSrc/com/intellij/openapi/editor/EditorPaintingTest.java
platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorImplTest.java
platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorRtlTest.java
platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceOnDocumentModificationTest.java
platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapStressTest.java
platform/util/resources/misc/registry.properties

index 8dd6d7b342c60078ab7e6295f3ae3b5190c5a6bd..92507f81b7efb656653259b51b1146e5c220a355 100644 (file)
@@ -850,6 +850,18 @@ private List<File> getChildren(File file) {
   return file.listFiles().sort { File f -> f.name.toLowerCase() }
 }
 
+binding.setVariable("signExecutableFiles", { String binDir ->
+  def fileBinDir = new File(binDir)
+  def fileName = ""
+  getChildren(fileBinDir).each {
+    fileName = it.getName()
+    if (fileName.endsWith(".exe")) {
+      projectBuilder.stage("Signing: ${fileName}")
+      executeExternalAnt(["dirName": binDir, "fileName": fileName], "$home/build/signBuild.xml")
+    }
+  }
+})
+
 binding.setVariable("bundledJDKs"){
   requireProperty("jdk16.mac", "true")
   requireProperty("jdk.bundled.win", "1.8")
index 821311a05063c3f0a20654536b859f915c0ecd1c..2a9c313047558ce1ec370f0cc7527d6dd4d0cbe3 100644 (file)
@@ -502,7 +502,7 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV
   @Nullable
   @Override
   public XValueModifier getModifier() {
-    return myValueDescriptor.canSetValue() ? new JavaValueModifier(this) : null;
+    return myValueDescriptor.canSetValue() ? myValueDescriptor.getModifier(this) : null;
   }
 
   private volatile XExpression evaluationExpression = null;
index 14f9160d2c3b94bf32d506095555cce136c5ed9a..8bf95abd4b03b8766d620333990653e9bc01b9aa 100644 (file)
@@ -17,7 +17,6 @@ package com.intellij.debugger.engine;
 
 import com.intellij.debugger.DebuggerBundle;
 import com.intellij.debugger.DebuggerInvocationUtil;
-import com.intellij.debugger.DebuggerManagerEx;
 import com.intellij.debugger.EvaluatingComputable;
 import com.intellij.debugger.engine.evaluation.*;
 import com.intellij.debugger.engine.evaluation.expression.*;
@@ -25,11 +24,9 @@ import com.intellij.debugger.engine.events.DebuggerContextCommandImpl;
 import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
 import com.intellij.debugger.impl.DebuggerContextImpl;
 import com.intellij.debugger.impl.DebuggerSession;
-import com.intellij.debugger.jdi.LocalVariableProxyImpl;
-import com.intellij.debugger.jdi.VirtualMachineProxyImpl;
-import com.intellij.debugger.ui.impl.watch.*;
+import com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl;
+import com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl;
 import com.intellij.openapi.progress.util.ProgressWindowWithNotification;
-import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.xdebugger.frame.XValueModifier;
 import com.sun.jdi.*;
@@ -41,7 +38,7 @@ import static com.intellij.psi.CommonClassNames.JAVA_LANG_STRING;
  * Class SetValueAction
  * @author Jeka
  */
-public class JavaValueModifier extends XValueModifier {
+public abstract class JavaValueModifier extends XValueModifier {
   private final JavaValue myJavaValue;
 
   public JavaValueModifier(JavaValue javaValue) {
@@ -92,7 +89,7 @@ public class JavaValueModifier extends XValueModifier {
   //  e.getPresentation().setVisible(enable);
   //}
   //
-  private static void update(final DebuggerContextImpl context) {
+  protected static void update(final DebuggerContextImpl context) {
     DebuggerInvocationUtil.swingInvokeLater(context.getProject(), new Runnable() {
       public void run() {
         final DebuggerSession session = context.getDebuggerSession();
@@ -104,6 +101,8 @@ public class JavaValueModifier extends XValueModifier {
     //node.setState(context);
   }
 
+  protected abstract void setValueImpl(@NotNull String expression, @NotNull XModificationCallback callback);
+
   @Override
   public void setValue(@NotNull String expression, @NotNull XModificationCallback callback) {
     final NodeDescriptorImpl descriptor = myJavaValue.getDescriptor();
@@ -116,136 +115,10 @@ public class JavaValueModifier extends XValueModifier {
       return;
     }
 
-    //final DebuggerTree tree = getTree(event.getDataContext());
-    //final DebuggerContextImpl debuggerContext = getDebuggerContext(event.getDataContext());
-    final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(myJavaValue.getProject()).getContext();
-    //tree.saveState(node);
-
-    if (descriptor instanceof FieldDescriptorImpl) {
-      FieldDescriptorImpl fieldDescriptor = (FieldDescriptorImpl)descriptor;
-      final Field field = fieldDescriptor.getField();
-      if (!field.isStatic()) {
-        final ObjectReference object = fieldDescriptor.getObject();
-        if (object != null) {
-          set(expression, callback, debuggerContext, new SetValueRunnable() {
-            public void setValue(EvaluationContextImpl evaluationContext, Value newValue)
-              throws ClassNotLoadedException, InvalidTypeException, EvaluateException {
-              object.setValue(field, preprocessValue(evaluationContext, newValue, field.type()));
-              update(debuggerContext);
-            }
-
-            public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws
-                                                                                                      InvocationException,
-                                                                                                      ClassNotLoadedException,
-                                                                                                      IncompatibleThreadStateException,
-                                                                                                      InvalidTypeException,
-                                                                                                      EvaluateException {
-              return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, field.declaringType().classLoader());
-            }
-          });
-        }
-      }
-      else {
-        // field is static
-        ReferenceType refType = field.declaringType();
-        if (refType instanceof ClassType) {
-          final ClassType classType = (ClassType)refType;
-          set(expression, callback, debuggerContext, new SetValueRunnable() {
-            public void setValue(EvaluationContextImpl evaluationContext, Value newValue)
-              throws ClassNotLoadedException, InvalidTypeException, EvaluateException {
-              classType.setValue(field, preprocessValue(evaluationContext, newValue, field.type()));
-              update(debuggerContext);
-            }
-
-            public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws
-                                                                                                      InvocationException,
-                                                                                                      ClassNotLoadedException,
-                                                                                                      IncompatibleThreadStateException,
-                                                                                                      InvalidTypeException,
-                                                                                                      EvaluateException {
-              return evaluationContext.getDebugProcess().loadClass(evaluationContext, className,
-                                                                   field.declaringType().classLoader());
-            }
-          });
-        }
-      }
-    }
-    else if (descriptor instanceof LocalVariableDescriptorImpl) {
-      LocalVariableDescriptorImpl localDescriptor = (LocalVariableDescriptorImpl)descriptor;
-      final LocalVariableProxyImpl local = localDescriptor.getLocalVariable();
-      if (local != null) {
-        set(expression, callback, debuggerContext, new SetValueRunnable() {
-          public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException,
-                                                                                               InvalidTypeException,
-                                                                                               EvaluateException {
-            debuggerContext.getFrameProxy().setValue(local, preprocessValue(evaluationContext, newValue, local.getType()));
-            update(debuggerContext);
-          }
-
-          public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException,
-                                                                                                           ClassNotLoadedException,
-                                                                                                           IncompatibleThreadStateException,
-                                                                                                           InvalidTypeException,
-                                                                                                           EvaluateException {
-            return evaluationContext.getDebugProcess().loadClass(evaluationContext, className,
-                                                                 evaluationContext.getClassLoader());
-          }
-        });
-      }
-    }
-    else if (descriptor instanceof ArrayElementDescriptorImpl) {
-      final ArrayElementDescriptorImpl elementDescriptor = (ArrayElementDescriptorImpl)descriptor;
-      final ArrayReference array = elementDescriptor.getArray();
-      if (array != null) {
-        if (VirtualMachineProxyImpl.isCollected(array)) {
-          // will only be the case if debugger does not use ObjectReference.disableCollection() because of Patches.IBM_JDK_DISABLE_COLLECTION_BUG
-          Messages.showWarningDialog(myJavaValue.getProject(), DebuggerBundle.message("evaluation.error.array.collected") + "\n"+ DebuggerBundle.message("warning.recalculate"), DebuggerBundle.message("title.set.value"));
-          //node.getParent().calcValue();
-          return;
-        }
-        final ArrayType arrType = (ArrayType)array.referenceType();
-        set(expression, callback, debuggerContext, new SetValueRunnable() {
-          public void setValue(EvaluationContextImpl evaluationContext, Value newValue)
-            throws ClassNotLoadedException, InvalidTypeException, EvaluateException {
-            array.setValue(elementDescriptor.getIndex(), preprocessValue(evaluationContext, newValue, arrType.componentType()));
-            update(debuggerContext);
-          }
-
-          public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException,
-                                                                                                           ClassNotLoadedException,
-                                                                                                           IncompatibleThreadStateException,
-                                                                                                           InvalidTypeException,
-                                                                                                           EvaluateException {
-            return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, arrType.classLoader());
-          }
-        });
-      }
-    }
-    else if (descriptor instanceof EvaluationDescriptor) {
-      final EvaluationDescriptor evaluationDescriptor = (EvaluationDescriptor)descriptor;
-      if (evaluationDescriptor.canSetValue()) {
-        set(expression, callback, debuggerContext, new SetValueRunnable() {
-          public void setValue(EvaluationContextImpl evaluationContext, Value newValue)
-            throws ClassNotLoadedException, InvalidTypeException, EvaluateException {
-            final Modifier modifier = evaluationDescriptor.getModifier();
-            modifier.setValue(preprocessValue(evaluationContext, newValue, modifier.getExpectedType()));
-            update(debuggerContext);
-          }
-
-          public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException,
-                                                                                                           ClassNotLoadedException,
-                                                                                                           IncompatibleThreadStateException,
-                                                                                                           InvalidTypeException,
-                                                                                                           EvaluateException {
-            return evaluationContext.getDebugProcess().loadClass(evaluationContext, className,
-                                                                 evaluationContext.getClassLoader());
-          }
-        });
-      }
-    }
+    setValueImpl(expression, callback);
   }
 
-  private static Value preprocessValue(EvaluationContextImpl context, Value value, Type varType) throws EvaluateException {
+  protected static Value preprocessValue(EvaluationContextImpl context, Value value, Type varType) throws EvaluateException {
     if (value != null && JAVA_LANG_STRING.equals(varType.name()) && !(value instanceof StringReference)) {
       String v = DebuggerUtils.getValueAsString(context, value);
       if (v != null) {
@@ -273,7 +146,7 @@ public class JavaValueModifier extends XValueModifier {
     return value;
   }
 
-  private interface SetValueRunnable {
+  protected interface SetValueRunnable {
     void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException,
                                                                                           InvalidTypeException,
                                                                                           EvaluateException,
@@ -331,7 +204,7 @@ public class JavaValueModifier extends XValueModifier {
     }
   }
 
-  private void set(@NotNull final String expression, final XModificationCallback callback, final DebuggerContextImpl debuggerContext, final SetValueRunnable setValueRunnable) {
+  protected void set(@NotNull final String expression, final XModificationCallback callback, final DebuggerContextImpl debuggerContext, final SetValueRunnable setValueRunnable) {
     final ProgressWindowWithNotification progressWindow = new ProgressWindowWithNotification(true, debuggerContext.getProject());
     final EvaluationContextImpl evaluationContext = myJavaValue.getEvaluationContext();
 
index 87a958286a5a667dc01fbd1792b26490ae175425..eca23584a3bcad583634b34077aa421a381200c0 100644 (file)
@@ -50,6 +50,7 @@ class LocalVariableEvaluator implements Evaluator {
   private final String myLocalVariableName;
   private EvaluationContextImpl myContext;
   private LocalVariableProxyImpl myEvaluatedVariable;
+  private DecompiledLocalVariable myEvaluatedDecompiledVariable;
   private final boolean myCanScanFrames;
 
   public LocalVariableEvaluator(String localVariableName, boolean canScanFrames) {
@@ -95,6 +96,8 @@ class LocalVariableEvaluator implements Evaluator {
             for (Map.Entry<DecompiledLocalVariable, Value> entry : vars.entrySet()) {
               DecompiledLocalVariable var = entry.getKey();
               if (var.getMatchedNames().contains(myLocalVariableName) || var.getDefaultName().equals(myLocalVariableName)) {
+                myEvaluatedDecompiledVariable = var;
+                myContext = context;
                 return entry.getValue();
               }
             }
@@ -137,7 +140,7 @@ class LocalVariableEvaluator implements Evaluator {
   @Override
   public Modifier getModifier() {
     Modifier modifier = null;
-    if (myEvaluatedVariable != null && myContext != null) {
+    if ((myEvaluatedVariable != null || myEvaluatedDecompiledVariable != null) && myContext != null) {
       modifier = new Modifier() {
         @Override
         public boolean canInspect() {
@@ -154,7 +157,12 @@ class LocalVariableEvaluator implements Evaluator {
           StackFrameProxyImpl frameProxy = myContext.getFrameProxy();
           try {
             assert frameProxy != null;
-            frameProxy.setValue(myEvaluatedVariable, value);
+            if (myEvaluatedVariable != null) {
+              frameProxy.setValue(myEvaluatedVariable, value);
+            }
+            else { // no debug info
+              LocalVariablesUtil.setValue(frameProxy.getStackFrame(), myEvaluatedDecompiledVariable.getSlot(), value);
+            }
           }
           catch (EvaluateException e) {
             LOG.error(e);
index 00f2ea5d2448a1024628b42682838bf0034e9d91..4dfb02456bbc8aba31151f5c204837cc88e2bf94 100644 (file)
@@ -19,6 +19,7 @@ import com.intellij.debugger.SourcePosition;
 import com.intellij.debugger.engine.ContextUtil;
 import com.intellij.debugger.engine.DebugProcess;
 import com.intellij.debugger.engine.StackFrameContext;
+import com.intellij.debugger.engine.evaluation.EvaluateException;
 import com.intellij.debugger.impl.DebuggerUtilsEx;
 import com.intellij.debugger.impl.SimpleStackFrameContext;
 import com.intellij.openapi.application.ApplicationManager;
@@ -26,13 +27,14 @@ import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.util.Computable;
 import com.intellij.psi.*;
 import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.ReflectionUtil;
 import com.intellij.util.containers.MultiMap;
 import com.sun.jdi.*;
 import org.jetbrains.annotations.NotNull;
 
 import java.lang.reflect.Array;
 import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.*;
 
@@ -94,22 +96,27 @@ public class LocalVariablesUtil {
   private static final boolean ourInitializationOk;
   private static Class<?> ourSlotInfoClass;
   private static Constructor<?> slotInfoConstructor;
-  private static Class<?> ourGetValuesClass;
   private static Method ourEnqueueMethod;
   private static Method ourWaitForReplyMethod;
 
+  private static final boolean ourInitializationOkSet;
+  private static Class<?> ourSlotInfoClassSet;
+  private static Constructor<?> slotInfoConstructorSet;
+  private static Method ourEnqueueMethodSet;
+  private static Method ourWaitForReplyMethodSet;
+
   static {
+    // get values init
     boolean success = false;
     try {
-      ourSlotInfoClass = Class.forName("com.sun.tools.jdi.JDWP$StackFrame$GetValues$SlotInfo");
+      String GetValuesClassName = "com.sun.tools.jdi.JDWP$StackFrame$GetValues";
+      ourSlotInfoClass = Class.forName(GetValuesClassName + "$SlotInfo");
       slotInfoConstructor = ourSlotInfoClass.getDeclaredConstructor(int.class, byte.class);
       slotInfoConstructor.setAccessible(true);
 
-      ourGetValuesClass = Class.forName("com.sun.tools.jdi.JDWP$StackFrame$GetValues");
-      ourEnqueueMethod = findMethod(ourGetValuesClass, "enqueueCommand");
-      ourEnqueueMethod.setAccessible(true);
-      ourWaitForReplyMethod = findMethod(ourGetValuesClass, "waitForReply");
-      ourWaitForReplyMethod.setAccessible(true);
+      Class<?> ourGetValuesClass = Class.forName(GetValuesClassName);
+      ourEnqueueMethod = getDeclaredMethodByName(ourGetValuesClass, "enqueueCommand");
+      ourWaitForReplyMethod = getDeclaredMethodByName(ourGetValuesClass, "waitForReply");
 
       success = true;
     }
@@ -117,6 +124,25 @@ public class LocalVariablesUtil {
       LOG.info(e);
     }
     ourInitializationOk = success;
+
+    // set value init
+    success = false;
+    try {
+      String setValuesClassName = "com.sun.tools.jdi.JDWP$StackFrame$SetValues";
+      ourSlotInfoClassSet = Class.forName(setValuesClassName + "$SlotInfo");
+      slotInfoConstructorSet = ourSlotInfoClassSet.getDeclaredConstructors()[0];
+      slotInfoConstructorSet.setAccessible(true);
+
+      Class<?> ourGetValuesClassSet = Class.forName(setValuesClassName);
+      ourEnqueueMethodSet = getDeclaredMethodByName(ourGetValuesClassSet, "enqueueCommand");
+      ourWaitForReplyMethodSet = getDeclaredMethodByName(ourGetValuesClassSet, "waitForReply");
+
+      success = true;
+    }
+    catch (Throwable e) {
+      LOG.info(e);
+    }
+    ourInitializationOkSet = success;
   }
 
   public static Map<DecompiledLocalVariable, Value> fetchValues(@NotNull StackFrameProxyImpl frameProxy, DebugProcess process) throws Exception {
@@ -161,13 +187,9 @@ public class LocalVariablesUtil {
   private static Map<DecompiledLocalVariable, Value> fetchSlotValues(Map<DecompiledLocalVariable, Value> map,
                                                                      List<DecompiledLocalVariable> vars,
                                                                      StackFrame frame) throws Exception {
-    final Field frameIdField = frame.getClass().getDeclaredField("id");
-    frameIdField.setAccessible(true);
-    final Object frameId = frameIdField.get(frame);
-
+    final Long frameId = ReflectionUtil.getField(frame.getClass(), frame, long.class, "id");
     final VirtualMachine vm = frame.virtualMachine();
-    final Method stateMethod = vm.getClass().getDeclaredMethod("state");
-    stateMethod.setAccessible(true);
+    final Method stateMethod = ReflectionUtil.getDeclaredMethod(vm.getClass(), "state");
 
     Object slotInfoArray = createSlotInfoArray(vars);
 
@@ -178,9 +200,7 @@ public class LocalVariablesUtil {
     }
 
     final Object reply = ourWaitForReplyMethod.invoke(null, vm, ps);
-    final Field valuesField = reply.getClass().getDeclaredField("values");
-    valuesField.setAccessible(true);
-    final Value[] values = (Value[])valuesField.get(reply);
+    final Value[] values = ReflectionUtil.getField(reply.getClass(), reply, Value[].class, "values");
     if (vars.size() != values.length) {
       throw new InternalException("Wrong number of values returned from target VM");
     }
@@ -191,6 +211,38 @@ public class LocalVariablesUtil {
     return map;
   }
 
+  public static boolean canSetValues() {
+    return ourInitializationOkSet;
+  }
+
+  public static void setValue(StackFrame frame, int slot, Value value) throws EvaluateException {
+    try {
+      final Long frameId = ReflectionUtil.getField(frame.getClass(), frame, long.class, "id");
+      final VirtualMachine vm = frame.virtualMachine();
+      final Method stateMethod = ReflectionUtil.getDeclaredMethod(vm.getClass(), "state");
+
+      Object slotInfoArray = createSlotInfoArraySet(slot, value);
+
+      Object ps;
+      final Object vmState = stateMethod.invoke(vm);
+      synchronized (vmState) {
+        ps = ourEnqueueMethodSet.invoke(null, vm, frame.thread(), frameId, slotInfoArray);
+      }
+
+      ourWaitForReplyMethodSet.invoke(null, vm, ps);
+    }
+    catch (Exception e) {
+      throw new EvaluateException("Unable to set value", e);
+    }
+  }
+
+  private static Object createSlotInfoArraySet(int slot, Value value)
+    throws IllegalAccessException, InvocationTargetException, InstantiationException {
+    Object arrayInstance = Array.newInstance(ourSlotInfoClassSet, 1);
+    Array.set(arrayInstance, 0, slotInfoConstructorSet.newInstance(slot, value));
+    return arrayInstance;
+  }
+
   private static Object createSlotInfoArray(Collection<DecompiledLocalVariable> vars) throws Exception {
     final Object arrayInstance = Array.newInstance(ourSlotInfoClass, vars.size());
 
@@ -203,9 +255,10 @@ public class LocalVariablesUtil {
     return arrayInstance;
   }
 
-  private static Method findMethod(Class aClass, String methodName) throws NoSuchMethodException {
+  private static Method getDeclaredMethodByName(Class aClass, String methodName) throws NoSuchMethodException {
     for (Method method : aClass.getDeclaredMethods()) {
       if (methodName.equals(method.getName())) {
+        method.setAccessible(true);
         return method;
       }
     }
index b3b33fee9a627f27998c15d598e99133b05f258c..e2e120cf4323b4e85905e0f49fff8e63776456d2 100644 (file)
@@ -17,17 +17,23 @@ package com.intellij.debugger.ui.impl.watch;
 
 import com.intellij.debugger.DebuggerBundle;
 import com.intellij.debugger.DebuggerContext;
+import com.intellij.debugger.DebuggerManagerEx;
+import com.intellij.debugger.engine.JavaValue;
+import com.intellij.debugger.engine.JavaValueModifier;
 import com.intellij.debugger.engine.evaluation.EvaluateException;
 import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
+import com.intellij.debugger.impl.DebuggerContextImpl;
 import com.intellij.debugger.impl.PositionUtil;
 import com.intellij.debugger.jdi.DecompiledLocalVariable;
+import com.intellij.debugger.jdi.LocalVariablesUtil;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.JavaPsiFacade;
 import com.intellij.psi.PsiElementFactory;
 import com.intellij.psi.PsiExpression;
 import com.intellij.util.IncorrectOperationException;
-import com.sun.jdi.PrimitiveValue;
-import com.sun.jdi.Value;
+import com.intellij.xdebugger.frame.XValueModifier;
+import com.sun.jdi.*;
+import org.jetbrains.annotations.NotNull;
 
 public class ArgumentValueDescriptorImpl extends ValueDescriptorImpl{
   private final DecompiledLocalVariable myVariable;
@@ -40,7 +46,7 @@ public class ArgumentValueDescriptorImpl extends ValueDescriptorImpl{
 
   @Override
   public boolean canSetValue() {
-    return false;
+    return LocalVariablesUtil.canSetValues();
   }
 
   public boolean isPrimitive() {
@@ -72,4 +78,39 @@ public class ArgumentValueDescriptorImpl extends ValueDescriptorImpl{
       throw new EvaluateException(DebuggerBundle.message("error.invalid.local.variable.name", getName()), e);
     }
   }
+
+  @Override
+  public XValueModifier getModifier(JavaValue value) {
+    return new JavaValueModifier(value) {
+      @Override
+      protected void setValueImpl(@NotNull String expression, @NotNull XModificationCallback callback) {
+        final DecompiledLocalVariable local = ArgumentValueDescriptorImpl.this.getVariable();
+        if (local != null) {
+          final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext();
+          set(expression, callback, debuggerContext, new SetValueRunnable() {
+            public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException,
+                                                                                                 InvalidTypeException,
+                                                                                                 EvaluateException {
+              try {
+                LocalVariablesUtil.setValue(debuggerContext.getFrameProxy().getStackFrame(), local.getSlot(), newValue);
+              }
+              catch (Exception e) {
+                e.printStackTrace();
+              }
+              update(debuggerContext);
+            }
+
+            public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException,
+                                                                                                             ClassNotLoadedException,
+                                                                                                             IncompatibleThreadStateException,
+                                                                                                             InvalidTypeException,
+                                                                                                             EvaluateException {
+              return evaluationContext.getDebugProcess().loadClass(evaluationContext, className,
+                                                                   evaluationContext.getClassLoader());
+            }
+          });
+        }
+      }
+    };
+  }
 }
\ No newline at end of file
index bdc0d385e4319e2f3047b8cdceb221b7dfce4e11..b1f1da671fd79ecdccbd2a9c8721461c92827dab 100644 (file)
  */
 package com.intellij.debugger.ui.impl.watch;
 
+import com.intellij.debugger.DebuggerBundle;
 import com.intellij.debugger.DebuggerContext;
+import com.intellij.debugger.DebuggerManagerEx;
+import com.intellij.debugger.engine.JavaValue;
+import com.intellij.debugger.engine.JavaValueModifier;
 import com.intellij.debugger.engine.evaluation.EvaluateException;
 import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
 import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
+import com.intellij.debugger.impl.DebuggerContextImpl;
+import com.intellij.debugger.jdi.VirtualMachineProxyImpl;
 import com.intellij.debugger.ui.tree.ArrayElementDescriptor;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.Messages;
 import com.intellij.psi.JavaPsiFacade;
 import com.intellij.psi.PsiElementFactory;
 import com.intellij.psi.PsiExpression;
 import com.intellij.util.IncorrectOperationException;
-import com.sun.jdi.ArrayReference;
-import com.sun.jdi.ObjectCollectedException;
-import com.sun.jdi.Value;
+import com.intellij.xdebugger.frame.XValueModifier;
+import com.sun.jdi.*;
+import org.jetbrains.annotations.NotNull;
 
 public class ArrayElementDescriptorImpl extends ValueDescriptorImpl implements ArrayElementDescriptor{
   private final int myIndex;
@@ -74,4 +81,40 @@ public class ArrayElementDescriptorImpl extends ValueDescriptorImpl implements A
       throw new EvaluateException(e.getMessage(), e);
     }
   }
+
+  @Override
+  public XValueModifier getModifier(JavaValue value) {
+    return new JavaValueModifier(value) {
+      @Override
+      protected void setValueImpl(@NotNull String expression, @NotNull XModificationCallback callback) {
+        final ArrayElementDescriptorImpl elementDescriptor = ArrayElementDescriptorImpl.this;
+        final ArrayReference array = elementDescriptor.getArray();
+        if (array != null) {
+          if (VirtualMachineProxyImpl.isCollected(array)) {
+            // will only be the case if debugger does not use ObjectReference.disableCollection() because of Patches.IBM_JDK_DISABLE_COLLECTION_BUG
+            Messages.showWarningDialog(getProject(), DebuggerBundle.message("evaluation.error.array.collected") + "\n" + DebuggerBundle.message("warning.recalculate"), DebuggerBundle.message("title.set.value"));
+            //node.getParent().calcValue();
+            return;
+          }
+          final ArrayType arrType = (ArrayType)array.referenceType();
+          final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext();
+          set(expression, callback, debuggerContext, new SetValueRunnable() {
+            public void setValue(EvaluationContextImpl evaluationContext, Value newValue)
+              throws ClassNotLoadedException, InvalidTypeException, EvaluateException {
+              array.setValue(elementDescriptor.getIndex(), preprocessValue(evaluationContext, newValue, arrType.componentType()));
+              update(debuggerContext);
+            }
+
+            public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException,
+                                                                                                             ClassNotLoadedException,
+                                                                                                             IncompatibleThreadStateException,
+                                                                                                             InvalidTypeException,
+                                                                                                             EvaluateException {
+              return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, arrType.classLoader());
+            }
+          });
+        }
+      }
+    };
+  }
 }
index 620424e34457b47c7ddcf7f4cc02c2ff222903fc..f1ac04c4de0351ba8b6755ffbb73c84c0b68198d 100644 (file)
  */
 package com.intellij.debugger.ui.impl.watch;
 
-import com.intellij.debugger.DebuggerBundle;
-import com.intellij.debugger.DebuggerContext;
-import com.intellij.debugger.DebuggerInvocationUtil;
-import com.intellij.debugger.EvaluatingComputable;
+import com.intellij.debugger.*;
 import com.intellij.debugger.engine.ContextUtil;
+import com.intellij.debugger.engine.JavaValue;
+import com.intellij.debugger.engine.JavaValueModifier;
 import com.intellij.debugger.engine.StackFrameContext;
 import com.intellij.debugger.engine.evaluation.EvaluateException;
 import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
@@ -28,6 +27,7 @@ import com.intellij.debugger.engine.evaluation.TextWithImports;
 import com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator;
 import com.intellij.debugger.engine.evaluation.expression.Modifier;
 import com.intellij.debugger.engine.evaluation.expression.UnsupportedExpressionException;
+import com.intellij.debugger.impl.DebuggerContextImpl;
 import com.intellij.debugger.impl.DebuggerUtilsEx;
 import com.intellij.debugger.impl.PositionUtil;
 import com.intellij.debugger.jdi.StackFrameProxyImpl;
@@ -37,8 +37,9 @@ import com.intellij.psi.*;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.refactoring.extractMethod.PrepareFailedException;
 import com.intellij.refactoring.extractMethodObject.ExtractLightMethodObjectHandler;
-import com.sun.jdi.ObjectCollectedException;
-import com.sun.jdi.Value;
+import com.intellij.xdebugger.frame.XValueModifier;
+import com.sun.jdi.*;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -160,4 +161,34 @@ public abstract class EvaluationDescriptor extends ValueDescriptorImpl{
   public TextWithImports getEvaluationText() {
     return myText;
   }
+
+  @Override
+  public XValueModifier getModifier(JavaValue value) {
+    return new JavaValueModifier(value) {
+      @Override
+      protected void setValueImpl(@NotNull String expression, @NotNull XModificationCallback callback) {
+        final EvaluationDescriptor evaluationDescriptor = EvaluationDescriptor.this;
+        if (evaluationDescriptor.canSetValue()) {
+          final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext();
+          set(expression, callback, debuggerContext, new SetValueRunnable() {
+            public void setValue(EvaluationContextImpl evaluationContext, Value newValue)
+              throws ClassNotLoadedException, InvalidTypeException, EvaluateException {
+              final Modifier modifier = evaluationDescriptor.getModifier();
+              modifier.setValue(preprocessValue(evaluationContext, newValue, modifier.getExpectedType()));
+              update(debuggerContext);
+            }
+
+            public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException,
+                                                                                                             ClassNotLoadedException,
+                                                                                                             IncompatibleThreadStateException,
+                                                                                                             InvalidTypeException,
+                                                                                                             EvaluateException {
+              return evaluationContext.getDebugProcess().loadClass(evaluationContext, className,
+                                                                   evaluationContext.getClassLoader());
+            }
+          });
+        }
+      }
+    };
+  }
 }
index 03596922ad277858e45e621ca5d9cebb6744e23a..ac64b580c8df7f4cd0b9eda846f761dbd2c6c422 100644 (file)
@@ -17,11 +17,15 @@ package com.intellij.debugger.ui.impl.watch;
 
 import com.intellij.debugger.DebuggerBundle;
 import com.intellij.debugger.DebuggerContext;
+import com.intellij.debugger.DebuggerManagerEx;
 import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
 import com.intellij.debugger.engine.DebuggerUtils;
+import com.intellij.debugger.engine.JavaValue;
+import com.intellij.debugger.engine.JavaValueModifier;
 import com.intellij.debugger.engine.evaluation.EvaluateException;
 import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
 import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
+import com.intellij.debugger.impl.DebuggerContextImpl;
 import com.intellij.debugger.impl.PositionUtil;
 import com.intellij.debugger.settings.NodeRendererSettings;
 import com.intellij.debugger.ui.tree.FieldDescriptor;
@@ -32,10 +36,8 @@ import com.intellij.psi.JavaPsiFacade;
 import com.intellij.psi.PsiElementFactory;
 import com.intellij.psi.PsiExpression;
 import com.intellij.util.IncorrectOperationException;
-import com.sun.jdi.Field;
-import com.sun.jdi.ObjectCollectedException;
-import com.sun.jdi.ObjectReference;
-import com.sun.jdi.Value;
+import com.intellij.xdebugger.frame.XValueModifier;
+import com.sun.jdi.*;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -153,4 +155,61 @@ public class FieldDescriptorImpl extends ValueDescriptorImpl implements FieldDes
       throw new EvaluateException(DebuggerBundle.message("error.invalid.field.name", getName()), e);
     }
   }
+
+  @Override
+  public XValueModifier getModifier(JavaValue value) {
+    return new JavaValueModifier(value) {
+      @Override
+      protected void setValueImpl(@NotNull String expression, @NotNull XModificationCallback callback) {
+        final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext();
+        FieldDescriptorImpl fieldDescriptor = FieldDescriptorImpl.this;
+        final Field field = fieldDescriptor.getField();
+        if (!field.isStatic()) {
+          final ObjectReference object = fieldDescriptor.getObject();
+          if (object != null) {
+            set(expression, callback, debuggerContext, new SetValueRunnable() {
+              public void setValue(EvaluationContextImpl evaluationContext, Value newValue)
+                throws ClassNotLoadedException, InvalidTypeException, EvaluateException {
+                object.setValue(field, preprocessValue(evaluationContext, newValue, field.type()));
+                update(debuggerContext);
+              }
+
+              public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws
+                                                                                                        InvocationException,
+                                                                                                        ClassNotLoadedException,
+                                                                                                        IncompatibleThreadStateException,
+                                                                                                        InvalidTypeException,
+                                                                                                        EvaluateException {
+                return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, field.declaringType().classLoader());
+              }
+            });
+          }
+        }
+        else {
+          // field is static
+          ReferenceType refType = field.declaringType();
+          if (refType instanceof ClassType) {
+            final ClassType classType = (ClassType)refType;
+            set(expression, callback, debuggerContext, new SetValueRunnable() {
+              public void setValue(EvaluationContextImpl evaluationContext, Value newValue)
+                throws ClassNotLoadedException, InvalidTypeException, EvaluateException {
+                classType.setValue(field, preprocessValue(evaluationContext, newValue, field.type()));
+                update(debuggerContext);
+              }
+
+              public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws
+                                                                                                        InvocationException,
+                                                                                                        ClassNotLoadedException,
+                                                                                                        IncompatibleThreadStateException,
+                                                                                                        InvalidTypeException,
+                                                                                                        EvaluateException {
+                return evaluationContext.getDebugProcess().loadClass(evaluationContext, className,
+                                                                     field.declaringType().classLoader());
+              }
+            });
+          }
+        }
+      }
+    };
+  }
 }
index f05998002c03ddd86f0940529d6d8e49ecc1d64c..42169f855f3820044caa6a841daee71e7b244c5b 100644 (file)
@@ -17,9 +17,13 @@ package com.intellij.debugger.ui.impl.watch;
 
 import com.intellij.debugger.DebuggerBundle;
 import com.intellij.debugger.DebuggerContext;
+import com.intellij.debugger.DebuggerManagerEx;
 import com.intellij.debugger.engine.DebuggerUtils;
+import com.intellij.debugger.engine.JavaValue;
+import com.intellij.debugger.engine.JavaValueModifier;
 import com.intellij.debugger.engine.evaluation.EvaluateException;
 import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
+import com.intellij.debugger.impl.DebuggerContextImpl;
 import com.intellij.debugger.impl.PositionUtil;
 import com.intellij.debugger.jdi.LocalVariableProxyImpl;
 import com.intellij.debugger.jdi.StackFrameProxyImpl;
@@ -30,7 +34,8 @@ import com.intellij.psi.JavaPsiFacade;
 import com.intellij.psi.PsiElementFactory;
 import com.intellij.psi.PsiExpression;
 import com.intellij.util.IncorrectOperationException;
-import com.sun.jdi.Value;
+import com.intellij.xdebugger.frame.XValueModifier;
+import com.sun.jdi.*;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -111,4 +116,34 @@ public class LocalVariableDescriptorImpl extends ValueDescriptorImpl implements
       throw new EvaluateException(DebuggerBundle.message("error.invalid.local.variable.name", getName()), e);
     }
   }
+
+  @Override
+  public XValueModifier getModifier(JavaValue value) {
+    return new JavaValueModifier(value) {
+      @Override
+      protected void setValueImpl(@NotNull String expression, @NotNull XModificationCallback callback) {
+        final LocalVariableProxyImpl local = LocalVariableDescriptorImpl.this.getLocalVariable();
+        if (local != null) {
+          final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext();
+          set(expression, callback, debuggerContext, new SetValueRunnable() {
+            public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException,
+                                                                                                 InvalidTypeException,
+                                                                                                 EvaluateException {
+              debuggerContext.getFrameProxy().setValue(local, preprocessValue(evaluationContext, newValue, local.getType()));
+              update(debuggerContext);
+            }
+
+            public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException,
+                                                                                                             ClassNotLoadedException,
+                                                                                                             IncompatibleThreadStateException,
+                                                                                                             InvalidTypeException,
+                                                                                                             EvaluateException {
+              return evaluationContext.getDebugProcess().loadClass(evaluationContext, className,
+                                                                   evaluationContext.getClassLoader());
+            }
+          });
+        }
+      }
+    };
+  }
 }
\ No newline at end of file
index 902d2c6855d8ceb1d0a4b02b6ee87b0e734a864c..6423c55365528e312789feff1827b22bf18775f7 100644 (file)
@@ -39,6 +39,7 @@ import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiExpression;
 import com.intellij.util.StringBuilderSpinAllocator;
 import com.intellij.util.concurrency.Semaphore;
+import com.intellij.xdebugger.frame.XValueModifier;
 import com.intellij.xdebugger.impl.ui.tree.ValueMarkup;
 import com.sun.jdi.*;
 import org.jetbrains.annotations.NotNull;
@@ -541,6 +542,10 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
     return myValueReady && !myIsSynthetic && isLvalue();
   }
 
+  public XValueModifier getModifier(JavaValue value) {
+    return null;
+  }
+
   @NotNull
   public String getIdLabel() {
     return StringUtil.notNullize(myIdLabel);
index 80448f9d3a96081605cfb7e196158d2c152e4fad..0a5a45eb1cadb51e7ea6f52f652903cea4305498 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * 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.
@@ -37,6 +37,7 @@ import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.*;
 import com.intellij.psi.impl.source.codeStyle.ImportHelper;
 import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.testFramework.EditorTestUtil;
 import com.intellij.util.ui.UIUtil;
 import org.jetbrains.annotations.NonNls;
 
@@ -370,6 +371,7 @@ public class ImportHelperTest extends DaemonAnalyzerTestCase {
   public void testAutoImportOfGenericReference() throws Throwable {
     @NonNls final String text = "class S {{ new ArrayList<caret><String> }}";
     configureByText(StdFileTypes.JAVA, text);
+    EditorTestUtil.setEditorVisibleSize(myEditor, 1000, 1000); // make sure editor is visible - auto-import works only for visible area
     boolean old = CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY;
     CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = true;
     DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);
index 0e5c30e7b38d95322d2bd81bb0341f6f78b69264..172c58b953dbe7acbe7be0dc50ee0b4eda18a4db 100644 (file)
@@ -29,7 +29,6 @@ import com.intellij.openapi.editor.markup.HighlighterLayer;
 import com.intellij.openapi.editor.markup.HighlighterTargetArea;
 import com.intellij.openapi.editor.markup.TextAttributes;
 import com.intellij.openapi.util.io.FileUtil;
-import com.intellij.openapi.util.registry.Registry;
 import com.intellij.psi.tree.IElementType;
 import com.intellij.rt.execution.junit.FileComparisonFailure;
 import com.intellij.testFramework.MockFontLayoutService;
@@ -87,13 +86,11 @@ public class EditorPaintingTest extends AbstractEditorTest {
   protected void setUp() throws Exception {
     super.setUp();
     FontLayoutService.setInstance(new MockFontLayoutService(BitmapFont.CHAR_WIDTH, BitmapFont.CHAR_HEIGHT, BitmapFont.CHAR_DESCENT));
-    Registry.get("editor.new.rendering").setValue(true);
   }
 
   @Override
   protected void tearDown() throws Exception {
     try {
-      Registry.get("editor.new.rendering").setValue(false);
       FontLayoutService.setInstance(null);
     }
     finally {
index 2c1fbe1e4cdc07dd4ba2081ea32688a95e6a9945..ebc3a285bc2a46445fdbf427e82634e9dd427437 100644 (file)
@@ -23,7 +23,6 @@ import com.intellij.openapi.editor.LogicalPosition;
 import com.intellij.openapi.editor.VisualPosition;
 import com.intellij.openapi.editor.ex.DocumentEx;
 import com.intellij.openapi.editor.ex.util.EditorUtil;
-import com.intellij.openapi.util.registry.Registry;
 import com.intellij.testFramework.EditorTestUtil;
 
 import java.awt.*;
@@ -194,16 +193,10 @@ public class EditorImplTest extends AbstractEditorTest {
   }
   
   public void testEditorSizeCalculationOnOpening() throws Exception {
-    Registry.get("editor.new.rendering").setValue(true);
-    try {
-      initText("a\nbbb\nccccc");
-      myEditor.putUserData(EditorImpl.DO_DOCUMENT_UPDATE_TEST, Boolean.TRUE);
-      myEditor.getSettings().setAdditionalColumnsCount(0);
-      myEditor.getSettings().setAdditionalLinesCount(0);
-      assertEquals(new Dimension(50, 30), myEditor.getContentComponent().getPreferredSize());
-    }
-    finally {
-      Registry.get("editor.new.rendering").setValue(false);
-    }
+    initText("a\nbbb\nccccc");
+    myEditor.putUserData(EditorImpl.DO_DOCUMENT_UPDATE_TEST, Boolean.TRUE);
+    myEditor.getSettings().setAdditionalColumnsCount(0);
+    myEditor.getSettings().setAdditionalLinesCount(0);
+    assertEquals(new Dimension(50, 30), myEditor.getContentComponent().getPreferredSize());
   }
 }
index 302710ea536a87b3dcd67a9e386f222163aaf594..2f2c9a00bc64148ef58c4198a90a65db5ab4d4ec 100644 (file)
@@ -19,7 +19,6 @@ import com.intellij.openapi.actionSystem.IdeActions;
 import com.intellij.openapi.editor.Caret;
 import com.intellij.openapi.editor.LogicalPosition;
 import com.intellij.openapi.editor.VisualPosition;
-import com.intellij.openapi.util.registry.Registry;
 import com.intellij.testFramework.TestFileType;
 
 import java.awt.*;
@@ -32,22 +31,6 @@ public class EditorRtlTest extends AbstractEditorTest {
   private static final char RTL_CHAR_REPRESENTATION = 'R';
   private static final char RTL_CHAR = '\u05d0'; // Hebrew 'aleph' letter
 
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
-    Registry.get("editor.new.rendering").setValue(true);
-  }
-
-  @Override
-  protected void tearDown() throws Exception {
-    try {
-      Registry.get("editor.new.rendering").setValue(false);
-    }
-    finally {
-      super.tearDown();      
-    }
-  }
-
   public void testPositionCalculations() throws IOException {
     prepareText("LLRR");
     
index 9f669b0a81ef47fd611025c5739efb39ba305bd1..884755c595ff4980595a21d2d5bf3ef1d0beebde 100644 (file)
@@ -18,6 +18,7 @@ package com.intellij.openapi.editor.impl.softwrap.mapping;
 import com.intellij.codeInsight.folding.CodeFoldingManager;
 import com.intellij.openapi.editor.*;
 import com.intellij.openapi.editor.ex.DocumentEx;
+import com.intellij.openapi.editor.ex.util.EditorUtil;
 import com.intellij.openapi.editor.impl.AbstractEditorTest;
 import com.intellij.openapi.editor.impl.EditorImpl;
 import com.intellij.openapi.editor.impl.SoftWrapModelImpl;
@@ -177,7 +178,7 @@ public class SoftWrapApplianceOnDocumentModificationTest extends AbstractEditorT
       "line1\n" +
       "long line<caret>";
     
-    init(48, text, 7);
+    init(69, text, 10);
 
     int softWrapsBefore = getSoftWrapModel().getRegisteredSoftWraps().size();
     assertTrue(softWrapsBefore > 0);
@@ -459,7 +460,7 @@ public class SoftWrapApplianceOnDocumentModificationTest extends AbstractEditorT
       "line4\n" +
       "line5";
     
-    init(30, text, 7);
+    init(43, text, 10);
     int start = text.indexOf("line3") - 1;
     addCollapsedFoldRegion(start, text.length(), "...");
     assertEquals(1, getSoftWrapModel().getRegisteredSoftWraps().size());
@@ -577,7 +578,7 @@ public class SoftWrapApplianceOnDocumentModificationTest extends AbstractEditorT
       "this is line 4\n" +
       "this is line 5";
     
-    init(50, text, 7);
+    init(71, text, 10);
     VisualPosition changePosition = new VisualPosition(1, 0);
     myEditor.getCaretModel().moveToVisualPosition(changePosition);
     
@@ -585,7 +586,7 @@ public class SoftWrapApplianceOnDocumentModificationTest extends AbstractEditorT
     int offsetBefore = myEditor.getCaretModel().getOffset();
     
     LogicalPosition logicalPositionBefore = myEditor.visualToLogicalPosition(changePosition);
-    assertEquals(1, logicalPositionBefore.softWrapLinesOnCurrentLogicalLine);
+    assertEquals(1, EditorUtil.getSoftWrapCountAfterLineStart(myEditor, logicalPositionBefore));
     assertTrue(logicalPositionBefore.column > 0);
     
     SoftWrap softWrap = getSoftWrapModel().getSoftWrap(offsetBefore);
@@ -801,10 +802,9 @@ public class SoftWrapApplianceOnDocumentModificationTest extends AbstractEditorT
     init(10, text);
     getEditor().getSettings().setCustomSoftWrapIndent(0);
     getEditor().getSettings().setUseCustomSoftWrapIndent(true);
-    int textLength = getEditor().getDocument().getTextLength();
     //Trigger soft wraps recalculation.
-    assertEquals(new LogicalPosition(0, textLength), myEditor.offsetToLogicalPosition(textLength));
-    
+    ((SoftWrapModelImpl)myEditor.getSoftWrapModel()).prepareToMapping();
+
     // Don't expect soft wraps to be registered as there is no point in wrapping at the first non-white space symbol position
     // in all cases when soft wrap is located at the left screen edge.
     assertEmpty(getSoftWrapModel().getRegisteredSoftWraps());
@@ -875,13 +875,13 @@ public class SoftWrapApplianceOnDocumentModificationTest extends AbstractEditorT
   public void testNoPreliminarySoftWrapAtLineEnd() throws IOException {
     // We used to make soft wrap when the string was couple of visual columns before the right screen edge even if it could
     // be completely shown.
-    init(37, "a b c", 7);
+    init(52, "a b c", 10);
     assertEmpty(getSoftWrapModel().getRegisteredSoftWraps());
   }
 
   public void testNoPreliminarySoftWrapBeforeFoldingAtLineEnd() throws IOException {
     final String text = "a b c test";
-    init(50, text, 7);
+    init(71, text, 10);
     addCollapsedFoldRegion(text.indexOf("t"), text.length(), ".");
     assertEmpty(getSoftWrapModel().getRegisteredSoftWraps());
   }
@@ -924,7 +924,7 @@ public class SoftWrapApplianceOnDocumentModificationTest extends AbstractEditorT
   
   public void testEnsureBeforeSoftWrapSignIsVisible() throws IOException {
     final String text = "a.b.c.d";
-    init(43, text, 7);
+    init(61, text, 10);
     
     checkSoftWraps(text.indexOf('c') + 1);
   }
@@ -1000,14 +1000,14 @@ public class SoftWrapApplianceOnDocumentModificationTest extends AbstractEditorT
   public void testNoUnnecessaryHorizontalScrollBar() throws IOException {
     // Inspired by IDEA-87184
     final String text = "12345678 abcdefgh";
-    init(15, 7, text);
+    init(15, 10, text);
     myEditor.getCaretModel().moveToOffset(text.length());
     final Ref<Boolean> fail = new Ref<>(true);
     SoftWrapApplianceManager applianceManager = ((SoftWrapModelImpl)myEditor.getSoftWrapModel()).getApplianceManager();
     SoftWrapAwareDocumentParsingListener listener = new SoftWrapAwareDocumentParsingListenerAdapter() {
       @Override
       public void beforeSoftWrapLineFeed(@NotNull EditorPosition position) {
-        if (position.x == text.indexOf("a") * 7) {
+        if (position.x == text.indexOf("a") * 10) {
           fail.set(false);
         }
       }
@@ -1126,7 +1126,7 @@ public class SoftWrapApplianceOnDocumentModificationTest extends AbstractEditorT
   }
   
   private void init(final int visibleWidthInColumns, @NotNull String fileText) throws IOException {
-    init(visibleWidthInColumns, 7, fileText);
+    init(visibleWidthInColumns, 10, fileText);
   }
 
   private void init(final int visibleWidthInColumns, final int symbolWidthInPixels, @NotNull String fileText) throws IOException {
index 5680cb3dcb9bf6095c8b653ab05c24bfab869310..fdc7acd86bdb259dcd9c625a63450afbea8a756e 100644 (file)
@@ -19,6 +19,7 @@ import com.intellij.openapi.editor.*;
 import com.intellij.openapi.editor.ex.DocumentEx;
 import com.intellij.openapi.editor.impl.AbstractEditorTest;
 import com.intellij.openapi.editor.impl.SoftWrapModelImpl;
+import com.intellij.openapi.util.registry.Registry;
 import gnu.trove.TIntObjectProcedure;
 import org.jetbrains.annotations.NotNull;
 
@@ -45,6 +46,7 @@ public class SoftWrapStressTest extends AbstractEditorTest {
   private long mySeed;
   
   public void testSoftWrapModelInternalCachesStayConsistentAfterDocumentAndFoldingChanges() {
+    Registry.get("editor.new.rendering").setValue(false);
     int i = 0;
     try {
       initText("");
@@ -57,6 +59,9 @@ public class SoftWrapStressTest extends AbstractEditorTest {
     catch (Throwable t) {
       throw new RuntimeException("Failed when run with seed=" + mySeed + " in iteration " + i, t);
     }
+    finally {
+      Registry.get("editor.new.rendering").setValue(true);
+    }
   }
   
   private void doRandomAction() {
index fb3532dbf08fae6362095f333447f15dceb37c21..879deaa6e0082b278124e506d49d0af4683739d8 100644 (file)
@@ -554,7 +554,7 @@ html.prefer.short.notation.of.boolean.attributes=true
 editor.disable.rtl=false
 editor.disable.rtl.description=Disables RTL support in editor (all characters are displayed in LTR order)
 
-editor.new.rendering=false
+editor.new.rendering=true
 editor.new.rendering.description=Enables new editor rendering code, with support for RTL.
 
 editor.zero.latency.typing=false