diff --git a/bin/idea.properties b/bin/idea.properties index cd6960d75f5c..47fe054b320a 100644 --- a/bin/idea.properties +++ b/bin/idea.properties @@ -80,9 +80,12 @@ sun.java2d.noddraw=true sun.java2d.d3d=false #--------------------------------------------------------------------- -# Workaround for slow scrolling in JDK6 +# Set swing.bufferPerWindow=false to workaround a slow scrolling in JDK6 (see IDEA-35883), +# But this may lead to performance degradation, because it disables a double buffering, +# which is needed to eliminate tearing on blit-accelerated scrolling and to restore +# a frame buffer content without the usual repainting, even when the EDT is blocked. #--------------------------------------------------------------------- -swing.bufferPerWindow=false +swing.bufferPerWindow=true #--------------------------------------------------------------------- # Removing this property may lead to editor performance degradation under X Window. diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java b/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java index 3830212254e7..f1efc8458f4a 100644 --- a/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -383,14 +383,15 @@ public class VirtualMachineProxyImpl implements JdiTimer, VirtualMachineProxy { catch (UnsupportedOperationException e) { LOG.info(e); } - - if (Patches.JDK_BUG_EVENT_CONTROLLER_LEAK) { - // Memory leak workaround, see IDEA-163334 - TargetVM target = ReflectionUtil.getField(myVirtualMachine.getClass(), myVirtualMachine, TargetVM.class, "target"); - if (target != null) { - Thread controller = ReflectionUtil.getField(target.getClass(), target, Thread.class, "eventController"); - if (controller != null) { - controller.stop(); + finally { + if (Patches.JDK_BUG_EVENT_CONTROLLER_LEAK) { + // Memory leak workaround, see IDEA-163334 + TargetVM target = ReflectionUtil.getField(myVirtualMachine.getClass(), myVirtualMachine, TargetVM.class, "target"); + if (target != null) { + Thread controller = ReflectionUtil.getField(target.getClass(), target, Thread.class, "eventController"); + if (controller != null) { + controller.stop(); + } } } } diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java b/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java index 1c4823bbdd4f..771900896656 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java @@ -173,7 +173,7 @@ public class CaptureConfigurable implements SearchableConfigurable { } }); try { - JDOMUtil.writeDocument(new Document(rootElement), wrapper.getFile(), "\n"); + JDOMUtil.write(rootElement, wrapper.getFile()); } catch (Exception ex) { final String msg = ex.getLocalizedMessage(); diff --git a/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java b/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java index c52c72a16bb2..4bfa06a48a46 100644 --- a/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java +++ b/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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,7 +23,6 @@ import com.intellij.openapi.extensions.PluginId; import com.intellij.openapi.module.ModuleType; import com.intellij.openapi.module.ModuleTypeManager; import com.intellij.openapi.util.ClearableLazyValue; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.platform.ProjectTemplate; import com.intellij.platform.ProjectTemplatesFactory; import com.intellij.util.ArrayUtil; @@ -95,7 +94,7 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory { @NotNull @TestOnly public static MultiMap createFromText(@NotNull String value) throws IOException, JDOMException { - return create(JDOMUtil.loadDocument(value).getRootElement()); + return create(JdomKt.loadElement(value)); } @NotNull diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowRunner.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowRunner.java index aa08cf6ebede..3f8943eb0cbf 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowRunner.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowRunner.java @@ -49,6 +49,9 @@ public class DataFlowRunner { private Instruction[] myInstructions; private final MultiMap myNestedClosures = new MultiMap<>(); + // Closures which were registered for previous instruction and can be queried by visitor + // to adjust them somehow + private final List myStackTopClosures = new ArrayList<>(); @NotNull private final DfaValueFactory myValueFactory; private final boolean myShouldCheckLimitTime; @@ -90,6 +93,10 @@ public class DataFlowRunner { return Collections.singletonList(createMemoryState()); } + List getStackTopClosures() { + return new ArrayList<>(myStackTopClosures); + } + @NotNull public final RunnerResult analyzeMethod(@NotNull PsiElement psiBlock, @NotNull InstructionVisitor visitor) { Collection initialStates = createInitialStates(psiBlock, visitor); @@ -109,6 +116,7 @@ public class DataFlowRunner { int endOffset = flow.getInstructionCount(); myInstructions = flow.getInstructions(); myNestedClosures.clear(); + myStackTopClosures.clear(); Set joinInstructions = ContainerUtil.newHashSet(); for (int index = 0; index < myInstructions.length; index++) { @@ -270,6 +278,9 @@ public class DataFlowRunner { @NotNull protected DfaInstructionState[] acceptInstruction(@NotNull InstructionVisitor visitor, @NotNull DfaInstructionState instructionState) { Instruction instruction = instructionState.getInstruction(); + DfaInstructionState[] states = instruction.accept(this, instructionState.getMemoryState(), visitor); + + myStackTopClosures.clear(); PsiElement closure = DfaUtil.getClosureInside(instruction); if (closure instanceof PsiClass) { registerNestedClosures(instructionState, (PsiClass)closure); @@ -277,7 +288,7 @@ public class DataFlowRunner { registerNestedClosures(instructionState, (PsiLambdaExpression)closure); } - return instruction.accept(this, instructionState.getMemoryState(), visitor); + return states; } private void registerNestedClosures(@NotNull DfaInstructionState instructionState, @NotNull PsiClass nestedClass) { @@ -285,14 +296,14 @@ public class DataFlowRunner { for (PsiMethod method : nestedClass.getMethods()) { PsiCodeBlock body = method.getBody(); if (body != null) { - myNestedClosures.putValue(body, state.createClosureState()); + myNestedClosures.putValue(body, createClosureState(state)); } } for (PsiClassInitializer initializer : nestedClass.getInitializers()) { - myNestedClosures.putValue(initializer.getBody(), state.createClosureState()); + myNestedClosures.putValue(initializer.getBody(), createClosureState(state)); } for (PsiField field : nestedClass.getFields()) { - myNestedClosures.putValue(field, state.createClosureState()); + myNestedClosures.putValue(field, createClosureState(state)); } } @@ -300,10 +311,17 @@ public class DataFlowRunner { DfaMemoryState state = instructionState.getMemoryState(); PsiElement body = expr.getBody(); if (body != null) { - myNestedClosures.putValue(body, state.createClosureState()); + myNestedClosures.putValue(body, createClosureState(state)); } } + @NotNull + private DfaMemoryState createClosureState(DfaMemoryState state) { + DfaMemoryState closureState = state.createClosureState(); + myStackTopClosures.add(closureState); + return closureState; + } + @NotNull protected DfaMemoryState createMemoryState() { return new DfaMemoryStateImpl(myValueFactory); diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java index e34694d07798..1d94c9949f35 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java @@ -53,8 +53,6 @@ public class DfaMemoryStateImpl implements DfaMemoryState { // dfa value id -> indices in myEqClasses list of the classes which contain the id (or wrapped) private final TIntObjectHashMap myIdToEqClassesIndices; private final Stack myStack; - // Closures which correspond to the stack top (do not track other closures for now) - private final List myStackTopClosures = new ArrayList<>(); private final TLongHashSet myDistinctClasses; private final LinkedHashMap myVariableStates; private final Map myDefaultVariableStates; @@ -118,14 +116,9 @@ public class DfaMemoryStateImpl implements DfaMemoryState { copy.flushDependencies(value); } copy.emptyStack(); - myStackTopClosures.add(copy); return copy; } - List getStackTopClosures() { - return new ArrayList<>(myStackTopClosures); - } - public boolean equals(Object obj) { if (obj == this) return true; if (!(obj instanceof DfaMemoryStateImpl)) return false; @@ -241,7 +234,6 @@ public class DfaMemoryStateImpl implements DfaMemoryState { @Override public DfaValue pop() { myCachedHash = null; - myStackTopClosures.clear(); return myStack.pop(); } @@ -253,14 +245,12 @@ public class DfaMemoryStateImpl implements DfaMemoryState { @Override public void push(@NotNull DfaValue value) { myCachedHash = null; - myStackTopClosures.clear(); myStack.push(value); } @Override public void emptyStack() { myCachedHash = null; - myStackTopClosures.clear(); while (!myStack.isEmpty() && !(myStack.peek() instanceof DfaControlTransferValue)) { myStack.pop(); } diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StandardInstructionVisitor.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StandardInstructionVisitor.java index 6d0130b73580..9b4e2984cdec 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StandardInstructionVisitor.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StandardInstructionVisitor.java @@ -229,7 +229,7 @@ public class StandardInstructionVisitor extends InstructionVisitor { if (methodName == null || !OPTIONAL_METHOD_NAMES.contains(methodName)) return Collections.emptyList(); PsiMethod method = call.resolveMethod(); if (method == null || !TypeUtils.isOptional(method.getContainingClass())) return Collections.emptyList(); - List closures = ((DfaMemoryStateImpl)memState).getStackTopClosures(); + List closures = runner.getStackTopClosures(); DfaValue[] argValues = popCallArguments(instruction, runner, memState); final DfaValue qualifier = popQualifier(instruction, runner, memState); switch (methodName) { diff --git a/java/java-impl/src/com/intellij/codeInspection/SimplifyStreamApiCallChainsInspection.java b/java/java-impl/src/com/intellij/codeInspection/SimplifyStreamApiCallChainsInspection.java index 3ffc8f82676b..9d1d57972700 100644 --- a/java/java-impl/src/com/intellij/codeInspection/SimplifyStreamApiCallChainsInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/SimplifyStreamApiCallChainsInspection.java @@ -890,6 +890,10 @@ public class SimplifyStreamApiCallChainsInspection extends BaseJavaBatchLocalIns .parameterCount(1); private static final CallMatcher INT_STREAM_RANGE = CallMatcher.staticCall(CommonClassNames.JAVA_UTIL_STREAM_INT_STREAM, "range").parameterTypes("int", "int"); + private static final CallMatcher MIN_INT = + CallMatcher.anyOf( + CallMatcher.staticCall(CommonClassNames.JAVA_LANG_MATH, "min").parameterTypes("int", "int"), + CallMatcher.staticCall(CommonClassNames.JAVA_LANG_INTEGER, "min").parameterTypes("int", "int")); private final String myName; @@ -913,8 +917,10 @@ public class SimplifyStreamApiCallChainsInspection extends BaseJavaBatchLocalIns public PsiElement simplify(PsiMethodCallExpression mapToObjCall) { Project project = mapToObjCall.getProject(); PsiExpression mapper = ArrayUtil.getFirstElement(mapToObjCall.getArgumentList().getExpressions()); - IndexedContainer container = extractContainer(getQualifierMethodCall(mapToObjCall), mapper); - if (container == null) return null; + LimitedContainer limitedContainer = extractContainer(getQualifierMethodCall(mapToObjCall), mapper); + if (limitedContainer == null) return null; + IndexedContainer container = limitedContainer.myContainer; + PsiExpression limit = limitedContainer.myLimit; PsiExpression containerQualifier = container.getQualifier(); PsiType type = containerQualifier.getType(); PsiType elementType = container.getElementType(); @@ -929,6 +935,9 @@ public class SimplifyStreamApiCallChainsInspection extends BaseJavaBatchLocalIns } PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); CommentTracker ct = new CommentTracker(); + if (limit != null) { + replacement += ".limit(" + ct.text(limit) + ")"; + } if (mapper instanceof PsiMethodReferenceExpression) { mapper = LambdaRefactoringUtil.convertMethodReferenceToLambda((PsiMethodReferenceExpression)mapper, false, true); } @@ -975,22 +984,39 @@ public class SimplifyStreamApiCallChainsInspection extends BaseJavaBatchLocalIns static CallHandler handler() { return CallHandler.of(INT_STREAM_MAP, call -> { PsiExpression mapper = call.getArgumentList().getExpressions()[0]; - IndexedContainer container = extractContainer(getQualifierMethodCall(call), mapper); - if (container == null) return null; - return new ReplaceWithElementIterationFix(container, call.getMethodExpression().getReferenceName()); + LimitedContainer limitedContainer = extractContainer(getQualifierMethodCall(call), mapper); + if (limitedContainer == null) return null; + return new ReplaceWithElementIterationFix(limitedContainer.myContainer, call.getMethodExpression().getReferenceName()); }); } @Contract("null, _ -> null") - private static IndexedContainer extractContainer(PsiMethodCallExpression qualifierCall, PsiExpression mapper) { + private static LimitedContainer extractContainer(PsiMethodCallExpression qualifierCall, PsiExpression mapper) { if (!INT_STREAM_RANGE.test(qualifierCall)) return null; PsiExpression[] rangeArgs = qualifierCall.getArgumentList().getExpressions(); if (!ExpressionUtils.isZero(rangeArgs[0])) return null; - PsiExpression bound = rangeArgs[1]; + PsiExpression bound = ExpressionUtils.resolveExpression(rangeArgs[1]); IndexedContainer container = IndexedContainer.fromLengthExpression(bound); - if (container == null || !StreamApiUtil.isSupportedStreamElement(container.getElementType())) return null; + PsiExpression limit = null; + if (container == null) { + if(bound instanceof PsiMethodCallExpression && MIN_INT.test((PsiMethodCallExpression)bound)) { + PsiExpression[] args = ((PsiMethodCallExpression)bound).getArgumentList().getExpressions(); + container = IndexedContainer.fromLengthExpression(args[0]); + if(container != null) { + limit = args[1]; + } else { + container = IndexedContainer.fromLengthExpression(args[1]); + if(container != null) { + limit = args[0]; + } + } + } + if(container == null) return null; + } + if (!StreamApiUtil.isSupportedStreamElement(container.getElementType())) return null; + LimitedContainer limitedContainer = new LimitedContainer(container, limit); if (mapper instanceof PsiMethodReferenceExpression && container.isGetMethodReference((PsiMethodReferenceExpression)mapper)) { - return container; + return limitedContainer; } if (mapper instanceof PsiLambdaExpression) { PsiLambdaExpression lambda = (PsiLambdaExpression)mapper; @@ -1001,12 +1027,23 @@ public class SimplifyStreamApiCallChainsInspection extends BaseJavaBatchLocalIns if (body == null) return null; Collection refs = ReferencesSearch.search(indexParameter, new LocalSearchScope(body)).findAll(); if (!refs.isEmpty() && - refs.stream().allMatch(ref -> container.extractGetExpressionFromIndex(tryCast(ref, PsiExpression.class)) != null)) { - return container; + refs.stream() + .allMatch(ref -> limitedContainer.myContainer.extractGetExpressionFromIndex(tryCast(ref, PsiExpression.class)) != null)) { + return limitedContainer; } } return null; } + + static class LimitedContainer { + @NotNull final IndexedContainer myContainer; + @Nullable final PsiExpression myLimit; + + LimitedContainer(@NotNull IndexedContainer container, @Nullable PsiExpression limit) { + myContainer = container; + myLimit = limit; + } + } } private static class RemoveBooleanIdentityFix implements CallChainSimplification { diff --git a/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavadocHtmlLintAnnotator.kt b/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavadocHtmlLintAnnotator.kt index 8c534ddaef10..ba5c2402d4a4 100644 --- a/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavadocHtmlLintAnnotator.kt +++ b/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavadocHtmlLintAnnotator.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -46,9 +46,7 @@ import com.intellij.psi.util.PsiTreeUtil import com.sun.tools.doclint.DocLint import java.io.File -class JavadocHtmlLintAnnotator() : - ExternalAnnotator() { - +class JavadocHtmlLintAnnotator : ExternalAnnotator() { data class Info(val file: PsiFile) data class Anno(val row: Int, val col: Int, val error: Boolean, val message: String) data class Result(val annotations: List) diff --git a/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavadocHtmlLintInspection.kt b/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavadocHtmlLintInspection.kt index a174ec94b592..c722bde3d2d8 100644 --- a/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavadocHtmlLintInspection.kt +++ b/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavadocHtmlLintInspection.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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,5 +25,5 @@ class JavadocHtmlLintInspection : LocalInspectionTool(), ExternalAnnotatorBatchI val SHORT_NAME = "JavadocHtmlLint" } - override fun getBatchSuppressActions(element: PsiElement?) = SuppressQuickFix.EMPTY_ARRAY + override fun getBatchSuppressActions(element: PsiElement?): Array = SuppressQuickFix.EMPTY_ARRAY } \ No newline at end of file diff --git a/java/java-impl/src/com/intellij/codeInspection/magicConstant/MagicConstantInspection.java b/java/java-impl/src/com/intellij/codeInspection/magicConstant/MagicConstantInspection.java index 07e430afcb76..0a666ff45051 100644 --- a/java/java-impl/src/com/intellij/codeInspection/magicConstant/MagicConstantInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/magicConstant/MagicConstantInspection.java @@ -45,6 +45,8 @@ import com.intellij.psi.search.LocalSearchScope; import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.*; import com.intellij.slicer.*; +import com.intellij.util.ArrayUtil; +import com.intellij.util.IncorrectOperationException; import com.intellij.util.Processor; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.indexing.FileBasedIndex; @@ -325,42 +327,60 @@ public class MagicConstantInspection extends BaseJavaLocalInspectionTool { private static AllowedValues getAllowedValuesFromMagic(@NotNull PsiType type, @NotNull PsiAnnotation magic, @NotNull PsiManager manager) { - PsiAnnotationMemberValue[] allowedValues; - final boolean canBeOred; + PsiAnnotationMemberValue[] allowedValues = PsiAnnotationMemberValue.EMPTY_ARRAY; + boolean values = false, flags = false; if (TypeConversionUtil.getTypeRank(type) <= TypeConversionUtil.LONG_RANK) { PsiAnnotationMemberValue intValues = magic.findAttributeValue("intValues"); - allowedValues = intValues instanceof PsiArrayInitializerMemberValue ? ((PsiArrayInitializerMemberValue)intValues).getInitializers() : PsiAnnotationMemberValue.EMPTY_ARRAY; - if (allowedValues.length == 0) { - PsiAnnotationMemberValue orValue = magic.findAttributeValue("flags"); - allowedValues = orValue instanceof PsiArrayInitializerMemberValue ? ((PsiArrayInitializerMemberValue)orValue).getInitializers() : PsiAnnotationMemberValue.EMPTY_ARRAY; - canBeOred = true; + if (intValues instanceof PsiArrayInitializerMemberValue) { + final PsiAnnotationMemberValue[] initializers = ((PsiArrayInitializerMemberValue)intValues).getInitializers(); + if (initializers.length != 0) { + allowedValues = initializers; + values = true; + } } - else { - canBeOred = false; + if (!values) { + PsiAnnotationMemberValue orValue = magic.findAttributeValue("flags"); + if (orValue instanceof PsiArrayInitializerMemberValue) { + final PsiAnnotationMemberValue[] initializers = ((PsiArrayInitializerMemberValue)orValue).getInitializers(); + if (initializers.length != 0) { + allowedValues = initializers; + flags = true; + } + } } } else if (type.equals(PsiType.getJavaLangString(manager, GlobalSearchScope.allScope(manager.getProject())))) { PsiAnnotationMemberValue strValuesAttr = magic.findAttributeValue("stringValues"); - allowedValues = strValuesAttr instanceof PsiArrayInitializerMemberValue ? ((PsiArrayInitializerMemberValue)strValuesAttr).getInitializers() : PsiAnnotationMemberValue.EMPTY_ARRAY; - canBeOred = false; + if (strValuesAttr instanceof PsiArrayInitializerMemberValue) { + final PsiAnnotationMemberValue[] initializers = ((PsiArrayInitializerMemberValue)strValuesAttr).getInitializers(); + if (initializers.length != 0) { + allowedValues = initializers; + values = true; + } + } } else { return null; //other types not supported } - if (allowedValues.length != 0) { - return new AllowedValues(allowedValues, canBeOred); + PsiAnnotationMemberValue[] valuesFromClass = readFromClass("valuesFromClass", magic, type, manager); + if (valuesFromClass != null) { + allowedValues = ArrayUtil.mergeArrays(allowedValues, valuesFromClass, PsiAnnotationMemberValue.ARRAY_FACTORY); + values = true; } - - // last resort: try valuesFromClass - PsiAnnotationMemberValue[] values = readFromClass("valuesFromClass", magic, type, manager); - boolean ored = false; - if (values == null) { - values = readFromClass("flagsFromClass", magic, type, manager); - ored = true; + PsiAnnotationMemberValue[] flagsFromClass = readFromClass("flagsFromClass", magic, type, manager); + if (flagsFromClass != null) { + allowedValues = ArrayUtil.mergeArrays(allowedValues, flagsFromClass, PsiAnnotationMemberValue.ARRAY_FACTORY); + flags = true; } - if (values == null) return null; - return new AllowedValues(values, ored); + if (allowedValues.length == 0) { + return null; + } + if (values && flags) { + throw new IncorrectOperationException( + "Misconfiguration of @MagicConstant annotation: 'flags' and 'values' shouldn't be used at the same time"); + } + return new AllowedValues(allowedValues, flags); } private static PsiAnnotationMemberValue[] readFromClass(@NonNls @NotNull String attributeName, diff --git a/java/java-impl/src/com/intellij/codeInspection/streamMigration/CollectMigration.java b/java/java-impl/src/com/intellij/codeInspection/streamMigration/CollectMigration.java index 0b137baf7981..e50668d03df5 100644 --- a/java/java-impl/src/com/intellij/codeInspection/streamMigration/CollectMigration.java +++ b/java/java-impl/src/com/intellij/codeInspection/streamMigration/CollectMigration.java @@ -106,7 +106,8 @@ class CollectMigration extends BaseStreamApiMigration { return initializerClass != null && varClass != null && CommonClassNames.JAVA_UTIL_HASH_MAP.equals(initializerClass.getQualifiedName()) && - CommonClassNames.JAVA_UTIL_MAP.equals(varClass.getQualifiedName()); + CommonClassNames.JAVA_UTIL_MAP.equals(varClass.getQualifiedName()) && + !ConstructionUtils.isCustomizedEmptyCollectionInitializer(initializer); } @Nullable @@ -315,13 +316,14 @@ class CollectMigration extends BaseStreamApiMigration { PsiClassType rawVarType = type instanceof PsiClassType ? ((PsiClassType)type).rawType() : null; if (rawType != null && rawVarType != null && rawType.equalsToText(CommonClassNames.JAVA_UTIL_ARRAY_LIST) && - (rawVarType.equalsToText(CommonClassNames.JAVA_UTIL_LIST) || rawVarType.equalsToText(CommonClassNames.JAVA_UTIL_COLLECTION))) { + (rawVarType.equalsToText(CommonClassNames.JAVA_UTIL_LIST) || rawVarType.equalsToText(CommonClassNames.JAVA_UTIL_COLLECTION)) && + !ConstructionUtils.isCustomizedEmptyCollectionInitializer(initializer)) { collector = "toList()"; } else if (rawType != null && rawVarType != null && rawType.equalsToText(CommonClassNames.JAVA_UTIL_HASH_SET) && - (rawVarType.equalsToText(CommonClassNames.JAVA_UTIL_SET) || - rawVarType.equalsToText(CommonClassNames.JAVA_UTIL_COLLECTION))) { + (rawVarType.equalsToText(CommonClassNames.JAVA_UTIL_SET) || rawVarType.equalsToText(CommonClassNames.JAVA_UTIL_COLLECTION)) && + !ConstructionUtils.isCustomizedEmptyCollectionInitializer(initializer)) { collector = "toSet()"; } else { @@ -331,7 +333,7 @@ class CollectMigration extends BaseStreamApiMigration { PsiExpressionList argumentList = ((PsiNewExpression)copy).getArgumentList(); if (argumentList != null) { PsiExpression arg = ArrayUtil.getFirstElement(argumentList.getExpressions()); - if (arg != null) { + if (arg != null && !(arg.getType() instanceof PsiPrimitiveType)) { arg.delete(); } } diff --git a/java/java-impl/src/com/intellij/jarFinder/SourceSearcher.java b/java/java-impl/src/com/intellij/jarFinder/SourceSearcher.java index 3533f1a4bb21..4279ec53191f 100644 --- a/java/java-impl/src/com/intellij/jarFinder/SourceSearcher.java +++ b/java/java-impl/src/com/intellij/jarFinder/SourceSearcher.java @@ -1,13 +1,27 @@ +/* + * Copyright 2000-2017 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.jarFinder; import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.util.JDOMUtil; -import com.intellij.openapi.util.io.StreamUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.JdomKt; import com.intellij.util.io.HttpRequests; -import org.jdom.Document; +import org.jdom.Element; import org.jdom.JDOMException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -52,14 +66,14 @@ public abstract class SourceSearcher { } @NotNull - protected static Document readDocumentCancelable(final ProgressIndicator indicator, String url) throws IOException { + protected static Element readDocumentCancelable(final ProgressIndicator indicator, String url) throws IOException { return HttpRequests.request(url) .accept("application/xml") - .connect(new HttpRequests.RequestProcessor() { + .connect(new HttpRequests.RequestProcessor() { @Override - public Document process(@NotNull HttpRequests.Request request) throws IOException { + public Element process(@NotNull HttpRequests.Request request) throws IOException { try { - return JDOMUtil.loadDocument(request.getReader(indicator)); + return JdomKt.loadElement(request.getReader(indicator)); } catch (JDOMException e) { throw new IOException(e); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaLangClassMemberReference.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaLangClassMemberReference.java index a5b849bd7e56..2e658a640d66 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaLangClassMemberReference.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaLangClassMemberReference.java @@ -18,8 +18,8 @@ package com.intellij.psi.impl.source.resolve.reference.impl; import com.intellij.codeInsight.completion.InsertHandler; import com.intellij.codeInsight.completion.InsertionContext; import com.intellij.codeInsight.completion.JavaLookupElementBuilder; +import com.intellij.codeInsight.completion.PrioritizedLookupElement; import com.intellij.codeInsight.lookup.LookupElement; -import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.psi.*; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtilCore; @@ -29,6 +29,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Arrays; +import java.util.Comparator; import static com.intellij.psi.impl.source.resolve.reference.impl.JavaReflectionReferenceUtil.*; @@ -71,7 +72,7 @@ public class JavaLangClassMemberReference extends PsiReferenceBase isRegularMethod(method) && isReachable(method, psiClass)); + return ContainerUtil.find(methods, method -> isRegularMethod(method) && isPotentiallyAccessible(method, psiClass)); } } } @@ -115,21 +116,30 @@ public class JavaLangClassMemberReference extends PsiReferenceBase lookupField(field)) + .toArray(); case FIELD: - return ContainerUtil.filter(psiClass.getAllFields(), field -> isReachable(field, psiClass)).toArray(); + return Arrays.stream(psiClass.getAllFields()) + .filter(field -> isPotentiallyAccessible(field, psiClass)) + .sorted(Comparator.comparingInt((PsiField field) -> isPublic(field) ? 0 : 1).thenComparing(PsiField::getName)) + .map(field -> withPriority(lookupField(field), isPublic(field))) + .toArray(); case DECLARED_METHOD: return Arrays.stream(psiClass.getMethods()) .filter(method -> isRegularMethod(method)) - .map(this::lookupMethod) + .sorted(Comparator.comparing(PsiMethod::getName)) + .map(method -> lookupMethod(method)) .toArray(); case METHOD: return Arrays.stream(psiClass.getAllMethods()) - .filter(method -> isRegularMethod(method) && isReachable(method, psiClass) && !isJavaLangObject(method.getContainingClass())) - .map(this::lookupMethod) + .filter(method -> isRegularMethod(method) && isPotentiallyAccessible(method, psiClass)) + .sorted(Comparator.comparingInt((PsiMethod method) -> getMethodSortOrder(method)).thenComparing(PsiMethod::getName)) + .map(method -> PrioritizedLookupElement.withPriority(lookupMethod(method), -getMethodSortOrder(method))) .toArray(); } } @@ -137,8 +147,17 @@ public class JavaLangClassMemberReference extends PsiReferenceBase DECLARED_NAMES = + ContainerUtil.immutableSet(DECLARED_CONSTRUCTOR, DECLARED_ANNOTATION, DECLARED_ANNOTATIONS_BY_TYPE); private static final ElementPattern CONSTRUCTOR_ARGUMENTS = psiElement(PsiExpressionList.class) .withParent(psiExpression().methodCall( psiMethod() - .withName("getConstructor", "getDeclaredConstructor") + .withName(CONSTRUCTOR, DECLARED_CONSTRUCTOR) .definedInClass(CommonClassNames.JAVA_LANG_CLASS))); private static final ElementPattern ANNOTATION_ARGUMENTS = psiElement(PsiExpressionList.class) .withParent(psiExpression().methodCall( psiMethod() - .withName("getAnnotation", "getDeclaredAnnotation", "getAnnotationsByType", "getDeclaredAnnotationsByType") - .with(new MethodDefinedInInterfacePatternCondition("java.lang.reflect.AnnotatedElement")))); + .withName(ANNOTATION, DECLARED_ANNOTATION, ANNOTATIONS_BY_TYPE, DECLARED_ANNOTATIONS_BY_TYPE) + .with(new MethodDefinedInInterfacePatternCondition(ANNOTATED_ELEMENT)))); private static final ElementPattern BEGINNING_OF_CONSTRUCTOR_ARGUMENTS = beginningOfArguments(CONSTRUCTOR_ARGUMENTS); @@ -79,28 +88,32 @@ public class JavaReflectionCompletionContributor extends CompletionContributor { } if (BEGINNING_OF_ANNOTATION_ARGUMENTS.accepts(position)) { - PsiClass psiClass = getQualifierClass(position); - if (psiClass != null) { - addAnnotationClasses(psiClass, result); - } + addVariants(position, (psiClass, isDeclared) -> addAnnotationClasses(psiClass, isDeclared, result)); //TODO handle annotations on fields and methods } - if (BEGINNING_OF_CONSTRUCTOR_ARGUMENTS.accepts(position)) { - PsiClass psiClass = getQualifierClass(position); + else if (BEGINNING_OF_CONSTRUCTOR_ARGUMENTS.accepts(position)) { + addVariants(position, (psiClass, isDeclared) -> addConstructorParameterTypes(psiClass, isDeclared, result)); + } + } + + private static void addVariants(PsiElement position, BiConsumer variantAdder) { + PsiMethodCallExpression methodCall = PsiTreeUtil.getParentOfType(position, PsiMethodCallExpression.class); + if (methodCall != null) { + PsiClass psiClass = getReflectiveClass(methodCall.getMethodExpression().getQualifierExpression()); if (psiClass != null) { - addConstructorParameterTypes(psiClass, result); + String methodName = methodCall.getMethodExpression().getReferenceName(); + if (methodName != null) { + variantAdder.accept(psiClass, DECLARED_NAMES.contains(methodName)); + } } } } - @Nullable - private static PsiClass getQualifierClass(@Nullable PsiElement position) { - PsiMethodCallExpression methodCall = PsiTreeUtil.getParentOfType(position, PsiMethodCallExpression.class); - return methodCall != null ? getReflectiveClass(methodCall.getMethodExpression().getQualifierExpression()) : null; - } + private static void addAnnotationClasses(@NotNull PsiClass psiClass, boolean isDeclared, @NotNull CompletionResultSet result) { + Set declaredAnnotations = + isDeclared ? ContainerUtil.set(AnnotationUtil.getAllAnnotations(psiClass, false, null, false)) : null; - private static void addAnnotationClasses(@NotNull PsiModifierListOwner annotationsOwner, @NotNull CompletionResultSet result) { - PsiAnnotation[] annotations = AnnotationUtil.getAllAnnotations(annotationsOwner, true, null); + PsiAnnotation[] annotations = AnnotationUtil.getAllAnnotations(psiClass, true, null, false); for (PsiAnnotation annotation : annotations) { PsiJavaCodeReferenceElement referenceElement = annotation.getNameReferenceElement(); if (referenceElement != null) { @@ -112,6 +125,9 @@ public class JavaReflectionCompletionContributor extends CompletionContributor { LookupElement lookupElement = LookupElementBuilder.createWithIcon(annotationClass) .withPresentableText(className + ".class") .withInsertHandler(JavaReflectionCompletionContributor::handleAnnotationClassInsertion); + if (isDeclared) { + lookupElement = withPriority(lookupElement, declaredAnnotations.contains(annotation)); + } result.addElement(lookupElement); } } @@ -119,26 +135,22 @@ public class JavaReflectionCompletionContributor extends CompletionContributor { } } - private static void addConstructorParameterTypes(@NotNull PsiClass psiClass, @NotNull CompletionResultSet result) { + private static void addConstructorParameterTypes(@NotNull PsiClass psiClass, boolean isDeclared, @NotNull CompletionResultSet result) { PsiMethod[] constructors = psiClass.getConstructors(); - if (constructors.length != 0) { - for (PsiMethod constructor : constructors) { - String parameterTypesText = Arrays.stream(constructor.getParameterList().getParameters()) - .map(p -> p.getType().getCanonicalText()) - .collect(Collectors.joining(",", constructor.getName() + "(", ")")); - - LookupElement lookupElement = LookupElementBuilder.createWithIcon(constructor) - .withPresentableText(parameterTypesText) - .withInsertHandler(JavaReflectionCompletionContributor::handleConstructorSignatureInsertion); - result.addElement(lookupElement); + for (PsiMethod constructor : constructors) { + LookupElement lookupElement = JavaLookupElementBuilder.forMethod(constructor, PsiSubstitutor.EMPTY) + .withInsertHandler(JavaReflectionCompletionContributor::handleConstructorSignatureInsertion); + if (isDeclared) { + lookupElement = withPriority(lookupElement, isPublic(constructor)); } + result.addElement(lookupElement); } } private static void handleAnnotationClassInsertion(@NotNull InsertionContext context, @NotNull LookupElement item) { Object object = item.getObject(); if (object instanceof PsiClass) { - String className = ((PsiClass)object).getName(); + String className = ((PsiClass)object).getQualifiedName(); if (className != null) { handleParametersInsertion(context, className + ".class"); } diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionReferenceUtil.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionReferenceUtil.java index 3860543111a7..682145fdd0c2 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionReferenceUtil.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionReferenceUtil.java @@ -16,6 +16,8 @@ package com.intellij.psi.impl.source.resolve.reference.impl; import com.intellij.codeInsight.completion.InsertionContext; +import com.intellij.codeInsight.completion.PrioritizedLookupElement; +import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.RecursionGuard; import com.intellij.openapi.util.RecursionManager; @@ -151,7 +153,7 @@ class JavaReflectionReferenceUtil { * Non-public members of superclass/superinterface can't be obtained via reflection, they need to be filtered out. */ @Contract("null, _ -> false") - static boolean isReachable(PsiMember member, PsiClass psiClass) { + static boolean isPotentiallyAccessible(PsiMember member, PsiClass psiClass) { return member != null && (member.getContainingClass() == psiClass || isPublic(member)); } @@ -175,4 +177,9 @@ class JavaReflectionReferenceUtil { JavaCodeStyleManager.getInstance(context.getProject()).shortenClassReferences(methodCall.getArgumentList()); } } + + @NotNull + static LookupElement withPriority(LookupElement lookupElement, boolean hasPriority) { + return PrioritizedLookupElement.withPriority(lookupElement, hasPriority ? 1 : -1); + } } diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java b/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java index 7b3ddd164e56..a1fafd56f62a 100644 --- a/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java +++ b/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java @@ -62,10 +62,9 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor { ProgressManager.checkCanceled(); if (psiClass.isInterface()) { @@ -76,13 +75,17 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor parameters.getScope().intersectWith(info.getDirtyScope())); + useScope = ReadAction.compute(() -> baseClass.getUseScope().intersectWith(info.getDirtyScope())); } PsiClass[] cache = getOrCalculateDirectSubClasses(project, baseClass, useScope); diff --git a/java/java-psi-api/src/com/intellij/psi/PsiModifier.java b/java/java-psi-api/src/com/intellij/psi/PsiModifier.java index e442927406f1..629d35d116c6 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiModifier.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiModifier.java @@ -35,13 +35,14 @@ public interface PsiModifier { String VOLATILE = "volatile"; String DEFAULT = "default"; String OPEN = "open"; + String TRANSITIVE = "transitive"; String[] MODIFIERS = { - PUBLIC, PROTECTED, PRIVATE, STATIC, ABSTRACT, FINAL, NATIVE, SYNCHRONIZED, STRICTFP, TRANSIENT, VOLATILE, DEFAULT, OPEN + PUBLIC, PROTECTED, PRIVATE, STATIC, ABSTRACT, FINAL, NATIVE, SYNCHRONIZED, STRICTFP, TRANSIENT, VOLATILE, DEFAULT, OPEN, TRANSITIVE }; @MagicConstant(stringValues = { - PUBLIC, PROTECTED, PRIVATE, STATIC, ABSTRACT, FINAL, NATIVE, SYNCHRONIZED, STRICTFP, TRANSIENT, VOLATILE, DEFAULT, OPEN, PACKAGE_LOCAL + PUBLIC, PROTECTED, PRIVATE, STATIC, ABSTRACT, FINAL, NATIVE, SYNCHRONIZED, STRICTFP, TRANSIENT, VOLATILE, DEFAULT, OPEN, TRANSITIVE, PACKAGE_LOCAL }) @interface ModifierConstant { } } \ No newline at end of file diff --git a/java/java-psi-api/src/com/intellij/psi/PsiRequiresStatement.java b/java/java-psi-api/src/com/intellij/psi/PsiRequiresStatement.java index 41b703090e24..d58edc61ad70 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiRequiresStatement.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiRequiresStatement.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -22,7 +22,7 @@ import org.jetbrains.annotations.Nullable; * * @since 2016.3 */ -public interface PsiRequiresStatement extends PsiElement { +public interface PsiRequiresStatement extends PsiModifierListOwner { PsiRequiresStatement[] EMPTY_ARRAY = new PsiRequiresStatement[0]; @Nullable PsiJavaModuleReferenceElement getReferenceElement(); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/cache/ModifierFlags.java b/java/java-psi-impl/src/com/intellij/psi/impl/cache/ModifierFlags.java index 159f4aa17424..2c225b41c2a6 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/cache/ModifierFlags.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/cache/ModifierFlags.java @@ -42,6 +42,7 @@ public final class ModifierFlags { public static final int STRICTFP_MASK = 0x0800; public static final int PACKAGE_LOCAL_MASK = 0x1000; public static final int OPEN_MASK = 0x2000; + public static final int TRANSITIVE_MASK = 0x4000; public static final TObjectIntHashMap NAME_TO_MODIFIER_FLAG_MAP = new TObjectIntHashMap(); public static final TIntObjectHashMap MODIFIER_FLAG_TO_NAME_MAP = new TIntObjectHashMap(); @@ -61,6 +62,7 @@ public final class ModifierFlags { NAME_TO_MODIFIER_FLAG_MAP.put(PsiModifier.STRICTFP, STRICTFP_MASK); NAME_TO_MODIFIER_FLAG_MAP.put(PsiModifier.PACKAGE_LOCAL, PACKAGE_LOCAL_MASK); NAME_TO_MODIFIER_FLAG_MAP.put(PsiModifier.OPEN, OPEN_MASK); + NAME_TO_MODIFIER_FLAG_MAP.put(PsiModifier.TRANSITIVE, TRANSITIVE_MASK); for (Object name : NAME_TO_MODIFIER_FLAG_MAP.keys()) { MODIFIER_FLAG_TO_NAME_MAP.put(NAME_TO_MODIFIER_FLAG_MAP.get((String)name), (String)name); @@ -79,6 +81,7 @@ public final class ModifierFlags { KEYWORD_TO_MODIFIER_FLAG_MAP.put(JavaTokenType.ABSTRACT_KEYWORD, ABSTRACT_MASK); KEYWORD_TO_MODIFIER_FLAG_MAP.put(JavaTokenType.STRICTFP_KEYWORD, STRICTFP_MASK); KEYWORD_TO_MODIFIER_FLAG_MAP.put(JavaTokenType.OPEN_KEYWORD, OPEN_MASK); + KEYWORD_TO_MODIFIER_FLAG_MAP.put(JavaTokenType.TRANSITIVE_KEYWORD, TRANSITIVE_MASK); } public static boolean hasModifierProperty(String name, int mask) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsJavaModuleImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsJavaModuleImpl.java index 3971d929bfbe..cd521cf28ab2 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsJavaModuleImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsJavaModuleImpl.java @@ -34,6 +34,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Collections; import static com.intellij.util.containers.ContainerUtil.newArrayList; +import static java.util.Arrays.asList; public class ClsJavaModuleImpl extends ClsRepositoryPsiElement implements PsiJavaModule { private PsiJavaModuleReferenceElement myReference; @@ -93,16 +94,16 @@ public class ClsJavaModuleImpl extends ClsRepositoryPsiElement implements PsiModifierList { - public ClsModifierListImpl(final PsiModifierListStub stub) { + public ClsModifierListImpl(PsiModifierListStub stub) { super(stub); } @@ -78,29 +76,29 @@ public class ClsModifierListImpl extends ClsRepositoryPsiElementtreeToPsiNotNull(element).getModifierList()); + } + + @Override + public PsiModifierList getModifierList() { + StubElement childStub = getStub().findChildStubByType(JavaStubElementTypes.MODIFIER_LIST); + return childStub != null ? childStub.getPsi() : null; + } + + @Override + public boolean hasModifierProperty(@NotNull String name) { + PsiModifierList modifierList = getModifierList(); + return modifierList != null && modifierList.hasModifierProperty(name); } @Override diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/ClsStubPsiFactory.java b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/ClsStubPsiFactory.java index 7d2c736428c2..2849838d4ad1 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/ClsStubPsiFactory.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/ClsStubPsiFactory.java @@ -18,7 +18,7 @@ package com.intellij.psi.impl.java.stubs; import com.intellij.psi.*; import com.intellij.psi.impl.compiled.*; -/* +/** * @author max */ public class ClsStubPsiFactory extends StubPsiFactory { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/SourceStubPsiFactory.java b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/SourceStubPsiFactory.java index dc3c480170f6..752087caa7d6 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/SourceStubPsiFactory.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/SourceStubPsiFactory.java @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * @author max - */ package com.intellij.psi.impl.java.stubs; import com.intellij.psi.*; import com.intellij.psi.impl.source.*; import com.intellij.psi.impl.source.tree.java.*; +/** + * @author max + */ public class SourceStubPsiFactory extends StubPsiFactory { public static final SourceStubPsiFactory INSTANCE = new SourceStubPsiFactory(); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/StubPsiFactory.java b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/StubPsiFactory.java index a3349489d50f..92636ddb4cb7 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/StubPsiFactory.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/StubPsiFactory.java @@ -17,7 +17,7 @@ package com.intellij.psi.impl.java.stubs; import com.intellij.psi.*; -/* +/** * @author max */ public abstract class StubPsiFactory { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiModifierListImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiModifierListImpl.java index e819008d0010..e7da8743175e 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiModifierListImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiModifierListImpl.java @@ -61,6 +61,7 @@ public class PsiModifierListImpl extends JavaStubPsiElement NAME_TO_KEYWORD_TYPE_MAP.put(VOLATILE, JavaTokenType.VOLATILE_KEYWORD); NAME_TO_KEYWORD_TYPE_MAP.put(DEFAULT, JavaTokenType.DEFAULT_KEYWORD); NAME_TO_KEYWORD_TYPE_MAP.put(OPEN, JavaTokenType.OPEN_KEYWORD); + NAME_TO_KEYWORD_TYPE_MAP.put(TRANSITIVE, JavaTokenType.TRANSITIVE_KEYWORD); KEYWORD_TYPE_TO_NAME_MAP = ContainerUtil.newTroveMap(); for (String name : NAME_TO_KEYWORD_TYPE_MAP.keySet()) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiRequiresStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiRequiresStatementImpl.java index 5e4f6c4c9780..0a1d04aac566 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiRequiresStatementImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiRequiresStatementImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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,6 +67,17 @@ public class PsiRequiresStatementImpl extends JavaStubPsiElement"); + } +} + +class Test { + public Test() {} + Test(int n) {} + public void method(){} + public void method2(A a, B b){} + void method1(){} +} + +class A {} +class B {} +class C {} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflection/HasConstructor_after.java b/java/java-tests/testData/codeInsight/completion/reflection/HasConstructor_after.java new file mode 100644 index 000000000000..63ab44953f48 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflection/HasConstructor_after.java @@ -0,0 +1,17 @@ +class HasConstructor { + void foo() { + Test.class.getMethod("method1"); + } +} + +class Test { + public Test() {} + Test(int n) {} + public void method(){} + public void method2(A a, B b){} + void method1(){} +} + +class A {} +class B {} +class C {} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectMethods.java b/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectMethods.java new file mode 100644 index 000000000000..4c73e541bb03 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectMethods.java @@ -0,0 +1,9 @@ +class Main { + void foo() { + Test.class.getMethod(""); + } +} + +class Test { + public void method(){} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectMethods_after.java b/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectMethods_after.java new file mode 100644 index 000000000000..fe138e3d1018 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectMethods_after.java @@ -0,0 +1,9 @@ +class Main { + void foo() { + Test.class.getMethod("notifyAll"); + } +} + +class Test { + public void method(){} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectOwnMethods.java b/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectOwnMethods.java new file mode 100644 index 000000000000..7fde3dd7de4e --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectOwnMethods.java @@ -0,0 +1,5 @@ +class Main { + void foo() { + Object.class.getMethod(""); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectOwnMethods_after.java b/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectOwnMethods_after.java new file mode 100644 index 000000000000..50cb8701f7a1 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectOwnMethods_after.java @@ -0,0 +1,5 @@ +class Main { + void foo() { + Object.class.getMethod("wait", long.class); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionOverload/OverloadMethods.java b/java/java-tests/testData/codeInsight/completion/reflectionOverload/OverloadMethods.java new file mode 100644 index 000000000000..5af0ceb54e60 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionOverload/OverloadMethods.java @@ -0,0 +1,17 @@ +class Main { + void foo() { + Test.class.getMethod(""); + } +} + +class Test { + public Test() {} + Test(int n) {} + public void method(){} + void method(A a, B b){} + public void method(C c){} +} + +class A {} +class B {} +class C {} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionOverload/OverloadMethods_after.java b/java/java-tests/testData/codeInsight/completion/reflectionOverload/OverloadMethods_after.java new file mode 100644 index 000000000000..11aec53c2962 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionOverload/OverloadMethods_after.java @@ -0,0 +1,17 @@ +class Main { + void foo() { + Test.class.getMethod("method", A.class, B.class); + } +} + +class Test { + public Test() {} + Test(int n) {} + public void method(){} + void method(A a, B b){} + public void method(C c){} +} + +class A {} +class B {} +class C {} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/Annotation.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Annotation.java index fa54541138af..22d4427b7860 100644 --- a/java/java-tests/testData/codeInsight/completion/reflectionParameters/Annotation.java +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Annotation.java @@ -1,7 +1,6 @@ import foo.bar.*; class Main { void foo() throws ReflectiveOperationException { - Class aType = Baz.class; Test.class.getAnnotation(); } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/Annotation_after.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Annotation_after.java index b18777005dcd..11d8436d32cd 100644 --- a/java/java-tests/testData/codeInsight/completion/reflectionParameters/Annotation_after.java +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Annotation_after.java @@ -1,7 +1,6 @@ import foo.bar.*; class Main { void foo() throws ReflectiveOperationException { - Class aType = Baz.class; Test.class.getAnnotation(Bar.class); } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/DeclaredAnnotation_after.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/DeclaredAnnotation_after.java index 441e07f2117d..9b1e0e8aa8e5 100644 --- a/java/java-tests/testData/codeInsight/completion/reflectionParameters/DeclaredAnnotation_after.java +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/DeclaredAnnotation_after.java @@ -1,6 +1,6 @@ import foo.bar.*; class Main { void foo() throws ReflectiveOperationException { - Test.class.getDeclaredAnnotation(Bar.class); + Test.class.getDeclaredAnnotation(Foo.class); } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/Imports.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Imports.java new file mode 100644 index 000000000000..20a7645c15ba --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Imports.java @@ -0,0 +1,6 @@ +import foo.bar.*; +class Main { + void foo() throws ReflectiveOperationException { + More.class.getAnnotation(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/Imports_after.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Imports_after.java new file mode 100644 index 000000000000..33ede903277a --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Imports_after.java @@ -0,0 +1,8 @@ +import foo.bar.*; +import foo.baz.Baz; + +class Main { + void foo() throws ReflectiveOperationException { + More.class.getAnnotation(Baz.class); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedAnnotation.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedAnnotation.java index fa54541138af..22d4427b7860 100644 --- a/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedAnnotation.java +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedAnnotation.java @@ -1,7 +1,6 @@ import foo.bar.*; class Main { void foo() throws ReflectiveOperationException { - Class aType = Baz.class; Test.class.getAnnotation(); } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedAnnotation_after.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedAnnotation_after.java index 02cdb98460a2..e2f62c2634b1 100644 --- a/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedAnnotation_after.java +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedAnnotation_after.java @@ -1,7 +1,6 @@ import foo.bar.*; class Main { void foo() throws ReflectiveOperationException { - Class aType = Baz.class; Test.class.getAnnotation(Foo.class); } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedDeclaredAnnotation_after.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedDeclaredAnnotation_after.java index 9b1e0e8aa8e5..441e07f2117d 100644 --- a/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedDeclaredAnnotation_after.java +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedDeclaredAnnotation_after.java @@ -1,6 +1,6 @@ import foo.bar.*; class Main { void foo() throws ReflectiveOperationException { - Test.class.getDeclaredAnnotation(Foo.class); + Test.class.getDeclaredAnnotation(Bar.class); } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/Variable.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Variable.java new file mode 100644 index 000000000000..b85dc5238482 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Variable.java @@ -0,0 +1,8 @@ +import foo.bar.*; +import foo.baz.Baz; +class Main { + void foo() throws ReflectiveOperationException { + Class aType = Baz.class; + Test.class.getAnnotation(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/Variable_after.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Variable_after.java new file mode 100644 index 000000000000..fdd7410ec6ad --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Variable_after.java @@ -0,0 +1,8 @@ +import foo.bar.*; +import foo.baz.Baz; +class Main { + void foo() throws ReflectiveOperationException { + Class aType = Baz.class; + Test.class.getAnnotation(aType); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterCollectCustomConstructor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterCollectCustomConstructor.java new file mode 100644 index 000000000000..ac0b5bcf3f96 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterCollectCustomConstructor.java @@ -0,0 +1,52 @@ +// "Fix all 'Loop can be collapsed with Stream API' problems in file" "true" + +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +public class Test { + void testList(List input) { + List result = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toCollection(() -> new ArrayList<>(10))); + System.out.println(result); + + ArrayList result2 = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toCollection(() -> new ArrayList<>(20))); + System.out.println(result2); + + // Non-empty + ArrayList result3 = new ArrayList<>(input); + input.stream().filter(s -> !s.isEmpty()).forEach(result3::add); + System.out.println(result3); + } + + void testSet(List input) { + Set result = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toCollection(() -> new HashSet<>(10))); + System.out.println(result); + + Collection result2 = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toCollection(() -> new LinkedHashSet<>(20, 0.8f))); + System.out.println(result2); + + // Non-empty + AbstractSet result3 = new HashSet<>(input); + input.stream().filter(s -> !s.isEmpty()).forEach(result3::add); + System.out.println(result3); + + Collection result4 = input.stream().filter(s -> !s.isEmpty()).map(TimeUnit::valueOf).collect(Collectors.toCollection(() -> EnumSet.noneOf(TimeUnit.class))); + System.out.println(result4); + } + + void testMap(List input) { + Map result = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toMap(String::length, s -> s, (a, b) -> b, () -> new HashMap<>(10))); + System.out.println(result); + + Map result2 = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toMap(String::length, s -> s, (a, b) -> b, () -> new HashMap<>(10, 0.8f))); + System.out.println(result2); + + EnumMap result3 = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toMap(TimeUnit::valueOf, s -> s, (a, b) -> b, () -> new EnumMap<>(TimeUnit.class))); + System.out.println(result3); + + // Non-empty + EnumMap result4 = new EnumMap<>(result3); + input.stream().filter(s -> !s.isEmpty()).forEach(s -> result4.put(TimeUnit.valueOf(s), s)); + System.out.println(result4); + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterRangeLimited.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterRangeLimited.java new file mode 100644 index 000000000000..7509256ce897 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterRangeLimited.java @@ -0,0 +1,14 @@ +// "Replace with collect" "true" + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class Test { + public List test(String[] data) { + int top = Math.min(10, data.length); + List result = Arrays.stream(data).limit(10).map(String::trim).filter(item -> !item.isEmpty()).collect(Collectors.toList()); + return result; + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeCollectCustomConstructor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeCollectCustomConstructor.java new file mode 100644 index 000000000000..503747e9d353 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeCollectCustomConstructor.java @@ -0,0 +1,103 @@ +// "Fix all 'Loop can be collapsed with Stream API' problems in file" "true" + +import java.util.*; +import java.util.concurrent.TimeUnit; + +public class Test { + void testList(List input) { + List result = new ArrayList<>(10); + for (String s : input) { + if (!s.isEmpty()) { + result.add(s); + } + } + System.out.println(result); + + ArrayList result2 = new ArrayList<>(20); + for (String s : input) { + if (!s.isEmpty()) { + result2.add(s); + } + } + System.out.println(result2); + + // Non-empty + ArrayList result3 = new ArrayList<>(input); + for (String s : input) { + if (!s.isEmpty()) { + result3.add(s); + } + } + System.out.println(result3); + } + + void testSet(List input) { + Set result = new HashSet<>(10); + for (String s : input) { + if (!s.isEmpty()) { + result.add(s); + } + } + System.out.println(result); + + Collection result2 = new LinkedHashSet<>(20, 0.8f); + for (String s : input) { + if (!s.isEmpty()) { + result2.add(s); + } + } + System.out.println(result2); + + // Non-empty + AbstractSet result3 = new HashSet<>(input); + for (String s : input) { + if (!s.isEmpty()) { + result3.add(s); + } + } + System.out.println(result3); + + Collection result4 = EnumSet.noneOf(TimeUnit.class); + for (String s : input) { + if (!s.isEmpty()) { + result4.add(TimeUnit.valueOf(s)); + } + } + System.out.println(result4); + } + + void testMap(List input) { + Map result = new HashMap<>(10); + for (String s : input) { + if (!s.isEmpty()) { + result.put(s.length(), s); + } + } + System.out.println(result); + + Map result2 = new HashMap<>(10, 0.8f); + for (String s : input) { + if (!s.isEmpty()) { + result2.put(s.length(), s); + } + } + System.out.println(result2); + + EnumMap result3 = new EnumMap<>(TimeUnit.class); + for (String s : input) { + if (!s.isEmpty()) { + result3.put(TimeUnit.valueOf(s), s); + } + } + System.out.println(result3); + + // Non-empty + EnumMap result4 = new EnumMap<>(result3); + for (String s : input) { + if (!s.isEmpty()) { + result4.put(TimeUnit.valueOf(s), s); + } + } + System.out.println(result4); + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeRangeLimited.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeRangeLimited.java new file mode 100644 index 000000000000..d1676c8ef6ef --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeRangeLimited.java @@ -0,0 +1,18 @@ +// "Replace with collect" "true" + +import java.util.ArrayList; +import java.util.List; + +public class Test { + public List test(String[] data) { + int top = Math.min(10, data.length); + List result = new ArrayList<>(); + for(int i=0; i + + + X.java + 31 + magic constant + Should be one of: Const1.X, Const2.I + + + X.java + 32 + magic constant + Should be one of: Const1.X, Const2.I + + + X.java + 33 + magic constant + Should be one of: Const1.X, Const2.I + + + + X.java + 44 + magic constant + Should be one of: Const2.I, Const1.X + + + X.java + 45 + magic constant + Should be one of: Const2.I, Const1.X + + + X.java + 46 + magic constant + Should be one of: Const2.I, Const1.X + + + + X.java + 57 + magic constant + Should be one of: Const1.X, Const2.I or their combination + + + X.java + 58 + magic constant + Should be one of: Const1.X, Const2.I or their combination + + + X.java + 59 + magic constant + Should be one of: Const1.X, Const2.I + + + X.java + 61 + magic constant + Should be one of: Const1.X, Const2.I or their combination + + + + X.java + 72 + magic constant + Should be one of: Const2.I, Const1.X or their combination + + + X.java + 73 + magic constant + Should be one of: Const2.I, Const1.X or their combination + + + diff --git a/java/java-tests/testData/inspection/magic/manyConstantSources/src/X.java b/java/java-tests/testData/inspection/magic/manyConstantSources/src/X.java new file mode 100644 index 000000000000..950683a5e24d --- /dev/null +++ b/java/java-tests/testData/inspection/magic/manyConstantSources/src/X.java @@ -0,0 +1,82 @@ +/* + * Copyright 2000-2011 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. + */ + +import org.intellij.lang.annotations.MagicConstant; + +class Const1 { + public static final int X = 1; +} + +class Const2 { + public static final int I = 4; +} + +public class X { + + void f(@MagicConstant(intValues = {Const1.X, Const2.I}) int x) { + /////////// BAD + f(0); + f(1); + f(Const1.X | Const2.I); + + ////////////// GOOD + f(Const1.X); + f(Const2.I); + + f2(x); + } + + void f2(@MagicConstant(valuesFromClass = Const1.class, intValues = {Const2.I}) int x) { + /////////// BAD + f2(0); + f2(1); + f2(Const1.X | Const2.I); + + ////////////// GOOD + f2(Const1.X); + f2(Const2.I); + + f(x); + } + + void f3(@MagicConstant(flags = {Const1.X, Const2.I}) int x) { + /////////// BAD + f3(2); + f3(1); + f(Const1.X | Const2.I); + int i = Const1.X | 4; + f3(i); + + ////////////// GOOD + f3(Const1.X); + f3(Const2.I); + + f4(x); + } + + void f4(@MagicConstant(flagsFromClass = Const1.class, flags = {Const2.I}) int x) { + /////////// BAD + f4(-3); + f4(1); + + ////////////// GOOD + f4(Const1.X); + f4(Const2.I); + f4(Const1.X | Const2.I); + + f3(x); + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionOverloadTest.kt b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionOverloadTest.kt new file mode 100644 index 000000000000..f1084f2ed35b --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionOverloadTest.kt @@ -0,0 +1,53 @@ +/* + * Copyright 2000-2017 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.codeInsight.completion + +import com.intellij.JavaTestUtil + +/** + * @author Pavel.Dolgov + */ +class JavaReflectionCompletionOverloadTest : LightFixtureCompletionTestCase() { + + override fun getBasePath() = JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/completion/reflectionOverload/" + + fun testOverloadMethods() = doTest(2, "method()", "method(C c)", "method(A a,B b)") + + fun testJavaLangObjectMethods() = doTest(6, + "method()", + "equals(java.lang.Object obj)", "hashCode()", "toString()", + "getClass()", "notify()", "notifyAll()", + "wait()", "wait(long timeout)", "wait(long timeout,int nanos)" + ) + + fun testJavaLangObjectOwnMethods() = doTest(9, + "clone()", "equals(java.lang.Object obj)", "hashCode()", + "toString()", "finalize()", "getClass()", + "notify()", "notifyAll()", + "wait()", "wait(long timeout)", "wait(long timeout,int nanos)", + "registerNatives()") + + + private fun doTest(index: Int, vararg expected: String) { + configureByFile(getTestName(false) + ".java") + + val lookupItems = lookup.items + val texts = lookupItemTexts(lookupItems, expected.size) + assertOrderedEquals(texts, *expected) + if (index >= 0) selectItem(lookupItems[index]) + myFixture.checkResultByFile(getTestName(false) + "_after.java") + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionTest.java index c9fe7b8c6c2b..1695dc736f28 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionTest.java @@ -34,15 +34,15 @@ public class JavaReflectionCompletionTest extends LightFixtureCompletionTestCase } public void testDeclaredField() throws Exception { - doTest(1, "num", "num2", "num3"); + doTest(2, "num", "num1", "num2"); } public void testDeclaredMethod() throws Exception { - doTest(1, "method", "method2", "method3"); + doTest(2, "method", "method1", "method2"); } public void testDeclaredMethod2() throws Exception { - doTest(2, "method", "method2", "method3"); + doTest(1, "method", "method1", "method2"); } public void testMethod() throws Exception { @@ -50,7 +50,7 @@ public class JavaReflectionCompletionTest extends LightFixtureCompletionTestCase } public void testForNameDeclaredMethod() throws Exception { - doTest(1, "method", "method2", "method3"); + doTest(2, "method", "method1", "method2"); } public void testForNameMethod() throws Exception { @@ -62,7 +62,7 @@ public class JavaReflectionCompletionTest extends LightFixtureCompletionTestCase } public void testForNameDeclaredField() throws Exception { - doTest(2, "num", "num2", "num3"); + doTest(1, "num", "num1", "num2"); } public void testVarargMethod() throws Exception { @@ -135,7 +135,7 @@ public class JavaReflectionCompletionTest extends LightFixtureCompletionTestCase } public void testConstantGetClassField() throws Exception { - doTest(1, "num", "num2", "num3"); + doTest(2, "num", "num3", "num2"); } public void testExpressionGetClassField() throws Exception { @@ -165,9 +165,14 @@ public class JavaReflectionCompletionTest extends LightFixtureCompletionTestCase doTest(0, "PublicClass"); } + public void testHasConstructor() { + doTest(2, "method", "method2", "method1"); + } + + private void doTest(int index, String... expected) { configureByFile(getTestName(false) + ".java"); - assertStringItems(expected); + assertFirstStringItems(expected); if (index >= 0) selectItem(getLookup().getItems().get(index)); myFixture.checkResultByFile(getTestName(false) + "_after.java"); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionParametersCompletionTest.kt b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionParametersCompletionTest.kt index ad561a743d22..f9c0bc2273bb 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionParametersCompletionTest.kt +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionParametersCompletionTest.kt @@ -31,7 +31,9 @@ package com.intellij.codeInsight.completion import com.intellij.JavaTestUtil +import com.intellij.codeInsight.lookup.LookupElement import com.intellij.codeInsight.lookup.LookupElementPresentation +import com.intellij.psi.PsiMethod import com.intellij.testFramework.LightProjectDescriptor /** @@ -42,26 +44,36 @@ class JavaReflectionParametersCompletionTest : LightFixtureCompletionTestCase() override fun getProjectDescriptor(): LightProjectDescriptor = com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase.JAVA_8 - fun testAnnotation() = doTest(0, "Bar.class", "Foo.class", "aType") + fun testAnnotation() = doTest(0, "Bar.class", "Foo.class") - fun testInheritedAnnotation() = doTest(1, "Bar.class", "Foo.class", "aType") + fun testInheritedAnnotation() = doTest(1, "Bar.class", "Foo.class") - fun testDeclaredAnnotation() = doTest(0, "Bar.class", "Foo.class") + fun testDeclaredAnnotation() = doTest(0, "Foo.class", "Bar.class") - fun testInheritedDeclaredAnnotation() = doTest(1, "Bar.class", "Foo.class") + fun testInheritedDeclaredAnnotation() = doTest(1, "Foo.class", "Bar.class") fun testAnnotationsByType() = doTest(0, "Bar.class", "Foo.class") - fun testDeclaredAnnotationsByType() = doTest(1, "Bar.class", "Foo.class") + fun testDeclaredAnnotationsByType() = doTest(0, "Foo.class", "Bar.class") fun testConstructor() { addConstructors() - doTest(2, "Construct()", "Construct(int)", "Construct(int,java.lang.String)", "Construct(java.lang.String)") + doTest(3, "Construct()", "Construct(int n)", "Construct(java.lang.String s)", "Construct(int n,java.lang.String s)") } fun testDeclaredConstructor() { addConstructors() - doTest(0, "Construct()", "Construct(int)", "Construct(int,java.lang.String)", "Construct(java.lang.String)") + doTest(0, "Construct()", "Construct(int n,java.lang.String s)", "Construct(int n)", "Construct(java.lang.String s)") + } + + fun testImports() { + addMoreClasses() + doTest(1, "Bar.class", "Baz.class") + } + + fun testVariable() { + addMoreClasses() + doTest(2, "Bar.class", "Foo.class", "aType") } private fun doTest(index: Int, vararg expected: String) { @@ -69,11 +81,7 @@ class JavaReflectionParametersCompletionTest : LightFixtureCompletionTestCase() configureByFile(getTestName(false) + ".java") val lookupItems = lookup.items - val texts = lookupItems.subList(0, Math.min(lookupItems.size, expected.size)).map { - val presentation = LookupElementPresentation() - it?.renderElement(presentation) - presentation.itemText ?: "" - } + val texts = lookupItemTexts(lookupItems, expected.size) assertOrderedEquals(texts, *expected) selectItem(lookupItems[index]) myFixture.checkResultByFile(getTestName(false) + "_after.java") @@ -82,9 +90,13 @@ class JavaReflectionParametersCompletionTest : LightFixtureCompletionTestCase() private fun addClasses() { myFixture.addClass("package foo.bar; public @interface Foo {}") myFixture.addClass("package foo.bar; public @interface Bar {}") - myFixture.addClass("package foo.bar; public @interface Baz {}") - myFixture.addClass("package foo.bar; @Foo class Parent {}") - myFixture.addClass("package foo.bar; @Bar class Test extends Parent {}") + myFixture.addClass("package foo.bar; @Bar class Parent {}") + myFixture.addClass("package foo.bar; @Foo class Test extends Parent {}") + } + + private fun addMoreClasses() { + myFixture.addClass("package foo.baz; public @interface Baz {}") + myFixture.addClass("package foo.bar; @foo.baz.Baz class More extends Parent {}") } private fun addConstructors() { @@ -96,4 +108,20 @@ public class Construct { public Construct() {} }""") } + } +fun lookupItemTexts(lookupItems: List, maxSize: Int): List = + lookupItems.subList(0, Math.min(lookupItems.size, maxSize)).map { + val obj = it?.`object` + when (obj) { + is PsiMethod -> { + obj.name + obj.parameterList.parameters.map { it.type.canonicalText + " " + it.name } + .joinToString(",", prefix = "(", postfix = ")") + } + else -> { + val presentation = LookupElementPresentation() + it?.renderElement(presentation) + presentation.itemText ?: "" + } + } + } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/LightJavadocGeneratorTest.kt b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/LightJavadocGeneratorTest.kt index 090876763d60..a8902bb467f9 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/LightJavadocGeneratorTest.kt +++ b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/LightJavadocGeneratorTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -15,11 +15,11 @@ */ package com.intellij.codeInsight.javadoc -import com.intellij.openapi.util.JDOMUtil import com.intellij.psi.PsiJavaFile -import com.intellij.testFramework.assertions.Assertions.assertThat import com.intellij.testFramework.LightProjectDescriptor +import com.intellij.testFramework.assertions.Assertions.assertThat import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase +import com.intellij.util.loadElement class LightJavadocGeneratorTest : LightCodeInsightFixtureTestCase() { override fun getProjectDescriptor(): LightProjectDescriptor = JAVA_9 @@ -45,7 +45,7 @@ class LightJavadocGeneratorTest : LightCodeInsightFixtureTestCase() { val file = myFixture.configureByText("module-info.java", text) val module = (file as PsiJavaFile).moduleDeclaration!! val docInfo = JavaDocInfoGeneratorFactory.create(project, module).generateDocInfo(null)!! - val body = JDOMUtil.loadDocument(docInfo).rootElement.getChild("body") + val body = loadElement(docInfo).getChild("body") assertThat(body).isEqualTo(expected) } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy index e46bca927635..e711200ee90f 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy @@ -35,6 +35,7 @@ import com.intellij.psi.codeStyle.CommonCodeStyleSettings import com.intellij.testFramework.LightPlatformCodeInsightTestCase import com.intellij.testFramework.fixtures.CodeInsightTestUtil import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase +import com.intellij.util.JdomKt import com.intellij.util.containers.ContainerUtil import com.intellij.util.ui.UIUtil import org.jdom.Element @@ -658,11 +659,11 @@ class Outer { } void testDontSaveDefaultContexts() { - def defElement = JDOMUtil.loadDocument('''\ + def defElement = JdomKt.loadElement('''\ ''').rootElement +''') def defContext = new TemplateContext() defContext.readTemplateContext(defElement) @@ -695,10 +696,10 @@ class Outer { } void "test adding new context to Other"() { - def defElement = JDOMUtil.loadDocument('''\ + def defElement = JdomKt.loadElement('''\ ''').rootElement +''') def context = new TemplateContext() context.readTemplateContext(defElement) diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java index 3c28371a74c2..fcf45f01e189 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java @@ -92,6 +92,8 @@ public class MagicConstantInspectionTest extends InspectionTestCase { } public void testSimple() throws Exception { doTest(); } + + public void testManyConstantSources() throws Exception { doTest(); } // test that the optimisation for not loading AST works public void testWithLibrary() throws Exception { doTest(); } } diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java index 2a4c24924f3a..90a8700beaeb 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -117,7 +117,7 @@ public class InspectionProfileTest extends LightIdeaTestCase { } public void testConvertOldProfile() throws Exception { - Element element = JDOMUtil.loadDocument("\n" + + Element element = JdomKt.loadElement("\n" + " ").getRootElement(); + ""); InspectionProfileImpl profile = createProfile(); profile.readExternal(element); profile.getModifiableModel().commit(); @@ -296,7 +296,7 @@ public class InspectionProfileTest extends LightIdeaTestCase { InspectionToolsConfigurable.importInspectionProfile(toImportElement, getApplicationProfileManager(), getProject(), null); //check merged - Element mergedElement = JDOMUtil.loadDocument(mergedText).getRootElement(); + Element mergedElement = JdomKt.loadElement(mergedText); profile = createProfile(new InspectionProfileImpl("foo")); profile.readExternal(mergedElement); profile.getModifiableModel().commit(); @@ -307,7 +307,7 @@ public class InspectionProfileTest extends LightIdeaTestCase { public void testStoredMemberVisibility() throws Exception { InspectionProfileImpl profile = createProfile(new InspectionProfileImpl("foo")); - profile.readExternal(JDOMUtil.loadDocument("\n" + + profile.readExternal(JdomKt.loadElement("\n" + " \n" + " \n" + - "").getRootElement()); + "")); profile.modifyProfile(it -> { InspectionToolWrapper toolWrapper = it.getInspectionTool("unused", getProject()); UnusedDeclarationInspectionBase tool = (UnusedDeclarationInspectionBase)toolWrapper.getTool(); @@ -481,7 +481,7 @@ public class InspectionProfileTest extends LightIdeaTestCase { } private static void checkMergedNoChanges(String initialText) throws Exception { - final Element element = JDOMUtil.loadDocument(initialText).getRootElement(); + final Element element = JdomKt.loadElement(initialText); InspectionProfileImpl profile = createProfile(new InspectionProfileImpl("foo")); profile.readExternal(element); profile.getModifiableModel().commit(); @@ -615,13 +615,13 @@ public class InspectionProfileTest extends LightIdeaTestCase { public void testInspectionInitializationForSerialization() throws Exception { InspectionProfileImpl foo = new InspectionProfileImpl("foo"); - foo.readExternal(JDOMUtil.loadDocument("\n" + + foo.readExternal(JdomKt.loadElement("\n" + " ").getRootElement()); + "")); foo.initInspectionTools(getProject()); assertEquals(1, countInitializedTools(foo)); } diff --git a/java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java b/java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java index d00b71835a4e..bf7050ac2884 100644 --- a/java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java +++ b/java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -21,11 +21,11 @@ import com.intellij.execution.configurations.UnknownConfigurationType; import com.intellij.execution.junit.JUnitConfigurationType; import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.Trinity; import com.intellij.testFramework.LightIdeaTestCase; import com.intellij.ui.RowsDnDSupport; import com.intellij.ui.treeStructure.Tree; +import com.intellij.util.JdomKt; import org.jdom.Element; import javax.swing.tree.DefaultMutableTreeNode; @@ -66,7 +66,7 @@ public class RunConfigurableTest extends LightIdeaTestCase { @Override protected void setUp() throws Exception { super.setUp(); - myConfigurable = new MockRunConfigurable(createRunManager(JDOMUtil.loadDocument(FOLDERS_CONFIGURATION).getRootElement())); + myConfigurable = new MockRunConfigurable(createRunManager(JdomKt.loadElement(FOLDERS_CONFIGURATION))); myTree = myConfigurable.myTree; myRoot = myConfigurable.myRoot; myModel = myConfigurable.myTreeModel; diff --git a/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationHandlerTest.java b/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationHandlerTest.java index 5beb72020985..bf3a0ba2b971 100644 --- a/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationHandlerTest.java +++ b/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationHandlerTest.java @@ -282,6 +282,18 @@ public class GotoImplementationHandlerTest extends JavaCodeInsightFixtureTestCas assertEquals(1, impls.length); } + public void testPrivateClassInheritors() { + PsiFile file = myFixture.addFileToProject("Foo.java", + "class C {\n" + + " private static class Private {}\n" + + " public static class Public extends Private {}" + + "}"); + myFixture.addClass("class Inheritor extends C.Public {}"); + myFixture.configureFromExistingVirtualFile(file.getVirtualFile()); + + assertSize(2, getTargets(file)); + } + private PsiElement[] getTargets(PsiFile file) { GotoTargetHandler.GotoData gotoData = CodeInsightTestUtil.gotoImplementation(myFixture.getEditor(), file); assertNotNull(gotoData); diff --git a/java/java-tests/testSrc/com/intellij/openapi/wm/impl/HiddenSidebarButtonTest.java b/java/java-tests/testSrc/com/intellij/openapi/wm/impl/HiddenSidebarButtonTest.java index 5a01dfbfd7e1..dc052f954581 100644 --- a/java/java-tests/testSrc/com/intellij/openapi/wm/impl/HiddenSidebarButtonTest.java +++ b/java/java-tests/testSrc/com/intellij/openapi/wm/impl/HiddenSidebarButtonTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -16,10 +16,10 @@ package com.intellij.openapi.wm.impl; import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.wm.ToolWindowEP; import com.intellij.openapi.wm.ToolWindowId; import com.intellij.usageView.impl.UsageViewManagerImpl; +import com.intellij.util.JdomKt; import java.util.Arrays; @@ -41,7 +41,7 @@ public class HiddenSidebarButtonTest extends ToolWindowManagerTestCase { public void testHiddenButton() throws Exception { DesktopLayout layout = myManager.getLayout(); - layout.readExternal(JDOMUtil.loadDocument(LAYOUT).getRootElement()); + layout.readExternal(JdomKt.loadElement(LAYOUT)); for (String ID : IDS) { assertFalse(layout.isToolWindowRegistered(ID)); assertTrue(layout.isToolWindowUnregistered(ID)); diff --git a/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java b/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java index 58259fb6a967..0abd8a4279bc 100644 --- a/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -206,6 +206,8 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase { } assertEquals(expected, ClsFileImpl.decompile(file).toString()); + + ((ClsFileImpl)getPsiManager().findFile(file)).getMirror(); } private static boolean isInner(String name) throws IOException { diff --git a/java/java-tests/testSrc/com/intellij/run/JavaPathMacroCollectorTest.groovy b/java/java-tests/testSrc/com/intellij/run/JavaPathMacroCollectorTest.groovy index 2dfdfa16e5c1..fff924767a09 100644 --- a/java/java-tests/testSrc/com/intellij/run/JavaPathMacroCollectorTest.groovy +++ b/java/java-tests/testSrc/com/intellij/run/JavaPathMacroCollectorTest.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -16,8 +16,8 @@ package com.intellij.run import com.intellij.application.options.PathMacrosCollector -import com.intellij.openapi.util.JDOMUtil import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase +import com.intellij.util.JdomKt class JavaPathMacroCollectorTest extends LightCodeInsightFixtureTestCase { void testJunitConfiguration() { @@ -56,8 +56,7 @@ class JavaPathMacroCollectorTest extends LightCodeInsightFixtureTestCase { ''' - def element = JDOMUtil.loadDocument(text).rootElement - assert PathMacrosCollector.getMacroNames(element).empty + assert PathMacrosCollector.getMacroNames(JdomKt.loadElement(text)).empty } } diff --git a/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsProjectConfiguration.java b/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsProjectConfiguration.java index b8ec30df259d..6c2ccaf41c06 100644 --- a/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsProjectConfiguration.java +++ b/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsProjectConfiguration.java @@ -1,9 +1,11 @@ package com.jetbrains.jsonSchema; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.components.*; import com.intellij.openapi.fileTypes.ex.FileTypeManagerEx; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Condition; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.xmlb.annotations.Transient; import org.jetbrains.annotations.NotNull; @@ -74,7 +76,7 @@ public class JsonSchemaMappingsProjectConfiguration extends JsonSchemaMappingsCo private void recalculateSchemaFiles() { ApplicationManager.getApplication().invokeLater(() -> { ApplicationManager.getApplication().runWriteAction(() -> FileTypeManagerEx.getInstanceEx().fireFileTypesChanged()); - }, o -> !myProject.isDisposed()); + }, ModalityState.NON_MODAL, myProject == null ? Condition.FALSE : myProject.getDisposed()); mySchemaFiles.clear(); if (myProject == null || myProject.getBaseDir() == null) return; diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java index 1bd194384199..7b5444ed5916 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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,17 +20,19 @@ import com.intellij.codeInspection.ex.InspectionProfileImpl; import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.io.FileUtil; import com.intellij.profile.codeInspection.InspectionProfileManager; +import com.intellij.util.JdomKt; +import com.intellij.util.io.PathKt; import org.jdom.Element; import org.jdom.JDOMException; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; @@ -93,20 +95,19 @@ public class InspectionProfileConvertor { } private static void renameOldDefaultsProfile() { - String directoryPath = PathManager.getConfigPath() + File.separator + InspectionProfileManager.INSPECTION_DIR; - File profileDirectory = new File(directoryPath); - if (!profileDirectory.exists()) { + Path directoryPath = Paths.get(PathManager.getConfigPath(), InspectionProfileManager.INSPECTION_DIR); + if (!PathKt.exists(directoryPath)) { return; } - File[] files = profileDirectory.listFiles(pathname -> pathname.getPath().endsWith(File.separator + DEFAULT_XML)); + File[] files = directoryPath.toFile().listFiles(pathname -> pathname.getPath().endsWith(File.separator + DEFAULT_XML)); if (files == null || files.length != 1 || !files[0].isFile() || files[0].length() == 0) { return; } try { - Element root = JDOMUtil.load(files[0]); + Element root = JdomKt.loadElement(files[0].toPath()); if (root.getAttributeValue(VERSION_ATT) == null){ - JDOMUtil.writeParent(root, new FileOutputStream(new File(profileDirectory, OLD_DEFAUL_PROFILE + XML_EXTENSION)), "\n"); + JdomKt.write(root, directoryPath.resolve(OLD_DEFAUL_PROFILE + XML_EXTENSION)); FileUtil.delete(files[0]); } } diff --git a/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileLoadUtil.java b/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileLoadUtil.java index 96c240864f61..ac0a6a02788b 100644 --- a/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileLoadUtil.java +++ b/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileLoadUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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,8 +18,8 @@ package com.intellij.profile.codeInspection; import com.intellij.codeInspection.ex.InspectionProfileImpl; import com.intellij.codeInspection.ex.InspectionToolRegistrar; import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.util.JdomKt; import org.jdom.Element; import org.jdom.JDOMException; import org.jetbrains.annotations.NotNull; @@ -46,7 +46,7 @@ public class InspectionProfileLoadUtil { public static InspectionProfileImpl load(@NotNull File file, @NotNull InspectionToolRegistrar registrar, @NotNull InspectionProfileManager profileManager) throws JDOMException, IOException, InvalidDataException { - Element element = JDOMUtil.load(file); + Element element = JdomKt.loadElement(file.getPath()); InspectionProfileImpl profile = new InspectionProfileImpl(getProfileName(file, element), registrar, (BaseInspectionProfileManager)profileManager); final Element profileElement = element.getChild("profile"); diff --git a/platform/bootstrap/src/com/intellij/ide/BootstrapClassLoaderUtil.java b/platform/bootstrap/src/com/intellij/ide/BootstrapClassLoaderUtil.java index 0e84306e675f..72f186746272 100644 --- a/platform/bootstrap/src/com/intellij/ide/BootstrapClassLoaderUtil.java +++ b/platform/bootstrap/src/com/intellij/ide/BootstrapClassLoaderUtil.java @@ -50,7 +50,6 @@ public class BootstrapClassLoaderUtil extends ClassUtilCore { @NotNull public static ClassLoader initClassLoader(boolean updatePlugins) throws MalformedURLException { PathManager.loadProperties(); - PathManager.patchProperties(); Collection classpath = new LinkedHashSet(); addParentClasspath(classpath, false); diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy index e92d457a1b83..f1c136aa5ffd 100644 --- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy +++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy @@ -18,6 +18,7 @@ package org.jetbrains.intellij.build.impl import com.intellij.openapi.util.MultiValuesMap import com.intellij.openapi.util.io.FileUtil import org.apache.tools.ant.types.FileSet +import org.apache.tools.ant.types.resources.FileProvider import org.jetbrains.intellij.build.BuildContext import org.jetbrains.intellij.build.BuildOptions import org.jetbrains.intellij.build.BuildTasks @@ -32,7 +33,7 @@ import org.jetbrains.jps.util.JpsPathUtil /** * Assembles output of modules to platform JARs (in {@link org.jetbrains.intellij.build.BuildPaths#distAll distAll}/lib directory), - * bunlded plugins' JARs (in {@link org.jetbrains.intellij.build.BuildPaths#distAll distAll}/plugins directory) and zip archives with + * bundled plugins' JARs (in {@link org.jetbrains.intellij.build.BuildPaths#distAll distAll}/plugins directory) and zip archives with * non-bundled plugins (in {@link org.jetbrains.intellij.build.BuildPaths#artifacts artifacts}/plugins directory). * * @author nik @@ -293,27 +294,31 @@ class DistributionJARsBuilder { def enabledModulesSet = buildContext.productProperties.productLayout.enabledPluginModules pluginsToInclude.each { plugin -> def actualModuleJars = plugin.getActualModules(enabledModulesSet) - checkOutputOfPluginModules(plugin.mainModule, actualModuleJars.values()) + checkOutputOfPluginModules(plugin.mainModule, actualModuleJars.values(), plugin.moduleExcludes) buildByLayout(layoutBuilder, plugin, "$targetDirectory/$plugin.directoryName", actualModuleJars) } } - private void checkOutputOfPluginModules(String mainPluginModule, Collection moduleNames) { - def modulesWithPluginXml = moduleNames.findAll { containsFileInOutput(it, "META-INF/plugin.xml") } + private void checkOutputOfPluginModules(String mainPluginModule, Collection moduleNames, MultiValuesMap moduleExcludes) { + def modulesWithPluginXml = moduleNames.findAll { containsFileInOutput(it, "META-INF/plugin.xml", moduleExcludes.get(it)) } if (modulesWithPluginXml.size() > 1) { buildContext.messages.error("Multiple modules (${modulesWithPluginXml.join(", ")}) from '$mainPluginModule' plugin contain plugin.xml files so the plugin won't work properly") } moduleNames.each { - if (containsFileInOutput(it, "com/intellij/uiDesigner/core/GridLayoutManager.class")) { + if (containsFileInOutput(it, "com/intellij/uiDesigner/core/GridLayoutManager.class", moduleExcludes.get(it))) { buildContext.messages.error("Runtime classes of GUI designer must not be packaged to '$mainPluginModule' plugin, because they are included into a platform JAR. " + "Make sure that 'Automatically copy form runtime classes to the output directory' is disabled in Settings | Editor | GUI Designer.") } } } - private boolean containsFileInOutput(String moduleName, String filePath) { - return new File(buildContext.projectBuilder.getModuleOutput(buildContext.findRequiredModule(moduleName), false), filePath).exists() + private boolean containsFileInOutput(String moduleName, String filePath, Collection excludes) { + def moduleOutput = new File(buildContext.projectBuilder.getModuleOutput(buildContext.findRequiredModule(moduleName), false)) + def fileInOutput = new File(moduleOutput, filePath) + return fileInOutput.exists() && (excludes == null || excludes.every { + createFileSet(it, moduleOutput).iterator().every { !(it instanceof FileProvider && FileUtil.filesEqual(it.file, fileInOutput))} + }) } private void buildByLayout(LayoutBuilder layoutBuilder, BaseLayout layout, String targetDirectory, MultiValuesMap moduleJars) { @@ -419,22 +424,26 @@ class DistributionJARsBuilder { moduleExcludes.entrySet().each { entry -> String module = entry.key entry.value.each { pattern -> - def fileSet = new FileSet() - fileSet.setProject(buildContext.ant.antProject) def moduleOutput = new File(buildContext.projectBuilder.getModuleOutput(buildContext.findRequiredModule(module), false)) if (!moduleOutput.exists()) { buildContext.messages.error("There are excludes defined for module '$module', but the module wasn't compiled; " + "most probably it means that '$module' isn't include into the product distribution so it makes no sense to define excludes for it.") } - fileSet.setDir(moduleOutput) - fileSet.createInclude().setName(pattern) - if (fileSet.size() == 0) { + if (createFileSet(pattern, moduleOutput).size() == 0) { buildContext.messages.error("Incorrect exludes for module '$module': nothing matches to $pattern in the module output") } } } } + private FileSet createFileSet(String pattern, File baseDir) { + def fileSet = new FileSet() + fileSet.setProject(buildContext.ant.antProject) + fileSet.setDir(baseDir) + fileSet.createInclude().setName(pattern) + return fileSet + } + static String basePath(BuildContext buildContext, String moduleName) { JpsPathUtil.urlToPath(buildContext.findRequiredModule(moduleName).contentRootsList.urls.first()) } diff --git a/platform/configuration-store-impl/src/FileBasedStorage.kt b/platform/configuration-store-impl/src/FileBasedStorage.kt index 74db699aa40d..a47c1c32608f 100644 --- a/platform/configuration-store-impl/src/FileBasedStorage.kt +++ b/platform/configuration-store-impl/src/FileBasedStorage.kt @@ -132,7 +132,8 @@ open class FileBasedStorage(file: Path, else { val charBuffer = StandardCharsets.UTF_8.decode(ByteBuffer.wrap(file.contentsToByteArray())) lineSeparator = detectLineSeparators(charBuffer, if (isUseXmlProlog) null else LineSeparator.LF) - return JDOMUtil.loadDocument(charBuffer).detachRootElement() + @Suppress("DEPRECATION") + return loadElement(charBuffer) } return null } @@ -242,7 +243,7 @@ private fun doWrite(requestor: Any, file: VirtualFile, content: Any, lineSeparat out.write(lineSeparator.separatorBytes) } if (content is Element) { - JDOMUtil.writeParent(content, out, lineSeparator.separatorString) + JDOMUtil.write(content, out, lineSeparator.separatorString) } else { (content as BufferExposingByteArrayOutputStream).writeTo(out) @@ -253,7 +254,7 @@ private fun doWrite(requestor: Any, file: VirtualFile, content: Any, lineSeparat internal fun Parent.toBufferExposingByteArray(lineSeparator: String = "\n"): BufferExposingByteArrayOutputStream { val out = BufferExposingByteArrayOutputStream(512) - JDOMUtil.writeParent(this, out, lineSeparator) + JDOMUtil.write(this, out, lineSeparator) return out } diff --git a/platform/configuration-store-impl/src/ProjectStoreImpl.kt b/platform/configuration-store-impl/src/ProjectStoreImpl.kt index b29e01341be0..93ecc2836170 100644 --- a/platform/configuration-store-impl/src/ProjectStoreImpl.kt +++ b/platform/configuration-store-impl/src/ProjectStoreImpl.kt @@ -129,7 +129,7 @@ abstract class ProjectStoreBase(override final val project: ProjectImpl) : Compo wrapper.addContent(profile) val path = Paths.get(storageManager.expandMacro(PROJECT_CONFIG_DIR), if (isInspection) "inspectionProfiles" else "copyright", "${FileUtil.sanitizeFileName(schemeName, true)}.xml") - JDOMUtil.writeParent(wrapper, path.outputStream(), "\n") + JDOMUtil.write(wrapper, path.outputStream(), "\n") } } diff --git a/platform/configuration-store-impl/src/StateMap.kt b/platform/configuration-store-impl/src/StateMap.kt index c89569b3d6af..3804b0f14bd1 100644 --- a/platform/configuration-store-impl/src/StateMap.kt +++ b/platform/configuration-store-impl/src/StateMap.kt @@ -58,7 +58,7 @@ fun getNewByteIfDiffers(key: String, newState: Any, oldState: ByteArray): ByteAr val logChangedComponents = SystemProperties.getBooleanProperty("idea.log.changed.components", false) if (ApplicationManager.getApplication().isUnitTestMode || logChangedComponents ) { - fun stateToString(state: Any) = JDOMUtil.writeParent(state as? Element ?: unarchiveState(state as ByteArray), "\n") + fun stateToString(state: Any) = JDOMUtil.write(state as? Element ?: unarchiveState(state as ByteArray), "\n") val before = stateToString(oldState) val after = stateToString(newState) diff --git a/platform/configuration-store-impl/testSrc/xml/XmlSerializerTest.kt b/platform/configuration-store-impl/testSrc/xml/XmlSerializerTest.kt index b825be8c8370..dd39eec7e98e 100644 --- a/platform/configuration-store-impl/testSrc/xml/XmlSerializerTest.kt +++ b/platform/configuration-store-impl/testSrc/xml/XmlSerializerTest.kt @@ -634,7 +634,7 @@ internal class XmlSerializerTest { private fun checkSmartSerialization(bean: Bean2, serialized: String) { val serializer = SmartSerializer() - serializer.readExternal(bean, JDOMUtil.loadDocument(serialized).rootElement) + serializer.readExternal(bean, JDOMUtil.load(serialized)) val serializedState = Element("Bean2") serializer.writeExternal(bean, serializedState) assertThat(JDOMUtil.writeElement(serializedState)).isEqualTo(serialized) diff --git a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java index 7b219916d8b0..6d109c51695f 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java +++ b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java @@ -164,14 +164,14 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi PsiDocumentManager.getInstance(project).getLastCommittedText(document)); } - @NotNull - private CommitTask doQueue(@NotNull Project project, + private void doQueue(@NotNull Project project, @NotNull Document document, @NotNull List> oldFileNodes, @NotNull Object reason, @NotNull ModalityState currentModalityState, @NotNull CharSequence lastCommittedText) { synchronized (lock) { + if (!project.isInitialized()) return; // check the project is disposed under lock. CommitTask newTask = createNewTaskAndCancelSimilar(project, document, oldFileNodes, reason, currentModalityState, lastCommittedText); @@ -179,7 +179,6 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi log(project, "Queued", newTask, reason); wakeUpQueue(); - return newTask; } } @@ -556,10 +555,8 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi if (task.reason.equals(SYNC_COMMIT_REASON)) { throw new PsiInvalidElementAccessException(file, "File " + file + " invalidated during sync commit"); } - else { - commitAsynchronously(project, document, "File " + file + " invalidated during background commit; task: "+task, - task.myCreationModalityState); - } + commitAsynchronously(project, document, "File " + file + " invalidated during background commit; task: "+task, + task.myCreationModalityState); } } } diff --git a/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java b/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java index 0ff6b9d52750..2fbbf26dd7b8 100644 --- a/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java @@ -204,6 +204,7 @@ public class TextMergeViewer implements MergeTool.MergeViewer { myTextDiffProvider = new TextDiffProviderBase(getTextSettings(), myInnerDiffWorker::onSettingsChanged, + this, ar(IgnorePolicy.DEFAULT), ar(HighlightPolicy.BY_LINE, HighlightPolicy.BY_WORD)); diff --git a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedDiffViewer.java index e349a8d24e94..6ec2a2249e20 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedDiffViewer.java @@ -122,7 +122,7 @@ public class UnifiedDiffViewer extends ListenerDiffViewerBase { myEditorSettingsAction = new SetEditorSettingsAction(getTextSettings(), getEditors()); myEditorSettingsAction.applyDefaults(); - myTextDiffProvider = DiffUtil.createNoIgnoreTextDiffProvider(getProject(), getRequest(), getTextSettings(), this::rediff); + myTextDiffProvider = DiffUtil.createNoIgnoreTextDiffProvider(getProject(), getRequest(), getTextSettings(), this::rediff, this); new MyOpenInEditorWithMouseAction().install(getEditors()); diff --git a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java index 957d5645f9cc..defe89e10024 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java @@ -80,7 +80,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { myModifierProvider = new ModifierProvider(); - myTextDiffProvider = DiffUtil.createTextDiffProvider(getProject(), getRequest(), getTextSettings(), this::rediff); + myTextDiffProvider = DiffUtil.createTextDiffProvider(getProject(), getRequest(), getTextSettings(), this::rediff, this); DiffUtil.registerAction(new ReplaceSelectedChangesAction(Side.LEFT, true), myPanel); DiffUtil.registerAction(new AppendSelectedChangesAction(Side.LEFT, true), myPanel); diff --git a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleOnesideDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleOnesideDiffViewer.java index c71919ade10d..c5e898b4c2e9 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleOnesideDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleOnesideDiffViewer.java @@ -56,7 +56,7 @@ public class SimpleOnesideDiffViewer extends OnesideTextDiffViewer { public SimpleOnesideDiffViewer(@NotNull DiffContext context, @NotNull DiffRequest request) { super(context, (ContentDiffRequest)request); - myTextDiffProvider = DiffUtil.createTextDiffProvider(getProject(), getRequest(), getTextSettings(), this::rediff); + myTextDiffProvider = DiffUtil.createTextDiffProvider(getProject(), getRequest(), getTextSettings(), this::rediff, this); } @Override diff --git a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java index c56f9631da6e..8b96b57d2f5d 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java @@ -49,7 +49,7 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewerEx { public SimpleThreesideDiffViewer(@NotNull DiffContext context, @NotNull DiffRequest request) { super(context, (ContentDiffRequest)request); - myTextDiffProvider = new SimpleThreesideTextDiffProvider(getTextSettings(), this::rediff); + myTextDiffProvider = new SimpleThreesideTextDiffProvider(getTextSettings(), this::rediff, this); } @NotNull diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffSettingsHolder.kt b/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffSettingsHolder.kt index 5c1a3d347322..e73fb380730a 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffSettingsHolder.kt +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffSettingsHolder.kt @@ -17,12 +17,15 @@ package com.intellij.diff.tools.util.base import com.intellij.diff.util.DiffPlaces import com.intellij.diff.util.DiffUtil +import com.intellij.openapi.Disposable import com.intellij.openapi.components.PersistentStateComponent import com.intellij.openapi.components.State import com.intellij.openapi.components.Storage import com.intellij.openapi.components.service import com.intellij.openapi.util.Key +import com.intellij.util.EventDispatcher import com.intellij.util.xmlb.annotations.MapAnnotation +import com.intellij.util.xmlb.annotations.Transient import java.util.* @State( @@ -61,12 +64,19 @@ class TextDiffSettingsHolder : PersistentStateComponent = EventDispatcher.create(TextDiffSettings.Listener::class.java) + } class TextDiffSettings internal constructor(private val SHARED_SETTINGS: SharedSettings, private val PLACE_SETTINGS: PlaceSettings) { constructor() : this(SharedSettings(), PlaceSettings()) + fun addListener(listener: Listener, disposable: Disposable) { + PLACE_SETTINGS.eventDispatcher.addListener(listener, disposable) + } + // Presentation settings var isEnableSyncScroll: Boolean @@ -77,11 +87,13 @@ class TextDiffSettingsHolder : PersistentStateComponent().getSettings(place) } + + interface Listener : EventListener { + fun highlightPolicyChanged() {} + fun ignorePolicyChanged() {} + } } fun getSettings(place: String?): TextDiffSettings { diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffViewerUtil.java b/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffViewerUtil.java index 75a29ea24570..afbb66c661fd 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffViewerUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffViewerUtil.java @@ -261,14 +261,11 @@ public class TextDiffViewerUtil { public static class HighlightPolicySettingAction extends EnumPolicySettingAction { @NotNull protected final TextDiffSettings mySettings; - @NotNull private final Runnable myRediffRunnable; public HighlightPolicySettingAction(@NotNull TextDiffSettings settings, - @NotNull Runnable rediff, @NotNull HighlightPolicy... policies) { super(policies); mySettings = settings; - myRediffRunnable = rediff; } @Override @@ -276,7 +273,6 @@ public class TextDiffViewerUtil { if (getValue() == option) return; UsageTrigger.trigger("diff.TextDiffSettings.HighlightPolicy." + option.name()); mySettings.setHighlightPolicy(option); - myRediffRunnable.run(); } @NotNull @@ -306,14 +302,11 @@ public class TextDiffViewerUtil { public static class IgnorePolicySettingAction extends EnumPolicySettingAction { @NotNull protected final TextDiffSettings mySettings; - @NotNull private final Runnable myRediffRunnable; public IgnorePolicySettingAction(@NotNull TextDiffSettings settings, - @NotNull Runnable rediff, @NotNull IgnorePolicy... policies) { super(policies); mySettings = settings; - myRediffRunnable = rediff; } @Override @@ -321,7 +314,6 @@ public class TextDiffViewerUtil { if (getValue() == option) return; UsageTrigger.trigger("diff.TextDiffSettings.IgnorePolicy." + option.name()); mySettings.setIgnorePolicy(option); - myRediffRunnable.run(); } @NotNull diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/text/SimpleTextDiffProvider.java b/platform/diff-impl/src/com/intellij/diff/tools/util/text/SimpleTextDiffProvider.java index 0935043c9372..96c00f7d1572 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/text/SimpleTextDiffProvider.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/text/SimpleTextDiffProvider.java @@ -21,7 +21,8 @@ import com.intellij.diff.fragments.LineFragment; import com.intellij.diff.tools.util.base.HighlightPolicy; import com.intellij.diff.tools.util.base.IgnorePolicy; import com.intellij.diff.tools.util.base.TextDiffSettingsHolder.TextDiffSettings; -import com.intellij.diff.util.DiffUserDataKeysEx; +import com.intellij.diff.util.DiffUserDataKeysEx.DiffComputer; +import com.intellij.openapi.Disposable; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NotNull; @@ -32,7 +33,7 @@ import static com.intellij.diff.tools.util.base.HighlightPolicy.*; import static com.intellij.diff.tools.util.base.IgnorePolicy.*; public class SimpleTextDiffProvider extends TwosideTextDiffProviderBase implements TwosideTextDiffProvider { - static final DiffUserDataKeysEx.DiffComputer DEFAULT_COMPUTER = (text1, text2, policy, innerChanges, indicator) -> { + static final DiffComputer DEFAULT_COMPUTER = (text1, text2, policy, innerChanges, indicator) -> { if (innerChanges) { return ComparisonManager.getInstance().compareLinesInner(text1, text2, policy, indicator); } @@ -44,25 +45,28 @@ public class SimpleTextDiffProvider extends TwosideTextDiffProviderBase implemen private static final IgnorePolicy[] IGNORE_POLICIES = {DEFAULT, TRIM_WHITESPACES, IGNORE_WHITESPACES, IGNORE_WHITESPACES_CHUNKS}; private static final HighlightPolicy[] HIGHLIGHT_POLICIES = {BY_LINE, BY_WORD, BY_WORD_SPLIT, DO_NOT_HIGHLIGHT}; - @NotNull private final DiffUserDataKeysEx.DiffComputer myDiffComputer; + @NotNull private final DiffComputer myDiffComputer; public SimpleTextDiffProvider(@NotNull TextDiffSettings settings, - @NotNull Runnable rediff) { - this(settings, rediff, DEFAULT_COMPUTER); + @NotNull Runnable rediff, + @NotNull Disposable disposable) { + this(settings, rediff, disposable, DEFAULT_COMPUTER); } public SimpleTextDiffProvider(@NotNull TextDiffSettings settings, @NotNull Runnable rediff, - @NotNull DiffUserDataKeysEx.DiffComputer diffComputer) { - this(settings, rediff, diffComputer, IGNORE_POLICIES, HIGHLIGHT_POLICIES); + @NotNull Disposable disposable, + @NotNull DiffComputer diffComputer) { + this(settings, rediff, disposable, diffComputer, IGNORE_POLICIES, HIGHLIGHT_POLICIES); } private SimpleTextDiffProvider(@NotNull TextDiffSettings settings, @NotNull Runnable rediff, - @NotNull DiffUserDataKeysEx.DiffComputer diffComputer, + @NotNull Disposable disposable, + @NotNull DiffComputer diffComputer, @NotNull IgnorePolicy[] ignorePolicies, @NotNull HighlightPolicy[] highlightPolicies) { - super(settings, rediff, ignorePolicies, highlightPolicies); + super(settings, rediff, disposable, ignorePolicies, highlightPolicies); myDiffComputer = diffComputer; } @@ -79,12 +83,12 @@ public class SimpleTextDiffProvider extends TwosideTextDiffProviderBase implemen public static class NoIgnore extends SimpleTextDiffProvider implements TwosideTextDiffProvider.NoIgnore { - public NoIgnore(@NotNull TextDiffSettings settings, @NotNull Runnable rediff) { - this(settings, rediff, DEFAULT_COMPUTER); + public NoIgnore(@NotNull TextDiffSettings settings, @NotNull Runnable rediff, @NotNull Disposable disposable) { + this(settings, rediff, disposable, DEFAULT_COMPUTER); } - public NoIgnore(@NotNull TextDiffSettings settings, @NotNull Runnable rediff, @NotNull DiffUserDataKeysEx.DiffComputer diffComputer) { - super(settings, rediff, diffComputer, IGNORE_POLICIES, ArrayUtil.remove(HIGHLIGHT_POLICIES, DO_NOT_HIGHLIGHT)); + public NoIgnore(@NotNull TextDiffSettings settings, @NotNull Runnable rediff, @NotNull Disposable disposable, @NotNull DiffComputer diffComputer) { + super(settings, rediff, disposable, diffComputer, IGNORE_POLICIES, ArrayUtil.remove(HIGHLIGHT_POLICIES, DO_NOT_HIGHLIGHT)); } @NotNull diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/text/SimpleThreesideTextDiffProvider.java b/platform/diff-impl/src/com/intellij/diff/tools/util/text/SimpleThreesideTextDiffProvider.java index 9033bd4e875b..3fffcdc1e4e6 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/text/SimpleThreesideTextDiffProvider.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/text/SimpleThreesideTextDiffProvider.java @@ -24,6 +24,7 @@ import com.intellij.diff.tools.util.base.TextDiffSettingsHolder.TextDiffSettings import com.intellij.diff.util.DiffUtil; import com.intellij.diff.util.MergeConflictType; import com.intellij.diff.util.ThreeSide; +import com.intellij.openapi.Disposable; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; @@ -40,8 +41,9 @@ public class SimpleThreesideTextDiffProvider extends TextDiffProviderBase { private static final HighlightPolicy[] HIGHLIGHT_POLICIES = {BY_LINE, BY_WORD}; public SimpleThreesideTextDiffProvider(@NotNull TextDiffSettings settings, - @NotNull Runnable rediff) { - super(settings, rediff, IGNORE_POLICIES, HIGHLIGHT_POLICIES); + @NotNull Runnable rediff, + @NotNull Disposable disposable) { + super(settings, rediff, disposable, IGNORE_POLICIES, HIGHLIGHT_POLICIES); } @NotNull diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/text/SmartTextDiffProvider.java b/platform/diff-impl/src/com/intellij/diff/tools/util/text/SmartTextDiffProvider.java index 44fd83b3a3ae..eb53db9c76ca 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/text/SmartTextDiffProvider.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/text/SmartTextDiffProvider.java @@ -25,6 +25,7 @@ import com.intellij.diff.tools.util.base.HighlightPolicy; import com.intellij.diff.tools.util.base.IgnorePolicy; import com.intellij.diff.tools.util.base.TextDiffSettingsHolder.TextDiffSettings; import com.intellij.diff.util.Side; +import com.intellij.openapi.Disposable; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; @@ -51,24 +52,26 @@ public class SmartTextDiffProvider extends TwosideTextDiffProviderBase implement public static TwosideTextDiffProvider create(@Nullable Project project, @NotNull ContentDiffRequest request, @NotNull TextDiffSettings settings, - @NotNull Runnable rediff) { + @NotNull Runnable rediff, + @NotNull Disposable disposable) { DiffContent content1 = Side.LEFT.select(request.getContents()); DiffContent content2 = Side.RIGHT.select(request.getContents()); DiffIgnoredRangeProvider ignoredRangeProvider = getIgnoredRangeProvider(project, content1, content2); if (ignoredRangeProvider == null) return null; - return new SmartTextDiffProvider(project, content1, content2, settings, rediff, ignoredRangeProvider); + return new SmartTextDiffProvider(project, content1, content2, settings, rediff, disposable, ignoredRangeProvider); } @Nullable public static TwosideTextDiffProvider.NoIgnore createNoIgnore(@Nullable Project project, @NotNull ContentDiffRequest request, @NotNull TextDiffSettings settings, - @NotNull Runnable rediff) { + @NotNull Runnable rediff, + @NotNull Disposable disposable) { DiffContent content1 = Side.LEFT.select(request.getContents()); DiffContent content2 = Side.RIGHT.select(request.getContents()); DiffIgnoredRangeProvider ignoredRangeProvider = getIgnoredRangeProvider(project, content1, content2); if (ignoredRangeProvider == null) return null; - return new SmartTextDiffProvider.NoIgnore(project, content1, content2, settings, rediff, ignoredRangeProvider); + return new SmartTextDiffProvider.NoIgnore(project, content1, content2, settings, rediff, disposable, ignoredRangeProvider); } private SmartTextDiffProvider(@Nullable Project project, @@ -76,8 +79,9 @@ public class SmartTextDiffProvider extends TwosideTextDiffProviderBase implement @NotNull DiffContent content2, @NotNull TextDiffSettings settings, @NotNull Runnable rediff, + @NotNull Disposable disposable, @NotNull DiffIgnoredRangeProvider ignoredRangeProvider) { - this(project, content1, content2, settings, rediff, ignoredRangeProvider, IGNORE_POLICIES, HIGHLIGHT_POLICIES); + this(project, content1, content2, settings, rediff, disposable, ignoredRangeProvider, IGNORE_POLICIES, HIGHLIGHT_POLICIES); } private SmartTextDiffProvider(@Nullable Project project, @@ -85,10 +89,11 @@ public class SmartTextDiffProvider extends TwosideTextDiffProviderBase implement @NotNull DiffContent content2, @NotNull TextDiffSettings settings, @NotNull Runnable rediff, + @NotNull Disposable disposable, @NotNull DiffIgnoredRangeProvider ignoredRangeProvider, @NotNull IgnorePolicy[] ignorePolicies, @NotNull HighlightPolicy[] highlightPolicies) { - super(settings, rediff, ignorePolicies, highlightPolicies); + super(settings, rediff, disposable, ignorePolicies, highlightPolicies); myProject = project; myContent1 = content1; myContent2 = content2; @@ -151,8 +156,9 @@ public class SmartTextDiffProvider extends TwosideTextDiffProviderBase implement @NotNull DiffContent content2, @NotNull TextDiffSettings settings, @NotNull Runnable rediff, + @NotNull Disposable disposable, @NotNull DiffIgnoredRangeProvider ignoredRangeProvider) { - super(project, content1, content2, settings, rediff, ignoredRangeProvider, + super(project, content1, content2, settings, rediff, disposable, ignoredRangeProvider, IGNORE_POLICIES, ArrayUtil.remove(HIGHLIGHT_POLICIES, DO_NOT_HIGHLIGHT)); } diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/text/TextDiffProviderBase.java b/platform/diff-impl/src/com/intellij/diff/tools/util/text/TextDiffProviderBase.java index b694652d147b..4fb4596ef62b 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/text/TextDiffProviderBase.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/text/TextDiffProviderBase.java @@ -20,6 +20,7 @@ import com.intellij.diff.tools.util.base.IgnorePolicy; import com.intellij.diff.tools.util.base.TextDiffSettingsHolder.TextDiffSettings; import com.intellij.diff.tools.util.base.TextDiffViewerUtil.HighlightPolicySettingAction; import com.intellij.diff.tools.util.base.TextDiffViewerUtil.IgnorePolicySettingAction; +import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.Separator; import org.jetbrains.annotations.NotNull; @@ -36,10 +37,12 @@ public class TextDiffProviderBase implements TextDiffProvider { public TextDiffProviderBase(@NotNull TextDiffSettings settings, @NotNull Runnable rediff, + @NotNull Disposable disposable, @NotNull IgnorePolicy[] ignorePolicies, @NotNull HighlightPolicy[] highlightPolicies) { - myIgnorePolicySettingAction = new MyIgnorePolicySettingAction(settings, rediff, ignorePolicies); - myHighlightPolicySettingAction = new MyHighlightPolicySettingAction(settings, rediff, highlightPolicies); + myIgnorePolicySettingAction = new MyIgnorePolicySettingAction(settings, ignorePolicies); + myHighlightPolicySettingAction = new MyHighlightPolicySettingAction(settings, highlightPolicies); + settings.addListener(new MyListener(rediff), disposable); } @NotNull @@ -86,9 +89,8 @@ public class TextDiffProviderBase implements TextDiffProvider { private class MyIgnorePolicySettingAction extends IgnorePolicySettingAction { public MyIgnorePolicySettingAction(@NotNull TextDiffSettings settings, - @NotNull Runnable rediff, @NotNull IgnorePolicy[] ignorePolicies) { - super(settings, rediff, ignorePolicies); + super(settings, ignorePolicies); } @NotNull @@ -100,9 +102,8 @@ public class TextDiffProviderBase implements TextDiffProvider { private class MyHighlightPolicySettingAction extends HighlightPolicySettingAction { public MyHighlightPolicySettingAction(@NotNull TextDiffSettings settings, - @NotNull Runnable rediff, @NotNull HighlightPolicy[] highlightPolicies) { - super(settings, rediff, highlightPolicies); + super(settings, highlightPolicies); } @NotNull @@ -111,4 +112,22 @@ public class TextDiffProviderBase implements TextDiffProvider { return notNullize(TextDiffProviderBase.this.getText(option), super.getText(option)); } } + + private static class MyListener implements TextDiffSettings.Listener { + @NotNull private final Runnable myRediff; + + public MyListener(@NotNull Runnable rediff) { + myRediff = rediff; + } + + @Override + public void highlightPolicyChanged() { + myRediff.run(); + } + + @Override + public void ignorePolicyChanged() { + myRediff.run(); + } + } } diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/text/TwosideTextDiffProviderBase.java b/platform/diff-impl/src/com/intellij/diff/tools/util/text/TwosideTextDiffProviderBase.java index c774f0879845..c43e3628a354 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/text/TwosideTextDiffProviderBase.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/text/TwosideTextDiffProviderBase.java @@ -21,6 +21,7 @@ import com.intellij.diff.fragments.LineFragment; import com.intellij.diff.tools.util.base.HighlightPolicy; import com.intellij.diff.tools.util.base.IgnorePolicy; import com.intellij.diff.tools.util.base.TextDiffSettingsHolder.TextDiffSettings; +import com.intellij.openapi.Disposable; import com.intellij.openapi.progress.ProgressIndicator; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -30,9 +31,10 @@ import java.util.List; abstract class TwosideTextDiffProviderBase extends TextDiffProviderBase implements TwosideTextDiffProvider { protected TwosideTextDiffProviderBase(@NotNull TextDiffSettings settings, @NotNull Runnable rediff, + @NotNull Disposable disposable, @NotNull IgnorePolicy[] ignorePolicies, @NotNull HighlightPolicy[] highlightPolicies) { - super(settings, rediff, ignorePolicies, highlightPolicies); + super(settings, rediff, disposable, ignorePolicies, highlightPolicies); } @Nullable diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java b/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java index 511a71fcc67f..4420b55e645c 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java @@ -600,28 +600,30 @@ public class DiffUtil { public static TwosideTextDiffProvider createTextDiffProvider(@Nullable Project project, @NotNull ContentDiffRequest request, @NotNull TextDiffSettings settings, - @NotNull Runnable rediff) { + @NotNull Runnable rediff, + @NotNull Disposable disposable) { DiffUserDataKeysEx.DiffComputer diffComputer = request.getUserData(DiffUserDataKeysEx.CUSTOM_DIFF_COMPUTER); - if (diffComputer != null) return new SimpleTextDiffProvider(settings, rediff, diffComputer); + if (diffComputer != null) return new SimpleTextDiffProvider(settings, rediff, disposable, diffComputer); - TwosideTextDiffProvider smartProvider = SmartTextDiffProvider.create(project, request, settings, rediff); + TwosideTextDiffProvider smartProvider = SmartTextDiffProvider.create(project, request, settings, rediff, disposable); if (smartProvider != null) return smartProvider; - return new SimpleTextDiffProvider(settings, rediff); + return new SimpleTextDiffProvider(settings, rediff, disposable); } @NotNull public static TwosideTextDiffProvider.NoIgnore createNoIgnoreTextDiffProvider(@Nullable Project project, @NotNull ContentDiffRequest request, @NotNull TextDiffSettings settings, - @NotNull Runnable rediff) { + @NotNull Runnable rediff, + @NotNull Disposable disposable) { DiffUserDataKeysEx.DiffComputer diffComputer = request.getUserData(DiffUserDataKeysEx.CUSTOM_DIFF_COMPUTER); - if (diffComputer != null) return new SimpleTextDiffProvider.NoIgnore(settings, rediff, diffComputer); + if (diffComputer != null) return new SimpleTextDiffProvider.NoIgnore(settings, rediff, disposable, diffComputer); - TwosideTextDiffProvider.NoIgnore smartProvider = SmartTextDiffProvider.createNoIgnore(project, request, settings, rediff); + TwosideTextDiffProvider.NoIgnore smartProvider = SmartTextDiffProvider.createNoIgnore(project, request, settings, rediff, disposable); if (smartProvider != null) return smartProvider; - return new SimpleTextDiffProvider.NoIgnore(settings, rediff); + return new SimpleTextDiffProvider.NoIgnore(settings, rediff, disposable); } @Nullable diff --git a/platform/diff-impl/tests/com/intellij/diff/tools/fragmented/UnifiedFragmentBuilderTest.kt b/platform/diff-impl/tests/com/intellij/diff/tools/fragmented/UnifiedFragmentBuilderTest.kt index f59a22baba1e..6503c4e82c43 100644 --- a/platform/diff-impl/tests/com/intellij/diff/tools/fragmented/UnifiedFragmentBuilderTest.kt +++ b/platform/diff-impl/tests/com/intellij/diff/tools/fragmented/UnifiedFragmentBuilderTest.kt @@ -17,83 +17,365 @@ package com.intellij.diff.tools.fragmented import com.intellij.diff.DiffTestCase import com.intellij.diff.comparison.ComparisonPolicy +import com.intellij.diff.comparison.iterables.DiffIterable +import com.intellij.diff.comparison.iterables.DiffIterableUtil +import com.intellij.diff.fragments.LineFragment +import com.intellij.diff.fragments.LineFragmentImpl import com.intellij.diff.util.LineRange +import com.intellij.diff.util.Range import com.intellij.diff.util.Side import com.intellij.openapi.editor.impl.DocumentImpl -import com.intellij.openapi.progress.DumbProgressIndicator +import junit.framework.TestCase +import java.util.* class UnifiedFragmentBuilderTest : DiffTestCase() { - fun testEquals() { - val builder = createBuilder("A\nB\nC", "A\nB\nC", Side.LEFT) + fun testSimple() { + Test("", "", + ".", + " ") + .run() - assertTrue(builder.isEqual) - assertEquals(builder.text.toString(), "A\nB\nC\n") - assertEmpty(builder.changedLines) - assertEmpty(builder.blocks) + Test("A_B_C", "A_B_C", + "A_B_C", + " _ _ ") + .run() + + // empty document has one line, so it's "modified" case (and not "deleted") + Test("A", "", + "A_.", + "L_R") + .run() + + Test("", "A", + "._A", + "L_R") + .run() + + Test("A_", "", + "A_.", + "L_ ") + .run() + + Test("A_", "B", + "A_._B", + "L_L_R") + .run() + + Test("B_", "B", + "B_.", + " _L") + .run() + + Test("_B", "B", + "._B", + "L_ ") + .run() + + Test("A_A", "B", + "A_A_B", + "L_L_R") + .run() + + Test("A_B_C_D", "A_D", + "A_B_C_D", + " _L_L_ ") + .run() + + Test("X_B_C", "A_B_C", + "X_A_B_C", + "L_R_ _ ") + .run() + + Test("A_B_C", "A_B_Y", + "A_B_C_Y", + " _ _L_R") + .run() + + Test("A_B_C_D_E_F", "A_X_C_D_Y_F", + "A_B_X_C_D_E_Y_F", + " _L_R_ _ _L_R_ ") + .run() + + Test("A_B_C_D_E_F", "A_B_X_C_D_F", + "A_B_X_C_D_E_F", + " _ _R_ _ _L_ ") + .run() + + Test("A_B_C_D_E_F", "A_B_X_Y_E_F", + "A_B_C_D_X_Y_E_F", + " _ _L_L_R_R_ _ ") + .run() + + Test("", "", + ".", + " ") + .changes() + .run() + + Test("A", "B", + "A_B", + "L_R") + .changes(mod(0, 0, 1, 1)) + .runLeft() + + Test("A", "B", + "A", + " ") + .changes() + .runLeft() + + Test("A", "B", + "B", + " ") + .changes() + .runRight() } - fun testWrongEndLineTypoBug() { - val builder = createBuilder("A\nB\nC\nD", "A\nD", Side.RIGHT) + fun testNonFair() { + Test("A_B", "", + "A_B", + " _ ") + .changes() + .runLeft() - assertFalse(builder.isEqual) - assertEquals(builder.text.toString(), "A\nB\nC\nD\n") - assertEquals(builder.changedLines, listOf(LineRange(1, 3))) + Test("A_B", "", + ".", + " ") + .changes() + .runRight() - assertEquals(builder.blocks.size, 1) - val block = builder.blocks[0] - assertEquals(block.line1, 1) - assertEquals(block.line2, 3) - assertEquals(block.range1.start, 1) - assertEquals(block.range1.end, 3) - assertEquals(block.range2.start, 3) - assertEquals(block.range2.end, 3) + Test("A_B", "A_._B", + "A_B", + " _ ") + .changes() + .runLeft() + + Test("A_B", "A_._B", + "A_._B", + " _ _ ") + .changes() + .runRight() + + Test("_._A_._", "X", + "._._A_X_._.", + " _ _L_R_ _ ") + .changes(mod(2, 0, 1, 1)) + .runLeft() + + Test("_._A_._", "X", + "A_X", + "L_R") + .changes(mod(2, 0, 1, 1)) + .runRight() + + Test("A_B_C_D", "X_BC_Y", + "A_X_BC_D_Y", + "L_R_ _L_R") + .changes(mod(0, 0, 1, 1), mod(3, 2, 1, 1)) + .runRight() + + Test("A_B_C_D", "A_BC_Y", + "A_BC_D_Y", + " _ _L_R") + .changes(mod(3, 2, 1, 1)) + .runRight() + + Test("AB_C_DE", "A_B_D_E", + "AB_C_DE", + " _L_ ") + .changes(del(1, 2, 1)) + .runLeft() + + Test("AB_C_DE", "A_B_D_E", + "A_B_C_D_E", + " _ _L_ _ ") + .changes(del(1, 2, 1)) + .runRight() + + Test("AB_DE", "A_B_C_D_E", + "AB_C_DE", + " _R_ ") + .changes(ins(1, 2, 1)) + .runLeft() + + Test("AB_DE", "A_B_C_D_E", + "A_B_C_D_E", + " _ _R_ _ ") + .changes(ins(1, 2, 1)) + .runRight() } - fun testFirstLineChange() { - val builder = createBuilder("X\nB\nC", "A\nB\nC", Side.RIGHT) + private inner class Test(val input1: String, val input2: String, + val result: String, + val lineMapping: String) { + private var customFragments: List? = null - assertFalse(builder.isEqual) - assertEquals(builder.text.toString(), "X\nA\nB\nC\n") - assertEquals(builder.changedLines, listOf(LineRange(0, 1), LineRange(1, 2))) + fun runLeft() { + doRun(Side.LEFT) + } - assertEquals(builder.blocks.size, 1) - val block = builder.blocks[0] - assertEquals(block.line1, 0) - assertEquals(block.line2, 2) - assertEquals(block.range1.start, 0) - assertEquals(block.range1.end, 1) - assertEquals(block.range2.start, 1) - assertEquals(block.range2.end, 2) + fun runRight() { + doRun(Side.RIGHT) + } + + fun run() { + doRun(Side.LEFT, Side.RIGHT) + } + + private fun doRun(vararg sides: Side) { + sides.forEach { side -> + assert(result.length == lineMapping.length) + + val text1 = processText(input1) + val text2 = processText(input2) + + val fragments = if (customFragments != null) customFragments!! + else MANAGER.compareLines(text1, text2, ComparisonPolicy.DEFAULT, INDICATOR) + + val builder = UnifiedFragmentBuilder(fragments, DocumentImpl(text1), DocumentImpl(text2), side) + builder.exec() + + + val lineCount1 = input1.count({ it == '_' }) + 1 + val lineCount2 = input2.count({ it == '_' }) + 1 + val resultLineCount = result.count({ it == '_' }) + 1 + val lineIterable = DiffIterableUtil.create(fragments.map { Range(it.startLine1, it.endLine1, it.startLine2, it.endLine2) }, + lineCount1, lineCount2) + + val expectedText = processText(result) + val actualText = processActualText(builder) + + val expectedMapping = processExpectedLineMapping(lineMapping) + val actualMapping = processActualLineMapping(builder.blocks, resultLineCount) + + val expectedChangedLines = processExpectedChangedLines(lineMapping) + val actualChangedLines = processActualChangedLines(builder.changedLines) + + val expectedMappedLines1 = processExpectedMappedLines(lineIterable, Side.LEFT) + val expectedMappedLines2 = processExpectedMappedLines(lineIterable, Side.RIGHT) + val actualMappedLines1 = processActualMappedLines(builder.convertor1, resultLineCount) + val actualMappedLines2 = processActualMappedLines(builder.convertor2, resultLineCount) + + assertEquals(expectedText, actualText) + assertEquals(expectedMapping, actualMapping) + assertEquals(expectedChangedLines, actualChangedLines) + + if (customFragments == null) { + assertEquals(expectedMappedLines1, actualMappedLines1) + assertEquals(expectedMappedLines2, actualMappedLines2) + } + } + } + + fun changes(vararg ranges: Range): Test { + customFragments = ranges.map { + LineFragmentImpl(it.start1, it.end1, it.start2, it.end2, + -1, -1, -1, -1) + } + return this + } + + private fun processText(text: String): String { + return text.filterNot { it == '.' }.replace('_', '\n') + } + + private fun processActualText(builder: UnifiedFragmentBuilder): String { + return builder.text.toString().removeSuffix("\n") + } + + private fun processExpectedLineMapping(lineMapping: String): LineMapping { + val leftSet = BitSet() + val rightSet = BitSet() + val unchangedSet = BitSet() + + lineMapping.split('_').forEachIndexed { index, line -> + if (!line.isEmpty()) { + val left = line.all { it == 'L' } + val right = line.all { it == 'R' } + val unchanged = line.all { it == ' ' } + + if (left) leftSet.set(index) + else if (right) rightSet.set(index) + else if (unchanged) unchangedSet.set(index) + else TestCase.fail() + } + } + + return LineMapping(leftSet, rightSet, unchangedSet) + } + + private fun processActualLineMapping(blocks: List, lineCount: Int): LineMapping { + val leftSet = BitSet() + val rightSet = BitSet() + val unchangedSet = BitSet() + + blocks.forEach { + leftSet.set(it.range1.start, it.range1.end) + rightSet.set(it.range2.start, it.range2.end) + } + + unchangedSet.set(0, lineCount) + unchangedSet.andNot(leftSet) + unchangedSet.andNot(rightSet) + + return LineMapping(leftSet, rightSet, unchangedSet) + } + + private fun processExpectedChangedLines(lineMapping: String): BitSet { + val expectedMapping = processExpectedLineMapping(lineMapping) + val result = BitSet() + result.or(expectedMapping.left) + result.or(expectedMapping.right) + return result + } + + private fun processActualChangedLines(changedRanges: List): BitSet { + val result = BitSet() + changedRanges.forEach { + result.set(it.start, it.end) + } + return result + } + + private fun processExpectedMappedLines(iterable: DiffIterable, side: Side): BitSet { + val result = BitSet() + DiffIterableUtil.iterateAll(iterable).forEach { pair -> + val range = pair.first + val start = side.select(range.start1, range.start2) + val end = side.select(range.end1, range.end2) + result.set(start, end) + } + return result + } + + private fun processActualMappedLines(convertor: LineNumberConvertor, lineCount: Int): BitSet { + val result = BitSet() + for (i in -5..lineCount + 5) { + val line = convertor.convert(i) + if (line != -1) { + if (result[line]) TestCase.fail() + result.set(line) + } + } + return result + } } - fun testDeletion() { - val builder = createBuilder("A\n", "", Side.LEFT) - - assertFalse(builder.isEqual) - assertEquals(builder.text.toString(), "A\n\n") - assertEquals(builder.changedLines, listOf(LineRange(0, 1))) - - assertEquals(builder.blocks.size, 1) - val block = builder.blocks[0] - assertEquals(block.line1, 0) - assertEquals(block.line2, 1) - assertEquals(block.range1.start, 0) - assertEquals(block.range1.end, 1) - assertEquals(block.range2.start, 1) - assertEquals(block.range2.end, 1) + private fun mod(line1: Int, line2: Int, count1: Int, count2: Int): Range { + assert(count1 != 0) + assert(count2 != 0) + return Range(line1, line1 + count1, line2, line2 + count2) } - - private fun createBuilder(text1: String, text2: String, side: Side): UnifiedFragmentBuilder { - val document1 = DocumentImpl(text1) - val document2 = DocumentImpl(text2) - - val fragments = MANAGER.compareLinesInner(document1.charsSequence, document2.charsSequence, - ComparisonPolicy.DEFAULT, DumbProgressIndicator.INSTANCE) - - val builder = UnifiedFragmentBuilder(fragments, document1, document2, side) - builder.exec() - - return builder + private fun del(line1: Int, line2: Int, count1: Int): Range { + assert(count1 != 0) + return Range(line1, line1 + count1, line2, line2) } + + private fun ins(line1: Int, line2: Int, count2: Int): Range { + assert(count2 != 0) + return Range(line1, line1, line2, line2 + count2) + } + + private data class LineMapping(val left: BitSet, val right: BitSet, val unchanged: BitSet) } diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/PrePushHandler.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/PrePushHandler.java index b0096db7675b..cf8ec8494de0 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/PrePushHandler.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/PrePushHandler.java @@ -59,7 +59,7 @@ public interface PrePushHandler { String getPresentableName(); /** - * Check synchronously if the push operation should be performed or canceled for specified {@link PushDetail}s + * Check synchronously if the push operation should be performed or canceled for specified {@link PushInfo}s *

* Note: it is permissible for a handler to show it's own modal dialogs with specifying * the supplied {@code indicator}'s {@link ProgressIndicator#getModalityState() modality} state. @@ -70,6 +70,6 @@ public interface PrePushHandler { */ @CalledInAny @NotNull - Result handle(@NotNull List pushDetails, @NotNull ProgressIndicator indicator); + Result handle(@NotNull List pushDetails, @NotNull ProgressIndicator indicator); } diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java index c651e6cee30d..5f503e634cdc 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java @@ -524,7 +524,7 @@ public class PushController implements Disposable { @CalledInAny public PrePushHandler.Result executeHandlers(@NotNull ProgressIndicator indicator) throws ProcessCanceledException, HandlerException { if (myHandlers.isEmpty()) return PrePushHandler.Result.OK; - List pushDetails = preparePushDetails(); + List pushDetails = preparePushDetails(); StepsProgressIndicator stepsIndicator = new StepsProgressIndicator(indicator, myHandlers.size()); stepsIndicator.setIndeterminate(false); stepsIndicator.setFraction(0); @@ -588,8 +588,8 @@ public class PushController implements Disposable { } @NotNull - private List preparePushDetails() { - List allDetails = ContainerUtil.newArrayList(); + private List preparePushDetails() { + List allDetails = ContainerUtil.newArrayList(); Collection> repoModels = getSelectedRepoNode(); for (MyRepoModel model : repoModels) { @@ -608,7 +608,7 @@ public class PushController implements Disposable { //sort commits in the time-ascending order Collections.reverse(loadedCommits); - allDetails.add(new PushDetailImpl(model.getRepository(), pushSpec, loadedCommits)); + allDetails.add(new PushInfoImpl(model.getRepository(), pushSpec, loadedCommits)); } return Collections.unmodifiableList(allDetails); } @@ -736,15 +736,15 @@ public class PushController implements Disposable { }) ? commonTarget : null; } - private static class PushDetailImpl implements PushDetail { + private static class PushInfoImpl implements PushInfo { private final Repository myRepository; private final PushSpec myPushSpec; private final List myCommits; - private PushDetailImpl(@NotNull Repository repository, - @NotNull PushSpec spec, - @NotNull List commits) { + private PushInfoImpl(@NotNull Repository repository, + @NotNull PushSpec spec, + @NotNull List commits) { myRepository = repository; myPushSpec = spec; myCommits = commits; @@ -752,19 +752,19 @@ public class PushController implements Disposable { @NotNull @Override - public Repository repository() { + public Repository getRepository() { return myRepository; } @NotNull @Override - public PushSpec pushSpec() { + public PushSpec getPushSpec() { return myPushSpec; } @NotNull @Override - public List commits() { + public List getCommits() { return myCommits; } } diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/PushDetail.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/PushInfo.java similarity index 69% rename from platform/dvcs-impl/src/com/intellij/dvcs/push/PushDetail.java rename to platform/dvcs-impl/src/com/intellij/dvcs/push/PushInfo.java index 471c08b9cf1e..4eef6cf480eb 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/PushDetail.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/PushInfo.java @@ -22,28 +22,27 @@ import org.jetbrains.annotations.NotNull; import java.util.List; /** - * Upcoming push information holder + * Upcoming push information holder for one repository */ -public interface PushDetail { +public interface PushInfo { /** * Repository of the push source */ @NotNull - Repository repository(); + Repository getRepository(); /** - * For a {@link #repository()} specifies what would be pushed and where + * Specifies what would be pushed and where for this repository * * @return push specification */ @NotNull - PushSpec pushSpec(); + PushSpec getPushSpec(); /** * Returns list of commits to be pushed. - * a.e. result of `git log source..target` for updated git branches; empty list for newly created branches. - * Commits should be ordered by commit time (ex: committer time for git); + * Commits are ordered so that the most recent come last, e.g. as in the output of git log source..target but in reverse order */ @NotNull - List commits(); + List getCommits(); } diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java b/platform/dvcs-impl/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java index 839575e63556..f19f6432ad9b 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java @@ -393,14 +393,18 @@ public class BranchActionGroupPopup extends FlatSpeedSearchPopup { @NotNull private final String myToCollapseText; @NotNull private final String myToExpandText; - public MoreAction(@NotNull Project project, int numberOfHiddenNodes, @Nullable String settingName, boolean defaultExpandValue) { + public MoreAction(@NotNull Project project, + int numberOfHiddenNodes, + @Nullable String settingName, + boolean defaultExpandValue, + boolean hasFavorites) { super(); myProject = project; mySettingName = settingName; myDefaultExpandValue = defaultExpandValue; assert numberOfHiddenNodes > 0; myToExpandText = "Show " + numberOfHiddenNodes + " More..."; - myToCollapseText = "Show Only Favorites"; + myToCollapseText = "Show " + (hasFavorites ? "Only Favorites" : "Less"); setExpanded( settingName != null ? PropertiesComponent.getInstance(project).getBoolean(settingName, defaultExpandValue) : defaultExpandValue); } @@ -466,7 +470,9 @@ public class BranchActionGroupPopup extends FlatSpeedSearchPopup { @NotNull DefaultActionGroup parentGroup, @NotNull List actionList, int maxIndex, @Nullable String settingName, boolean defaultExpandValue) { if (actionList.size() > maxIndex) { - MoreAction moreAction = new MoreAction(project, actionList.size() - maxIndex, settingName, defaultExpandValue); + boolean hasFavorites = + actionList.stream().anyMatch(action -> action instanceof BranchActionGroup && ((BranchActionGroup)action).isFavorite()); + MoreAction moreAction = new MoreAction(project, actionList.size() - maxIndex, settingName, defaultExpandValue, hasFavorites); for (int i = 0; i < actionList.size(); i++) { parentGroup.add(i < maxIndex ? actionList.get(i) : new HideableActionGroup(actionList.get(i), moreAction)); } diff --git a/platform/indexing-api/src/com/intellij/psi/search/searches/DefinitionsScopedSearch.java b/platform/indexing-api/src/com/intellij/psi/search/searches/DefinitionsScopedSearch.java index 03cfe5540943..500c000a9cd9 100644 --- a/platform/indexing-api/src/com/intellij/psi/search/searches/DefinitionsScopedSearch.java +++ b/platform/indexing-api/src/com/intellij/psi/search/searches/DefinitionsScopedSearch.java @@ -17,9 +17,11 @@ package com.intellij.psi.search.searches; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.util.Computable; import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; import com.intellij.psi.search.PsiSearchHelper; import com.intellij.psi.search.SearchScope; import com.intellij.util.Processor; @@ -98,11 +100,10 @@ public class DefinitionsScopedSearch extends ExtensibleQueryFactory() { - @Override - public SearchScope compute() { - return myScope.intersectWith(PsiSearchHelper.SERVICE.getInstance(myElement.getProject()).getUseScope(myElement)); - } + return ReadAction.compute(() -> { + PsiFile file = myElement.getContainingFile(); + return myScope.intersectWith( + PsiSearchHelper.SERVICE.getInstance(myElement.getProject()).getUseScope(file != null ? file : myElement)); }); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/TargetElementEvaluatorEx2.java b/platform/lang-impl/src/com/intellij/codeInsight/TargetElementEvaluatorEx2.java index fda13bfafdef..f5811d484907 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/TargetElementEvaluatorEx2.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/TargetElementEvaluatorEx2.java @@ -88,6 +88,10 @@ public abstract class TargetElementEvaluatorEx2 implements TargetElementEvaluato return true; } + /** + * @return a scope where element's implementations (Goto/Show Implementations) should be searched. + * If null is returned, default (module-with-dependents) scope will be used. + */ @Nullable public SearchScope getSearchScope(Editor editor, @NotNull PsiElement element) { return null; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/TargetElementUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/TargetElementUtil.java index cd70174abbe2..5cb5fefd70bd 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/TargetElementUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/TargetElementUtil.java @@ -457,7 +457,10 @@ public class TargetElementUtil extends TargetElementUtilBase { public SearchScope getSearchScope(Editor editor, @NotNull PsiElement element) { TargetElementEvaluatorEx2 evaluator = getElementEvaluatorsEx2(element.getLanguage()); SearchScope result = evaluator != null ? evaluator.getSearchScope(editor, element) : null; - return result != null ? result : PsiSearchHelper.SERVICE.getInstance(element.getProject()).getUseScope(element); + if (result != null) return result; + + PsiFile file = element.getContainingFile(); + return PsiSearchHelper.SERVICE.getInstance(element.getProject()).getUseScope(file != null ? file : element); } protected final LanguageExtension targetElementEvaluator = diff --git a/platform/lang-impl/src/com/intellij/codeInsight/TargetElementUtilBase.java b/platform/lang-impl/src/com/intellij/codeInsight/TargetElementUtilBase.java index 578c684ccd4f..ed9fb72e507b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/TargetElementUtilBase.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/TargetElementUtilBase.java @@ -96,6 +96,9 @@ public abstract class TargetElementUtilBase { public abstract boolean acceptImplementationForReference(@Nullable PsiReference reference, @Nullable PsiElement element); + /** + * @return a scope where element's implementations (Goto/Show Implementations) should be searched + */ @NotNull public abstract SearchScope getSearchScope(Editor editor, @NotNull PsiElement element); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipUtil.java index 24b83c685eee..dc7a9ed89861 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipUtil.java @@ -18,7 +18,6 @@ package com.intellij.codeInsight.daemon.impl; import com.intellij.codeInsight.hint.TooltipController; import com.intellij.codeInsight.hint.TooltipGroup; -import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.editor.Editor; import com.intellij.ui.HintHint; import org.jetbrains.annotations.NotNull; @@ -46,7 +45,6 @@ public class DaemonTooltipUtil { public static void showInfoTooltip(@NotNull final HighlightInfo info, @NotNull Editor editor, final int defaultOffset, final int currentWidth, final boolean requestFocus) { if (info.getToolTip() == null) return; - if (HighlightSeverity.INFORMATION.equals(info.getSeverity())) return; Rectangle visibleArea = editor.getScrollingModel().getVisibleArea(); Point bestPoint = editor.logicalPositionToXY(editor.offsetToLogicalPosition(defaultOffset)); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java index f693233e86df..138064c40cd3 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java @@ -355,13 +355,22 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass .range(psiElement, textRange.getStartOffset(), textRange.getEndOffset()) .description(message) .severity(severity); - if (toolTip != null) b.escapedToolTip(toolTip); + boolean invisible = HighlightSeverity.INFORMATION.equals(severity); + if (toolTip != null && !invisible) b.escapedToolTip(toolTip); if (attributes != null) b.textAttributes(attributes); if (problemDescriptor.isAfterEndOfLine()) b.endOfLine(); if (isFileLevel) b.fileLevelAnnotation(); if (problemDescriptor.getProblemGroup() != null) b.problemGroup(problemDescriptor.getProblemGroup()); + if (!invisible) return b.create(); - return b.create(); + HighlightInfo info = b.createUnconditionally(); + for (HighlightInfoFilter filter : HighlightInfoFilter.EXTENSION_POINT_NAME.getExtensions()) { + if (!(filter instanceof HighlightInfoFilterImpl) && !filter.accept(info, myFile)) { + return null; + } + } + info.psiElement = psiElement; + return info; } private final Map ranges2markersCache = new THashMap<>(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/JoinLinesHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/JoinLinesHandler.java index a541b4c1e030..9c92e968866c 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/JoinLinesHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/JoinLinesHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -142,6 +142,8 @@ public class JoinLinesHandler extends EditorActionHandler { @NotNull PsiFile psiFile, int startLine, Ref caretRestoreOffset) { + if (startLine >= doc.getLineCount() - 1) return; + docManager.doPostponedOperationsAndUnblockDocument(doc); docManager.commitDocument(doc); CharSequence text = doc.getCharsSequence(); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/ExportHTMLAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/ExportHTMLAction.java index fa5374f4d1ec..e834de735305 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/ExportHTMLAction.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/ExportHTMLAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -172,9 +172,9 @@ public class ExportHTMLAction extends AnAction implements DumbAware { if (profileName != null) { element.setAttribute(InspectionApplication.PROFILE, profileName); } - JDOMUtil.writeParent(element, - new File(outputDirectoryName, InspectionApplication.DESCRIPTIONS + InspectionApplication.XML_EXTENSION), - CodeStyleSettingsManager.getSettings(null).getLineSeparator()); + JDOMUtil.write(element, + new File(outputDirectoryName, InspectionApplication.DESCRIPTIONS + InspectionApplication.XML_EXTENSION), + CodeStyleSettingsManager.getSettings(null).getLineSeparator()); } catch (IOException e) { ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog(myView, e.getMessage())); diff --git a/platform/lang-impl/src/com/intellij/execution/actions/BaseRunConfigurationAction.java b/platform/lang-impl/src/com/intellij/execution/actions/BaseRunConfigurationAction.java index 121515c68f71..ebba0dbe0364 100644 --- a/platform/lang-impl/src/com/intellij/execution/actions/BaseRunConfigurationAction.java +++ b/platform/lang-impl/src/com/intellij/execution/actions/BaseRunConfigurationAction.java @@ -70,9 +70,7 @@ public abstract class BaseRunConfigurationAction extends ActionGroup { for (final ConfigurationFromContext fromContext : producers) { final ConfigurationType configurationType = fromContext.getConfigurationType(); final RunConfiguration configuration = fromContext.getConfiguration(); - final String actionName = configuration instanceof LocatableConfiguration - ? StringUtil.unquoteString(suggestRunActionName((LocatableConfiguration)configuration)) - : configurationType.getDisplayName(); + final String actionName = childActionName(configurationType, configuration); final AnAction anAction = new AnAction(actionName, configurationType.getDisplayName(), configuration.getIcon()) { @Override public void actionPerformed(AnActionEvent e) { @@ -140,7 +138,7 @@ public abstract class BaseRunConfigurationAction extends ActionGroup { @Override @NotNull public String getTextFor(final ConfigurationFromContext producer) { - return StringUtil.notNullize(producer.getConfiguration().getName(), producer.getConfigurationType().getDisplayName()); + return childActionName(producer.getConfigurationType(), producer.getConfiguration()); } @Override @@ -220,6 +218,13 @@ public abstract class BaseRunConfigurationAction extends ActionGroup { return ProgramRunnerUtil.shortenName(configuration.getName(), 0); } + @NotNull + private static String childActionName(ConfigurationType configurationType, RunConfiguration configuration) { + return configuration instanceof LocatableConfiguration + ? StringUtil.unquoteString(suggestRunActionName((LocatableConfiguration)configuration)) + : configurationType.getDisplayName(); + } + protected abstract void updatePresentation(Presentation presentation, @NotNull String actionText, ConfigurationContext context); } diff --git a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java index 1e9edb5cca3e..5cb8a77b4bd6 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java @@ -101,7 +101,6 @@ import com.intellij.psi.codeStyle.NameUtil; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.ui.*; import com.intellij.ui.awt.RelativePoint; -import com.intellij.ui.border.CustomLineBorder; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBList; import com.intellij.ui.components.JBScrollPane; @@ -124,6 +123,7 @@ import org.jetbrains.annotations.Nullable; import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.swing.*; +import javax.swing.border.Border; import javax.swing.event.DocumentEvent; import java.awt.*; import java.awt.event.*; @@ -152,6 +152,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA public static final int MAX_SEARCH_EVERYWHERE_HISTORY = 50; public static final int MAX_TOP_HIT = 15; private static final Logger LOG = Logger.getInstance("#" + SearchEverywhereAction.class.getName()); + private static final Border RENDERER_BORDER = JBUI.Borders.empty(0, 0, 2, 0); private SearchEverywhereAction.MyListRenderer myRenderer; MySearchTextField myPopupField; @@ -1099,14 +1100,17 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA cmp.setBackground(UIUtil.getListBackground(isSelected)); bg = cmp.getBackground(); } - myMainPanel.setBorder(new CustomLineBorder(bg, 0, 0, 2, 0)); String title = getModel().titleIndex.getTitle(index); myMainPanel.removeAll(); if (title != null) { myTitle.setText(title); myMainPanel.add(createTitle(" " + title), BorderLayout.NORTH); } - myMainPanel.add(cmp, BorderLayout.CENTER); + JPanel wrapped = new JPanel(new BorderLayout()); + wrapped.setBackground(bg); + wrapped.setBorder(RENDERER_BORDER); + wrapped.add(cmp, BorderLayout.CENTER); + myMainPanel.add(wrapped, BorderLayout.CENTER); if (cmp instanceof Accessible) { myMainPanel.setAccessible((Accessible)cmp); } diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPSIPane.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPSIPane.java index b268f54425d3..7db83f57afb1 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPSIPane.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPSIPane.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -255,14 +255,18 @@ public abstract class AbstractProjectViewPSIPane extends AbstractProjectViewPane @NotNull public ActionCallback selectCB(Object element, VirtualFile file, boolean requestFocus) { if (file != null) { - BaseProjectTreeBuilder builder = (BaseProjectTreeBuilder)getTreeBuilder(); - // actually, getInitialized().doWhenDone() should be called by builder internally - // this will be done in 2017 - return builder.getInitialized().doWhenDone(() -> builder.select(element, file, requestFocus)); + beforeSelect().doWhenDone(() -> ((BaseProjectTreeBuilder)getTreeBuilder()).select(element, file, requestFocus)); } return ActionCallback.DONE; } + @NotNull + public ActionCallback beforeSelect() { + // actually, getInitialized().doWhenDone() should be called by builder internally + // this will be done in 2017 + return getTreeBuilder().getInitialized(); + } + @NotNull protected BaseProjectTreeBuilder createBuilder(DefaultTreeModel treeModel) { return new ProjectTreeBuilder(myProject, myTree, treeModel, null, (ProjectAbstractTreeStructureBase)myTreeStructure) { diff --git a/platform/lang-impl/src/com/intellij/internal/DumpIntentionsAction.java b/platform/lang-impl/src/com/intellij/internal/DumpIntentionsAction.java index d3408b33cae9..146203e41f00 100644 --- a/platform/lang-impl/src/com/intellij/internal/DumpIntentionsAction.java +++ b/platform/lang-impl/src/com/intellij/internal/DumpIntentionsAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2017 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,15 +25,13 @@ import com.intellij.codeInsight.intention.impl.config.IntentionManagerSettings; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.fileChooser.FileChooser; import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; -import com.intellij.openapi.util.JDOMUtil; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.VfsUtil; -import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.project.DumbAware; -import org.jdom.Document; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.VfsUtilCore; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.JdomKt; import org.jdom.Element; import java.io.File; @@ -53,7 +51,7 @@ public class DumpIntentionsAction extends AnAction implements DumbAware { FileChooser.chooseFile(FileChooserDescriptorFactory.createSingleFolderDescriptor(), e.getData(CommonDataKeys.PROJECT), null); if (file != null) { final List list = IntentionManagerSettings.getInstance().getMetaData(); - final File root = VfsUtil.virtualToIoFile(file); + final File root = VfsUtilCore.virtualToIoFile(file); Element el = new Element("root"); Map categoryMap = new HashMap<>(); for (IntentionActionMetaData metaData : list) { @@ -73,7 +71,7 @@ public class DumpIntentionsAction extends AnAction implements DumbAware { } try { - JDOMUtil.writeDocument(new Document(el), new File(root, "intentions.xml"), "\n"); + JdomKt.write(el, root.toPath().resolve("intentions.xml")); } catch (IOException e1) { e1.printStackTrace(); diff --git a/platform/lang-impl/src/com/intellij/platform/templates/LocalArchivedTemplate.java b/platform/lang-impl/src/com/intellij/platform/templates/LocalArchivedTemplate.java index a0b231cb1f5a..cbf85904fbd5 100644 --- a/platform/lang-impl/src/com/intellij/platform/templates/LocalArchivedTemplate.java +++ b/platform/lang-impl/src/com/intellij/platform/templates/LocalArchivedTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -21,12 +21,11 @@ import com.intellij.openapi.module.ModuleType; import com.intellij.openapi.module.ModuleTypeManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.IconLoader; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.io.StreamUtil; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.openapi.vfs.VirtualFile; -import org.jdom.Document; +import com.intellij.util.JdomKt; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -67,7 +66,7 @@ public class LocalArchivedTemplate extends ArchivedProjectTemplate { String s = readEntry(TEMPLATE_DESCRIPTOR); if (s != null) { try { - Element templateElement = JDOMUtil.loadDocument(s).getRootElement(); + Element templateElement = JdomKt.loadElement(s); populateFromElement(templateElement); String iconPath = templateElement.getChildText("icon-path"); if (iconPath != null) { @@ -82,7 +81,7 @@ public class LocalArchivedTemplate extends ArchivedProjectTemplate { String meta = readEntry(META_TEMPLATE_DESCRIPTOR_PATH); if (meta != null) { try { - Element templateElement = JDOMUtil.loadDocument(meta).getRootElement(); + Element templateElement = JdomKt.loadElement(meta); String unencoded = templateElement.getAttributeValue(UNENCODED_ATTRIBUTE); if (unencoded != null) { myEscaped = !Boolean.valueOf(unencoded); @@ -171,8 +170,7 @@ public class LocalArchivedTemplate extends ArchivedProjectTemplate { String iml = template.readEntry(".iml"); if (iml == null) return ModuleType.EMPTY; try { - Document document = JDOMUtil.loadDocument(iml); - String type = document.getRootElement().getAttributeValue(Module.ELEMENT_TYPE); + String type = JdomKt.loadElement(iml).getAttributeValue(Module.ELEMENT_TYPE); return ModuleTypeManager.getInstance().findByID(type); } catch (Exception e) { diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/header/InspectionToolsConfigurable.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/header/InspectionToolsConfigurable.java index 08e7d145d831..3f7dc519af2e 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/header/InspectionToolsConfigurable.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/header/InspectionToolsConfigurable.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -41,7 +41,6 @@ import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.JDOMUtil; -import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.profile.codeInspection.BaseInspectionProfileManager; @@ -51,6 +50,7 @@ import com.intellij.profile.codeInspection.ui.ErrorsConfigurable; import com.intellij.profile.codeInspection.ui.SingleInspectionProfilePanel; import com.intellij.ui.IdeBorderFactory; import com.intellij.util.Alarm; +import com.intellij.util.JdomKt; import com.intellij.util.SmartList; import com.intellij.util.ui.JBInsets; import com.intellij.util.ui.JBUI; @@ -62,8 +62,10 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; -import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.*; import java.util.List; import java.util.regex.Matcher; @@ -361,14 +363,14 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable InspectionProfileImpl profile = getSelectedObject(); LOG.assertTrue(true); Element element = profile.writeScheme(false); - File file = new File(FileUtil.toSystemDependentName(dir.getPath()), sanitizeFileName(profile.getName()) + ".xml"); - if (file.isFile() && + Path file = Paths.get(dir.getPath(), sanitizeFileName(profile.getName()) + ".xml"); + if (Files.isRegularFile(file.toAbsolutePath()) && Messages.showOkCancelDialog(wholePanel, "File \'" + file + "\' already exist. Do you want to overwrite it?", "Warning", Messages.getQuestionIcon()) != Messages.OK) { return; } - JDOMUtil.writeParent(element, file, "\n"); + JdomKt.write(element, file); } catch (IOException e1) { LOG.error(e1); diff --git a/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java b/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java index 343051d96c9c..23c49f40a720 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java +++ b/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java @@ -23,6 +23,8 @@ import com.intellij.ide.DataManager; import com.intellij.lang.Language; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ex.ApplicationManagerEx; +import com.intellij.openapi.application.impl.ApplicationImpl; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.command.UndoConfirmationPolicy; import com.intellij.openapi.command.undo.BasicUndoableAction; @@ -40,6 +42,7 @@ import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.EmptyRunnable; import com.intellij.openapi.util.Factory; import com.intellij.openapi.util.Ref; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.impl.status.StatusBarUtil; import com.intellij.psi.PsiDocumentManager; @@ -149,6 +152,7 @@ public abstract class BaseRefactoringProcessor implements Runnable { */ protected abstract void performRefactoring(@NotNull UsageInfo[] usages); + @NotNull protected abstract String getCommandName(); protected void doRun() { @@ -464,34 +468,38 @@ public abstract class BaseRefactoringProcessor implements Runnable { ProgressManager.getInstance().runProcessWithProgressSynchronously(prepareHelpersRunnable, "Prepare ...", false, myProject); - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override - public void run() { - final String refactoringId = getRefactoringId(); + Runnable performRefactoringRunnable = () -> { + final String refactoringId = getRefactoringId(); + if (refactoringId != null) { + RefactoringEventData data = getBeforeData(); + if (data != null) { + data.addUsages(usageInfoSet); + } + myProject.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringStarted(refactoringId, data); + } + + try { if (refactoringId != null) { - RefactoringEventData data = getBeforeData(); - if (data != null) { - data.addUsages(usageInfoSet); - } - myProject.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringStarted(refactoringId, data); + UndoableAction action1 = new UndoRefactoringAction(myProject, refactoringId); + UndoManager.getInstance(myProject).undoableActionPerformed(action1); } - try { - if (refactoringId != null) { - UndoableAction action = new UndoRefactoringAction(myProject, refactoringId); - UndoManager.getInstance(myProject).undoableActionPerformed(action); - } - - performRefactoring(writableUsageInfos); - } - finally { - if (refactoringId != null) { - myProject.getMessageBus() - .syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringDone(refactoringId, getAfterData(writableUsageInfos)); - } + performRefactoring(writableUsageInfos); + } + finally { + if (refactoringId != null) { + myProject.getMessageBus() + .syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringDone(refactoringId, getAfterData(writableUsageInfos)); } } - }); + }; + ApplicationImpl app = (ApplicationImpl)ApplicationManagerEx.getApplicationEx(); + if (Registry.is("run.refactorings.under.progress")) { + app.runWriteActionWithProgressInDispatchThread(getCommandName(), myProject, null, null, indicator -> performRefactoringRunnable.run()); + } + else { + app.runWriteAction(performRefactoringRunnable); + } DumbService.getInstance(myProject).completeJustSubmittedTasks(); @@ -500,12 +508,7 @@ public abstract class BaseRefactoringProcessor implements Runnable { e.getKey().performOperation(myProject, e.getValue()); } myTransaction.commit(); - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override - public void run() { - performPsiSpoilingRefactoring(); - } - }); + app.runWriteAction(() -> performPsiSpoilingRefactoring()); } finally { action.finish(); diff --git a/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesHandler.java b/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesHandler.java index ac914491fcc3..df04bc35708a 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesHandler.java +++ b/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesHandler.java @@ -44,6 +44,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.IOException; +import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Set; @@ -136,7 +137,10 @@ public class CopyFilesOrDirectoriesHandler extends CopyHandlerDelegateBase { return; } - copyImpl(elements, newName, targetDirectory, false, openInEditor); + SmartPointerManager manager = SmartPointerManager.getInstance(project); + copyImpl(Arrays.stream(elements) + .map(el -> manager.createSmartPsiElementPointer(el)) + .toArray(SmartPsiElementPointer[]::new), newName, targetDirectory, false, openInEditor); } } @@ -160,7 +164,10 @@ public class CopyFilesOrDirectoriesHandler extends CopyHandlerDelegateBase { CopyFilesOrDirectoriesDialog dialog = new CopyFilesOrDirectoriesDialog(elements, null, element.getProject(), true); if (dialog.showAndGet()) { String newName = dialog.getNewName(); - copyImpl(elements, newName, targetDirectory, true, true); + SmartPointerManager manager = SmartPointerManager.getInstance(element.getProject()); + copyImpl(Arrays.stream(elements) + .map(el -> manager.createSmartPsiElementPointer(el)) + .toArray(SmartPsiElementPointer[]::new), newName, targetDirectory, true, true); } } @@ -203,7 +210,7 @@ public class CopyFilesOrDirectoriesHandler extends CopyHandlerDelegateBase { * @param targetDirectory * @param openInEditor */ - private static void copyImpl(@NotNull final PsiElement[] elements, + private static void copyImpl(@NotNull final SmartPsiElementPointer[] elements, @Nullable final String newName, @NotNull final PsiDirectory targetDirectory, final boolean doClone, @@ -225,8 +232,10 @@ public class CopyFilesOrDirectoriesHandler extends CopyHandlerDelegateBase { try { PsiFile firstFile = null; final int[] choice = elements.length > 1 || elements[0] instanceof PsiDirectory ? new int[]{-1} : null; - for (PsiElement element : elements) { - PsiFile f = copyToDirectory((PsiFileSystemItem)element, newName, targetDirectory, choice, title); + for (SmartPsiElementPointer element : elements) { + PsiElement psiElement = element.getElement(); + if (psiElement == null) continue; + PsiFile f = copyToDirectory((PsiFileSystemItem)psiElement, newName, targetDirectory, choice, title); if (firstFile == null) { firstFile = f; } diff --git a/platform/lang-impl/src/com/intellij/webcore/packaging/InstalledPackagesPanel.java b/platform/lang-impl/src/com/intellij/webcore/packaging/InstalledPackagesPanel.java index de1d102c51cb..148834789e93 100644 --- a/platform/lang-impl/src/com/intellij/webcore/packaging/InstalledPackagesPanel.java +++ b/platform/lang-impl/src/com/intellij/webcore/packaging/InstalledPackagesPanel.java @@ -152,6 +152,7 @@ public class InstalledPackagesPanel extends JPanel { new PackageManagementService.Listener() { @Override public void operationStarted(String packageName) { + myNotificationArea.hide(); myPackagesTable.setPaintBusy(true); } diff --git a/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java b/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java index 7b4b7dbce655..c5fd63f9a7c2 100644 --- a/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java +++ b/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java @@ -250,6 +250,7 @@ public class ManagePackagesDialog extends DialogWrapper { } private void handleInstallationStarted(String packageName) { + myNotificationArea.hide(); setDownloadStatus(true); myCurrentlyInstalling.add(packageName); if (myPackageListener != null) { diff --git a/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java b/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java index 1713920d1f26..20efec02a10d 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java @@ -20,7 +20,6 @@ import com.intellij.openapi.util.Disposer; import com.intellij.ui.components.JBLayeredPane; import com.intellij.ui.components.panels.NonOpaquePanel; import com.intellij.util.Alarm; -import com.intellij.util.SystemProperties; import com.intellij.util.ui.Animator; import com.intellij.util.ui.AsyncProcessIcon; import com.intellij.util.ui.UIUtil; @@ -75,27 +74,18 @@ public class LoadingDecorator { myPane.add(content, JLayeredPane.DEFAULT_LAYER, 0); - if (!SystemProperties.isTrueSmoothScrollingEnabled()) { - myPane.add(myLoadingLayer, JLayeredPane.DRAG_LAYER, 1); - } Disposer.register(parent, myLoadingLayer.myProgress); } + /** + * Removes a loading layer to restore a blit-accelerated scrolling. + */ private void hideLoadingLayer() { - if (SystemProperties.isTrueSmoothScrollingEnabled()) { - myPane.remove(myLoadingLayer); - } + myPane.remove(myLoadingLayer); myLoadingLayer.setVisible(false); } - public void setLoadingLayerVisible(boolean visible, boolean takeSnapshot) { - if (SystemProperties.isTrueSmoothScrollingEnabled() && visible) { - setLoadingLayerPresent(); - } - myLoadingLayer.setVisible(visible, takeSnapshot); - } - /* Placing the invisible layer on top of JViewport suppresses blit-accelerated scrolling as JViewport.canUseWindowBlitter() doesn't take component's visibility into account. @@ -103,8 +93,8 @@ public class LoadingDecorator { Blit-acceleration copies as much of the rendered area as possible and then repaints only newly exposed region. This helps to improve scrolling performance and to reduce CPU usage (especially if drawing is compute-intensive). */ - private void setLoadingLayerPresent() { - if (myPane.getComponentCount() < 2) { + private void addLoadingLayerOnDemand() { + if (myPane != myLoadingLayer.getParent()) { myPane.add(myLoadingLayer, JLayeredPane.DRAG_LAYER, 1); } } @@ -145,7 +135,8 @@ public class LoadingDecorator { } protected void _startLoading(final boolean takeSnapshot) { - setLoadingLayerVisible(true, takeSnapshot); + addLoadingLayerOnDemand(); + myLoadingLayer.setVisible(true, takeSnapshot); } public void stopLoading() { @@ -154,7 +145,7 @@ public class LoadingDecorator { if (!isLoading()) return; - setLoadingLayerVisible(false, false); + myLoadingLayer.setVisible(false, false); } diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java index cd643eb17a29..9cf532cfbc84 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java @@ -1688,7 +1688,7 @@ public class Messages { } } - protected static class InputDialog extends MessageDialog { + public static class InputDialog extends MessageDialog { protected JTextComponent myField; private final InputValidator myValidator; diff --git a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java index 120f8a30dc71..0b0066a7f814 100644 --- a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java +++ b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java @@ -852,7 +852,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible, Co } if (attributes.isSearchMatch()) { - searchMatches.add(new Object[]{(int)offset, (int)(offset + fragmentWidth), textBaseline, myFragments.get(i), g.getFont(), attributes}); + searchMatches.add(new Object[]{offset, offset + fragmentWidth, (float)textBaseline, myFragments.get(i), g.getFont(), attributes}); } offset = endOffset; @@ -870,12 +870,12 @@ public class SimpleColoredComponent extends JComponent implements Accessible, Co // draw search matches after all for (final Object[] info : searchMatches) { - Integer x1 = (Integer)info[0]; - Integer x2 = (Integer)info[1]; - UIUtil.drawSearchMatch(g, x1, x2, getHeight()); + float x1 = (float)info[0]; + float x2 = (float)info[1]; + UIUtil.drawSearchMatch(g, (int)x1, (int)x2, getHeight()); g.setFont((Font)info[4]); - Integer baseline = (Integer)info[2]; + float baseline = (float)info[2]; String text = (String)info[3]; if (shouldDrawMacShadow()) { g.setColor(SHADOW_COLOR); @@ -886,7 +886,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible, Co g.drawString(text, x1, baseline); if (((SimpleTextAttributes)info[5]).isStrikeout()) { - EffectPainter.STRIKE_THROUGH.paint(g, x1, baseline, x2 - x1, getCharHeight(g), g.getFont()); + EffectPainter.STRIKE_THROUGH.paint(g, (int)x1, (int)baseline, (int)(x2 - x1), getCharHeight(g), g.getFont()); } } return (int)offset; diff --git a/platform/platform-api/src/com/intellij/ui/components/DefaultScrollBarUI.java b/platform/platform-api/src/com/intellij/ui/components/DefaultScrollBarUI.java index 465082ebd351..234f9d607255 100644 --- a/platform/platform-api/src/com/intellij/ui/components/DefaultScrollBarUI.java +++ b/platform/platform-api/src/com/intellij/ui/components/DefaultScrollBarUI.java @@ -195,6 +195,7 @@ class DefaultScrollBarUI extends ScrollBarUI { myScrollBar = (JScrollBar)c; ScrollColorProducer.setBackground(c); ScrollColorProducer.setForeground(c); + myScrollBar.setOpaque(false); myScrollBar.setFocusable(false); myScrollBar.addMouseListener(myListener); myScrollBar.addMouseMotionListener(myListener); diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java index 64d0db639e2d..2df72babd5a9 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java @@ -246,7 +246,7 @@ public class PluginManager extends PluginManagerCore { } if (pluginId != null && !CORE_PLUGIN_ID.equals(pluginId.getIdString())) { - throw new StartupAbortedException(new PluginException(t, pluginId)); + throw new StartupAbortedException("Fatal error initializing plugin " + pluginId.getIdString(), new PluginException(t, pluginId)); } else { throw new StartupAbortedException("Fatal error initializing '" + componentClassName + "'", t); diff --git a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java index 9ff02ff7a5a9..133890e04ebe 100644 --- a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java +++ b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java @@ -44,7 +44,6 @@ import com.intellij.ui.CustomProtocolHandler; import com.intellij.ui.Splash; import com.intellij.util.ArrayUtil; import com.intellij.util.IncorrectOperationException; -import com.intellij.util.SystemProperties; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -162,7 +161,7 @@ public class IdeaApplication { True double buffering is needed to eliminate tearing on blit-accelerated scrolling and to restore frame buffer content without the usual repainting, even when the EDT is blocked. */ - if (!SystemProperties.isTrueSmoothScrollingEnabled() && Patches.SUN_BUG_ID_6209673) { + if (Patches.REPAINT_MANAGER_LEAK) { RepaintManager.setCurrentManager(new IdeRepaintManager()); } diff --git a/platform/platform-impl/src/com/intellij/internal/inspector/UiInspectorAction.java b/platform/platform-impl/src/com/intellij/internal/inspector/UiInspectorAction.java index a75588f1f303..efbe49b70559 100644 --- a/platform/platform-impl/src/com/intellij/internal/inspector/UiInspectorAction.java +++ b/platform/platform-impl/src/com/intellij/internal/inspector/UiInspectorAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -15,6 +15,8 @@ */ package com.intellij.internal.inspector; +import com.intellij.ide.ui.AntialiasingType; +import com.intellij.ide.ui.UISettings; import com.intellij.notification.Notification; import com.intellij.notification.NotificationType; import com.intellij.notification.Notifications; @@ -24,6 +26,7 @@ import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.roots.ui.configuration.actions.IconWithTextAction; import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.openapi.ui.GraphicsConfig; import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.ui.StripeTable; import com.intellij.openapi.util.Disposer; @@ -563,6 +566,7 @@ public class UiInspectorAction extends ToggleAction implements DumbAware { @Override protected void paintComponent(final Graphics g) { Graphics2D g2d = (Graphics2D)g; + GraphicsConfig config = new GraphicsConfig(g).setAntialiasing(UISettings.getShadowInstance().getIdeAAType() != AntialiasingType.OFF); Rectangle bounds = getBounds(); g2d.setColor(getBackground()); @@ -599,6 +603,8 @@ public class UiInspectorAction extends ToggleAction implements DumbAware { g2d.drawRect(innerX - boxSize * 2, innerY - boxSize * 2, innerWidth + boxSize * 4, innerHeight + boxSize * 4); drawInsets(g2d, fm, "insets", myInsets, boxSize * 2, fontHeight, innerX, innerY, innerWidth, innerHeight); + + config.restore(); } private static void drawInsets(Graphics2D g2d, FontMetrics fm, String name, Insets insets, int offset, int fontHeight, int innerX, int innerY, int innerWidth, int innerHeight) { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index b0e982271d5a..b6a0f60f50fd 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -1525,7 +1525,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi finally { updatingSize = false; } - }, __->isDisposed()); + }, ModalityState.any(), __->isDisposed()); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java index 97cc7197ae2c..6624e7004b4a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java @@ -756,11 +756,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent } private static boolean isDetectable(@NotNull final VirtualFile file) { - if (file.isDirectory() || !file.isValid() || file.is(VFileProperty.SPECIAL)) { - return false; - } - long length = file.getLength(); - if (length == 0 || length >= FileUtilRt.LARGE_FOR_CONTENT_LOADING) { + if (file.isDirectory() || !file.isValid() || file.is(VFileProperty.SPECIAL) || file.getLength() == 0) { // for empty file there is still hope its type will change return false; } diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorExBase.java b/platform/platform-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorExBase.java index 2c839151d572..24c8f58efbf5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorExBase.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorExBase.java @@ -30,55 +30,7 @@ import java.util.List; public class AbstractProgressIndicatorExBase extends AbstractProgressIndicatorBase implements ProgressIndicatorEx { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.progress.util.ProgressIndicatorBase"); - private static final IndicatorAction CHECK_CANCELED_ACTION = new IndicatorAction() { - @Override - public void execute(@NotNull ProgressIndicatorEx each) { - each.checkCanceled(); - } - }; - private static final IndicatorAction STOP_ACTION = new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.stop(); - } - }; - private static final IndicatorAction START_ACTION = new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.start(); - } - }; - private static final IndicatorAction CANCEL_ACTION = new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.cancel(); - } - }; - private static final IndicatorAction PUSH_ACTION = new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.pushState(); - } - }; - private static final IndicatorAction POP_ACTION = new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.popState(); - } - }; - private static final IndicatorAction STARTNC_ACTION = new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.startNonCancelableSection(); - } - }; - private static final IndicatorAction FINISHNC_ACTION = new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.finishNonCancelableSection(); - } - }; - protected final boolean myReusable; + private final boolean myReusable; private volatile boolean myModalityEntered; private volatile List myStateDelegates; private volatile WeakList myFinished; @@ -97,7 +49,7 @@ public class AbstractProgressIndicatorExBase extends AbstractProgressIndicatorBa public void start() { synchronized (this) { super.start(); - delegateRunningChange(START_ACTION); + delegateRunningChange(ProgressIndicator::start); } myWasStarted = true; @@ -127,7 +79,7 @@ public class AbstractProgressIndicatorExBase extends AbstractProgressIndicatorBa @Override public void stop() { super.stop(); - delegateRunningChange(STOP_ACTION); + delegateRunningChange(ProgressIndicator::stop); exitModality(); } @@ -147,12 +99,7 @@ public class AbstractProgressIndicatorExBase extends AbstractProgressIndicatorBa @Override public void cancel() { super.cancel(); - delegateRunningChange(CANCEL_ACTION); - } - - @Override - public boolean isCanceled() { - return super.isCanceled(); + delegateRunningChange(ProgressIndicator::cancel); } @Override @@ -168,12 +115,7 @@ public class AbstractProgressIndicatorExBase extends AbstractProgressIndicatorBa } if (!finished.addIfAbsent(task)) return; - delegateRunningChange(new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.finish(task); - } - }); + delegateRunningChange(each -> each.finish(task)); } @Override @@ -198,71 +140,56 @@ public class AbstractProgressIndicatorExBase extends AbstractProgressIndicatorBa public final void checkCanceled() { super.checkCanceled(); - delegate(CHECK_CANCELED_ACTION); + delegate(ProgressIndicator::checkCanceled); } @Override public void setText(final String text) { super.setText(text); - delegateProgressChange(new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.setText(text); - } - }); + delegateProgressChange(each -> each.setText(text)); } @Override public void setText2(final String text) { super.setText2(text); - delegateProgressChange(new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.setText2(text); - } - }); + delegateProgressChange(each -> each.setText2(text)); } @Override public void setFraction(final double fraction) { super.setFraction(fraction); - delegateProgressChange(new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.setFraction(fraction); - } - }); + delegateProgressChange(each -> each.setFraction(fraction)); } @Override public synchronized void pushState() { super.pushState(); - delegateProgressChange(PUSH_ACTION); + delegateProgressChange(ProgressIndicator::pushState); } @Override public synchronized void popState() { super.popState(); - delegateProgressChange(POP_ACTION); + delegateProgressChange(ProgressIndicator::popState); } @Override public void startNonCancelableSection() { super.startNonCancelableSection(); - delegateProgressChange(STARTNC_ACTION); + delegateProgressChange(ProgressIndicator::startNonCancelableSection); } @Override public void finishNonCancelableSection() { super.finishNonCancelableSection(); - delegateProgressChange(FINISHNC_ACTION); + delegateProgressChange(ProgressIndicator::finishNonCancelableSection); } @Override @@ -274,12 +201,7 @@ public class AbstractProgressIndicatorExBase extends AbstractProgressIndicatorBa public void setIndeterminate(final boolean indeterminate) { super.setIndeterminate(indeterminate); - delegateProgressChange(new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.setIndeterminate(indeterminate); - } - }); + delegateProgressChange(each -> each.setIndeterminate(indeterminate)); } @Override @@ -342,6 +264,7 @@ public class AbstractProgressIndicatorExBase extends AbstractProgressIndicatorBa return myWasStarted; } + @FunctionalInterface protected interface IndicatorAction { void execute(@NotNull ProgressIndicatorEx each); } diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/impl/HeadlessDialog.java b/platform/platform-impl/src/com/intellij/openapi/ui/impl/HeadlessDialog.java index 6065e057c54d..420a78a6e15d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/impl/HeadlessDialog.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/impl/HeadlessDialog.java @@ -33,6 +33,7 @@ import java.awt.event.MouseMotionListener; @SuppressWarnings("ConstantConditions") class HeadlessDialog implements AbstractDialog { @NotNull private final DialogWrapper myWrapper; + private String myTitle; HeadlessDialog(@NotNull DialogWrapper wrapper) { myWrapper = wrapper; @@ -113,7 +114,7 @@ class HeadlessDialog implements AbstractDialog { @Override public String getTitle() { - return null; + return myTitle; } @Override @@ -141,6 +142,7 @@ class HeadlessDialog implements AbstractDialog { @Override public void setTitle(String title) { + myTitle = title; } @Override diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/ShowUpdateInfoDialogAction.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/ShowUpdateInfoDialogAction.java index d813d34d191b..0e16b1d193f6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/ShowUpdateInfoDialogAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/ShowUpdateInfoDialogAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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,7 @@ package com.intellij.openapi.updateSettings.impl; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.application.ApplicationInfo; -import com.intellij.openapi.util.JDOMUtil; +import com.intellij.util.JdomKt; import java.util.Collections; @@ -32,11 +32,10 @@ public class ShowUpdateInfoDialogAction extends AnAction { public void actionPerformed(AnActionEvent e) { try { myShowBigData = ! myShowBigData; - UpdateChannel channel = new UpdateChannel(JDOMUtil.loadDocument(getXML(myShowBigData)).getRootElement()); + UpdateChannel channel = new UpdateChannel(JdomKt.loadElement(getXML(myShowBigData))); BuildInfo newBuild = channel.getBuilds().get(0); PatchInfo patchInfo = new PatchInfo( - JDOMUtil.loadDocument("") - .getRootElement()); + JdomKt.loadElement("")); new UpdateInfoDialog(channel, newBuild, patchInfo, true, UpdateSettings.getInstance().canUseSecureConnection(), Collections.emptyList(), Collections.emptyList()).show(); } diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/pluginsAdvertisement/PluginsAdvertiser.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/pluginsAdvertisement/PluginsAdvertiser.java index 3003f665547e..1892e1bf9f8e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/pluginsAdvertisement/PluginsAdvertiser.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/pluginsAdvertisement/PluginsAdvertiser.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -47,7 +47,6 @@ import com.intellij.util.io.HttpRequests; import com.intellij.util.xmlb.XmlSerializer; import com.intellij.util.xmlb.annotations.MapAnnotation; import com.intellij.util.xmlb.annotations.Tag; -import org.jdom.Document; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -179,7 +178,7 @@ public class PluginsAdvertiser implements StartupActivity { if (!plugins.isFile()) { FileUtil.ensureCanCreateFile(plugins); } - JDOMUtil.writeDocument(new Document(XmlSerializer.serialize(new KnownExtensions(extensions))), plugins, "\n"); + JDOMUtil.write(XmlSerializer.serialize(new KnownExtensions(extensions)), plugins); } public static void openDownloadPage() { diff --git a/platform/util/src/com/intellij/util/ui/ComboBoxTableCellRenderer.java b/platform/platform-impl/src/com/intellij/ui/ComboBoxTableCellRenderer.java similarity index 87% rename from platform/util/src/com/intellij/util/ui/ComboBoxTableCellRenderer.java rename to platform/platform-impl/src/com/intellij/ui/ComboBoxTableCellRenderer.java index 858dc92b5fe9..0f2117af9ecc 100644 --- a/platform/util/src/com/intellij/util/ui/ComboBoxTableCellRenderer.java +++ b/platform/platform-impl/src/com/intellij/ui/ComboBoxTableCellRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -13,17 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.util.ui; +package com.intellij.ui; import com.intellij.openapi.diagnostic.LogUtil; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.ui.ComboBox; import com.intellij.util.ListWithSelection; +import com.intellij.util.ui.JBUI; import javax.swing.*; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableCellRenderer; import java.awt.*; -import java.util.Arrays; +import java.util.Collections; public class ComboBoxTableCellRenderer extends JPanel implements TableCellRenderer { public static final TableCellRenderer INSTANCE = new ComboBoxTableCellRenderer(); @@ -35,7 +37,7 @@ public class ComboBoxTableCellRenderer extends JPanel implements TableCellRender @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (isSelected) { - value = new ListWithSelection(Arrays.asList(value)); + value = new ListWithSelection<>(Collections.singletonList(value)); return INSTANCE.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); @@ -44,12 +46,12 @@ public class ComboBoxTableCellRenderer extends JPanel implements TableCellRender private static final Logger LOG = Logger.getInstance("#com.intellij.util.ui.ComboBoxTableCellRenderer"); - private final JComboBox myCombo = new JComboBox(); + private final JComboBox myCombo = new ComboBox(); private ComboBoxTableCellRenderer() { super(new GridBagLayout()); add(myCombo, - new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); + new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, JBUI.emptyInsets(), 0, 0)); } @Override diff --git a/platform/platform-resources-en/src/messages/ExecutionBundle.properties b/platform/platform-resources-en/src/messages/ExecutionBundle.properties index 7cfeb2274f00..6e0c80d82a16 100644 --- a/platform/platform-resources-en/src/messages/ExecutionBundle.properties +++ b/platform/platform-resources-en/src/messages/ExecutionBundle.properties @@ -332,7 +332,7 @@ environment.variables.system.dialog.title=System Environment environment.variables.component.title=&Environment variables down.the.stack.trace=Down the stack trace up.the.stack.trace=Up the stack trace -configuration.action.chooser.title=Choose configuration type to run +configuration.action.chooser.title=Choose configuration to run env.vars.checkbox.title=&Include parent environment variables env.vars.show.system=Show diff --git a/platform/platform-resources/src/META-INF/XmlPlugin.xml b/platform/platform-resources/src/META-INF/XmlPlugin.xml index f6b3a3a9f471..4d447a1a75b6 100644 --- a/platform/platform-resources/src/META-INF/XmlPlugin.xml +++ b/platform/platform-resources/src/META-INF/XmlPlugin.xml @@ -440,7 +440,7 @@ bundle="messages.XmlBundle" key="html.inspections.check.valid.script.tag" groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name" implementationClass="com.intellij.xml.util.CheckValidXmlInScriptBodyInspection"/> - diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaterInvocatorTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaterInvocatorTest.java index cdf4f4b21ede..43dcdf8e0e8f 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaterInvocatorTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaterInvocatorTest.java @@ -96,7 +96,7 @@ public class LaterInvocatorTest extends PlatformTestCase { } }); if (exception[0] != null) throw exception[0]; - UIUtil.invokeAndWaitIfNeeded((Runnable)() -> TestCase.assertFalse("Can't run test", LaterInvocator.isInModalContext())); + UIUtil.invokeAndWaitIfNeeded((Runnable)() -> TestCase.assertFalse("Can't run test " + ModalityState.current(), LaterInvocator.isInModalContext())); flushSwingQueue(); } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/Option.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/Option.java index f2f55ad8d3e9..546c64f1c325 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/Option.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/Option.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -15,7 +15,7 @@ */ package com.intellij.openapi.editor.colors.impl; -import com.intellij.openapi.util.JDOMUtil; +import com.intellij.util.JdomKt; import org.jdom.Element; import org.jetbrains.annotations.NotNull; @@ -67,6 +67,6 @@ final class Option { static Element element(Object object) throws Exception { String xml = object == null ? null : object.toString(); System.out.println(xml); - return xml == null ? null : JDOMUtil.loadDocument(xml).getRootElement(); + return xml == null ? null : JdomKt.loadElement(xml); } } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java index b3c3519c0e94..c7b0e54b247f 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -30,7 +30,6 @@ import com.intellij.openapi.fileEditor.impl.LoadTextUtil; import com.intellij.openapi.fileTypes.*; import com.intellij.openapi.fileTypes.ex.FileTypeManagerEx; import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.WriteExternalException; import com.intellij.openapi.util.io.ByteSequence; @@ -48,6 +47,7 @@ import com.intellij.psi.impl.PsiManagerEx; import com.intellij.testFramework.PlatformTestCase; import com.intellij.testFramework.PlatformTestUtil; import com.intellij.testFramework.VfsTestUtil; +import com.intellij.util.JdomKt; import com.intellij.util.PatternUtil; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; @@ -504,12 +504,12 @@ public class FileTypesTest extends PlatformTestCase { myFileTypeManager.initStandardFileTypes(); myFileTypeManager.initComponent(); - Element element = JDOMUtil.loadDocument( + Element element = JdomKt.loadElement( "\n" + " \n" + " \n" + " \n" + - "").getRootElement(); + ""); myFileTypeManager.loadState(element); myFileTypeManager.initComponent(); diff --git a/platform/projectModel-api/projectModel-api.iml b/platform/projectModel-api/projectModel-api.iml index 9ae795864733..ecbad134ebbe 100644 --- a/platform/projectModel-api/projectModel-api.iml +++ b/platform/projectModel-api/projectModel-api.iml @@ -10,5 +10,6 @@ + \ No newline at end of file diff --git a/platform/projectModel-impl/src/com/intellij/util/io/path.kt b/platform/projectModel-api/src/com/intellij/util/io/path.kt similarity index 100% rename from platform/projectModel-impl/src/com/intellij/util/io/path.kt rename to platform/projectModel-api/src/com/intellij/util/io/path.kt diff --git a/platform/projectModel-impl/src/com/intellij/util/jdom.kt b/platform/projectModel-api/src/com/intellij/util/jdom.kt similarity index 84% rename from platform/projectModel-impl/src/com/intellij/util/jdom.kt rename to platform/projectModel-api/src/com/intellij/util/jdom.kt index 1e33e22ae541..e6dc40efd875 100644 --- a/platform/projectModel-impl/src/com/intellij/util/jdom.kt +++ b/platform/projectModel-api/src/com/intellij/util/jdom.kt @@ -18,21 +18,22 @@ package com.intellij.util import com.intellij.openapi.util.JDOMUtil import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream import com.intellij.reference.SoftReference +import com.intellij.util.io.inputStream +import com.intellij.util.io.outputStream import com.intellij.util.text.CharSequenceReader import com.sun.org.apache.xerces.internal.impl.Constants import org.apache.xerces.util.SecurityManager import org.jdom.Document import org.jdom.Element +import org.jdom.JDOMException +import org.jdom.Parent import org.jdom.filter.ElementFilter import org.jdom.input.SAXBuilder import org.jdom.input.SAXHandler import org.xml.sax.EntityResolver import org.xml.sax.InputSource import org.xml.sax.XMLReader -import java.io.CharArrayReader -import java.io.InputStream -import java.io.Reader -import java.nio.file.Files +import java.io.* import java.nio.file.Path private val cachedSaxBuilder = ThreadLocal>() @@ -57,13 +58,25 @@ private fun getSaxBuilder(): SAXBuilder { return saxBuilder } +@JvmOverloads +@Throws(IOException::class) +fun Parent.write(file: Path, lineSeparator: String = "\n") { + BufferedOutputStream(file.outputStream()).use { + JDOMUtil.write(this, it, lineSeparator) + } +} + +@Throws(IOException::class, JDOMException::class) fun loadElement(chars: CharSequence) = loadElement(CharSequenceReader(chars)) +@Throws(IOException::class, JDOMException::class) fun loadElement(reader: Reader): Element = loadDocument(reader).detachRootElement() +@Throws(IOException::class, JDOMException::class) fun loadElement(stream: InputStream): Element = loadDocument(stream.reader()).detachRootElement() -fun loadElement(path: Path): Element = loadDocument(Files.newInputStream(path).bufferedReader()).detachRootElement() +@Throws(IOException::class, JDOMException::class) +fun loadElement(path: Path): Element = loadDocument(path.inputStream().bufferedReader()).detachRootElement() private fun loadDocument(reader: Reader): Document = reader.use { getSaxBuilder().build(it) } @@ -101,7 +114,7 @@ fun Element.remove(name: String, transform: (child: Element) -> T): List fun Element.toByteArray(): ByteArray { val out = BufferExposingByteArrayOutputStream(512) - JDOMUtil.writeParent(this, out, "\n") + JDOMUtil.write(this, out, "\n") return out.toByteArray() } diff --git a/platform/projectModel-impl/projectModel-impl.iml b/platform/projectModel-impl/projectModel-impl.iml index 9c361c7c6638..30368b2eb8a0 100644 --- a/platform/projectModel-impl/projectModel-impl.iml +++ b/platform/projectModel-impl/projectModel-impl.iml @@ -14,6 +14,5 @@ - \ No newline at end of file diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java index 21e435fe3c9f..e46bceba3957 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java @@ -565,6 +565,7 @@ public class SearchDialog extends DialogWrapper { statusPanel.add(super.createSouthPanel(), BorderLayout.NORTH); statusPanel.add(statusText = new JLabel(SSRBundle.message("status.message")), BorderLayout.WEST); statusPanel.add(status = new JLabel(), BorderLayout.CENTER); + status.setMinimumSize(new Dimension(0, 0)); return statusPanel; } diff --git a/platform/testFramework/extensions/src/com/intellij/testFramework/assertions/JdomAssert.kt b/platform/testFramework/extensions/src/com/intellij/testFramework/assertions/JdomAssert.kt index 8ed846eadb7e..868864789e4b 100644 --- a/platform/testFramework/extensions/src/com/intellij/testFramework/assertions/JdomAssert.kt +++ b/platform/testFramework/extensions/src/com/intellij/testFramework/assertions/JdomAssert.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -16,11 +16,16 @@ package com.intellij.testFramework.assertions import com.intellij.openapi.util.JDOMUtil +import com.intellij.openapi.util.text.StringUtilRt +import com.intellij.rt.execution.junit.FileComparisonFailure +import com.intellij.util.io.readText import com.intellij.util.isEmpty +import com.intellij.util.loadElement import org.assertj.core.api.AbstractAssert import org.assertj.core.internal.Objects import org.jdom.Element import java.io.File +import java.nio.file.Path class JdomAssert(actual: Element?) : AbstractAssert(actual, JdomAssert::class.java) { fun isEmpty(): JdomAssert { @@ -33,8 +38,17 @@ class JdomAssert(actual: Element?) : AbstractAssert(actual return this } - fun isEqualTo(file: File): JdomAssert { - return isEqualTo(file.readText()) + @Deprecated("isEqualTo(file: Path)", ReplaceWith("isEqualTo(file.toPath())")) + fun isEqualTo(file: File) = isEqualTo(file.toPath()) + + fun isEqualTo(file: Path): JdomAssert { + isNotNull + + val expected = loadElement(file) + if (!JDOMUtil.areElementsEqual(actual, expected)) { + throw FileComparisonFailure(null, StringUtilRt.convertLineSeparators(file.readText()), JDOMUtil.writeElement(actual!!), file.toString()) + } + return this } fun isEqualTo(element: Element): JdomAssert { diff --git a/platform/testFramework/src/com/intellij/testFramework/FileEditorManagerTestCase.java b/platform/testFramework/src/com/intellij/testFramework/FileEditorManagerTestCase.java index 732cf900ccca..f4f4c726d185 100644 --- a/platform/testFramework/src/com/intellij/testFramework/FileEditorManagerTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/FileEditorManagerTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 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,14 +23,13 @@ import com.intellij.openapi.fileEditor.ex.FileEditorProviderManager; import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl; import com.intellij.openapi.fileEditor.impl.FileEditorProviderManagerImpl; import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import com.intellij.ui.docking.DockContainer; import com.intellij.ui.docking.DockManager; +import com.intellij.util.JdomKt; import com.intellij.util.ui.UIUtil; -import org.jdom.Document; import org.jdom.Element; import org.jdom.JDOMException; import org.jetbrains.annotations.NotNull; @@ -94,8 +93,7 @@ public abstract class FileEditorManagerTestCase extends LightPlatformCodeInsight } protected void openFiles(@NotNull String femSerialisedText) throws IOException, JDOMException, InterruptedException, ExecutionException { - Document document = JDOMUtil.loadDocument(femSerialisedText); - Element rootElement = document.getRootElement(); + Element rootElement = JdomKt.loadElement(femSerialisedText); ExpandMacroToPathMap map = new ExpandMacroToPathMap(); map.addMacroExpand(PathMacroUtil.PROJECT_DIR_MACRO_NAME, getTestDataPath()); map.substitute(rootElement, true, true); diff --git a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java index 78646ed91768..38ac565fe041 100644 --- a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java +++ b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java @@ -847,7 +847,7 @@ public class PlatformTestUtil { public static void assertElementEquals(final String expected, final Element actual) { try { - assertElementsEqual(JDOMUtil.loadDocument(expected).getRootElement(), actual); + assertElementsEqual(JdomKt.loadElement(expected), actual); } catch (IOException | JDOMException e) { throw new AssertionError(e); diff --git a/platform/testFramework/src/com/intellij/testFramework/VfsTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/VfsTestUtil.java index 4bd39aadd7b3..0b8a698bc92b 100644 --- a/platform/testFramework/src/com/intellij/testFramework/VfsTestUtil.java +++ b/platform/testFramework/src/com/intellij/testFramework/VfsTestUtil.java @@ -46,18 +46,22 @@ public class VfsTestUtil { private VfsTestUtil() { } + @NotNull public static VirtualFile createFile(@NotNull VirtualFile root, @NotNull String relativePath) { return createFile(root, relativePath, ""); } + @NotNull public static VirtualFile createFile(@NotNull VirtualFile root, @NotNull String relativePath, @NotNull String text) { return createFileOrDir(root, relativePath, text, false); } + @NotNull public static VirtualFile createDir(@NotNull VirtualFile root, @NotNull String relativePath) { return createFileOrDir(root, relativePath, "", true); } + @NotNull private static VirtualFile createFileOrDir(VirtualFile root, String relativePath, String text, boolean dir) { try { return WriteAction.compute(() -> { @@ -107,7 +111,7 @@ public class VfsTestUtil { }); } - public static void overwriteTestData(String filePath, String actual) { + public static void overwriteTestData(@NotNull String filePath, @NotNull String actual) { try { FileUtil.writeToFile(new File(filePath), actual); } diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/MessagesFixture.java b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/MessagesFixture.java index ca890a8621a4..994d1b8bcd8e 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/MessagesFixture.java +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/MessagesFixture.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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,12 +20,12 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.text.StringUtil; import com.intellij.testGuiFramework.framework.GuiTestUtil; import com.intellij.ui.messages.SheetController; +import com.intellij.util.JdomKt; import org.fest.swing.core.GenericTypeMatcher; import org.fest.swing.core.Robot; import org.fest.swing.exception.WaitTimedOutError; import org.fest.swing.fixture.ContainerFixture; import org.fest.swing.fixture.JPanelFixture; -import org.jdom.Document; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -33,7 +33,6 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; -import static com.intellij.openapi.util.JDOMUtil.loadDocument; import static org.fest.assertions.Assertions.assertThat; import static org.fest.reflect.core.Reflection.field; import static org.junit.Assert.assertNotNull; @@ -212,8 +211,7 @@ public class MessagesFixture { @Nullable private static String getHtmlBody(@NotNull String html) { try { - Document document = loadDocument(html); - Element rootElement = document.getRootElement(); + Element rootElement = JdomKt.loadElement(html); String sheetTitle = rootElement.getChild("body").getText(); return sheetTitle.replace("\n", "").trim(); } diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 28d2d6c0b748..932c07b512dc 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -466,6 +466,10 @@ core.pooled.threads=30 editor.dumb.mode.available=true editor.dumb.mode.available.description=Paint editor in buffer to avoid blinking during inplace refactorings + +run.refactorings.under.progress=true +run.refactorings.under.progress.description=Run refactorings write action under progress, not to freeze the UI during long operations + enable.animation.on.dialogs=false type.ahead.logging.enabled=false @@ -1002,7 +1006,7 @@ ide.new.editor.tabs.selection.description=New way to select an editor tab ide.new.editor.tabs.selection.color=439EB8 ide.new.editor.tabs.selection.color.description=Color to highlight selected editor tab javascript.unused.global.declarations.cached=false -javascript.unused.global.declarations.description=Allows caching of JavaScript unused property declarations; might contain threading issues, experimental +javascript.unused.global.declarations.cached.description=Allows caching of JavaScript unused property declarations; might contain threading issues, experimental php.register.class.references.in.strings=true php.register.class.references.in.strings.description=Enables extended class reference provider for php string literals. diff --git a/platform/util/src/com/intellij/Patches.java b/platform/util/src/com/intellij/Patches.java index a16b212a355a..f59bd79170d5 100644 --- a/platform/util/src/com/intellij/Patches.java +++ b/platform/util/src/com/intellij/Patches.java @@ -40,12 +40,14 @@ public class Patches { public static final boolean SLOW_GETTING_CLIPBOARD_CONTENTS = SystemInfo.isUnix; /** - * See https://bugs.openjdk.java.net/browse/JDK-6209673. * Huge int[] leak through VolatileImages cached in RepaintManager whenever screen configuration changes. * For instance screen saver activates or computer goes hibernate. The problem still exists in 1.6 when two (or more) * monitors exists + * + *

http://bugs.openjdk.java.net/browse/JDK-6209673 + *

http://bugs.openjdk.java.net/browse/JDK-8041654 */ - public static final boolean SUN_BUG_ID_6209673 = true; + public static final boolean REPAINT_MANAGER_LEAK = !SystemInfo.isJavaVersionAtLeast("1.8.0_60"); /** * Desktop API support on X Window is limited to GNOME (and even there it may work incorrectly). diff --git a/platform/util/src/com/intellij/openapi/application/PathManager.java b/platform/util/src/com/intellij/openapi/application/PathManager.java index 5e2a8a2302b8..5832d69d04f0 100644 --- a/platform/util/src/com/intellij/openapi/application/PathManager.java +++ b/platform/util/src/com/intellij/openapi/application/PathManager.java @@ -384,24 +384,6 @@ public class PathManager { } } - /** - * Provides a way to tweak system properties as early as possible. - */ - public static void patchProperties() { - /* Setting swing.bufferPerWindow = false disables true double buffering (by definition), - by forcing BUFFER_STRATEGY_TYPE = BUFFER_STRATEGY_SPECIFIED_OFF in RepaintManager's static initializer. - - At the same time, https://youtrack.jetbrains.com/issue/IDEA-35883 seems to be now fixed. - - This matters only if we use the default RepaintManager and don't invoke JComponent.getGraphics() directly. - - True double buffering is needed to eliminate tearing on blit-accelerated scrolling and to restore - frame buffer content without the usual repainting, even when the EDT is blocked. */ - if (SystemProperties.isTrueSmoothScrollingEnabled()) { - System.setProperty("swing.bufferPerWindow", "true"); - } - } - private static String getCustomPropertiesFile() { String configPath = getCustomOptionsDirectory(); return configPath != null ? configPath + File.separator + PROPERTIES_FILE_NAME : null; diff --git a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java index aa46e792ca73..18639c249bf7 100644 --- a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java +++ b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java @@ -16,6 +16,7 @@ package com.intellij.openapi.util; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.util.ArrayUtil; @@ -43,7 +44,10 @@ import org.xml.sax.XMLReader; import java.io.*; import java.lang.ref.SoftReference; import java.net.URL; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; /** * @author mike @@ -137,32 +141,16 @@ public class JDOMUtil { return i * 31 + s.hashCode(); } + /** + * @deprecated Use Element.getChildren() directly + */ @NotNull - public static Content[] getContent(@NotNull Element m) { - List list = m.getContent(); - return list.toArray(new Content[list.size()]); - } - - @NotNull + @Deprecated public static Element[] getElements(@NotNull Element m) { List list = m.getChildren(); return list.toArray(new Element[list.size()]); } - public static void addContent(@NotNull final Element targetElement, final Object node) { - if (node instanceof Content) { - Content content = (Content)node; - targetElement.addContent(content); - } - else if (node instanceof List) { - //noinspection unchecked - targetElement.addContent((List)node); - } - else { - throw new IllegalArgumentException("Wrong node: " + node); - } - } - public static void internElement(@NotNull Element element, @NotNull StringInterner interner) { element.setName(interner.intern(element.getName())); @@ -195,7 +183,7 @@ public class JDOMUtil { return result; } - public static void appendLegalized(@NotNull StringBuilder sb, char each) { + private static void appendLegalized(@NotNull StringBuilder sb, char each) { if (each == '<' || each == '>') { sb.append(each == '<' ? "<" : ">"); } @@ -253,11 +241,6 @@ public class JDOMUtil { return a1.getName().equals(a2.getName()) && a1.getValue().equals(a2.getValue()); } - @NotNull - public static Document loadDocument(char[] chars, int length) throws IOException, JDOMException { - return getSaxBuilder().build(new CharArrayReader(chars, 0, length)); - } - private static SAXBuilder getSaxBuilder() { SoftReference reference = ourSaxBuilder.get(); SAXBuilder saxBuilder = com.intellij.reference.SoftReference.dereference(reference); @@ -287,7 +270,11 @@ public class JDOMUtil { return saxBuilder; } + /** + * @deprecated Use load + */ @NotNull + @Deprecated public static Document loadDocument(@NotNull CharSequence seq) throws IOException, JDOMException { return loadDocument(new CharSequenceReader(seq)); } @@ -298,7 +285,7 @@ public class JDOMUtil { } @NotNull - public static Document loadDocument(@NotNull Reader reader) throws IOException, JDOMException { + private static Document loadDocument(@NotNull Reader reader) throws IOException, JDOMException { try { return getSaxBuilder().build(reader); } @@ -362,13 +349,19 @@ public class JDOMUtil { } public static void writeDocument(@NotNull Document document, @NotNull File file, String lineSeparator) throws IOException { - writeParent(document, file, lineSeparator); + write(document, file, lineSeparator); } - public static void writeParent(@NotNull Parent element, @NotNull File file, String lineSeparator) throws IOException { + public static void write(@NotNull Parent element, @NotNull File file) throws IOException { + write(element, file, "\n"); + } + + public static void write(@NotNull Parent element, @NotNull File file, @NotNull String lineSeparator) throws IOException { + FileUtil.createParentDirs(file); + OutputStream stream = new BufferedOutputStream(new FileOutputStream(file)); try { - writeParent(element, stream, lineSeparator); + write(element, stream, lineSeparator); } finally { stream.close(); @@ -376,10 +369,10 @@ public class JDOMUtil { } public static void writeDocument(@NotNull Document document, @NotNull OutputStream stream, String lineSeparator) throws IOException { - writeParent(document, stream, lineSeparator); + write(document, stream, lineSeparator); } - public static void writeParent(@NotNull Parent element, @NotNull OutputStream stream, @NotNull String lineSeparator) throws IOException { + public static void write(@NotNull Parent element, @NotNull OutputStream stream, @NotNull String lineSeparator) throws IOException { OutputStreamWriter writer = new OutputStreamWriter(stream, CharsetToolkit.UTF8_CHARSET); try { if (element instanceof Document) { @@ -416,10 +409,10 @@ public class JDOMUtil { } @NotNull - public static String writeParent(Parent element, String lineSeparator) { + public static String write(Parent element, String lineSeparator) { try { final StringWriter writer = new StringWriter(); - writeParent(element, writer, lineSeparator); + write(element, writer, lineSeparator); return writer.toString(); } catch (IOException e) { @@ -427,7 +420,7 @@ public class JDOMUtil { } } - public static void writeParent(Parent element, Writer writer, String lineSeparator) throws IOException { + public static void write(Parent element, Writer writer, String lineSeparator) throws IOException { if (element instanceof Element) { writeElement((Element) element, writer, lineSeparator); } else if (element instanceof Document) { diff --git a/platform/util/src/com/intellij/openapi/vfs/CharsetToolkit.java b/platform/util/src/com/intellij/openapi/vfs/CharsetToolkit.java index 0797eb94bef5..e0bd880c61c2 100644 --- a/platform/util/src/com/intellij/openapi/vfs/CharsetToolkit.java +++ b/platform/util/src/com/intellij/openapi/vfs/CharsetToolkit.java @@ -88,7 +88,7 @@ public class CharsetToolkit { private final byte[] buffer; @NotNull private final Charset defaultCharset; - private boolean enforce8Bit = false; + private boolean enforce8Bit; public static final byte[] UTF8_BOM = {0xffffffef, 0xffffffbb, 0xffffffbf}; public static final byte[] UTF16LE_BOM = {-1, -2, }; diff --git a/platform/util/src/com/intellij/util/ui/GraphicsUtil.java b/platform/util/src/com/intellij/util/ui/GraphicsUtil.java index 5280c1cf3bb8..ac40641aeaa9 100644 --- a/platform/util/src/com/intellij/util/ui/GraphicsUtil.java +++ b/platform/util/src/com/intellij/util/ui/GraphicsUtil.java @@ -17,7 +17,6 @@ package com.intellij.util.ui; import com.intellij.openapi.ui.GraphicsConfig; import com.intellij.util.MethodInvocator; -import com.intellij.util.SystemProperties; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -118,10 +117,9 @@ public class GraphicsUtil { * and don't forget to invoke {@link Graphics#dispose()} afterwards. * * @see JRootPane#disableTrueDoubleBuffering() - * @see JBViewport#isTrueDoubleBufferingAvailableFor(JComponent) */ public static Graphics safelyGetGraphics(Component c) { - return SystemProperties.isTrueSmoothScrollingEnabled() && ourSafelyGetGraphicsMethod.isAvailable() + return ourSafelyGetGraphicsMethod.isAvailable() ? (Graphics)ourSafelyGetGraphicsMethod.invoke(null, c) : c.getGraphics(); } diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 96ada003559e..02fc2a06b7a4 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -2399,6 +2399,7 @@ public class UIUtil { public void run() { if (isToDispose(progress)) { progress.getUI().uninstallUI(progress); + ReflectionUtil.resetField(progress, "ui"); progress.putClientProperty("isDisposed", Boolean.TRUE); } } diff --git a/platform/util/src/com/intellij/util/xmlb/BeanBinding.java b/platform/util/src/com/intellij/util/xmlb/BeanBinding.java index 198495e07d6f..c3af16cf06ff 100644 --- a/platform/util/src/com/intellij/util/xmlb/BeanBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/BeanBinding.java @@ -16,7 +16,6 @@ package com.intellij.util.xmlb; import com.intellij.openapi.util.Couple; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.ReflectionUtil; @@ -121,7 +120,7 @@ public class BeanBinding extends NotNullDeserializeBinding { element.setAttribute((org.jdom.Attribute)node); } else { - JDOMUtil.addContent(element, node); + addContent(element, node); } } } diff --git a/platform/util/src/com/intellij/util/xmlb/Binding.java b/platform/util/src/com/intellij/util/xmlb/Binding.java index 0d186d2a98a3..f5255ad05009 100644 --- a/platform/util/src/com/intellij/util/xmlb/Binding.java +++ b/platform/util/src/com/intellij/util/xmlb/Binding.java @@ -16,6 +16,7 @@ package com.intellij.util.xmlb; import com.intellij.openapi.diagnostic.Logger; +import org.jdom.Content; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -66,4 +67,18 @@ public abstract class Binding { } public abstract Object deserializeUnsafe(Object context, @NotNull Element element); + + protected static void addContent(@NotNull final Element targetElement, final Object node) { + if (node instanceof Content) { + Content content = (Content)node; + targetElement.addContent(content); + } + else if (node instanceof List) { + //noinspection unchecked + targetElement.addContent((List)node); + } + else { + throw new IllegalArgumentException("Wrong node: " + node); + } + } } diff --git a/platform/util/src/com/intellij/util/xmlb/OptionTagBinding.java b/platform/util/src/com/intellij/util/xmlb/OptionTagBinding.java index 06068650ac2f..c2675ca573be 100644 --- a/platform/util/src/com/intellij/util/xmlb/OptionTagBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/OptionTagBinding.java @@ -15,7 +15,6 @@ */ package com.intellij.util.xmlb; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.xmlb.annotations.OptionTag; import org.jdom.Attribute; @@ -75,7 +74,7 @@ class OptionTagBinding extends BasePrimitiveBinding { else { Object node = myBinding.serialize(value, targetElement, filter); if (node != null && targetElement != node) { - JDOMUtil.addContent(targetElement, node); + addContent(targetElement, node); } } } diff --git a/platform/util/src/com/intellij/util/xmlb/TagBinding.java b/platform/util/src/com/intellij/util/xmlb/TagBinding.java index dd0af3a8cd31..658df4d3f18d 100644 --- a/platform/util/src/com/intellij/util/xmlb/TagBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/TagBinding.java @@ -15,7 +15,6 @@ */ package com.intellij.util.xmlb; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.util.xmlb.annotations.Tag; import org.jdom.Element; import org.jdom.Text; @@ -49,7 +48,7 @@ class TagBinding extends BasePrimitiveBinding implements MultiNodeBinding { else { Object node = myBinding.serialize(value, serialized, filter); if (node != null && node != serialized) { - JDOMUtil.addContent(serialized, node); + addContent(serialized, node); } } return serialized; diff --git a/platform/util/testSrc/com/intellij/openapi/util/io/IoTestUtil.java b/platform/util/testSrc/com/intellij/openapi/util/io/IoTestUtil.java index 112caa1cb196..50d0e1d47661 100644 --- a/platform/util/testSrc/com/intellij/openapi/util/io/IoTestUtil.java +++ b/platform/util/testSrc/com/intellij/openapi/util/io/IoTestUtil.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.util.io; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.CharsetToolkit; @@ -26,6 +27,7 @@ import org.jetbrains.annotations.Nullable; import java.io.*; import java.nio.file.FileSystems; import java.nio.file.Files; +import java.util.Collection; import java.util.Locale; import java.util.Set; import java.util.jar.JarFile; @@ -201,11 +203,28 @@ public class IoTestUtil { } @NotNull - public static File createTestJar(@NotNull File jarFile, @NotNull String... data) { + public static File createTestJar(@NotNull File jarFile, @NotNull String... namesAndTexts) { try (ZipOutputStream stream = new ZipOutputStream(new FileOutputStream(jarFile))) { - for (int i = 0; i < data.length; i += 2) { - stream.putNextEntry(new ZipEntry(data[i])); - stream.write(data[i + 1].getBytes(CharsetToolkit.UTF8_CHARSET)); + for (int i = 0; i < namesAndTexts.length; i += 2) { + stream.putNextEntry(new ZipEntry(namesAndTexts[i])); + stream.write(namesAndTexts[i + 1].getBytes(CharsetToolkit.UTF8_CHARSET)); + stream.closeEntry(); + } + return jarFile; + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + @NotNull + public static File createTestJar(@NotNull File jarFile, @NotNull Collection> namesAndContents) { + try (ZipOutputStream stream = new ZipOutputStream(new FileOutputStream(jarFile))) { + for (Pair p : namesAndContents) { + String name = p.first; + byte[] content = p.second; + stream.putNextEntry(new ZipEntry(name)); + stream.write(content); stream.closeEntry(); } return jarFile; diff --git a/platform/vcs-tests/testSrc/com/intellij/vcs/test/VcsPlatformTest.kt b/platform/vcs-tests/testSrc/com/intellij/vcs/test/VcsPlatformTest.kt index 8633198dd3ba..20572182b148 100644 --- a/platform/vcs-tests/testSrc/com/intellij/vcs/test/VcsPlatformTest.kt +++ b/platform/vcs-tests/testSrc/com/intellij/vcs/test/VcsPlatformTest.kt @@ -73,9 +73,9 @@ abstract class VcsPlatformTest : PlatformTestCase() { override fun tearDown() { RunAll().append(ThrowableRunnable { waitForPendingTasks() }).append(ThrowableRunnable - { clearFields(this) }).append(ThrowableRunnable { runInEdtAndWait { super@VcsPlatformTest.tearDown() }}).append(ThrowableRunnable - { if (myAssertionsInTestDetected) TestLoggerFactory.dumpLogToStdout(myTestStartedIndicator) }) + { if (myAssertionsInTestDetected) TestLoggerFactory.dumpLogToStdout(myTestStartedIndicator) }).append(ThrowableRunnable + { clearFields(this) }) .run() } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesViewImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesViewImpl.java index 6b0674d04bf8..5f8b4c612779 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesViewImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesViewImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -135,7 +135,7 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget, ((event.getModifiers() & (InputEvent.SHIFT_MASK | InputEvent.ALT_MASK | InputEvent.CTRL_MASK | InputEvent.META_MASK)) !=0) ) { return false; } - boolean sameRow = isAboveSelectedItem(event, watchTree); + boolean sameRow = isAboveSelectedItem(event, watchTree, false); if (!sameRow || clickCount > 1) { editAlarm.cancelAllRequests(); return false; @@ -156,7 +156,7 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget, final ClickListener mouseEmptySpaceListener = new DoubleClickListener() { @Override protected boolean onDoubleClick(MouseEvent event) { - if (!isAboveSelectedItem(event, watchTree)) { + if (!isAboveSelectedItem(event, watchTree, true)) { myRootNode.addNewWatch(); return true; } @@ -204,9 +204,12 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget, super.dispose(); } - private static boolean isAboveSelectedItem(MouseEvent event, XDebuggerTree watchTree) { + private static boolean isAboveSelectedItem(MouseEvent event, XDebuggerTree watchTree, boolean fullWidth) { Rectangle bounds = watchTree.getRowBounds(watchTree.getLeadSelectionRow()); if (bounds != null) { + if (fullWidth) { + bounds.x = 0; + } bounds.width = watchTree.getWidth(); if (bounds.contains(event.getPoint())) { return true; diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ConstructionUtils.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ConstructionUtils.java index 1c6d3d20034f..a1e6ac5a74d6 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ConstructionUtils.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ConstructionUtils.java @@ -17,13 +17,24 @@ package com.siyeh.ig.psiutils; import com.intellij.psi.*; import com.intellij.psi.util.PsiUtil; +import com.intellij.util.containers.ContainerUtil; +import com.siyeh.ig.callMatcher.CallMatcher; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.Nullable; +import java.util.Set; +import java.util.function.Predicate; +import java.util.stream.Stream; + /** * @author Tagir Valeev */ public class ConstructionUtils { + private static final Set GUAVA_UTILITY_CLASSES = + ContainerUtil.set("com.google.common.collect.Maps", "com.google.common.collect.Lists", "com.google.common.collect.Sets"); + private static final CallMatcher ENUM_SET_NONE_OF = + CallMatcher.staticCall("java.util.EnumSet", "noneOf").parameterCount(1); + /** * Checks that given expression initializes empty StringBuilder or StringBuffer (either with explicit default capacity or not) * @@ -79,10 +90,11 @@ public class ConstructionUtils { expression = PsiUtil.skipParenthesizedExprDown(expression); if (expression instanceof PsiNewExpression) { PsiExpressionList argumentList = ((PsiNewExpression)expression).getArgumentList(); - if (argumentList == null || argumentList.getExpressions().length != 0) return false; - PsiType type = expression.getType(); - return com.intellij.psi.util.InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_COLLECTION) || - com.intellij.psi.util.InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_MAP); + if (argumentList != null && argumentList.getExpressions().length == 0) { + PsiType type = expression.getType(); + return com.intellij.psi.util.InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_COLLECTION) || + com.intellij.psi.util.InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_MAP); + } } if (expression instanceof PsiMethodCallExpression) { PsiMethodCallExpression call = (PsiMethodCallExpression)expression; @@ -94,15 +106,55 @@ public class ConstructionUtils { PsiClass aClass = method.getContainingClass(); if(aClass != null) { String qualifiedName = aClass.getQualifiedName(); - if("com.google.common.collect.Maps".equals(qualifiedName) || - "com.google.common.collect.Lists".equals(qualifiedName) || - "com.google.common.collect.Sets".equals(qualifiedName)) { + if (GUAVA_UTILITY_CLASSES.contains(qualifiedName)) { return true; } } } } } + return isCustomizedEmptyCollectionInitializer(expression); + } + + /** + * Checks that given expression initializes empty Collection or Map with custom initial capacity or load factor + * + * @param expression expression to check + * @return true if the expression is the empty Collection or Map initializer with custom initial capacity or load factor + */ + @Contract("null -> false") + public static boolean isCustomizedEmptyCollectionInitializer(PsiExpression expression) { + expression = PsiUtil.skipParenthesizedExprDown(expression); + if (expression instanceof PsiNewExpression) { + PsiExpressionList argumentList = ((PsiNewExpression)expression).getArgumentList(); + if (argumentList == null || argumentList.getExpressions().length == 0) return false; + PsiMethod constructor = ((PsiNewExpression)expression).resolveConstructor(); + if (constructor == null) return false; + PsiClass aClass = constructor.getContainingClass(); + if (aClass == null || aClass.getQualifiedName() == null || !aClass.getQualifiedName().startsWith("java.util.")) return false; + Predicate allowedParameterType = t -> t instanceof PsiPrimitiveType || + (t instanceof PsiClassType && + ((PsiClassType)t).rawType().equalsToText(CommonClassNames.JAVA_LANG_CLASS)); + return Stream.of(constructor.getParameterList().getParameters()).map(PsiParameter::getType).allMatch(allowedParameterType); + } + if (expression instanceof PsiMethodCallExpression) { + PsiMethodCallExpression call = (PsiMethodCallExpression)expression; + if (ENUM_SET_NONE_OF.test(call)) return true; + String name = call.getMethodExpression().getReferenceName(); + PsiExpressionList argumentList = call.getArgumentList(); + if (name != null && name.startsWith("new") && argumentList.getExpressions().length > 0) { + PsiMethod method = call.resolveMethod(); + if (method != null && method.getParameterList().getParametersCount() > 0) { + PsiClass aClass = method.getContainingClass(); + if (aClass != null) { + String qualifiedName = aClass.getQualifiedName(); + if (GUAVA_UTILITY_CLASSES.contains(qualifiedName)) { + return Stream.of(method.getParameterList().getParameters()).allMatch(p -> p.getType() instanceof PsiPrimitiveType); + } + } + } + } + } return false; } diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ExpressionUtils.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ExpressionUtils.java index 832688f716e0..9b455cd1eb2a 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ExpressionUtils.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ExpressionUtils.java @@ -19,6 +19,7 @@ import com.intellij.codeInsight.AnnotationUtil; import com.intellij.codeInsight.NullableNotNullManager; import com.intellij.openapi.project.Project; import com.intellij.psi.*; +import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.*; import com.intellij.psi.util.InheritanceUtil; @@ -936,4 +937,28 @@ public class ExpressionUtils { public static void bindCallTo(@NotNull PsiMethodCallExpression call, @NotNull String newName) { bindReferenceTo(call.getMethodExpression(), newName); } + + /** + * Returns the expression itself (probably with stripped parentheses) or the corresponding value if the expression is a local variable + * reference which is initialized and not used anywhere else + * + * @param expression + * @return a resolved expression or expression itself + */ + @Contract("null -> null") + @Nullable + public static PsiExpression resolveExpression(@Nullable PsiExpression expression) { + expression = PsiUtil.skipParenthesizedExprDown(expression); + if (expression instanceof PsiReferenceExpression) { + PsiReferenceExpression reference = (PsiReferenceExpression)expression; + PsiLocalVariable variable = ObjectUtils.tryCast(reference.resolve(), PsiLocalVariable.class); + if (variable != null) { + PsiExpression initializer = variable.getInitializer(); + if (initializer != null && ReferencesSearch.search(variable).forEach(ref -> ref == reference)) { + return initializer; + } + } + } + return expression; + } } \ No newline at end of file diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java index d23c70974bf0..71c99aee23e1 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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,7 +37,6 @@ import com.intellij.openapi.ui.SplitterProportionsData; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Factory; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.NullableFactory; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -59,7 +58,6 @@ import org.intellij.plugins.intelliLang.inject.InjectorUtils; import org.intellij.plugins.intelliLang.inject.LanguageInjectionSupport; import org.intellij.plugins.intelliLang.inject.config.BaseInjection; import org.intellij.plugins.intelliLang.inject.config.InjectionPlace; -import org.jdom.Document; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -291,9 +289,8 @@ public class InjectionsSettingsUI extends SearchableConfigurable.Parent.Abstract if (wrapper == null) return; final Configuration configuration = new Configuration(); configuration.setInjections(injections); - final Document document = new Document(configuration.getState()); try { - JDOMUtil.writeDocument(document, wrapper.getFile(), "\n"); + JdomKt.write(configuration.getState(), wrapper.getFile().toPath()); } catch (IOException ex) { final String msg = ex.getLocalizedMessage(); diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsAdd/ui/AddMultipleFilesOptionsDialog.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsAdd/ui/AddMultipleFilesOptionsDialog.java index c60efc426099..dc3f342c4c47 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsAdd/ui/AddMultipleFilesOptionsDialog.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsAdd/ui/AddMultipleFilesOptionsDialog.java @@ -33,7 +33,7 @@ import com.intellij.ui.treeStructure.treetable.TreeTable; import com.intellij.ui.treeStructure.treetable.TreeTableModel; import com.intellij.ui.treeStructure.treetable.TreeTableTree; import com.intellij.util.ui.ColumnInfo; -import com.intellij.util.ui.ComboBoxTableCellRenderer; +import com.intellij.ui.ComboBoxTableCellRenderer; import com.intellij.util.ui.table.ComboBoxTableCellEditor; import com.intellij.util.ui.tree.TreeUtil; import org.netbeans.lib.cvsclient.command.KeywordSubstitution; diff --git a/plugins/devkit/src/dom/IdeaPlugin.java b/plugins/devkit/src/dom/IdeaPlugin.java index 3da0c73df278..bcbd35956435 100644 --- a/plugins/devkit/src/dom/IdeaPlugin.java +++ b/plugins/devkit/src/dom/IdeaPlugin.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -56,6 +56,9 @@ public interface IdeaPlugin extends DomElement { @NotNull GenericAttributeValue getUseIdeaClassloader(); + @NotNull + GenericAttributeValue getAllowBundledUpdate(); + @NotNull @Stubbed GenericDomValue getName(); diff --git a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseClasspathTest.java b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseClasspathTest.java index 4e445469d5c6..a16326a7fa35 100644 --- a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseClasspathTest.java +++ b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseClasspathTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -79,7 +79,7 @@ public class EclipseClasspathTest extends IdeaTestCase { if (!SystemInfo.isWindows) { fileText = fileText.replaceAll(EclipseXml.FILE_PROTOCOL + "/", EclipseXml.FILE_PROTOCOL); } - final Element classpathElement = JDOMUtil.loadDocument(fileText).getRootElement(); + final Element classpathElement = JDOMUtil.load(fileText); final Module module = WriteCommandAction.runWriteCommandAction(null, (Computable)() -> { String imlPath = path + "/" + EclipseProjectFinder.findProjectName(path) + ModuleManagerImpl.IML_EXTENSION; @@ -108,7 +108,7 @@ public class EclipseClasspathTest extends IdeaTestCase { fileText1 = fileText1.replaceAll(EclipseXml.FILE_PROTOCOL + "/", EclipseXml.FILE_PROTOCOL); } - Element classpathElement1 = JDOMUtil.loadDocument(fileText1).getRootElement(); + Element classpathElement1 = JDOMUtil.load(fileText1); ModuleRootModel model = ModuleRootManager.getInstance(module); Element resultClasspathElement = new EclipseClasspathWriter().writeClasspath(classpathElement1, model); diff --git a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseEmlTest.java b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseEmlTest.java index a64c3abe7c6f..00fc065724e6 100644 --- a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseEmlTest.java +++ b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseEmlTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -95,7 +95,7 @@ public class EclipseEmlTest extends IdeaTestCase { final File emlFile = new File(path, module.getName() + EclipseXml.IDEA_SETTINGS_POSTFIX); Assert.assertTrue(resulted.replaceAll(StringUtil.escapeToRegexp(module.getProject().getBaseDir().getPath()), "\\$ROOT\\$"), - JDOMUtil.areElementsEqual(root, JDOMUtil.loadDocument(FileUtil.loadFile(emlFile)).getRootElement())); + JDOMUtil.areElementsEqual(root, JDOMUtil.load(emlFile))); } private static void replaceRoot(String path, final String child, final Project project) throws IOException, JDOMException { diff --git a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseImlTest.java b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseImlTest.java index 7427e6f32811..a7bf065cf8b2 100644 --- a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseImlTest.java +++ b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseImlTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -35,17 +35,18 @@ import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.impl.ModuleRootManagerImpl; import com.intellij.openapi.util.Computable; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.testFramework.IdeaTestCase; +import com.intellij.util.JdomKt; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.idea.eclipse.conversion.EclipseClasspathReader; import java.io.File; +import java.nio.file.Paths; import static com.intellij.testFramework.assertions.Assertions.assertThat; @@ -79,7 +80,7 @@ public class EclipseImlTest extends IdeaTestCase { } String communityLib = FileUtil.toSystemIndependentName(PathManagerEx.findFileUnderCommunityHome("lib").getAbsolutePath()); fileText = fileText.replaceAll("\\$" + JUNIT + "\\$", communityLib); - final Element classpathElement = JDOMUtil.loadDocument(fileText).getRootElement(); + final Element classpathElement = JdomKt.loadElement(fileText); final Module module = WriteCommandAction.runWriteCommandAction(null, (Computable)() -> ModuleManager.getInstance(project) .newModule(new File(path) + File.separator + EclipseProjectFinder .findProjectName(path) + ModuleManagerImpl.IML_EXTENSION, StdModuleTypes.JAVA.getId())); @@ -97,7 +98,7 @@ public class EclipseImlTest extends IdeaTestCase { PathMacroManager.getInstance(project).collapsePaths(actualImlElement); PathMacros.getInstance().removeMacro(JUNIT); - assertThat(actualImlElement).isEqualTo(new File(project.getBaseDir().getPath() + "/expected", "expected.iml")); + assertThat(actualImlElement).isEqualTo(Paths.get(project.getBaseDir().getPath(), "expected", "expected.iml")); } public void testWorkspaceOnly() throws Exception { diff --git a/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.java b/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.java deleted file mode 100644 index 02c4ae83c878..000000000000 --- a/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2000-2013 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 git4idea.actions; - -import com.intellij.openapi.project.Project; -import com.intellij.vcs.log.Hash; -import git4idea.branch.GitBrancher; -import git4idea.repo.GitRepository; -import org.jetbrains.annotations.NotNull; - -import static git4idea.branch.GitBranchUtil.getNewBranchNameFromUser; -import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; - -public class GitCreateNewBranchAction extends GitLogSingleCommitAction { - - @Override - protected void actionPerformed(@NotNull GitRepository repository, @NotNull Hash commit) { - Project project = repository.getProject(); - String name = getNewBranchNameFromUser(project, singleton(repository), "Checkout New Branch From " + commit.toShortString()); - if (name != null) { - GitBrancher brancher = GitBrancher.getInstance(project); - brancher.checkoutNewBranchStartingFrom(name, commit.asString(), singletonList(repository), null); - } - } -} diff --git a/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.kt b/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.kt new file mode 100644 index 000000000000..7663e516d961 --- /dev/null +++ b/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.kt @@ -0,0 +1,120 @@ +/* + * Copyright 2000-2013 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 git4idea.actions + +import com.intellij.dvcs.DvcsUtil.guessVcsRoot +import com.intellij.dvcs.branch.DvcsSyncSettings.Value.SYNC +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.actionSystem.CommonDataKeys.VIRTUAL_FILE +import com.intellij.openapi.project.DumbAwareAction +import com.intellij.openapi.project.Project +import com.intellij.vcs.log.Hash +import com.intellij.vcs.log.VcsLogDataKeys +import git4idea.GitUtil.HEAD +import git4idea.GitUtil.getRepositoryManager +import git4idea.branch.GitBranchUtil.getNewBranchNameFromUser +import git4idea.branch.GitBrancher +import git4idea.config.GitVcsSettings +import git4idea.repo.GitRepository + +internal class GitCreateNewBranchAction : DumbAwareAction() { + + override fun actionPerformed(e: AnActionEvent) { + val data = collectData(e) + when (data) { + is Data.WithCommit -> createBranchStartingFrom(data.repository, data.hash) + is Data.NoCommit -> createBranch(data.project, data.repositories) + } + } + + override fun update(e: AnActionEvent) { + super.update(e) + val data = collectData(e) + when (data) { + is Data.Invisible -> e.presentation.isEnabledAndVisible = false + is Data.Disabled -> { + e.presentation.isVisible = true + e.presentation.isEnabled = false + } + else -> e.presentation.isEnabledAndVisible = true + } + } + + private sealed class Data { + class Invisible : Data() + class Disabled : Data() + class WithCommit(val repository: GitRepository, val hash: Hash) : Data() + class NoCommit(val project: Project, val repositories: List) : Data() + } + + private fun collectData(e: AnActionEvent): Data { + val project = e.project ?: return Data.Invisible() + val manager = getRepositoryManager(project) + if (manager.repositories.isEmpty()) return Data.Invisible() + + val log = e.getData(VcsLogDataKeys.VCS_LOG) + if (log != null) { + val commits = log.selectedCommits + if (commits.isEmpty()) return Data.Invisible() + if (commits.size > 1) return Data.Disabled() + val commit = commits.first() + val repository = manager.getRepositoryForRoot(commit.root) + if (repository != null) { + return Data.WithCommit(repository, commit.hash) + } + } + + val repositories = + if (manager.moreThanOneRoot()) { + if (GitVcsSettings.getInstance(project).syncSetting == SYNC) manager.repositories + else { + val repository = manager.getRepositoryForRoot(guessVcsRoot(project, e.getData(VIRTUAL_FILE))) + repository?.let { listOf(repository) } + } + } + else listOf(manager.repositories.first()) + + if (repositories == null || repositories.any { it.isFresh }) return Data.Invisible() + return Data.NoCommit(project, repositories) + } + + fun createBranch(project: Project, repositories: List) { + val options = getNewBranchNameFromUser(project, repositories, "Create New Branch") + if (options != null) { + val brancher = GitBrancher.getInstance(project) + if (options.checkout) { + brancher.checkoutNewBranch(options.name, repositories) + } + else { + brancher.createBranch(options.name, repositories.map { it to HEAD }.toMap()) + } + } + } + + fun createBranchStartingFrom(repository: GitRepository, commit: Hash) { + val project = repository.project + val options = getNewBranchNameFromUser(project, setOf(repository), "Create New Branch From ${commit.toShortString()}") + if (options != null) { + val brancher = GitBrancher.getInstance(project) + if (options.checkout) { + brancher.checkoutNewBranchStartingFrom(options.name, commit.asString(), listOf(repository), null) + } + else { + brancher.createBranch(options.name, mapOf(repository to commit.asString())) + } + } + } +} diff --git a/plugins/git4idea/src/git4idea/branch/GitBranchUtil.java b/plugins/git4idea/src/git4idea/branch/GitBranchUtil.java index d90678ec1fb6..4792c378bc51 100644 --- a/plugins/git4idea/src/git4idea/branch/GitBranchUtil.java +++ b/plugins/git4idea/src/git4idea/branch/GitBranchUtil.java @@ -21,7 +21,6 @@ import com.google.common.collect.Collections2; import com.intellij.dvcs.DvcsUtil; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.CharsetToolkit; @@ -260,13 +259,16 @@ public class GitBranchUtil { } /** - * Shows a message dialog to enter the name of new branch. - * @return name of new branch or {@code null} if user has cancelled the dialog. + *

Shows a message dialog to enter the name of new branch.

+ *

Optionally allows to not checkout this branch, and just create it.

+ * + * @return the name of the new branch and whether it should be checked out, or {@code null} if user has cancelled the dialog. */ @Nullable - public static String getNewBranchNameFromUser(@NotNull Project project, @NotNull Collection repositories, @NotNull String dialogTitle) { - return Messages.showInputDialog(project, "New branch name:", dialogTitle, null, "", - GitNewBranchNameValidator.newInstance(repositories)); + public static GitNewBranchOptions getNewBranchNameFromUser(@NotNull Project project, + @NotNull Collection repositories, + @NotNull String dialogTitle) { + return new GitNewBranchDialog(project, dialogTitle, GitNewBranchNameValidator.newInstance(repositories)).showAndGetOptions(); } /** diff --git a/plugins/git4idea/src/git4idea/branch/GitBranchWorker.java b/plugins/git4idea/src/git4idea/branch/GitBranchWorker.java index b7d14ea9f283..2d6676b941be 100644 --- a/plugins/git4idea/src/git4idea/branch/GitBranchWorker.java +++ b/plugins/git4idea/src/git4idea/branch/GitBranchWorker.java @@ -38,6 +38,7 @@ import org.jetbrains.annotations.NotNull; import java.util.Collection; import java.util.List; +import java.util.Map; /** * Executes the logic of git branch operations. @@ -75,6 +76,11 @@ public final class GitBranchWorker { } } + public void createBranch(@NotNull String name, @NotNull Map startPoints) { + updateInfo(startPoints.keySet()); + new GitCreateBranchOperation(myProject, myGit, myUiHandler, name, startPoints).execute(); + } + public void createNewTag(@NotNull final String name, @NotNull final String reference, @NotNull final List repositories) { for (GitRepository repository : repositories) { myGit.createNewTag(repository, name, null, reference); diff --git a/plugins/git4idea/src/git4idea/branch/GitBrancher.java b/plugins/git4idea/src/git4idea/branch/GitBrancher.java index 6a2ca1b58e3b..645012bc4e71 100644 --- a/plugins/git4idea/src/git4idea/branch/GitBrancher.java +++ b/plugins/git4idea/src/git4idea/branch/GitBrancher.java @@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.List; +import java.util.Map; /** *

Executes various operations on Git branches: checkout, create new branch, merge, delete, compare.

@@ -29,7 +30,7 @@ import java.util.List; *

It also takes care of analyzing results and notifying the user.

*

All operations can be called for multiple repositories at once.

* - * @author Kirill Likhodedov + * @see GitBranchWorker */ public interface GitBrancher { static GitBrancher getInstance(@NotNull Project project) { @@ -48,6 +49,15 @@ public interface GitBrancher { */ void checkoutNewBranch(@NotNull String name, @NotNull List repositories); + /** + * Creates new branch without checking it out. + * + * @param name name of the new branch. + * @param startPoints position (commit hash) where the branch should be created, for each repository. + * Such position can be indicated by any valid Git reference (commit hash, branch name, etc.) + */ + void createBranch(@NotNull String name, @NotNull Map startPoints); + /** *

Creates new tag on the selected reference.

* diff --git a/plugins/git4idea/src/git4idea/branch/GitBrancherImpl.java b/plugins/git4idea/src/git4idea/branch/GitBrancherImpl.java index e05cac19eacf..4cb70e43d800 100644 --- a/plugins/git4idea/src/git4idea/branch/GitBrancherImpl.java +++ b/plugins/git4idea/src/git4idea/branch/GitBrancherImpl.java @@ -27,6 +27,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.List; +import java.util.Map; /** * @author Kirill Likhodedov @@ -55,6 +56,15 @@ class GitBrancherImpl implements GitBrancher { return new GitBranchWorker(myProject, myGit, new GitBranchUiHandlerImpl(myProject, myGit, indicator)); } + @Override + public void createBranch(@NotNull String name, @NotNull Map startPoints) { + new CommonBackgroundTask(myProject, "Creating branch " + name, null) { + @Override public void execute(@NotNull ProgressIndicator indicator) { + newWorker(indicator).createBranch(name, startPoints); + } + }.runInBackground(); + } + @Override public void createNewTag(@NotNull final String name, @NotNull final String reference, @NotNull final List repositories, @Nullable Runnable callInAwtLater) { diff --git a/plugins/git4idea/src/git4idea/branch/GitCreateBranchOperation.kt b/plugins/git4idea/src/git4idea/branch/GitCreateBranchOperation.kt new file mode 100644 index 000000000000..08ce58d07e2a --- /dev/null +++ b/plugins/git4idea/src/git4idea/branch/GitCreateBranchOperation.kt @@ -0,0 +1,78 @@ +/* + * Copyright 2000-2017 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 git4idea.branch + +import com.intellij.openapi.project.Project +import com.intellij.openapi.vcs.VcsNotifier +import git4idea.commands.Git +import git4idea.commands.GitCompoundResult +import git4idea.repo.GitRepository + +internal class GitCreateBranchOperation( + project: Project, + git: Git, + uiHandler: GitBranchUiHandler, + private val branchName: String, + private val startPoints: Map) : GitBranchOperation(project, git, uiHandler, startPoints.keys) { + + public override fun execute() { + var fatalErrorHappened = false + while (hasMoreRepositories() && !fatalErrorHappened) { + val repository = next() + val result = myGit.branchCreate(repository, branchName, startPoints[repository]!!) + + if (result.success()) { + repository.update() + markSuccessful(repository) + } + else { + fatalError("Couldn't create new branch $branchName", result.errorOutputAsJoinedString) + fatalErrorHappened = true + } + } + + if (!fatalErrorHappened) { + notifySuccess() + updateRecentBranch() + } + } + + override fun rollback() { + val repositories = successfulRepositories + val deleteResult = GitCompoundResult(myProject) + for (repository in repositories) { + deleteResult.append(repository, myGit.branchDelete(repository, branchName, false)) + repository.update() + } + + val vcsNotifier = VcsNotifier.getInstance(myProject) + if (deleteResult.totalSuccess()) { + vcsNotifier.notifySuccess("Rollback successful", "Deleted $branchName") + } + else { + vcsNotifier.notifyError("Error during rollback", deleteResult.errorOutputWithReposIndication) + } + } + + override fun getSuccessMessage() = "Branch $branchName was created" + + override fun getRollbackProposal() = """ + However the branch was created in the following ${repositories()}:
+ ${successfulRepositoriesJoined()}
+ You may rollback (delete $branchName) not to let branches diverge.""".trimIndent() + + override fun getOperationName() = "create branch" +} diff --git a/plugins/git4idea/src/git4idea/branch/GitNewBranchDialog.kt b/plugins/git4idea/src/git4idea/branch/GitNewBranchDialog.kt new file mode 100644 index 000000000000..045d7801b642 --- /dev/null +++ b/plugins/git4idea/src/git4idea/branch/GitNewBranchDialog.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2000-2017 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 git4idea.branch + +import com.intellij.openapi.project.Project +import com.intellij.openapi.ui.Messages +import com.intellij.ui.components.JBCheckBox +import com.intellij.util.ui.JBUI +import com.intellij.util.ui.UIUtil.DEFAULT_HGAP +import com.intellij.util.ui.UIUtil.DEFAULT_VGAP +import git4idea.validators.GitNewBranchNameValidator +import java.awt.BorderLayout +import java.awt.event.KeyEvent +import javax.swing.JComponent + +internal data class GitNewBranchOptions(val name: String, @get:JvmName("shouldCheckout") val checkout: Boolean) + +internal class GitNewBranchDialog(project: Project, dialogTitle: String, validator: GitNewBranchNameValidator) : + Messages.InputDialog(project, "New branch name:", dialogTitle, null, "", validator) { + + private lateinit var checkoutCheckbox : JBCheckBox + + fun showAndGetOptions(): GitNewBranchOptions? { + return if (showAndGet()) GitNewBranchOptions(inputString!!.trim(), checkoutCheckbox.isSelected) else null + } + + override fun createCenterPanel(): JComponent? { + checkoutCheckbox = JBCheckBox("Checkout branch", true) + checkoutCheckbox.mnemonic = KeyEvent.VK_C + + val panel = JBUI.Panels.simplePanel(DEFAULT_HGAP, DEFAULT_VGAP) + panel.add(checkoutCheckbox, BorderLayout.WEST) + return panel + } +} diff --git a/plugins/git4idea/src/git4idea/i18n/GitBundle.properties b/plugins/git4idea/src/git4idea/i18n/GitBundle.properties index d5524281af8b..3be3897da313 100644 --- a/plugins/git4idea/src/git4idea/i18n/GitBundle.properties +++ b/plugins/git4idea/src/git4idea/i18n/GitBundle.properties @@ -450,11 +450,11 @@ util.remote.renderer.none=None util.remote.renderer.normal={0}({1}) util.remote.renderer.self=Current repository vcs.unable.to.run.git=Unable to run git: {0} ({1}) -vfs.listener.add.single.prompt=Do you want to add the following file to Git?\n{0}\n\nIf you say No, you can still add it later manually. +vfs.listener.add.single.prompt=Do you want to add the following file to Git?\n{0}\n\nIf you choose No, you can still add it later manually. vfs.listener.add.single.title=Add File to Git vfs.listener.add.title=Add Files to Git vfs.listener.checking.ignored=Checking for ignored files -vfs.listener.delete.single.prompt=Do you want to delete the following file from Git?\n{0}\n\nIf you say No, you can still delete it later manually. +vfs.listener.delete.single.prompt=Do you want to delete the following file from Git?\n{0}\n\nIf you choose No, you can still delete it later manually. vfs.listener.delete.single.title=Delete File from Git vfs.listener.delete.title=Delete Files from Git diff --git a/plugins/git4idea/src/git4idea/rebase/GitRebaseEditor.java b/plugins/git4idea/src/git4idea/rebase/GitRebaseEditor.java index c556621e433f..6d881754d0a9 100644 --- a/plugins/git4idea/src/git4idea/rebase/GitRebaseEditor.java +++ b/plugins/git4idea/src/git4idea/rebase/GitRebaseEditor.java @@ -35,7 +35,6 @@ import com.intellij.util.ArrayUtil; import com.intellij.util.ListWithSelection; import com.intellij.util.PairFunction; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.ui.ComboBoxTableCellRenderer; import com.intellij.util.ui.EditableModel; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; diff --git a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java index 7db0a6cc5a76..76eb67b19bfe 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java +++ b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java @@ -53,6 +53,7 @@ class GitBranchPopup extends DvcsBranchPopup { private static final String DIMENSION_SERVICE_KEY = "Git.Branch.Popup"; static final String SHOW_ALL_LOCALS_KEY = "Git.Branch.Popup.ShowAllLocals"; static final String SHOW_ALL_REMOTES_KEY = "Git.Branch.Popup.ShowAllRemotes"; + static final String SHOW_ALL_REPOSITORIES = "Git.Branch.Popup.ShowAllRepositories"; /** * @param currentRepository Current repository, which means the repository of the currently open or selected file. @@ -154,7 +155,8 @@ class GitBranchPopup extends DvcsBranchPopup { .map(repo -> new RootAction<>(repo, highlightCurrentRepo() ? myCurrentRepository : null, new GitBranchPopupActions(repo.getProject(), repo).createActions(), GitBranchUtil.getDisplayableBranchText(repo))).collect(toList()); - wrapWithMoreActionIfNeeded(myProject, popupGroup, rootActions, rootActions.size() > MAX_NUM ? DEFAULT_NUM : MAX_NUM, null); + wrapWithMoreActionIfNeeded(myProject, popupGroup, rootActions, rootActions.size() > MAX_NUM ? DEFAULT_NUM : MAX_NUM, + SHOW_ALL_REPOSITORIES); return popupGroup; } diff --git a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java index bce8008ea8fe..30d91d851c22 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java +++ b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java @@ -29,8 +29,10 @@ import com.intellij.openapi.ui.Messages; import com.intellij.util.containers.ContainerUtil; import git4idea.branch.GitBranchUtil; import git4idea.branch.GitBrancher; +import git4idea.branch.GitNewBranchOptions; import git4idea.repo.GitRepository; import git4idea.validators.GitNewBranchNameValidator; +import one.util.streamex.StreamEx; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -40,6 +42,7 @@ import java.util.List; import static com.intellij.dvcs.ui.BranchActionGroupPopup.wrapWithMoreActionIfNeeded; import static com.intellij.dvcs.ui.BranchActionUtil.*; import static git4idea.GitStatisticsCollectorKt.reportUsage; +import static git4idea.GitUtil.HEAD; import static git4idea.branch.GitBranchType.LOCAL; import static git4idea.branch.GitBranchType.REMOTE; import static java.util.stream.Collectors.toList; @@ -100,11 +103,17 @@ class GitBranchPopupActions { @Override public void actionPerformed(AnActionEvent e) { - final String name = GitBranchUtil.getNewBranchNameFromUser(myProject, myRepositories, "Create New Branch"); - if (name != null) { + GitNewBranchOptions options = GitBranchUtil.getNewBranchNameFromUser(myProject, myRepositories, "Create New Branch"); + if (options != null) { GitBrancher brancher = GitBrancher.getInstance(myProject); - brancher.checkoutNewBranch(name, myRepositories); - reportUsage("git.branch.create.new"); + if (options.shouldCheckout()) { + reportUsage("git.branch.create.new"); + brancher.checkoutNewBranch(options.getName(), myRepositories); + } + else { + reportUsage("git.branch.create.new.nocheckout"); + brancher.createBranch(options.getName(), StreamEx.of(myRepositories).toMap(position -> HEAD)); + } } } } diff --git a/plugins/git4idea/tests/git4idea/branch/GitBranchWorkerTest.kt b/plugins/git4idea/tests/git4idea/branch/GitBranchWorkerTest.kt index 81a2ae75f211..3dfaffa161c3 100644 --- a/plugins/git4idea/tests/git4idea/branch/GitBranchWorkerTest.kt +++ b/plugins/git4idea/tests/git4idea/branch/GitBranchWorkerTest.kt @@ -23,8 +23,7 @@ import com.intellij.openapi.ui.DialogWrapper import com.intellij.openapi.util.Ref import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.text.StringUtil -import com.intellij.openapi.vcs.Executor -import com.intellij.openapi.vcs.Executor.cat +import com.intellij.openapi.vcs.Executor.* import com.intellij.openapi.vcs.changes.Change import com.intellij.openapi.vfs.VirtualFile import com.intellij.testFramework.runInEdtAndWait @@ -55,27 +54,42 @@ class GitBranchWorkerTest : GitPlatformTest() { public override fun setUp() { super.setUp() - Executor.cd(myProjectRoot) - val community = Executor.mkdir("community") - val contrib = Executor.mkdir("contrib") + cd(myProjectRoot) + val community = mkdir("community") + val contrib = mkdir("contrib") myUltimate = createRepository(myProjectPath) myCommunity = createRepository(community.path) myContrib = createRepository(contrib.path) - myRepositories = Arrays.asList(myUltimate, myCommunity, myContrib) + myRepositories = listOf(myUltimate, myCommunity, myContrib) - Executor.cd(myProjectRoot) - Executor.touch(".gitignore", "community\ncontrib") + cd(myProjectRoot) + touch(".gitignore", "community\ncontrib") git("add .gitignore") git("commit -m gitignore") + myUltimate.update() } fun test_create_new_branch_without_problems() { checkoutNewBranch("feature", TestUiHandler()) assertCurrentBranch("feature") - assertEquals("Notification about successful branch creation is incorrect", - "Branch " + bcode("feature") + " was created", myVcsNotifier.lastNotification.content) + assertSuccessfulNotification("Branch ${bcode("feature")} was created") + } + + fun `test create new branch without checkout not at HEAD`() { + val hashMap = myRepositories.map { it to it.currentRevision!! }.toMap() + myRepositories.forEach { cd(it); tac("f.txt") } + + GitBranchWorker(myProject, myGit, TestUiHandler()).createBranch("feature", myRepositories.map{ it to "HEAD^" }.toMap()) + + assertCurrentBranch("master") + myRepositories.forEach { + val branch = it.branches.findLocalBranch("feature") + assertNotNull("Branch not created in $it", branch) + assertEquals("Branch feature created at wrong point", hashMap[it], it.branches.getHash(branch!!)!!.asString()) + } + assertSuccessfulNotification("Branch ${bcode("feature")} was created") } fun test_create_new_branch_with_unmerged_files_in_first_repo_should_show_notification() { @@ -176,9 +190,7 @@ class GitBranchWorkerTest : GitPlatformTest() { unmergedFiles(myCommunity) checkoutBranch("feature", object : TestUiHandler() { - override fun showUnmergedFilesMessageWithRollback(operationName: String, rollbackProposal: String): Boolean { - return true - } + override fun showUnmergedFilesMessageWithRollback(operationName: String, rollbackProposal: String) = true }) assertCurrentBranch("master") @@ -189,9 +201,7 @@ class GitBranchWorkerTest : GitPlatformTest() { unmergedFiles(myCommunity) checkoutBranch("feature", object : TestUiHandler() { - override fun showUnmergedFilesMessageWithRollback(operationName: String, rollbackProposal: String): Boolean { - return false - } + override fun showUnmergedFilesMessageWithRollback(operationName: String, rollbackProposal: String) = false }) assertCurrentBranch(myUltimate, "feature") @@ -205,8 +215,7 @@ class GitBranchWorkerTest : GitPlatformTest() { checkoutRevision("feature", TestUiHandler()) assertDetachedState("feature") - assertEquals("Notification about successful branch checkout is incorrect", "Checked out " + bcode("feature"), - myVcsNotifier.lastNotification.content) + assertSuccessfulNotification("Checked out ${bcode("feature")}") } fun test_checkout_revision_checkout_ref_with_complete_success() { @@ -215,8 +224,7 @@ class GitBranchWorkerTest : GitPlatformTest() { checkoutRevision("feature~1", TestUiHandler()) assertDetachedState("master") - assertEquals("Notification about successful branch checkout is incorrect", "Checked out " + bcode("feature~1"), - myVcsNotifier.lastNotification.content) + assertSuccessfulNotification("Checked out ${bcode("feature~1")}") } fun test_checkout_revision_checkout_ref_with_complete_failure() { @@ -226,13 +234,11 @@ class GitBranchWorkerTest : GitPlatformTest() { assertCurrentBranch("master") assertCurrentRevision("master") - assertEquals("Notification about successful branch checkout is incorrect", - "Revision not found in project, community and contrib", - myVcsNotifier.lastNotification.content) + assertSuccessfulNotification("Revision not found in project, community and contrib") } fun test_checkout_revision_checkout_ref_with_partial_success() { - branchWithCommit(ContainerUtil.list(myCommunity, myContrib), "feature") + branchWithCommit(listOf(myCommunity, myContrib), "feature") checkoutRevision("feature", TestUiHandler()) @@ -240,10 +246,8 @@ class GitBranchWorkerTest : GitPlatformTest() { assertDetachedState(myCommunity, "feature") assertDetachedState(myContrib, "feature") - assertEquals("Notification about successful branch checkout is incorrect", - "Checked out " + bcode("feature") + " in community and contrib" + "
" + - "Revision not found in project" + "
Rollback", - myVcsNotifier.lastNotification.content) + assertSuccessfulNotification("Checked out ${bcode("feature")} in community and contrib
" + + "Revision not found in project
Rollback") } fun test_checkout_with_untracked_files_overwritten_by_checkout_in_first_repo_should_show_notification() { @@ -368,13 +372,8 @@ class GitBranchWorkerTest : GitPlatformTest() { private fun agree_to_smart_operation(operation: String, expectedSuccessMessage: String): List { val localChanges = prepareLocalChangesOverwrittenBy(myUltimate) - - val handler = TestUiHandler() - checkoutOrMerge(operation, "feature", handler) - - assertNotNull("No success notification was shown", myVcsNotifier.lastNotification) - assertEquals("Success message is incorrect", expectedSuccessMessage, myVcsNotifier.lastNotification.content) - + checkoutOrMerge(operation, "feature", TestUiHandler()) + assertSuccessfulNotification(expectedSuccessMessage) return localChanges } @@ -406,9 +405,7 @@ class GitBranchWorkerTest : GitPlatformTest() { changes: List, paths: Collection, operation: String, - forceButton: String?): Int { - return GitSmartOperationDialog.CANCEL_EXIT_CODE - } + forceButton: String?) = GitSmartOperationDialog.CANCEL_EXIT_CODE }) assertNull("Notification was unexpectedly shown:" + myVcsNotifier.lastNotification, myVcsNotifier.lastNotification) @@ -435,9 +432,7 @@ class GitBranchWorkerTest : GitPlatformTest() { changes: List, paths: Collection, operation: String, - forceButton: String?): Int { - return GitSmartOperationDialog.CANCEL_EXIT_CODE - } + forceButton: String?) = GitSmartOperationDialog.CANCEL_EXIT_CODE override fun notifyErrorWithRollbackProposal(title: String, message: String, @@ -459,21 +454,17 @@ class GitBranchWorkerTest : GitPlatformTest() { changes: List, paths: Collection, operation: String, - forceButton: String?): Int { - return GitSmartOperationDialog.FORCE_EXIT_CODE - } + forceButton: String?) = GitSmartOperationDialog.FORCE_EXIT_CODE }) brancher.checkoutNewBranchStartingFrom("new_branch", "feature", myRepositories) - assertEquals("Notification about successful branch creation is incorrect", - "Checked out new branch new_branch from feature", - myVcsNotifier.lastNotification.content) + assertSuccessfulNotification("Checked out new branch new_branch from feature") assertCurrentBranch("new_branch") } fun test_rollback_of_checkout_branch_as_new_branch_should_delete_branches() { branchWithCommit(myRepositories, "feature") - Executor.touch("feature.txt", "feature_content") + touch("feature.txt", "feature_content") git("add feature.txt") git("commit -m feature_changes") git("checkout master") @@ -546,9 +537,7 @@ class GitBranchWorkerTest : GitPlatformTest() { override fun showBranchIsNotFullyMergedDialog(project: Project, history: Map>, baseBranches: Map, - removedBranch: String): Boolean { - return true - } + removedBranch: String) = true }) assertBranchDeleted("todelete") } @@ -597,7 +586,7 @@ class GitBranchWorkerTest : GitPlatformTest() { git("push -u origin $feature") // create a commit and merge it to master, but not to feature's upstream - Executor.touch("feature.txt", "feature content") + touch("feature.txt", "feature content") git("add feature.txt") git("commit -m feature_branch") git("checkout master") @@ -638,9 +627,7 @@ class GitBranchWorkerTest : GitPlatformTest() { mergeBranch("master2", TestUiHandler()) - assertNotNull("Success message wasn't shown", myVcsNotifier.lastNotification) - assertEquals("Success message is incorrect", - "Merged " + bcode("master2") + " to " + bcode("master") + "
Delete master2", + assertSuccessfulNotification("Merged " + bcode("master2") + " to " + bcode("master") + "
Delete master2", myVcsNotifier.lastNotification.content) assertFile(myUltimate, "branch_file.txt", "branch content") assertFile(myCommunity, "branch_file.txt", "branch content") @@ -759,7 +746,7 @@ class GitBranchWorkerTest : GitPlatformTest() { fun test_checkout_in_detached_head() { cd(myCommunity) - Executor.touch("file.txt", "some content") + touch("file.txt", "some content") add("file.txt") commit("msg") git(myCommunity, "checkout HEAD^") @@ -903,7 +890,7 @@ class GitBranchWorkerTest : GitPlatformTest() { } cd(unmergedRepo) git("checkout todelete") - Executor.touch("afile.txt", "content") + touch("afile.txt", "content") git("add afile.txt") git("commit -m unmerged_commit") git("checkout master") diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java index dada1a19dea8..5e44418d11f1 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java @@ -157,7 +157,7 @@ public class UseDistributionWithSourcesNotificationProvider extends EditorNotifi String distributionUri = wrapperConfiguration.getDistribution().toString(); try { String host = new URI(distributionUri).getHost(); - return host.endsWith("gradle.org") && !GRADLE_SRC_DISTRIBUTION_PATTERN.matcher(distributionUri).matches(); + return host != null && host.endsWith("gradle.org") && !GRADLE_SRC_DISTRIBUTION_PATTERN.matcher(distributionUri).matches(); } catch (URISyntaxException ignore) { } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleResourceCompilerConfigurationGenerator.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleResourceCompilerConfigurationGenerator.java index 14abae3cb9e5..5d41af3777cb 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleResourceCompilerConfigurationGenerator.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleResourceCompilerConfigurationGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -35,11 +35,11 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.util.ArrayUtil; import com.intellij.util.Function; +import com.intellij.util.JdomKt; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.FactoryMap; import com.intellij.util.xmlb.XmlSerializer; import gnu.trove.THashMap; -import org.jdom.Document; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -127,8 +127,8 @@ public class GradleResourceCompilerConfigurationGenerator { // update with newly generated configuration projectConfig.moduleConfigurations.putAll(affectedGradleModuleConfigurations); - final Document document = new Document(new Element("gradle-project-configuration")); - XmlSerializer.serializeInto(projectConfig, document.getRootElement()); + final Element element = new Element("gradle-project-configuration"); + XmlSerializer.serializeInto(projectConfig, element); final boolean finalConfigurationUpdateRequired = configurationUpdateRequired; buildManager.runCommand(() -> { if (finalConfigurationUpdateRequired) { @@ -136,7 +136,7 @@ public class GradleResourceCompilerConfigurationGenerator { } FileUtil.createIfDoesntExist(gradleConfigFile); try { - JDOMUtil.writeDocument(document, gradleConfigFile, "\n"); + JdomKt.write(element, gradleConfigFile.toPath()); myModulesConfigurationHash.putAll(affectedConfigurationHash); } catch (IOException e) { diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java index 39e71c86ea88..c6b53496e4e5 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -24,10 +24,10 @@ import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall; +import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyNamesUtil; import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil; import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder; import org.jetbrains.plugins.groovy.lang.resolve.ClosureMissingMethodContributor; -import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyNamesUtil; import org.jetbrains.plugins.groovy.util.FixedValuesReferenceProvider; import java.lang.reflect.Modifier; @@ -126,6 +126,13 @@ public class GroovyMethodInfo { if (methodKind instanceof String) { lightMethodInfos = getInfos(LIGHT_METHOD_INFOS, (String)methodKind, method); } + + if (method instanceof PsiMirrorElement) { + PsiElement prototype = ((PsiMirrorElement)method).getPrototype(); + if (prototype instanceof PsiMethod) { + method = (PsiMethod)prototype; + } + } List methodInfos = null; diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyNamedArgumentProvider.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyNamedArgumentProvider.java index 74ffc3018459..396f0e1ca13c 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyNamedArgumentProvider.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyNamedArgumentProvider.java @@ -41,23 +41,37 @@ public abstract class GroovyNamedArgumentProvider { public static final ExtensionPointName EP_NAME = ExtensionPointName.create("org.intellij.groovy.namedArgumentProvider"); + @SuppressWarnings("unused") + @Deprecated public void getNamedArguments(@NotNull GrCall call, @Nullable PsiElement resolve, @Nullable String argumentName, boolean forCompletion, - Map result) { + @NotNull Map result) { // no op } + @SuppressWarnings("unused") + @Deprecated public void getNamedArguments(@NotNull GrCall call, @Nullable PsiElement resolve, @Nullable GroovyResolveResult resolveResult, @Nullable String argumentName, boolean forCompletion, - Map result) { + @NotNull Map result) { + //noinspection deprecation getNamedArguments(call, resolve, argumentName, forCompletion, result); } + public void getNamedArguments(@NotNull GrCall call, + @NotNull GroovyResolveResult resolveResult, + @Nullable String argumentName, + boolean forCompletion, + @NotNull Map result) { + //noinspection deprecation + getNamedArguments(call, resolveResult.getElement(), resolveResult, argumentName, forCompletion, result); + } + @NotNull public Map getNamedArguments(@NotNull GrListOrMap literal) { return Collections.emptyMap(); @@ -84,7 +98,7 @@ public abstract class GroovyNamedArgumentProvider { if (callVariants.length == 0 || PsiUtil.isSingleBindingVariant(callVariants)) { for (GroovyNamedArgumentProvider namedArgumentProvider : EP_NAME.getExtensions()) { - namedArgumentProvider.getNamedArguments(call, null, null, argumentName, forCompletion, namedArguments); + namedArgumentProvider.getNamedArguments(call, GroovyResolveResult.EMPTY_RESULT, argumentName, forCompletion, namedArguments); } } else { @@ -105,7 +119,7 @@ public abstract class GroovyNamedArgumentProvider { if (methodInfo.getNamedArguments() != null || methodInfo.isNamedArgumentProviderDefined()) { if (methodInfo.isApplicable(method)) { if (methodInfo.isNamedArgumentProviderDefined()) { - methodInfo.getNamedArgProvider().getNamedArguments(call, element, result, argumentName, forCompletion, namedArguments); + methodInfo.getNamedArgProvider().getNamedArguments(call, result, argumentName, forCompletion, namedArguments); } if (methodInfo.getNamedArguments() != null) { namedArguments.putAll(methodInfo.getNamedArguments()); @@ -116,7 +130,7 @@ public abstract class GroovyNamedArgumentProvider { } for (GroovyNamedArgumentProvider namedArgumentProvider : EP_NAME.getExtensions()) { - namedArgumentProvider.getNamedArguments(call, element, result, argumentName, forCompletion, namedArguments); + namedArgumentProvider.getNamedArguments(call, result, argumentName, forCompletion, namedArguments); } if (element instanceof GrVariable && diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyConstructorNamedArgumentProvider.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyConstructorNamedArgumentProvider.java index b9274369878c..e970aafba57e 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyConstructorNamedArgumentProvider.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyConstructorNamedArgumentProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -53,11 +53,12 @@ public class GroovyConstructorNamedArgumentProvider extends GroovyNamedArgumentP @Override public void getNamedArguments(@NotNull GrCall call, - @Nullable PsiElement resolve, + @NotNull GroovyResolveResult resolveResult, @Nullable String argumentName, boolean forCompletion, - Map result) { + @NotNull Map result) { if (!(call instanceof GrNewExpression)) return; + PsiElement resolve = resolveResult.getElement(); if (resolve != null) { if (!(resolve instanceof PsiMethod)) return; @@ -75,8 +76,8 @@ public class GroovyConstructorNamedArgumentProvider extends GroovyNamedArgumentP return; } - for (GroovyResolveResult resolveResult : newCall.multiResolveClass()) { - PsiElement element = resolveResult.getElement(); + for (GroovyResolveResult newResult : newCall.multiResolveClass()) { + PsiElement element = newResult.getElement(); if (!(element instanceof PsiClass)) continue; PsiClass aClass = (PsiClass)element; diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyMethodReturnNamedArgumentProvider.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyMethodReturnNamedArgumentProvider.java index a0303f512ba2..939b38f55ae8 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyMethodReturnNamedArgumentProvider.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyMethodReturnNamedArgumentProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 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,6 +23,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.extensions.GroovyNamedArgumentProvider; import org.jetbrains.plugins.groovy.extensions.NamedArgumentDescriptor; +import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrCall; import java.util.HashMap; @@ -34,10 +35,11 @@ import java.util.Map; public class GroovyMethodReturnNamedArgumentProvider extends GroovyNamedArgumentProvider { @Override public void getNamedArguments(@NotNull GrCall call, - @Nullable PsiElement resolve, + @NotNull GroovyResolveResult resolveResult, @Nullable String argumentName, boolean forCompletion, - Map result) { + @NotNull Map result) { + PsiElement resolve = resolveResult.getElement(); if (!forCompletion || !(resolve instanceof PsiMethod)) return; PsiType returnType = ((PsiMethod)resolve).getReturnType(); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovySourceCodeNamedArgumentProvider.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovySourceCodeNamedArgumentProvider.java index 9bf95b799931..24e01bf0d62a 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovySourceCodeNamedArgumentProvider.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovySourceCodeNamedArgumentProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 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,6 +20,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.extensions.GroovyNamedArgumentProvider; import org.jetbrains.plugins.groovy.extensions.NamedArgumentDescriptor; +import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrNamedArgumentSearchVisitor; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable; @@ -34,10 +35,11 @@ import java.util.Map; public class GroovySourceCodeNamedArgumentProvider extends GroovyNamedArgumentProvider { @Override public void getNamedArguments(@NotNull GrCall call, - @Nullable PsiElement resolve, + @NotNull GroovyResolveResult resolveResult, @Nullable String argumentName, boolean forCompletion, - Map result) { + @NotNull Map result) { + PsiElement resolve = resolveResult.getElement(); if (resolve instanceof GrMethod) { result.putAll(((GrMethod)resolve).getNamedParameters()); } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyImportUtil.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyImportUtil.java index dd9d861a0e05..4f4308b55701 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyImportUtil.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyImportUtil.java @@ -27,6 +27,7 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor; import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult; import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement; +import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.packaging.GrPackageDefinition; import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement; import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyImportHelper; import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint; @@ -54,13 +55,17 @@ public class GroovyImportUtil { file.accept(new PsiRecursiveElementWalkingVisitor() { @Override public void visitElement(PsiElement element) { - super.visitElement(element); + if (!(element instanceof GrImportStatement) && !(element instanceof GrPackageDefinition)) { + super.visitElement(element); + } if (element instanceof GrReferenceElement) { visitRefElement((GrReferenceElement)element); } } private void visitRefElement(GrReferenceElement refElement) { + if (refElement.isQualified()) return; + final String refName = refElement.getReferenceName(); if ("super".equals(refName)) return; diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/DependentResolver.kt b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/DependentResolver.kt index 8f061d7316b3..79604ea9d8d8 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/DependentResolver.kt +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/DependentResolver.kt @@ -22,7 +22,16 @@ import com.intellij.psi.impl.source.resolve.ResolveCache abstract class DependentResolver : ResolveCache.PolyVariantResolver { companion object { - private val resolvingDependencies = ThreadLocal.withInitial> { mutableSetOf() } + /** + * Given: resolve was called on a reference a.r1.r2...rN. + * Its dependencies: a, a.r1, a.r1.r2, ... , a.r1.r2...rN-1. + * We resolve dependencies in a loop. + * Assume currently resolving dependency is a.r1.r2...rK, K < N. + * By the time it is being processed all its dependencies are already resolved and the resolve results are stored in a list, + * so we do not need to collect/resolve its dependencies again. + * This field is needed to memoize currently resolving dependencies. + */ + private val resolvingDependencies = ThreadLocal.withInitial { mutableSetOf() } } override final fun resolve(ref: T, incomplete: Boolean): Array { diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNamedArgumentProvider.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNamedArgumentProvider.java index ab4117abd2e6..9c7d023251fd 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNamedArgumentProvider.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNamedArgumentProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.extensions.GroovyNamedArgumentProvider; import org.jetbrains.plugins.groovy.extensions.NamedArgumentDescriptor; import org.jetbrains.plugins.groovy.extensions.impl.TypeCondition; +import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrCall; import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil; import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames; @@ -39,10 +40,11 @@ public class SwingBuilderNamedArgumentProvider extends GroovyNamedArgumentProvid @Override public void getNamedArguments(@NotNull GrCall call, - @Nullable PsiElement resolve, + @NotNull GroovyResolveResult resolveResult, @Nullable String argumentName, boolean forCompletion, - Map result) { + @NotNull Map result) { + PsiElement resolve = resolveResult.getElement(); PsiType returnType = resolve == null ? null : ((PsiMethod)resolve).getReturnType(); PsiClass aClass = PsiTypesUtil.getPsiClass(returnType); if (aClass == null) return; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlockGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlockGenerator.java index 301eaf6f5600..d54618609dbe 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlockGenerator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlockGenerator.java @@ -617,20 +617,20 @@ public class GroovyBlockGenerator { ArrayList childList = new ArrayList<>(); PsiFile groovyFile = psi.getContainingFile().getViewProvider().getPsi(GroovyLanguage.INSTANCE); if (groovyFile instanceof GroovyFileBase) { - addChildNodes(groovyFile, childList, range); + addChildNodes(groovyFile, childList, range, psi); } return childList.toArray(new ASTNode[childList.size()]); } return node.getChildren(null); } - private static void addChildNodes(PsiElement elem, ArrayList childNodes, TextRange range) { + private static void addChildNodes(PsiElement elem, ArrayList childNodes, TextRange range, PsiElement root) { ASTNode node = elem.getNode(); - if (range.contains(elem.getTextRange()) && node != null) { + if (range.contains(elem.getTextRange()) && node != null && elem != root) { childNodes.add(node); } else { for (PsiElement child : elem.getChildren()) { - addChildNodes(child, childNodes, range); + addChildNodes(child, childNodes, range, root); } } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyMapAttributeTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyMapAttributeTest.groovy index 4af6105d6621..ad758ebdaf08 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyMapAttributeTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyMapAttributeTest.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -469,6 +469,7 @@ class Test { private doTestCompletionWithinMap(String text, String text2 = null) { PlatformTestUtil.registerExtension GroovyNamedArgumentProvider.EP_NAME, new GroovyNamedArgumentProvider() { + @NotNull @Override Map getNamedArguments(@NotNull GrListOrMap literal) { ['foo': NamedArgumentDescriptor.SIMPLE_NORMAL, 'bar': NamedArgumentDescriptor.SIMPLE_NORMAL] diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyStressPerformanceTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyStressPerformanceTest.groovy index 891a03467c27..93807db9bf3c 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyStressPerformanceTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyStressPerformanceTest.groovy @@ -538,9 +538,9 @@ class Node { def a = new Node() """ def data = [ - "(a${'.nn' * 1000}).nn", // (a.nn.nn ...).nn ... .nn - "a${'.nn()' * 500}.nn", // a.nn().nn() ... .nn().nn - "a${' += a' * 1000} += new Node()", // a += a += a ... += a += new Node() + "a${'.nn' * 500}.nn", // a.nn.nn ... .nn + "a${'.nn()' * 250}.nn", // a.nn() ... .nn().nn + "a${' += a' * 500} += new Node()", // a += a ... += a += new Node() ] for (expressionText in data) { def file = (GroovyFile)fixture.configureByText('_.groovy', header + expressionText) diff --git a/plugins/hg4idea/resources/org/zmlx/hg4idea/HgVcsMessages.properties b/plugins/hg4idea/resources/org/zmlx/hg4idea/HgVcsMessages.properties index caafa202b9e9..83e2e3bfe968 100644 --- a/plugins/hg4idea/resources/org/zmlx/hg4idea/HgVcsMessages.properties +++ b/plugins/hg4idea/resources/org/zmlx/hg4idea/HgVcsMessages.properties @@ -24,7 +24,7 @@ hg4idea.commit=Commit hg4idea.add.title=Add files to Mercurial hg4idea.add.single.title=Add file to Mercurial -hg4idea.add.body=Do you want to add the following file to Mercurial?\n{0}\n\nIf you say NO, you can still add it later manually. +hg4idea.add.body=Do you want to add the following file to Mercurial?\n{0}\n\nIf you choose NO, you can still add it later manually. hg4idea.add.progress=Adding files to Mercurial hg4idea.clone.title=Clone Mercurial Repository @@ -91,7 +91,7 @@ hg4idea.push.branch=&Branch\: hg4idea.push.force=&Force push hg4idea.remove.single.title=Remove file from Mercurial -hg4idea.remove.single.body=Do you want to remove the following file from Mercurial?\n{0}\n\nIf you say NO, you can still remove it later manually. +hg4idea.remove.single.body=Do you want to remove the following file from Mercurial?\n{0}\n\nIf you choose NO, you can still remove it later manually. hg4idea.remove.multiple.title=Remove files from Mercurial hg4idea.remove.progress=Removing files from the VCS... diff --git a/plugins/junit/test/com/intellij/execution/junit/JUnitConfigurationTest.java b/plugins/junit/test/com/intellij/execution/junit/JUnitConfigurationTest.java index 6913d966eac0..6c8acc849552 100644 --- a/plugins/junit/test/com/intellij/execution/junit/JUnitConfigurationTest.java +++ b/plugins/junit/test/com/intellij/execution/junit/JUnitConfigurationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -16,8 +16,8 @@ package com.intellij.execution.junit; import com.intellij.execution.testframework.TestSearchScope; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.testFramework.LightPlatformTestCase; +import com.intellij.util.JdomKt; import org.jdom.Element; public class JUnitConfigurationTest extends LightPlatformTestCase { @@ -27,11 +27,11 @@ public class JUnitConfigurationTest extends LightPlatformTestCase { JUnitConfiguration foo = new JUnitConfiguration("foo", getProject(), JUnitConfigurationType.getInstance().getConfigurationFactories()[0]); Element element = - JDOMUtil.loadDocument("\n" + - " \n" + - " ").getRootElement(); + JdomKt.loadElement("\n" + + " \n" + + " "); foo.readExternal(element); assertEquals(TestSearchScope.MODULE_WITH_DEPENDENCIES, foo.getPersistentData().getScope()); } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/FacetImporter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/FacetImporter.java index 262e8fa42559..42df462cf151 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/FacetImporter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/FacetImporter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -90,7 +90,20 @@ public abstract class FacetImporter result = new LinkedHashSet<>(); - List children = root.getChildren(ELEMENT_ARCHETYPE); + List children = JdomKt.loadElement(file).getChildren(ELEMENT_ARCHETYPE); for (int i = children.size() - 1; i >= 0; i--) { Element each = children.get(i); @@ -385,16 +390,15 @@ public class MavenIndicesManager implements Disposable { root.addContent(childElement); } try { - File file = getUserArchetypesFile(); - file.getParentFile().mkdirs(); - JDOMUtil.writeDocument(new Document(root), file, "\n"); + JdomKt.write(root, getUserArchetypesFile()); } catch (IOException e) { MavenLog.LOG.warn(e); } } - private File getUserArchetypesFile() { - return new File(getIndicesDir(), "UserArchetypes.xml"); + @NotNull + private Path getUserArchetypesFile() { + return getIndicesDir().resolve("UserArchetypes.xml"); } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenProjectIndicesManager.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenProjectIndicesManager.java index 729ad07c61dc..602ae4f36485 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenProjectIndicesManager.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenProjectIndicesManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -70,19 +70,13 @@ public class MavenProjectIndicesManager extends MavenSimpleProjectComponent { } getMavenProjectManager().addManagerListener(new MavenProjectsManager.Listener() { + @Override public void activated() { scheduleUpdateIndicesList(); } - - public void projectsScheduled() { - } - - @Override - public void importAndResolveScheduled() { - } }); - getMavenProjectManager().addProjectsTreeListener(new MavenProjectsTree.ListenerAdapter() { + getMavenProjectManager().addProjectsTreeListener(new MavenProjectsTree.Listener() { @Override public void projectsUpdated(List> updated, List deleted) { scheduleUpdateIndicesList(); @@ -102,6 +96,7 @@ public class MavenProjectIndicesManager extends MavenSimpleProjectComponent { public void scheduleUpdateIndicesList(@Nullable final Consumer> consumer) { myUpdateQueue.queue(new Update(MavenProjectIndicesManager.this) { + @Override public void run() { Set> remoteRepositoriesIdsAndUrls; File localRepository; diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigator.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigator.java index 33c38e9975c4..c669e4207d65 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigator.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -379,20 +379,12 @@ public class MavenProjectsNavigator extends MavenSimpleProjectComponent implemen scheduleStructureRequest(() -> myStructure.update()); } - private class MyProjectsListener extends MavenProjectsTree.ListenerAdapter implements MavenProjectsManager.Listener { + private class MyProjectsListener implements MavenProjectsManager.Listener, MavenProjectsTree.Listener { @Override public void activated() { scheduleStructureUpdate(); } - @Override - public void projectsScheduled() { - } - - @Override - public void importAndResolveScheduled() { - } - @Override public void projectsIgnoredStateChanged(final List ignored, final List unignored, boolean fromImport) { scheduleStructureRequest(() -> myStructure.updateIgnored(ContainerUtil.concat(ignored, unignored))); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java index 60d0daf189ef..3f4190baa4f3 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -40,7 +40,6 @@ import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.*; -import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VfsUtilCore; @@ -51,6 +50,7 @@ import com.intellij.util.EventDispatcher; import com.intellij.util.NullableConsumer; import com.intellij.util.ObjectUtils; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.io.PathKt; import com.intellij.util.ui.update.Update; import gnu.trove.THashMap; import gnu.trove.THashSet; @@ -69,6 +69,7 @@ import org.jetbrains.idea.maven.utils.*; import javax.swing.event.HyperlinkEvent; import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.locks.ReentrantLock; @@ -306,9 +307,9 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent private void initProjectsTree(boolean tryToLoadExisting) { if (tryToLoadExisting) { - File file = getProjectsTreeFile(); + Path file = getProjectsTreeFile(); try { - if (file.exists()) { + if (PathKt.exists(file)) { myProjectsTree = MavenProjectsTree.read(myProject, file); } } @@ -353,11 +354,12 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent } } - private File getProjectsTreeFile() { - return new File(getProjectsTreesDir(), myProject.getLocationHash() + "/tree.dat"); + private Path getProjectsTreeFile() { + return getProjectsTreesDir().resolve(myProject.getLocationHash()).resolve("tree.dat"); } - private static File getProjectsTreesDir() { + @NotNull + private static Path getProjectsTreesDir() { return MavenUtil.getPluginSystemDir("Projects"); } @@ -385,6 +387,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent private void listenForSettingsChanges() { getImportingSettings().addListener(new MavenImportingSettings.Listener() { + @Override public void autoImportChanged() { if (myProject.isDisposed()) return; @@ -393,10 +396,12 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent } } + @Override public void createModuleGroupsChanged() { scheduleImportSettings(true); } + @Override public void createModuleForAggregatorsChanged() { scheduleImportSettings(); } @@ -404,7 +409,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent } private void listenForProjectsTreeChanges() { - myProjectsTree.addListener(new MavenProjectsTree.ListenerAdapter() { + myProjectsTree.addListener(new MavenProjectsTree.Listener() { @Override public void projectsIgnoredStateChanged(List ignored, List unignored, boolean fromImport) { if (!fromImport) scheduleImport(); @@ -528,7 +533,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent mySaveQueue.flush(); if (isUnitTestMode()) { - FileUtil.delete(getProjectsTreesDir()); + PathKt.delete(getProjectsTreesDir()); } } finally { initLock.unlock(); @@ -701,10 +706,12 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent @Nullable public MavenProject findProject(@NotNull Module module) { VirtualFile f = findPomFile(module, new MavenModelsProvider() { + @Override public Module[] getModules() { throw new UnsupportedOperationException(); } + @Override public VirtualFile[] getContentRoots(Module module) { return ModuleRootManager.getInstance(module).getContentRoots(); } @@ -804,9 +811,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent public Set getRemoteRepositories() { Set result = new THashSet<>(); for (MavenProject each : getProjects()) { - for (MavenRemoteRepository eachRepository : each.getRemoteRepositories()) { - result.add(eachRepository); - } + result.addAll(each.getRemoteRepositories()); } return result; } @@ -989,6 +994,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent private Promise> scheduleImport() { final AsyncPromise> result = new AsyncPromise<>(); runWhenFullyOpen(() -> myImportingQueue.queue(new Update(MavenProjectsManager.this) { + @Override public void run() { result.setResult(importProjects()); } @@ -1178,6 +1184,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent } else { MavenUtil.runInBackground(myProject, ProjectBundle.message("maven.project.importing"), false, new MavenTask() { + @Override public void run(MavenProgressIndicator indicator) throws MavenProcessCanceledException { r.run(); } @@ -1257,10 +1264,13 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent } public interface Listener { - void activated(); + default void activated() { + } - void projectsScheduled(); + default void projectsScheduled() { + } - void importAndResolveScheduled(); + default void importAndResolveScheduled() { + } } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java index 5dacbbd09732..eff041bf6562 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 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,6 +32,7 @@ import com.intellij.util.containers.ArrayListSet; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.MultiMap; import com.intellij.util.containers.Stack; +import com.intellij.util.io.PathKt; import gnu.trove.THashSet; import gnu.trove.TObjectHashingStrategy; import org.jdom.Element; @@ -48,6 +49,7 @@ import org.jetbrains.idea.maven.server.NativeMavenProjectHolder; import org.jetbrains.idea.maven.utils.*; import java.io.*; +import java.nio.file.Path; import java.util.*; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantReadWriteLock; @@ -88,6 +90,7 @@ public class MavenProjectsTree { private final Project myProject; private final MavenProjectReaderProjectLocator myProjectLocator = new MavenProjectReaderProjectLocator() { + @Override public VirtualFile findProjectFile(MavenId coordinates) { MavenProject project = findProject(coordinates); return project == null ? null : project.getFile(); @@ -99,11 +102,10 @@ public class MavenProjectsTree { } @Nullable - public static MavenProjectsTree read(Project project, File file) throws IOException { + public static MavenProjectsTree read(Project project, Path file) throws IOException { MavenProjectsTree result = new MavenProjectsTree(project); - DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file))); - try { + try (DataInputStream in = new DataInputStream(new BufferedInputStream(PathKt.inputStream(file)))) { try { if (!STORAGE_VERSION.equals(in.readUTF())) return null; result.myManagedFilesPaths = readCollection(in, new LinkedHashSet<>()); @@ -115,16 +117,13 @@ public class MavenProjectsTree { } catch (IOException e) { in.close(); - file.delete(); + PathKt.delete(file); throw e; } catch (Throwable e) { throw new IOException(e); } } - finally { - in.close(); - } return result; } @@ -165,13 +164,11 @@ public class MavenProjectsTree { return result; } - public void save(File file) throws IOException { + public void save(@NotNull Path file) throws IOException { synchronized (myStateLock) { readLock(); try { - file.getParentFile().mkdirs(); - DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file))); - try { + try (DataOutputStream out = new DataOutputStream(new BufferedOutputStream(PathKt.outputStream(file)))) { out.writeUTF(STORAGE_VERSION); writeCollection(out, myManagedFilesPaths); writeCollection(out, myIgnoredFilesPaths); @@ -180,9 +177,6 @@ public class MavenProjectsTree { writeCollection(out, myExplicitProfiles.getDisabledProfiles()); writeProjectsRecursively(out, myRootProjects); } - finally { - out.close(); - } } finally { readUnlock(); @@ -373,8 +367,8 @@ public class MavenProjectsTree { } } - private void updateExplicitProfiles(Collection explicitProfiles, Collection temporarilyRemovedExplicitProfiles, - Collection available) { + private static void updateExplicitProfiles(Collection explicitProfiles, Collection temporarilyRemovedExplicitProfiles, + Collection available) { Collection removedProfiles = new THashSet<>(explicitProfiles); removedProfiles.removeAll(available); temporarilyRemovedExplicitProfiles.addAll(removedProfiles); @@ -1357,6 +1351,7 @@ public class MavenProjectsTree { console, process, new EmbedderTask() { + @Override public void run(MavenEmbedderWrapper embedder) throws MavenProcessCanceledException { process.checkCanceled(); process.setText(ProjectBundle.message("maven.updating.folders.pom", mavenProject.getDisplayName())); @@ -1656,48 +1651,30 @@ public class MavenProjectsTree { } public interface Listener extends EventListener { - void profilesChanged(); - - void projectsIgnoredStateChanged(List ignored, List unignored, boolean fromImport); - - void projectsUpdated(List> updated, List deleted); - - void projectResolved(Pair projectWithChanges, - @Nullable NativeMavenProjectHolder nativeMavenProject); - - void pluginsResolved(MavenProject project); - - void foldersResolved(Pair projectWithChanges); - - void artifactsDownloaded(MavenProject project); - } - - public static class ListenerAdapter implements Listener { - public void profilesChanged() { + default void profilesChanged() { } - public void projectsIgnoredStateChanged(List ignored, List unignored, boolean fromImport) { + default void projectsIgnoredStateChanged(List ignored, List unignored, boolean fromImport) { } - public void projectsUpdated(List> updated, List deleted) { + default void projectsUpdated(List> updated, List deleted) { } - public void projectResolved(Pair projectWithChanges, - @Nullable NativeMavenProjectHolder nativeMavenProject) { + default void projectResolved(Pair projectWithChanges, + @Nullable NativeMavenProjectHolder nativeMavenProject) { } - public void pluginsResolved(MavenProject project) { + default void pluginsResolved(MavenProject project) { } - public void foldersResolved(Pair projectWithChanges) { + default void foldersResolved(Pair projectWithChanges) { } - public void artifactsDownloaded(MavenProject project) { + default void artifactsDownloaded(MavenProject project) { } } private static class MavenCoordinateHashCodeStrategy implements TObjectHashingStrategy { - @Override public int computeHashCode(MavenCoordinate object) { String artifactId = object.getArtifactId(); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenResourceCompilerConfigurationGenerator.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenResourceCompilerConfigurationGenerator.java index 63b73b8185cb..71c5a93818fd 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenResourceCompilerConfigurationGenerator.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenResourceCompilerConfigurationGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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.openapi.project.Project; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.roots.*; import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.io.StreamUtil; import com.intellij.openapi.util.text.StringUtil; @@ -33,9 +32,9 @@ import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.JdomKt; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.xmlb.XmlSerializer; -import org.jdom.Document; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -189,13 +188,13 @@ public class MavenResourceCompilerConfigurationGenerator { addNonMavenResources(projectConfig); - final Document document = new Document(new Element("maven-project-configuration")); - XmlSerializer.serializeInto(projectConfig, document.getRootElement()); + final Element element = new Element("maven-project-configuration"); + XmlSerializer.serializeInto(projectConfig, element); buildManager.runCommand(() -> { buildManager.clearState(myProject); FileUtil.createIfDoesntExist(mavenConfigFile); try { - JDOMUtil.writeDocument(document, mavenConfigFile, "\n"); + JdomKt.write(element, mavenConfigFile.toPath()); DataOutputStream crcOutput = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(crcFile))); try { diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/MavenShortcutsManager.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/MavenShortcutsManager.java index c65ba7aaabb9..4c07fa1a6e51 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/MavenShortcutsManager.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/MavenShortcutsManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 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.openapi.project.DumbAwareRunnable; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.update.MergingUpdateQueue; import com.intellij.util.ui.update.Update; @@ -188,7 +187,7 @@ public class MavenShortcutsManager extends MavenSimpleProjectComponent implement } } - private class MyProjectsTreeListener extends MavenProjectsTree.ListenerAdapter implements MavenProjectsManager.Listener { + private class MyProjectsTreeListener implements MavenProjectsManager.Listener, MavenProjectsTree.Listener { private final Map mySheduledProjects = new THashMap<>(); private final MergingUpdateQueue myUpdateQueue = new MavenMergingUpdateQueue(getComponentName() + ": Keymap Update", 500, true, myProject); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenEditorTabTitleUpdater.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenEditorTabTitleUpdater.java index 9fc34de11a22..c460cae86032 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenEditorTabTitleUpdater.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenEditorTabTitleUpdater.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -35,7 +35,7 @@ public class MavenEditorTabTitleUpdater extends MavenSimpleProjectComponent { public void initComponent() { if (!isNormalProject()) return; - MavenProjectsManager.getInstance(myProject).addProjectsTreeListener(new MavenProjectsTree.ListenerAdapter() { + MavenProjectsManager.getInstance(myProject).addProjectsTreeListener(new MavenProjectsTree.Listener() { @Override public void projectsUpdated(List> updated, List deleted) { updateTabName(MavenUtil.collectFirsts(updated)); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenRehighlighter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenRehighlighter.java index b071905a5736..8f7681b62945 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenRehighlighter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenRehighlighter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -69,7 +69,7 @@ public class MavenRehighlighter { } }); - mavenProjectManager.addProjectsTreeListener(new MavenProjectsTree.ListenerAdapter() { + mavenProjectManager.addProjectsTreeListener(new MavenProjectsTree.Listener() { @Override public void projectsUpdated(List> updated, List deleted) { for (Pair each : updated) { diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java index 656913d24787..b31097ab33d5 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -80,6 +80,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.nio.file.Paths; import java.util.*; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -220,9 +221,10 @@ public class MavenUtil { Notifications.Bus.notify(new Notification(MAVEN_NOTIFICATION_GROUP, title, e.getMessage(), NotificationType.ERROR), project); } - public static File getPluginSystemDir(String folder) { + @NotNull + public static java.nio.file.Path getPluginSystemDir(@NotNull String folder) { // PathManager.getSystemPath() may return relative path - return new File(PathManager.getSystemPath(), "Maven" + "/" + folder).getAbsoluteFile(); + return Paths.get(PathManager.getSystemPath()).toAbsolutePath().resolve("Maven").resolve(folder); } public static File getBaseDir(@NotNull VirtualFile file) { diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomWithIndicesTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomWithIndicesTestCase.java index 0bc6355d34d5..09ac71f8c070 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomWithIndicesTestCase.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomWithIndicesTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -28,7 +28,7 @@ public abstract class MavenDomWithIndicesTestCase extends MavenDomTestCase { } protected MavenIndicesTestFixture createIndicesFixture() { - return new MavenIndicesTestFixture(myDir, myProject); + return new MavenIndicesTestFixture(myDir.toPath(), myProject); } @Override diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenExtensionCompletionAndResolutionTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenExtensionCompletionAndResolutionTest.java index 59944dd44371..96679839f600 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenExtensionCompletionAndResolutionTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenExtensionCompletionAndResolutionTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -28,7 +28,7 @@ import java.util.List; public class MavenExtensionCompletionAndResolutionTest extends MavenDomWithIndicesTestCase { @Override protected MavenIndicesTestFixture createIndicesFixture() { - return new MavenIndicesTestFixture(myDir, myProject, "plugins"); + return new MavenIndicesTestFixture(myDir.toPath(), myProject, "plugins"); } @Override diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.java index a18f9c4a7d8e..de68e2d36d45 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 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,7 +17,6 @@ package org.jetbrains.idea.maven.dom; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReference; import com.intellij.psi.xml.XmlTag; @@ -29,7 +28,7 @@ import java.util.List; public class MavenPluginCompletionAndResolutionTest extends MavenDomWithIndicesTestCase { @Override protected MavenIndicesTestFixture createIndicesFixture() { - return new MavenIndicesTestFixture(myDir, myProject, "plugins"); + return new MavenIndicesTestFixture(myDir.toPath(), myProject, "plugins"); } @Override diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesManagerTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesManagerTest.java index a9f32184ee0f..0ab997624182 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesManagerTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -33,15 +33,19 @@ public class MavenIndicesManagerTest extends MavenIndicesTestCase { @Override protected void setUp() throws Exception { super.setUp(); - myIndicesFixture = new MavenIndicesTestFixture(myDir, myProject); + myIndicesFixture = new MavenIndicesTestFixture(myDir.toPath(), myProject); myIndicesFixture.setUp(); MavenServerManager.getInstance().setUseMaven2(true); } @Override protected void tearDown() throws Exception { - myIndicesFixture.tearDown(); - super.tearDown(); + try { + myIndicesFixture.tearDown(); + } + finally { + super.tearDown(); + } } public void testEnsuringLocalRepositoryIndex() throws Exception { @@ -51,17 +55,17 @@ public class MavenIndicesManagerTest extends MavenIndicesTestCase { File dir4 = myIndicesFixture.getRepositoryHelper().getTestData("dir/bar"); List indices1 = myIndicesFixture.getIndicesManager().ensureIndicesExist(myProject, dir1, - Collections.>emptyList()); + Collections.emptyList()); assertEquals(1, indices1.size()); assertTrue(myIndicesFixture.getIndicesManager().getIndices().contains(indices1.get(0))); assertEquals(indices1, myIndicesFixture.getIndicesManager().ensureIndicesExist(myProject, dir2, - Collections.>emptyList())); + Collections.emptyList())); assertEquals(indices1, myIndicesFixture.getIndicesManager().ensureIndicesExist(myProject, dir3, - Collections.>emptyList())); + Collections.emptyList())); List indices2 = myIndicesFixture.getIndicesManager().ensureIndicesExist(myProject, dir4, - Collections.>emptyList()); + Collections.emptyList()); assertFalse(indices1.get(0).equals(indices2.get(0))); } @@ -87,7 +91,7 @@ public class MavenIndicesManagerTest extends MavenIndicesTestCase { public void testIndexedArchetypes() throws Exception { myIndicesFixture.getRepositoryHelper().addTestData("archetypes"); myIndicesFixture.getIndicesManager().ensureIndicesExist(myProject, myIndicesFixture.getRepositoryHelper().getTestData("archetypes"), - Collections.>emptyList()); + Collections.emptyList()); assertArchetypeExists("org.apache.maven.archetypes:maven-archetype-foobar:1.0"); } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTest.java index 4953e74fc805..5cf8036d3df7 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTest.java @@ -53,8 +53,12 @@ public class MavenIndicesTest extends MavenIndicesTestCase { @Override protected void tearDown() throws Exception { - shutdownIndices(); - super.tearDown(); + try { + shutdownIndices(); + } + finally { + super.tearDown(); + } } private void initIndices() throws Exception { diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTestFixture.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTestFixture.java index c7aa0c542300..bfe9a2ac6f91 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTestFixture.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTestFixture.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 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,9 +23,10 @@ import org.jetbrains.idea.maven.server.MavenServerManager; import java.io.File; import java.io.IOException; +import java.nio.file.Path; public class MavenIndicesTestFixture { - private File myDir; + private Path myDir; private Project myProject; private String myLocalRepoDir; private String[] myExtraRepoDirs; @@ -33,11 +34,15 @@ public class MavenIndicesTestFixture { private MavenCustomRepositoryHelper myRepositoryHelper; private MavenProjectIndicesManager myIndicesManager; - public MavenIndicesTestFixture(File dir, Project project) { + public MavenIndicesTestFixture(Path dir, Project project) { this(dir, project, "local1", "local2"); } - public MavenIndicesTestFixture(File dir, Project project, String localRepoDir, String... extraRepoDirs) { + public MavenIndicesTestFixture(File dir, Project project) { + this(dir.toPath(), project); + } + + public MavenIndicesTestFixture(Path dir, Project project, String localRepoDir, String... extraRepoDirs) { myDir = dir; myProject = project; myLocalRepoDir = localRepoDir; @@ -45,7 +50,7 @@ public class MavenIndicesTestFixture { } public void setUp() throws Exception { - myRepositoryHelper = new MavenCustomRepositoryHelper(myDir, ArrayUtil.append(myExtraRepoDirs, myLocalRepoDir)); + myRepositoryHelper = new MavenCustomRepositoryHelper(myDir.toFile(), ArrayUtil.append(myExtraRepoDirs, myLocalRepoDir)); for (String each : myExtraRepoDirs) { addToRepository(each); @@ -54,7 +59,7 @@ public class MavenIndicesTestFixture { MavenProjectsManager.getInstance(myProject).getGeneralSettings().setLocalRepository( myRepositoryHelper.getTestDataPath(myLocalRepoDir)); - getIndicesManager().setTestIndexDir(new File(myDir, "MavenIndices")); + getIndicesManager().setTestIndexDir(myDir.resolve("MavenIndices")); myIndicesManager = MavenProjectIndicesManager.getInstance(myProject); myIndicesManager.doInit(); } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenProjectIndicesManagerTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenProjectIndicesManagerTest.java index 67fb844f7a3c..42cd87f9b7f1 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenProjectIndicesManagerTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenProjectIndicesManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 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,14 +23,18 @@ public class MavenProjectIndicesManagerTest extends MavenIndicesTestCase { @Override protected void setUp() throws Exception { super.setUp(); - myIndicesFixture = new MavenIndicesTestFixture(myDir, myProject); + myIndicesFixture = new MavenIndicesTestFixture(myDir.toPath(), myProject); myIndicesFixture.setUp(); } @Override protected void tearDown() throws Exception { - myIndicesFixture.tearDown(); - super.tearDown(); + try { + myIndicesFixture.tearDown(); + } + finally { + super.tearDown(); + } } public void testAutomaticallyAddAndUpdateLocalRepository() throws Exception { @@ -78,7 +82,7 @@ public class MavenProjectIndicesManagerTest extends MavenIndicesTestCase { public void testUpdatingIndexUsingMirrors() throws Exception { myIndicesFixture.tearDown(); - myIndicesFixture = new MavenIndicesTestFixture(myDir, myProject, "local2", "remote_mirror"); + myIndicesFixture = new MavenIndicesTestFixture(myDir.toPath(), myProject, "local2", "remote_mirror"); myIndicesFixture.setUp(); updateSettingsXmlFully("" + @@ -127,7 +131,7 @@ public class MavenProjectIndicesManagerTest extends MavenIndicesTestCase { assertUnorderedElementsAreEqual(myIndicesFixture.getProjectIndicesManager().getGroupIds(), "test", "jmock", "junit"); myIndicesFixture.tearDown(); - myIndicesFixture = new MavenIndicesTestFixture(myDir, myProject, "local2", "remote_mirror"); + myIndicesFixture = new MavenIndicesTestFixture(myDir.toPath(), myProject, "local2", "remote_mirror"); myIndicesFixture.setUp(); updateSettingsXmlFully("" + @@ -147,7 +151,7 @@ public class MavenProjectIndicesManagerTest extends MavenIndicesTestCase { public void testCheckingLocalRepositoryForAbsentIndices() throws Exception { myIndicesFixture.tearDown(); - myIndicesFixture = new MavenIndicesTestFixture(myDir, myProject, "local2"); + myIndicesFixture = new MavenIndicesTestFixture(myDir.toPath(), myProject, "local2"); myIndicesFixture.setUp(); myIndicesFixture.addToRepository("local1"); diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenSearcherTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenSearcherTest.java index 48b8b6bfa3cb..032a7000eabd 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenSearcherTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenSearcherTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -26,14 +26,18 @@ public class MavenSearcherTest extends MavenIndicesTestCase { @Override protected void setUp() throws Exception { super.setUp(); - myIndicesFixture = new MavenIndicesTestFixture(myDir, myProject); + myIndicesFixture = new MavenIndicesTestFixture(myDir.toPath(), myProject); myIndicesFixture.setUp(); } @Override protected void tearDown() throws Exception { - myIndicesFixture.tearDown(); - super.tearDown(); + try { + myIndicesFixture.tearDown(); + } + finally { + super.tearDown(); + } } public void testClassSearch() throws Exception { @@ -117,12 +121,12 @@ public class MavenSearcherTest extends MavenIndicesTestCase { private List getClassSearchResults(String pattern) { List actualArtifacts = new ArrayList<>(); for (MavenClassSearchResult eachResult : new MavenClassSearcher().search(myProject, pattern, 100)) { - String s = eachResult.className + "(" + eachResult.packageName + ")"; + StringBuilder s = new StringBuilder(eachResult.className + "(" + eachResult.packageName + ")"); for (MavenArtifactInfo eachVersion : eachResult.versions) { - if (s.length() > 0) s += " "; - s += eachVersion.getGroupId() + ":" + eachVersion.getArtifactId()+ ":" + eachVersion.getVersion(); + if (s.length() > 0) s.append(" "); + s.append(eachVersion.getGroupId()).append(":").append(eachVersion.getArtifactId()).append(":").append(eachVersion.getVersion()); } - actualArtifacts.add(s); + actualArtifacts.add(s.toString()); } return actualArtifacts; } @@ -130,12 +134,12 @@ public class MavenSearcherTest extends MavenIndicesTestCase { private void assertArtifactSearchResults(String pattern, String... expected) { List actual = new ArrayList<>(); for (MavenArtifactSearchResult eachResult : new MavenArtifactSearcher(true).search(myProject, pattern, 100)) { - String s = ""; + StringBuilder s = new StringBuilder(); for (MavenArtifactInfo eachVersion : eachResult.versions) { - if (s.length() > 0) s += " "; - s += eachVersion.getGroupId() + ":" + eachVersion.getArtifactId()+ ":" + eachVersion.getVersion(); + if (s.length() > 0) s.append(" "); + s.append(eachVersion.getGroupId()).append(":").append(eachVersion.getArtifactId()).append(":").append(eachVersion.getVersion()); } - actual.add(s); + actual.add(s.toString()); } assertOrderedElementsAreEqual(actual, expected); } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsManagerTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsManagerTest.java index 850f6114689e..5c43b33fdb9e 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsManagerTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -864,7 +864,7 @@ public class MavenProjectsManagerTest extends MavenImportingTestCase { public void testDoNotScheduleResolveOfInvalidProjectsDeleted() throws Exception { final boolean[] called = new boolean[1]; - myProjectsManager.addProjectsTreeListener(new MavenProjectsTree.ListenerAdapter() { + myProjectsManager.addProjectsTreeListener(new MavenProjectsTree.Listener() { @Override public void projectResolved(Pair projectWithChanges, NativeMavenProjectHolder nativeMavenProject) { @@ -1086,14 +1086,14 @@ public class MavenProjectsManagerTest extends MavenImportingTestCase { final StringBuilder log = new StringBuilder(); myProjectsManager.performScheduledImportInTests(); - myProjectsManager.addProjectsTreeListener(new MavenProjectsTree.ListenerAdapter() { + myProjectsManager.addProjectsTreeListener(new MavenProjectsTree.Listener() { @Override public void projectsUpdated(List> updated, List deleted) { for (Pair each : updated) { - log.append("updated: " + each.first.getDisplayName() + " "); + log.append("updated: ").append(each.first.getDisplayName()).append(" "); } for (MavenProject each : deleted) { - log.append("deleted: " + each.getDisplayName() + " "); + log.append("deleted: ").append(each.getDisplayName()).append(" "); } } }); diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeIgnoresTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeIgnoresTest.java index 09d1dace13d3..b75bf2b3bfba 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeIgnoresTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeIgnoresTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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,7 +17,6 @@ package org.jetbrains.idea.maven.project.importing; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.Function; import org.jetbrains.idea.maven.project.MavenProject; import org.jetbrains.idea.maven.project.MavenProjectsTree; @@ -61,7 +60,7 @@ public class MavenProjectsTreeIgnoresTest extends MavenProjectsTreeTestCase { assertEquals("ignored: m1 ", myLog); myLog = ""; - myTree.setIgnoredFilesPatterns(Collections.emptyList()); + myTree.setIgnoredFilesPatterns(Collections.emptyList()); assertEquals("unignored: m1 ", myLog); myLog = ""; @@ -78,7 +77,7 @@ public class MavenProjectsTreeIgnoresTest extends MavenProjectsTreeTestCase { assertEquals("", myLog); } - private class MyLoggingListener extends MavenProjectsTree.ListenerAdapter { + private class MyLoggingListener implements MavenProjectsTree.Listener { @Override public void projectsIgnoredStateChanged(List ignored, List unignored, boolean fromImport) { if (!ignored.isEmpty()) myLog += "ignored: " + format(ignored) + " "; diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeReadingTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeReadingTest.java index 2221aa191ed5..5cb4f020e02b 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeReadingTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeReadingTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -21,7 +21,6 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.testFramework.PlatformTestUtil; -import com.intellij.util.Function; import org.jetbrains.idea.maven.model.MavenExplicitProfiles; import org.jetbrains.idea.maven.project.MavenEmbeddersManager; import org.jetbrains.idea.maven.project.MavenProject; @@ -31,7 +30,7 @@ import org.jetbrains.idea.maven.server.MavenServerManager; import org.jetbrains.idea.maven.server.NativeMavenProjectHolder; import org.jetbrains.idea.maven.utils.MavenUtil; -import java.io.File; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -624,7 +623,7 @@ public class MavenProjectsTreeReadingTest extends MavenProjectsTreeTestCase { MavenEmbeddersManager embeddersManager = new MavenEmbeddersManager(myProject); final List nativeProject = new ArrayList<>(); try { - myTree.addListener(new MavenProjectsTree.ListenerAdapter() { + myTree.addListener(new MavenProjectsTree.Listener() { @Override public void projectResolved(Pair projectWithChanges, NativeMavenProjectHolder nativeMavenProject) { @@ -674,7 +673,7 @@ public class MavenProjectsTreeReadingTest extends MavenProjectsTreeTestCase { MavenEmbeddersManager embeddersManager = new MavenEmbeddersManager(myProject); try { final NativeMavenProjectHolder[] nativeProject = new NativeMavenProjectHolder[1]; - myTree.addListener(new MavenProjectsTree.ListenerAdapter() { + myTree.addListener(new MavenProjectsTree.Listener() { @Override public void projectResolved(Pair projectWithChanges, NativeMavenProjectHolder nativeMavenProject) { @@ -1867,7 +1866,7 @@ public class MavenProjectsTreeReadingTest extends MavenProjectsTreeTestCase { embeddersManager.releaseInTests(); } - File f = new File(myDir, "tree.dat"); + Path f = myDir.toPath().resolve("tree.dat"); myTree.save(f); MavenProjectsTree read = MavenProjectsTree.read(myProject, f); @@ -2239,7 +2238,7 @@ public class MavenProjectsTreeReadingTest extends MavenProjectsTreeTestCase { PlatformTestUtil.assertPathsEqual(pathFromBasedir("my-target/test-classes"), project.getTestOutputDirectory()); } - private static class MyLoggingListener extends MavenProjectsTree.ListenerAdapter { + private static class MyLoggingListener implements MavenProjectsTree.Listener { String log = ""; @Override diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundlePropertiesUpdateManager.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundlePropertiesUpdateManager.java index 546de727e953..45e1aec1018a 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundlePropertiesUpdateManager.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundlePropertiesUpdateManager.java @@ -26,16 +26,19 @@ import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Pair; import com.intellij.pom.PomTarget; import com.intellij.pom.PomTargetPsiElement; -import com.intellij.psi.PsiComment; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiWhiteSpace; import com.intellij.psi.codeStyle.CodeStyleManager; import com.intellij.util.IncorrectOperationException; +import com.intellij.util.SmartList; +import com.intellij.util.containers.FactoryMap; +import com.intellij.util.containers.IntArrayList; import com.intellij.util.graph.*; +import gnu.trove.THashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; +import java.util.stream.Collectors; /** * @author Dmitry Batkovich @@ -166,18 +169,16 @@ public class ResourceBundlePropertiesUpdateManager { @Nullable private static Pair, Boolean> keysOrder(final ResourceBundle resourceBundle) { + final List propertiesOrders = + resourceBundle.getPropertiesFiles().stream().map(PropertiesOrder::new).collect(Collectors.toList()); + final boolean[] isAlphaSorted = new boolean[]{true}; final Graph generator = GraphGenerator.generate(CachingSemiGraph.cache(new InboundSemiGraph() { @Override public Collection getNodes() { final Set nodes = new LinkedHashSet<>(); - for (PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) { - for (IProperty property : propertiesFile.getProperties()) { - final String key = property.getKey(); - if (key != null) { - nodes.add(key); - } - } + for (PropertiesOrder order : propertiesOrders) { + nodes.addAll(order.myKeys); } return nodes; } @@ -185,23 +186,16 @@ public class ResourceBundlePropertiesUpdateManager { @Override public Iterator getIn(String n) { final Collection siblings = new LinkedHashSet<>(); - for (PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) { - for (IProperty property : propertiesFile.findPropertiesByKey(n)) { - PsiElement sibling = property.getPsiElement().getNextSibling(); - while (sibling instanceof PsiWhiteSpace || sibling instanceof PsiComment) { - sibling = sibling.getNextSibling(); - } - if (sibling instanceof IProperty) { - final String key = ((IProperty)sibling).getKey(); - if (key != null) { - if (isAlphaSorted[0] && String.CASE_INSENSITIVE_ORDER.compare(n, key) > 0) { - isAlphaSorted[0] = false; - } - siblings.add(key); - } + + for (PropertiesOrder order : propertiesOrders) { + for (String nextKey : order.getNext(n)) { + if (isAlphaSorted[0] && String.CASE_INSENSITIVE_ORDER.compare(n, nextKey) > 0) { + isAlphaSorted[0] = false; } + siblings.add(nextKey); } } + return siblings.iterator(); } })); @@ -230,4 +224,58 @@ public class ResourceBundlePropertiesUpdateManager { public boolean isSorted() { return myOrdered; } + + private static class PropertiesOrder { + List myKeys; + Map myKeyIndices; + + public PropertiesOrder(@NotNull PropertiesFile file) { + final List properties = file.getProperties(); + myKeys = new ArrayList<>(properties.size()); + myKeyIndices = new FactoryMap() { + + @Override + protected Map createMap() { + return new THashMap<>(properties.size()); + } + + @NotNull + @Override + protected IntArrayList create(String key) { + return new IntArrayList(1); + } + }; + + int index = 0; + for (IProperty property : properties) { + final String key = property.getKey(); + if (key != null) { + myKeys.add(key); + myKeyIndices.get(key).add(index); + } + index++; + } + } + + @NotNull + public List getNext(@NotNull String key) { + List nextProperties = null; + if (myKeyIndices.containsKey(key)) { + final IntArrayList indices = myKeyIndices.get(key); + for (int i = 0; i < indices.size(); i++) { + final int searchIdx = indices.getQuick(i) + 1; + if (searchIdx < myKeys.size()) { + final String nextProperty = myKeys.get(searchIdx); + if (nextProperty != null) { + if (nextProperties == null) { + nextProperties = new SmartList<>(); + } + nextProperties.add(nextProperty); + } + } + } + } + return nextProperties == null ? Collections.emptyList() : nextProperties; + } + } } diff --git a/plugins/properties/src/com/intellij/lang/properties/refactoring/rename/RenamePropertyProcessor.java b/plugins/properties/src/com/intellij/lang/properties/refactoring/rename/RenamePropertyProcessor.java index e42b52d0d24b..7078958d5986 100644 --- a/plugins/properties/src/com/intellij/lang/properties/refactoring/rename/RenamePropertyProcessor.java +++ b/plugins/properties/src/com/intellij/lang/properties/refactoring/rename/RenamePropertyProcessor.java @@ -48,13 +48,13 @@ public class RenamePropertyProcessor extends RenamePsiElementProcessor { final Map allRenamesCopy = new LinkedHashMap<>(allRenames); allRenames.clear(); - for (final Map.Entry e : allRenamesCopy.entrySet()) { - final IProperty property = PropertiesImplUtil.getProperty(e.getKey()); + allRenamesCopy.forEach((key, value) -> { + final IProperty property = PropertiesImplUtil.getProperty(key); final List properties = PropertiesUtil.findAllProperties(resourceBundle, property.getUnescapedKey()); for (final IProperty toRename : properties) { - allRenames.put(toRename.getPsiElement(), e.getValue()); + allRenames.put(toRename.getPsiElement(), value); } - } + }); } @Override @@ -62,18 +62,18 @@ public class RenamePropertyProcessor extends RenamePsiElementProcessor { final String newName, Map allRenames, List result) { - for (final Map.Entry e: allRenames.entrySet()) { - for (IProperty property : ((PropertiesFile)e.getKey().getContainingFile()).getProperties()) { - if (Comparing.strEqual(e.getValue(), property.getKey())) { - result.add(new UnresolvableCollisionUsageInfo(property.getPsiElement(), e.getKey()) { + allRenames.forEach((key, value) -> { + for (IProperty property : ((PropertiesFile)key.getContainingFile()).getProperties()) { + if (Comparing.strEqual(value, property.getKey())) { + result.add(new UnresolvableCollisionUsageInfo(property.getPsiElement(), key) { @Override public String getDescription() { - return "New property name \'" + e.getValue() + "\' hides existing property"; + return "New property name \'" + value + "\' hides existing property"; } }); } } - } + }); } @Override diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/context/WorkingContextManager.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/context/WorkingContextManager.java index 729f81a774ef..652eb706ce8d 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/context/WorkingContextManager.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/context/WorkingContextManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 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,17 +25,16 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.WriteExternalException; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.tasks.Task; +import com.intellij.util.JdomKt; import com.intellij.util.NullableFunction; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.io.zip.JBZipEntry; import com.intellij.util.io.zip.JBZipFile; -import org.jdom.Document; import org.jdom.Element; import org.jdom.output.XMLOutputter; import org.jetbrains.annotations.NonNls; @@ -183,9 +182,7 @@ public class WorkingContextManager { JBZipEntry entry = archive.getEntry(StringUtil.startsWithChar(entryName, '/') ? entryName : "/" + entryName); if (entry != null) { byte[] bytes = entry.getData(); - Document document = JDOMUtil.loadDocument(new String(bytes)); - Element rootElement = document.getRootElement(); - loadContext(rootElement); + loadContext(JdomKt.loadElement(new String(bytes))); return true; } } diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/TaskUtil.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/TaskUtil.java index 74bc704393ed..e50ca861b170 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/TaskUtil.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/TaskUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -28,6 +28,7 @@ import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.tasks.Task; import com.intellij.tasks.TaskRepository; import com.intellij.tasks.impl.httpclient.TaskResponseUtil; +import com.intellij.util.JdomKt; import com.intellij.util.text.DateFormatUtil; import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.HttpMethod; @@ -205,7 +206,7 @@ public class TaskUtil { public static void prettyFormatXmlToLog(@NotNull Logger logger, @NotNull String xml) { if (logger.isDebugEnabled()) { try { - logger.debug("\n" + JDOMUtil.createOutputter("\n").outputString(JDOMUtil.loadDocument(xml))); + logger.debug("\n" + JDOMUtil.createOutputter("\n").outputString(JdomKt.loadElement(xml))); } catch (Exception e) { logger.debug(e); diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/fileTemplate/SaveFormAsTemplateHandler.java b/plugins/ui-designer/src/com/intellij/uiDesigner/fileTemplate/SaveFormAsTemplateHandler.java index 75d5fb25466e..7bff07ecbb79 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/fileTemplate/SaveFormAsTemplateHandler.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/fileTemplate/SaveFormAsTemplateHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -15,6 +15,7 @@ */ package com.intellij.uiDesigner.fileTemplate; +import com.intellij.ide.actions.SaveFileAsTemplateHandler; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.util.JDOMUtil; import com.intellij.psi.PsiFile; @@ -22,16 +23,15 @@ import com.intellij.psi.codeStyle.CodeStyleSettingsManager; import com.intellij.uiDesigner.UIFormXmlConstants; import com.intellij.uiDesigner.compiler.Utils; import com.intellij.uiDesigner.lw.LwRootContainer; -import com.intellij.ide.actions.SaveFileAsTemplateHandler; +import com.intellij.util.JdomKt; import org.jdom.Attribute; -import org.jdom.Document; - -import java.io.CharArrayWriter; +import org.jdom.Element; /** * @author yole */ public class SaveFormAsTemplateHandler implements SaveFileAsTemplateHandler { + @Override public String getTemplateText(final PsiFile file, final String fileText, final String nameWithoutExtension) { if (StdFileTypes.GUI_DESIGNER_FORM.equals(file.getFileType())) { LwRootContainer rootContainer = null; @@ -42,15 +42,11 @@ public class SaveFormAsTemplateHandler implements SaveFileAsTemplateHandler { } if (rootContainer != null && rootContainer.getClassToBind() != null) { try { - Document document = JDOMUtil.loadDocument(fileText); + Element document = JdomKt.loadElement(fileText); - Attribute attribute = document.getRootElement().getAttribute(UIFormXmlConstants.ATTRIBUTE_BIND_TO_CLASS); + Attribute attribute = document.getAttribute(UIFormXmlConstants.ATTRIBUTE_BIND_TO_CLASS); attribute.detach(); - - CharArrayWriter writer = new CharArrayWriter(); - JDOMUtil.writeDocument(document, writer, CodeStyleSettingsManager.getSettings(file.getProject()).getLineSeparator()); - - return writer.toString(); + return JDOMUtil.write(document, CodeStyleSettingsManager.getSettings(file.getProject()).getLineSeparator()); } catch (Exception ignored) { } diff --git a/python/educational-core/student/src/com/jetbrains/edu/learning/StudySerializationUtils.java b/python/educational-core/student/src/com/jetbrains/edu/learning/StudySerializationUtils.java index 0163a3b895a4..6701b6bd4f6b 100644 --- a/python/educational-core/student/src/com/jetbrains/edu/learning/StudySerializationUtils.java +++ b/python/educational-core/student/src/com/jetbrains/edu/learning/StudySerializationUtils.java @@ -20,6 +20,7 @@ import com.jetbrains.edu.learning.stepic.StepicWrappers; import org.jdom.Attribute; import org.jdom.Element; import org.jdom.output.XMLOutputter; +import org.jetbrains.annotations.NotNull; import java.io.File; import java.lang.reflect.Type; @@ -208,6 +209,7 @@ public class StudySerializationUtils { return state; } + @NotNull public static Element convertToForthVersion(Element state) throws StudyUnrecognizedFormatException { Element taskManagerElement = state.getChild(MAIN_ELEMENT); Element courseElement = getChildWithName(taskManagerElement, COURSE).getChild(COURSE_TITLED); diff --git a/python/educational-core/student/student.iml b/python/educational-core/student/student.iml index 74bb142082e8..054fd550f453 100644 --- a/python/educational-core/student/student.iml +++ b/python/educational-core/student/student.iml @@ -36,5 +36,6 @@
+ \ No newline at end of file diff --git a/python/educational-core/student/testSrc/com/jetbrains/edu/learning/StudyMigrationTest.java b/python/educational-core/student/testSrc/com/jetbrains/edu/learning/StudyMigrationTest.java index 2d21fd58ed8d..34f7846b804d 100644 --- a/python/educational-core/student/testSrc/com/jetbrains/edu/learning/StudyMigrationTest.java +++ b/python/educational-core/student/testSrc/com/jetbrains/edu/learning/StudyMigrationTest.java @@ -1,26 +1,27 @@ package com.jetbrains.edu.learning; -import com.intellij.openapi.util.JDOMUtil; -import com.intellij.openapi.util.io.FileUtil; import com.intellij.testFramework.PlatformTestUtil; +import com.intellij.util.JdomKt; import org.jdom.Element; import org.jdom.JDOMException; +import org.jetbrains.annotations.NotNull; import org.junit.Test; -import java.io.File; import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +import static com.intellij.testFramework.assertions.Assertions.assertThat; public class StudyMigrationTest { - @Test public void testFromThirdToForth() throws JDOMException, IOException, StudySerializationUtils.StudyUnrecognizedFormatException { - Element element = JDOMUtil.load(new File(FileUtil.join(getTestDataPath(), "3.xml"))); - Element actual = StudySerializationUtils.Xml.convertToForthVersion(element); - Element expected = JDOMUtil.load(new File(FileUtil.join(getTestDataPath()), "4.xml")); - PlatformTestUtil.assertElementsEqual(expected, actual); + Element element = JdomKt.loadElement(getTestDataPath().resolve("3.xml")); + assertThat(StudySerializationUtils.Xml.convertToForthVersion(element)).isEqualTo(getTestDataPath().resolve("4.xml")); } - protected String getTestDataPath() { - return FileUtil.join(PlatformTestUtil.getCommunityPath(), "python/educational-core/student/testData/migration"); + @NotNull + protected Path getTestDataPath() { + return Paths.get(PlatformTestUtil.getCommunityPath(), "python/educational-core/student/testData/migration"); } } diff --git a/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator.c b/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator.c index faed4379451e..651d48fa407c 100644 --- a/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator.c +++ b/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator.c @@ -985,9 +985,12 @@ static const char __pyx_k_is_tracing[] = "is_tracing"; static const char __pyx_k_breakpoints[] = "breakpoints"; static const char __pyx_k_co_filename[] = "co_filename"; static const char __pyx_k_insert_code[] = "insert_code"; +static const char __pyx_k_pydev_state[] = "pydev_state"; +static const char __pyx_k_stop_reason[] = "stop_reason"; static const char __pyx_k_can_not_skip[] = "can_not_skip"; static const char __pyx_k_code_objects[] = "code_objects"; static const char __pyx_k_threading_py[] = "threading.py"; +static const char __pyx_k_STATE_SUSPEND[] = "STATE_SUSPEND"; static const char __pyx_k_currentThread[] = "currentThread"; static const char __pyx_k_get_file_type[] = "get_file_type"; static const char __pyx_k_weakrefset_py[] = "_weakrefset.py"; @@ -999,14 +1002,17 @@ static const char __pyx_k_additional_info[] = "additional_info"; static const char __pyx_k_frame_eval_func[] = "frame_eval_func"; static const char __pyx_k_stop_frame_eval[] = "stop_frame_eval"; static const char __pyx_k_pydevd_file_utils[] = "pydevd_file_utils"; +static const char __pyx_k_CMD_THREAD_SUSPEND[] = "CMD_THREAD_SUSPEND"; static const char __pyx_k_pydev_do_not_trace[] = "pydev_do_not_trace"; static const char __pyx_k_get_global_debugger[] = "get_global_debugger"; static const char __pyx_k_update_globals_dict[] = "update_globals_dict"; static const char __pyx_k_has_plugin_line_breaks[] = "has_plugin_line_breaks"; static const char __pyx_k_PyDBAdditionalThreadInfo[] = "PyDBAdditionalThreadInfo"; static const char __pyx_k_pydev_trace_code_wrapper[] = "pydev_trace_code_wrapper"; +static const char __pyx_k_process_internal_commands[] = "process_internal_commands"; static const char __pyx_k_pydevd_bundle_pydevd_comm[] = "_pydevd_bundle.pydevd_comm"; static const char __pyx_k_NORM_PATHS_AND_BASE_CONTAINER[] = "NORM_PATHS_AND_BASE_CONTAINER"; +static const char __pyx_k_pydevd_bundle_pydevd_constants[] = "_pydevd_bundle.pydevd_constants"; static const char __pyx_k_pydevd_frame_eval_pydevd_frame[] = "_pydevd_frame_eval.pydevd_frame_tracing"; static const char __pyx_k_get_abs_path_real_path_and_base[] = "get_abs_path_real_path_and_base_from_frame"; static const char __pyx_k_home_user_work_ultimate_communi[] = "/home/user/work/ultimate/community/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator.pyx"; @@ -1019,9 +1025,11 @@ static const char __pyx_k_pydevd_additional_thread_info_re[] = "pydevd_additiona static const char __pyx_k_pydevd_frame_eval_pydevd_frame_2[] = "_pydevd_frame_eval.pydevd_frame_evaluator"; static PyObject *__pyx_n_s_AVOID_RECURSION; static PyObject *__pyx_n_s_AttributeError; +static PyObject *__pyx_n_s_CMD_THREAD_SUSPEND; static PyObject *__pyx_n_s_DONT_TRACE; static PyObject *__pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER; static PyObject *__pyx_n_s_PyDBAdditionalThreadInfo; +static PyObject *__pyx_n_s_STATE_SUSPEND; static PyObject *__pyx_n_s_SetTrace; static PyObject *__pyx_n_s_additional_info; static PyObject *__pyx_n_s_append; @@ -1047,12 +1055,15 @@ static PyObject *__pyx_n_s_insert_code; static PyObject *__pyx_n_s_is_tracing; static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_plugin; +static PyObject *__pyx_n_s_process_internal_commands; static PyObject *__pyx_n_s_pydev_do_not_trace; static PyObject *__pyx_n_s_pydev_imps__pydev_saved_modules; +static PyObject *__pyx_n_s_pydev_state; static PyObject *__pyx_n_s_pydev_trace_code_wrapper; static PyObject *__pyx_kp_s_pydevd_additional_thread_info_re; static PyObject *__pyx_n_s_pydevd_bundle_pydevd_additional; static PyObject *__pyx_n_s_pydevd_bundle_pydevd_comm; +static PyObject *__pyx_n_s_pydevd_bundle_pydevd_constants; static PyObject *__pyx_n_s_pydevd_bundle_pydevd_dont_trace; static PyObject *__pyx_n_s_pydevd_file_utils; static PyObject *__pyx_n_s_pydevd_frame_eval_pydevd_frame; @@ -1061,6 +1072,7 @@ static PyObject *__pyx_n_s_pydevd_frame_eval_pydevd_modify; static PyObject *__pyx_n_s_set_trace_for_frame_and_parents; static PyObject *__pyx_n_s_state; static PyObject *__pyx_n_s_stop_frame_eval; +static PyObject *__pyx_n_s_stop_reason; static PyObject *__pyx_n_s_test; static PyObject *__pyx_n_s_threading; static PyObject *__pyx_kp_s_threading_py; @@ -1074,7 +1086,7 @@ static PyObject *__pyx_tuple__3; static PyObject *__pyx_codeobj__2; static PyObject *__pyx_codeobj__4; -/* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":18 +/* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":19 * get_file_type = DONT_TRACE.get * * cdef PyObject* get_bytecode_while_frame_eval(PyFrameObject *frame_obj, int exc): # <<<<<<<<<<<<<< @@ -1123,7 +1135,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec int __pyx_t_17; __Pyx_RefNannySetupContext("get_bytecode_while_frame_eval", 0); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":19 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":20 * * cdef PyObject* get_bytecode_while_frame_eval(PyFrameObject *frame_obj, int exc): * frame = frame_obj # <<<<<<<<<<<<<< @@ -1135,23 +1147,23 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_v_frame = __pyx_t_1; __pyx_t_1 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":20 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":21 * cdef PyObject* get_bytecode_while_frame_eval(PyFrameObject *frame_obj, int exc): * frame = frame_obj * cdef str filepath = frame.f_code.co_filename # <<<<<<<<<<<<<< * cdef bint skip_file = exc * */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 20, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_co_filename); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_co_filename); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 20, __pyx_L1_error) + if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 21, __pyx_L1_error) __pyx_v_filepath = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":21 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":22 * frame = frame_obj * cdef str filepath = frame.f_code.co_filename * cdef bint skip_file = exc # <<<<<<<<<<<<<< @@ -1160,22 +1172,22 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ __pyx_v_skip_file = __pyx_v_exc; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":23 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":24 * cdef bint skip_file = exc * * for file in AVOID_RECURSION: # <<<<<<<<<<<<<< * # we can't call any other function without this check, because we can get stack overflow * if filepath.endswith(file): */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_AVOID_RECURSION); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_AVOID_RECURSION); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0; __pyx_t_4 = NULL; } else { - __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 24, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { @@ -1183,17 +1195,17 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec if (likely(PyList_CheckExact(__pyx_t_1))) { if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 24, __pyx_L1_error) #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 24, __pyx_L1_error) #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } @@ -1203,7 +1215,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 23, __pyx_L1_error) + else __PYX_ERR(0, 24, __pyx_L1_error) } break; } @@ -1212,7 +1224,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_XDECREF_SET(__pyx_v_file, __pyx_t_2); __pyx_t_2 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":25 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":26 * for file in AVOID_RECURSION: * # we can't call any other function without this check, because we can get stack overflow * if filepath.endswith(file): # <<<<<<<<<<<<<< @@ -1221,12 +1233,12 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ if (unlikely(__pyx_v_filepath == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "endswith"); - __PYX_ERR(0, 25, __pyx_L1_error) + __PYX_ERR(0, 26, __pyx_L1_error) } - __pyx_t_5 = __Pyx_PyStr_Tailmatch(__pyx_v_filepath, __pyx_v_file, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 25, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyStr_Tailmatch(__pyx_v_filepath, __pyx_v_file, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 26, __pyx_L1_error) if ((__pyx_t_5 != 0)) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":26 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":27 * # we can't call any other function without this check, because we can get stack overflow * if filepath.endswith(file): * skip_file = True # <<<<<<<<<<<<<< @@ -1235,7 +1247,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ __pyx_v_skip_file = 1; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":27 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":28 * if filepath.endswith(file): * skip_file = True * break # <<<<<<<<<<<<<< @@ -1244,7 +1256,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ goto __pyx_L4_break; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":25 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":26 * for file in AVOID_RECURSION: * # we can't call any other function without this check, because we can get stack overflow * if filepath.endswith(file): # <<<<<<<<<<<<<< @@ -1253,7 +1265,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":23 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":24 * cdef bint skip_file = exc * * for file in AVOID_RECURSION: # <<<<<<<<<<<<<< @@ -1264,7 +1276,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_L4_break:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":29 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":30 * break * * if not skip_file: # <<<<<<<<<<<<<< @@ -1274,7 +1286,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_t_5 = ((!(__pyx_v_skip_file != 0)) != 0); if (__pyx_t_5) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":30 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":31 * * if not skip_file: * try: # <<<<<<<<<<<<<< @@ -1290,16 +1302,16 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_XGOTREF(__pyx_t_8); /*try:*/ { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":31 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":32 * if not skip_file: * try: * threading.currentThread() # <<<<<<<<<<<<<< * except: * skip_file = True */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_threading); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L7_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_threading); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_currentThread); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 31, __pyx_L7_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_currentThread); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 32, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; @@ -1313,16 +1325,16 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (__pyx_t_2) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L7_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L7_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L7_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L7_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":30 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":31 * * if not skip_file: * try: # <<<<<<<<<<<<<< @@ -1340,7 +1352,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":32 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":33 * try: * threading.currentThread() * except: # <<<<<<<<<<<<<< @@ -1349,12 +1361,12 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ /*except:*/ { __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.get_bytecode_while_frame_eval", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_9, &__pyx_t_2) < 0) __PYX_ERR(0, 32, __pyx_L9_except_error) + if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_9, &__pyx_t_2) < 0) __PYX_ERR(0, 33, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_9); __Pyx_GOTREF(__pyx_t_2); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":33 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":34 * threading.currentThread() * except: * skip_file = True # <<<<<<<<<<<<<< @@ -1369,7 +1381,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } __pyx_L9_except_error:; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":30 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":31 * * if not skip_file: * try: # <<<<<<<<<<<<<< @@ -1391,7 +1403,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_L14_try_end:; } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":29 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":30 * break * * if not skip_file: # <<<<<<<<<<<<<< @@ -1400,7 +1412,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":35 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":36 * skip_file = True * * if not skip_file: # <<<<<<<<<<<<<< @@ -1410,16 +1422,16 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_t_5 = ((!(__pyx_v_skip_file != 0)) != 0); if (__pyx_t_5) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":36 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":37 * * if not skip_file: * t = threading.currentThread() # <<<<<<<<<<<<<< * try: * additional_info = t.additional_info */ - __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_threading); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 36, __pyx_L1_error) + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_threading); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_currentThread); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_currentThread); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; @@ -1433,17 +1445,17 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (__pyx_t_9) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_t = __pyx_t_2; __pyx_t_2 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":37 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":38 * if not skip_file: * t = threading.currentThread() * try: # <<<<<<<<<<<<<< @@ -1459,19 +1471,19 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_XGOTREF(__pyx_t_6); /*try:*/ { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":38 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":39 * t = threading.currentThread() * try: * additional_info = t.additional_info # <<<<<<<<<<<<<< * if additional_info is None: * raise AttributeError() */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_additional_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L18_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_additional_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_additional_info = __pyx_t_2; __pyx_t_2 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":39 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":40 * try: * additional_info = t.additional_info * if additional_info is None: # <<<<<<<<<<<<<< @@ -1482,20 +1494,20 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_t_10 = (__pyx_t_5 != 0); if (__pyx_t_10) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":40 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":41 * additional_info = t.additional_info * if additional_info is None: * raise AttributeError() # <<<<<<<<<<<<<< * except: * additional_info = t.additional_info = PyDBAdditionalThreadInfo() */ - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_builtin_AttributeError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L18_error) + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_builtin_AttributeError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 41, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 40, __pyx_L18_error) + __PYX_ERR(0, 41, __pyx_L18_error) - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":39 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":40 * try: * additional_info = t.additional_info * if additional_info is None: # <<<<<<<<<<<<<< @@ -1504,7 +1516,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":37 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":38 * if not skip_file: * t = threading.currentThread() * try: # <<<<<<<<<<<<<< @@ -1522,7 +1534,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":41 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":42 * if additional_info is None: * raise AttributeError() * except: # <<<<<<<<<<<<<< @@ -1531,19 +1543,19 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ /*except:*/ { __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.get_bytecode_while_frame_eval", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_9) < 0) __PYX_ERR(0, 41, __pyx_L20_except_error) + if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_9) < 0) __PYX_ERR(0, 42, __pyx_L20_except_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_9); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":42 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":43 * raise AttributeError() * except: * additional_info = t.additional_info = PyDBAdditionalThreadInfo() # <<<<<<<<<<<<<< * * if additional_info.is_tracing or getattr(t, 'pydev_do_not_trace', None): */ - __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyDBAdditionalThreadInfo); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 42, __pyx_L20_except_error) + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyDBAdditionalThreadInfo); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 43, __pyx_L20_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { @@ -1556,16 +1568,16 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (__pyx_t_13) { - __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 42, __pyx_L20_except_error) + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 43, __pyx_L20_except_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } else { - __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 42, __pyx_L20_except_error) + __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 43, __pyx_L20_except_error) } __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_INCREF(__pyx_t_11); __Pyx_XDECREF_SET(__pyx_v_additional_info, __pyx_t_11); - if (__Pyx_PyObject_SetAttrStr(__pyx_v_t, __pyx_n_s_additional_info, __pyx_t_11) < 0) __PYX_ERR(0, 42, __pyx_L20_except_error) + if (__Pyx_PyObject_SetAttrStr(__pyx_v_t, __pyx_n_s_additional_info, __pyx_t_11) < 0) __PYX_ERR(0, 43, __pyx_L20_except_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -1574,7 +1586,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } __pyx_L20_except_error:; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":37 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":38 * if not skip_file: * t = threading.currentThread() * try: # <<<<<<<<<<<<<< @@ -1596,31 +1608,31 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_L25_try_end:; } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":44 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":45 * additional_info = t.additional_info = PyDBAdditionalThreadInfo() * * if additional_info.is_tracing or getattr(t, 'pydev_do_not_trace', None): # <<<<<<<<<<<<<< * return _PyEval_EvalFrameDefault(frame_obj, exc) * */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_additional_info, __pyx_n_s_is_tracing); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 44, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_additional_info, __pyx_n_s_is_tracing); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 44, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (!__pyx_t_5) { } else { __pyx_t_10 = __pyx_t_5; goto __pyx_L30_bool_binop_done; } - __pyx_t_9 = __Pyx_GetAttr3(__pyx_v_t, __pyx_n_s_pydev_do_not_trace, Py_None); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 44, __pyx_L1_error) + __pyx_t_9 = __Pyx_GetAttr3(__pyx_v_t, __pyx_n_s_pydev_do_not_trace, Py_None); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 44, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = __pyx_t_5; __pyx_L30_bool_binop_done:; if (__pyx_t_10) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":45 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":46 * * if additional_info.is_tracing or getattr(t, 'pydev_do_not_trace', None): * return _PyEval_EvalFrameDefault(frame_obj, exc) # <<<<<<<<<<<<<< @@ -1630,7 +1642,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_r = _PyEval_EvalFrameDefault(__pyx_v_frame_obj, __pyx_v_exc); goto __pyx_L0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":44 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":45 * additional_info = t.additional_info = PyDBAdditionalThreadInfo() * * if additional_info.is_tracing or getattr(t, 'pydev_do_not_trace', None): # <<<<<<<<<<<<<< @@ -1639,16 +1651,16 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":47 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":48 * return _PyEval_EvalFrameDefault(frame_obj, exc) * * additional_info.is_tracing = True # <<<<<<<<<<<<<< * try: * abs_path_real_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[frame.f_code.co_filename] */ - if (__Pyx_PyObject_SetAttrStr(__pyx_v_additional_info, __pyx_n_s_is_tracing, Py_True) < 0) __PYX_ERR(0, 47, __pyx_L1_error) + if (__Pyx_PyObject_SetAttrStr(__pyx_v_additional_info, __pyx_n_s_is_tracing, Py_True) < 0) __PYX_ERR(0, 48, __pyx_L1_error) - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":48 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":49 * * additional_info.is_tracing = True * try: # <<<<<<<<<<<<<< @@ -1664,28 +1676,28 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_XGOTREF(__pyx_t_8); /*try:*/ { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":49 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":50 * additional_info.is_tracing = True * try: * abs_path_real_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[frame.f_code.co_filename] # <<<<<<<<<<<<<< * except: * abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(frame) */ - __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 49, __pyx_L32_error) + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 50, __pyx_L32_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L32_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L32_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_co_filename); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L32_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_co_filename); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L32_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_GetItem(__pyx_t_9, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L32_error) + __pyx_t_1 = PyObject_GetItem(__pyx_t_9, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L32_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_abs_path_real_path_and_base = __pyx_t_1; __pyx_t_1 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":48 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":49 * * additional_info.is_tracing = True * try: # <<<<<<<<<<<<<< @@ -1706,7 +1718,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":50 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":51 * try: * abs_path_real_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[frame.f_code.co_filename] * except: # <<<<<<<<<<<<<< @@ -1715,19 +1727,19 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ /*except:*/ { __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.get_bytecode_while_frame_eval", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_9) < 0) __PYX_ERR(0, 50, __pyx_L34_except_error) + if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_9) < 0) __PYX_ERR(0, 51, __pyx_L34_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_9); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":51 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":52 * abs_path_real_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[frame.f_code.co_filename] * except: * abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(frame) # <<<<<<<<<<<<<< * * file_type = get_file_type(abs_path_real_path_and_base[-1]) #we don't want to debug anything related to pydevd */ - __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_abs_path_real_path_and_base); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 51, __pyx_L34_except_error) + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_abs_path_real_path_and_base); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 52, __pyx_L34_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { @@ -1740,13 +1752,13 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (!__pyx_t_13) { - __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_frame); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 51, __pyx_L34_except_error) + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_frame); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 52, __pyx_L34_except_error) __Pyx_GOTREF(__pyx_t_11); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_v_frame}; - __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 51, __pyx_L34_except_error) + __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 52, __pyx_L34_except_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_11); } else @@ -1754,19 +1766,19 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_v_frame}; - __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 51, __pyx_L34_except_error) + __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 52, __pyx_L34_except_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_11); } else #endif { - __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 51, __pyx_L34_except_error) + __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 52, __pyx_L34_except_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL; __Pyx_INCREF(__pyx_v_frame); __Pyx_GIVEREF(__pyx_v_frame); PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_v_frame); - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_14, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 51, __pyx_L34_except_error) + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_14, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 52, __pyx_L34_except_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } @@ -1781,7 +1793,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } __pyx_L34_except_error:; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":48 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":49 * * additional_info.is_tracing = True * try: # <<<<<<<<<<<<<< @@ -1803,16 +1815,16 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_L39_try_end:; } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":53 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":54 * abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(frame) * * file_type = get_file_type(abs_path_real_path_and_base[-1]) #we don't want to debug anything related to pydevd # <<<<<<<<<<<<<< * if file_type is not None: * additional_info.is_tracing = False */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_file_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_file_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_abs_path_real_path_and_base, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_abs_path_real_path_and_base, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { @@ -1825,14 +1837,14 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (!__pyx_t_11) { - __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_9); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_1}; - __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -1841,20 +1853,20 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_1}; - __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif { - __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL; __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } @@ -1863,7 +1875,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_v_file_type = __pyx_t_9; __pyx_t_9 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":54 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":55 * * file_type = get_file_type(abs_path_real_path_and_base[-1]) #we don't want to debug anything related to pydevd * if file_type is not None: # <<<<<<<<<<<<<< @@ -1874,16 +1886,16 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_t_5 = (__pyx_t_10 != 0); if (__pyx_t_5) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":55 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":56 * file_type = get_file_type(abs_path_real_path_and_base[-1]) #we don't want to debug anything related to pydevd * if file_type is not None: * additional_info.is_tracing = False # <<<<<<<<<<<<<< * return _PyEval_EvalFrameDefault(frame_obj, exc) * */ - if (__Pyx_PyObject_SetAttrStr(__pyx_v_additional_info, __pyx_n_s_is_tracing, Py_False) < 0) __PYX_ERR(0, 55, __pyx_L1_error) + if (__Pyx_PyObject_SetAttrStr(__pyx_v_additional_info, __pyx_n_s_is_tracing, Py_False) < 0) __PYX_ERR(0, 56, __pyx_L1_error) - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":56 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":57 * if file_type is not None: * additional_info.is_tracing = False * return _PyEval_EvalFrameDefault(frame_obj, exc) # <<<<<<<<<<<<<< @@ -1893,7 +1905,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_r = _PyEval_EvalFrameDefault(__pyx_v_frame_obj, __pyx_v_exc); goto __pyx_L0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":54 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":55 * * file_type = get_file_type(abs_path_real_path_and_base[-1]) #we don't want to debug anything related to pydevd * if file_type is not None: # <<<<<<<<<<<<<< @@ -1902,14 +1914,14 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":58 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":59 * return _PyEval_EvalFrameDefault(frame_obj, exc) * * main_debugger = get_global_debugger() # <<<<<<<<<<<<<< - * breakpoints = main_debugger.breakpoints.get(abs_path_real_path_and_base[1]) - * if breakpoints: + * if additional_info.pydev_state == STATE_SUSPEND and t.stop_reason == CMD_THREAD_SUSPEND: + * main_debugger.process_internal_commands() */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_global_debugger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_global_debugger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_12 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { @@ -1922,29 +1934,101 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (__pyx_t_12) { - __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 58, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else { - __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 58, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 59, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_main_debugger = __pyx_t_9; __pyx_t_9 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":59 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":60 * * main_debugger = get_global_debugger() + * if additional_info.pydev_state == STATE_SUSPEND and t.stop_reason == CMD_THREAD_SUSPEND: # <<<<<<<<<<<<<< + * main_debugger.process_internal_commands() + * + */ + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_additional_info, __pyx_n_s_pydev_state); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_STATE_SUSPEND); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_12 = PyObject_RichCompare(__pyx_t_9, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + if (__pyx_t_10) { + } else { + __pyx_t_5 = __pyx_t_10; + goto __pyx_L44_bool_binop_done; + } + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_stop_reason); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_CMD_THREAD_SUSPEND); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_9 = PyObject_RichCompare(__pyx_t_12, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_5 = __pyx_t_10; + __pyx_L44_bool_binop_done:; + if (__pyx_t_5) { + + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":61 + * main_debugger = get_global_debugger() + * if additional_info.pydev_state == STATE_SUSPEND and t.stop_reason == CMD_THREAD_SUSPEND: + * main_debugger.process_internal_commands() # <<<<<<<<<<<<<< + * + * breakpoints = main_debugger.breakpoints.get(abs_path_real_path_and_base[1]) + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_process_internal_commands); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_12 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_12)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_12); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (__pyx_t_12) { + __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + } else { + __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 61, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":60 + * + * main_debugger = get_global_debugger() + * if additional_info.pydev_state == STATE_SUSPEND and t.stop_reason == CMD_THREAD_SUSPEND: # <<<<<<<<<<<<<< + * main_debugger.process_internal_commands() + * + */ + } + + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":63 + * main_debugger.process_internal_commands() + * * breakpoints = main_debugger.breakpoints.get(abs_path_real_path_and_base[1]) # <<<<<<<<<<<<<< * if breakpoints: * was_break = False */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_breakpoints); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_breakpoints); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_abs_path_real_path_and_base, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_abs_path_real_path_and_base, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) { @@ -1957,14 +2041,14 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (!__pyx_t_1) { - __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_9); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_2}; - __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -1973,20 +2057,20 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_2}; - __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { - __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); __pyx_t_1 = NULL; __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_2); __pyx_t_2 = 0; - __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_11, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_11, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } @@ -1995,17 +2079,17 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_v_breakpoints = __pyx_t_9; __pyx_t_9 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":60 - * main_debugger = get_global_debugger() + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":64 + * * breakpoints = main_debugger.breakpoints.get(abs_path_real_path_and_base[1]) * if breakpoints: # <<<<<<<<<<<<<< * was_break = False * breakpoints_to_update = [] */ - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_breakpoints); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 60, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_breakpoints); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 64, __pyx_L1_error) if (__pyx_t_5) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":61 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":65 * breakpoints = main_debugger.breakpoints.get(abs_path_real_path_and_base[1]) * if breakpoints: * was_break = False # <<<<<<<<<<<<<< @@ -2014,40 +2098,40 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ __pyx_v_was_break = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":62 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":66 * if breakpoints: * was_break = False * breakpoints_to_update = [] # <<<<<<<<<<<<<< * code_object = frame.f_code * for offset, line in dis.findlinestarts(code_object): */ - __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 62, __pyx_L1_error) + __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 66, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_v_breakpoints_to_update = ((PyObject*)__pyx_t_9); __pyx_t_9 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":63 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":67 * was_break = False * breakpoints_to_update = [] * code_object = frame.f_code # <<<<<<<<<<<<<< * for offset, line in dis.findlinestarts(code_object): * if line in breakpoints: */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 63, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 67, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_v_code_object = __pyx_t_9; __pyx_t_9 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":64 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":68 * breakpoints_to_update = [] * code_object = frame.f_code * for offset, line in dis.findlinestarts(code_object): # <<<<<<<<<<<<<< * if line in breakpoints: * breakpoint = breakpoints[line] */ - __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_dis); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_dis); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_findlinestarts); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_findlinestarts); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = NULL; @@ -2061,13 +2145,13 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (!__pyx_t_12) { - __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_code_object); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_code_object); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_code_object}; - __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_9); } else @@ -2075,19 +2159,19 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_code_object}; - __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_9); } else #endif { - __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_12); __pyx_t_12 = NULL; __Pyx_INCREF(__pyx_v_code_object); __Pyx_GIVEREF(__pyx_v_code_object); PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_code_object); - __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_2, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_2, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } @@ -2097,9 +2181,9 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_t_11 = __pyx_t_9; __Pyx_INCREF(__pyx_t_11); __pyx_t_3 = 0; __pyx_t_4 = NULL; } else { - __pyx_t_3 = -1; __pyx_t_11 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_3 = -1; __pyx_t_11 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_4 = Py_TYPE(__pyx_t_11)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_4 = Py_TYPE(__pyx_t_11)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 68, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; for (;;) { @@ -2107,17 +2191,17 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec if (likely(PyList_CheckExact(__pyx_t_11))) { if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_11)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_9 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_3); __Pyx_INCREF(__pyx_t_9); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_9 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_3); __Pyx_INCREF(__pyx_t_9); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 68, __pyx_L1_error) #else - __pyx_t_9 = PySequence_ITEM(__pyx_t_11, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_9 = PySequence_ITEM(__pyx_t_11, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); #endif } else { if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_11)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_3); __Pyx_INCREF(__pyx_t_9); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_3); __Pyx_INCREF(__pyx_t_9); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 68, __pyx_L1_error) #else - __pyx_t_9 = PySequence_ITEM(__pyx_t_11, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_9 = PySequence_ITEM(__pyx_t_11, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); #endif } @@ -2127,7 +2211,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 64, __pyx_L1_error) + else __PYX_ERR(0, 68, __pyx_L1_error) } break; } @@ -2143,7 +2227,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 64, __pyx_L1_error) + __PYX_ERR(0, 68, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { @@ -2156,98 +2240,98 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_12); #else - __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); #endif __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else { Py_ssize_t index = -1; - __pyx_t_1 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_1 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_15 = Py_TYPE(__pyx_t_1)->tp_iternext; - index = 0; __pyx_t_2 = __pyx_t_15(__pyx_t_1); if (unlikely(!__pyx_t_2)) goto __pyx_L46_unpacking_failed; + index = 0; __pyx_t_2 = __pyx_t_15(__pyx_t_1); if (unlikely(!__pyx_t_2)) goto __pyx_L49_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); - index = 1; __pyx_t_12 = __pyx_t_15(__pyx_t_1); if (unlikely(!__pyx_t_12)) goto __pyx_L46_unpacking_failed; + index = 1; __pyx_t_12 = __pyx_t_15(__pyx_t_1); if (unlikely(!__pyx_t_12)) goto __pyx_L49_unpacking_failed; __Pyx_GOTREF(__pyx_t_12); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_1), 2) < 0) __PYX_ERR(0, 64, __pyx_L1_error) + if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_1), 2) < 0) __PYX_ERR(0, 68, __pyx_L1_error) __pyx_t_15 = NULL; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L47_unpacking_done; - __pyx_L46_unpacking_failed:; + goto __pyx_L50_unpacking_done; + __pyx_L49_unpacking_failed:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_15 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 64, __pyx_L1_error) - __pyx_L47_unpacking_done:; + __PYX_ERR(0, 68, __pyx_L1_error) + __pyx_L50_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_offset, __pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF_SET(__pyx_v_line, __pyx_t_12); __pyx_t_12 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":65 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":69 * code_object = frame.f_code * for offset, line in dis.findlinestarts(code_object): * if line in breakpoints: # <<<<<<<<<<<<<< * breakpoint = breakpoints[line] * if code_object not in breakpoint.code_objects: */ - __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_v_line, __pyx_v_breakpoints, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 65, __pyx_L1_error) + __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_v_line, __pyx_v_breakpoints, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 69, __pyx_L1_error) __pyx_t_10 = (__pyx_t_5 != 0); if (__pyx_t_10) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":66 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":70 * for offset, line in dis.findlinestarts(code_object): * if line in breakpoints: * breakpoint = breakpoints[line] # <<<<<<<<<<<<<< * if code_object not in breakpoint.code_objects: * # This check is needed for generator functions, because after each yield the new frame is created */ - __pyx_t_9 = PyObject_GetItem(__pyx_v_breakpoints, __pyx_v_line); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 66, __pyx_L1_error) + __pyx_t_9 = PyObject_GetItem(__pyx_v_breakpoints, __pyx_v_line); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_XDECREF_SET(__pyx_v_breakpoint, __pyx_t_9); __pyx_t_9 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":67 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":71 * if line in breakpoints: * breakpoint = breakpoints[line] * if code_object not in breakpoint.code_objects: # <<<<<<<<<<<<<< * # This check is needed for generator functions, because after each yield the new frame is created * # but the former code object is used */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_breakpoint, __pyx_n_s_code_objects); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 67, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_breakpoint, __pyx_n_s_code_objects); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = (__Pyx_PySequence_ContainsTF(__pyx_v_code_object, __pyx_t_9, Py_NE)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 67, __pyx_L1_error) + __pyx_t_10 = (__Pyx_PySequence_ContainsTF(__pyx_v_code_object, __pyx_t_9, Py_NE)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_5 = (__pyx_t_10 != 0); if (__pyx_t_5) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":70 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":74 * # This check is needed for generator functions, because after each yield the new frame is created * # but the former code object is used * breakpoints_to_update.append(breakpoint) # <<<<<<<<<<<<<< * new_code = insert_code(frame.f_code, pydev_trace_code_wrapper.__code__, line) * Py_INCREF(new_code) */ - __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_breakpoints_to_update, __pyx_v_breakpoint); if (unlikely(__pyx_t_16 == -1)) __PYX_ERR(0, 70, __pyx_L1_error) + __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_breakpoints_to_update, __pyx_v_breakpoint); if (unlikely(__pyx_t_16 == -1)) __PYX_ERR(0, 74, __pyx_L1_error) - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":71 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":75 * # but the former code object is used * breakpoints_to_update.append(breakpoint) * new_code = insert_code(frame.f_code, pydev_trace_code_wrapper.__code__, line) # <<<<<<<<<<<<<< * Py_INCREF(new_code) * frame_obj.f_code = new_code */ - __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_insert_code); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_insert_code); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pydev_trace_code_wrapper); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pydev_trace_code_wrapper); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_code); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_code); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; @@ -2265,7 +2349,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_2, __pyx_t_14, __pyx_v_line}; - __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_17, 3+__pyx_t_17); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_17, 3+__pyx_t_17); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -2275,7 +2359,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_2, __pyx_t_14, __pyx_v_line}; - __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_17, 3+__pyx_t_17); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_17, 3+__pyx_t_17); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -2283,7 +2367,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } else #endif { - __pyx_t_13 = PyTuple_New(3+__pyx_t_17); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_13 = PyTuple_New(3+__pyx_t_17); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); if (__pyx_t_1) { __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_1); __pyx_t_1 = NULL; @@ -2297,7 +2381,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_17, __pyx_v_line); __pyx_t_2 = 0; __pyx_t_14 = 0; - __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } @@ -2305,7 +2389,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_XDECREF_SET(__pyx_v_new_code, __pyx_t_9); __pyx_t_9 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":72 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":76 * breakpoints_to_update.append(breakpoint) * new_code = insert_code(frame.f_code, pydev_trace_code_wrapper.__code__, line) * Py_INCREF(new_code) # <<<<<<<<<<<<<< @@ -2314,7 +2398,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ Py_INCREF(__pyx_v_new_code); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":73 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":77 * new_code = insert_code(frame.f_code, pydev_trace_code_wrapper.__code__, line) * Py_INCREF(new_code) * frame_obj.f_code = new_code # <<<<<<<<<<<<<< @@ -2323,7 +2407,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ __pyx_v_frame_obj->f_code = ((PyCodeObject *)__pyx_v_new_code); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":74 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":78 * Py_INCREF(new_code) * frame_obj.f_code = new_code * was_break = True # <<<<<<<<<<<<<< @@ -2332,7 +2416,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ __pyx_v_was_break = 1; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":67 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":71 * if line in breakpoints: * breakpoint = breakpoints[line] * if code_object not in breakpoint.code_objects: # <<<<<<<<<<<<<< @@ -2341,7 +2425,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":65 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":69 * code_object = frame.f_code * for offset, line in dis.findlinestarts(code_object): * if line in breakpoints: # <<<<<<<<<<<<<< @@ -2350,7 +2434,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":64 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":68 * breakpoints_to_update = [] * code_object = frame.f_code * for offset, line in dis.findlinestarts(code_object): # <<<<<<<<<<<<<< @@ -2360,7 +2444,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":75 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":79 * frame_obj.f_code = new_code * was_break = True * if was_break: # <<<<<<<<<<<<<< @@ -2370,16 +2454,16 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_t_5 = (__pyx_v_was_break != 0); if (__pyx_t_5) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":76 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":80 * was_break = True * if was_break: * update_globals_dict(frame.f_globals) # <<<<<<<<<<<<<< * for bp in breakpoints_to_update: * bp.code_objects.append(frame.f_code) */ - __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_update_globals_dict); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 76, __pyx_L1_error) + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_update_globals_dict); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_globals); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 76, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_globals); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { @@ -2392,14 +2476,14 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (!__pyx_t_13) { - __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 76, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_11); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_12}; - __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 76, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; @@ -2408,20 +2492,20 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_12}; - __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 76, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif { - __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 76, __pyx_L1_error) + __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL; __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_12); __pyx_t_12 = 0; - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_14, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 76, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_14, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } @@ -2429,7 +2513,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":77 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":81 * if was_break: * update_globals_dict(frame.f_globals) * for bp in breakpoints_to_update: # <<<<<<<<<<<<<< @@ -2440,30 +2524,30 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec for (;;) { if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_11)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_9 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_3); __Pyx_INCREF(__pyx_t_9); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 77, __pyx_L1_error) + __pyx_t_9 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_3); __Pyx_INCREF(__pyx_t_9); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 81, __pyx_L1_error) #else - __pyx_t_9 = PySequence_ITEM(__pyx_t_11, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 77, __pyx_L1_error) + __pyx_t_9 = PySequence_ITEM(__pyx_t_11, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 81, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); #endif __Pyx_XDECREF_SET(__pyx_v_bp, __pyx_t_9); __pyx_t_9 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":78 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":82 * update_globals_dict(frame.f_globals) * for bp in breakpoints_to_update: * bp.code_objects.append(frame.f_code) # <<<<<<<<<<<<<< * else: * if main_debugger.has_plugin_line_breaks: */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_bp, __pyx_n_s_code_objects); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 78, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_bp, __pyx_n_s_code_objects); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 78, __pyx_L1_error) + __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); - __pyx_t_16 = __Pyx_PyObject_Append(__pyx_t_9, __pyx_t_14); if (unlikely(__pyx_t_16 == -1)) __PYX_ERR(0, 78, __pyx_L1_error) + __pyx_t_16 = __Pyx_PyObject_Append(__pyx_t_9, __pyx_t_14); if (unlikely(__pyx_t_16 == -1)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":77 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":81 * if was_break: * update_globals_dict(frame.f_globals) * for bp in breakpoints_to_update: # <<<<<<<<<<<<<< @@ -2473,7 +2557,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":75 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":79 * frame_obj.f_code = new_code * was_break = True * if was_break: # <<<<<<<<<<<<<< @@ -2482,17 +2566,17 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":60 - * main_debugger = get_global_debugger() + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":64 + * * breakpoints = main_debugger.breakpoints.get(abs_path_real_path_and_base[1]) * if breakpoints: # <<<<<<<<<<<<<< * was_break = False * breakpoints_to_update = [] */ - goto __pyx_L43; + goto __pyx_L46; } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":80 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":84 * bp.code_objects.append(frame.f_code) * else: * if main_debugger.has_plugin_line_breaks: # <<<<<<<<<<<<<< @@ -2500,22 +2584,22 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec * if can_not_skip: */ /*else*/ { - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_has_plugin_line_breaks); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 80, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_has_plugin_line_breaks); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 80, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (__pyx_t_5) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":81 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":85 * else: * if main_debugger.has_plugin_line_breaks: * can_not_skip = main_debugger.plugin.can_not_skip(main_debugger, None, frame) # <<<<<<<<<<<<<< * if can_not_skip: * main_debugger.SetTrace(main_debugger.trace_dispatch) */ - __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_plugin); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 81, __pyx_L1_error) + __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_plugin); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_can_not_skip); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 81, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_can_not_skip); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = NULL; @@ -2533,7 +2617,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[4] = {__pyx_t_14, __pyx_v_main_debugger, Py_None, __pyx_v_frame}; - __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_17, 3+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 81, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_17, 3+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GOTREF(__pyx_t_11); } else @@ -2541,13 +2625,13 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[4] = {__pyx_t_14, __pyx_v_main_debugger, Py_None, __pyx_v_frame}; - __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_17, 3+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 81, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_17, 3+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GOTREF(__pyx_t_11); } else #endif { - __pyx_t_12 = PyTuple_New(3+__pyx_t_17); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 81, __pyx_L1_error) + __pyx_t_12 = PyTuple_New(3+__pyx_t_17); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); if (__pyx_t_14) { __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_14); __pyx_t_14 = NULL; @@ -2561,7 +2645,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_INCREF(__pyx_v_frame); __Pyx_GIVEREF(__pyx_v_frame); PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_17, __pyx_v_frame); - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 81, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } @@ -2569,26 +2653,26 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_v_can_not_skip = __pyx_t_11; __pyx_t_11 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":82 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":86 * if main_debugger.has_plugin_line_breaks: * can_not_skip = main_debugger.plugin.can_not_skip(main_debugger, None, frame) * if can_not_skip: # <<<<<<<<<<<<<< * main_debugger.SetTrace(main_debugger.trace_dispatch) * main_debugger.set_trace_for_frame_and_parents(frame) */ - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_can_not_skip); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 82, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_can_not_skip); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 86, __pyx_L1_error) if (__pyx_t_5) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":83 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":87 * can_not_skip = main_debugger.plugin.can_not_skip(main_debugger, None, frame) * if can_not_skip: * main_debugger.SetTrace(main_debugger.trace_dispatch) # <<<<<<<<<<<<<< * main_debugger.set_trace_for_frame_and_parents(frame) * */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_SetTrace); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_SetTrace); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_trace_dispatch); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_trace_dispatch); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_14 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { @@ -2601,14 +2685,14 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (!__pyx_t_14) { - __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_11); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_12}; - __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; @@ -2617,20 +2701,20 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_12}; - __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif { - __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14); __pyx_t_14 = NULL; __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_12); __pyx_t_12 = 0; - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_13, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_13, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } @@ -2638,14 +2722,14 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":84 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":88 * if can_not_skip: * main_debugger.SetTrace(main_debugger.trace_dispatch) * main_debugger.set_trace_for_frame_and_parents(frame) # <<<<<<<<<<<<<< * * additional_info.is_tracing = False */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_set_trace_for_frame_and_parents); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 84, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_set_trace_for_frame_and_parents); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_13 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { @@ -2658,13 +2742,13 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (!__pyx_t_13) { - __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_frame); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 84, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_frame); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_v_frame}; - __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 84, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_11); } else @@ -2672,19 +2756,19 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_v_frame}; - __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 84, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_11); } else #endif { - __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 84, __pyx_L1_error) + __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); __pyx_t_13 = NULL; __Pyx_INCREF(__pyx_v_frame); __Pyx_GIVEREF(__pyx_v_frame); PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_v_frame); - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 84, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } @@ -2692,7 +2776,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":82 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":86 * if main_debugger.has_plugin_line_breaks: * can_not_skip = main_debugger.plugin.can_not_skip(main_debugger, None, frame) * if can_not_skip: # <<<<<<<<<<<<<< @@ -2701,7 +2785,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":80 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":84 * bp.code_objects.append(frame.f_code) * else: * if main_debugger.has_plugin_line_breaks: # <<<<<<<<<<<<<< @@ -2710,18 +2794,18 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } } - __pyx_L43:; + __pyx_L46:; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":86 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":90 * main_debugger.set_trace_for_frame_and_parents(frame) * * additional_info.is_tracing = False # <<<<<<<<<<<<<< * return _PyEval_EvalFrameDefault(frame_obj, exc) * */ - if (__Pyx_PyObject_SetAttrStr(__pyx_v_additional_info, __pyx_n_s_is_tracing, Py_False) < 0) __PYX_ERR(0, 86, __pyx_L1_error) + if (__Pyx_PyObject_SetAttrStr(__pyx_v_additional_info, __pyx_n_s_is_tracing, Py_False) < 0) __PYX_ERR(0, 90, __pyx_L1_error) - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":35 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":36 * skip_file = True * * if not skip_file: # <<<<<<<<<<<<<< @@ -2730,7 +2814,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":87 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":91 * * additional_info.is_tracing = False * return _PyEval_EvalFrameDefault(frame_obj, exc) # <<<<<<<<<<<<<< @@ -2740,7 +2824,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_r = _PyEval_EvalFrameDefault(__pyx_v_frame_obj, __pyx_v_exc); goto __pyx_L0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":18 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":19 * get_file_type = DONT_TRACE.get * * cdef PyObject* get_bytecode_while_frame_eval(PyFrameObject *frame_obj, int exc): # <<<<<<<<<<<<<< @@ -2781,7 +2865,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec return __pyx_r; } -/* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":89 +/* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":93 * return _PyEval_EvalFrameDefault(frame_obj, exc) * * def frame_eval_func(): # <<<<<<<<<<<<<< @@ -2809,7 +2893,7 @@ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_frame_ev __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("frame_eval_func", 0); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":90 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":94 * * def frame_eval_func(): * cdef PyThreadState *state = PyThreadState_Get() # <<<<<<<<<<<<<< @@ -2818,7 +2902,7 @@ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_frame_ev */ __pyx_v_state = PyThreadState_Get(); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":91 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":95 * def frame_eval_func(): * cdef PyThreadState *state = PyThreadState_Get() * state.interp.eval_frame = get_bytecode_while_frame_eval # <<<<<<<<<<<<<< @@ -2827,7 +2911,7 @@ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_frame_ev */ __pyx_v_state->interp->eval_frame = __pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytecode_while_frame_eval; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":89 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":93 * return _PyEval_EvalFrameDefault(frame_obj, exc) * * def frame_eval_func(): # <<<<<<<<<<<<<< @@ -2842,7 +2926,7 @@ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_frame_ev return __pyx_r; } -/* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":93 +/* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":97 * state.interp.eval_frame = get_bytecode_while_frame_eval * * def stop_frame_eval(): # <<<<<<<<<<<<<< @@ -2870,7 +2954,7 @@ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_2stop_fr __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stop_frame_eval", 0); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":94 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":98 * * def stop_frame_eval(): * cdef PyThreadState *state = PyThreadState_Get() # <<<<<<<<<<<<<< @@ -2878,14 +2962,14 @@ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_2stop_fr */ __pyx_v_state = PyThreadState_Get(); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":95 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":99 * def stop_frame_eval(): * cdef PyThreadState *state = PyThreadState_Get() * state.interp.eval_frame = _PyEval_EvalFrameDefault # <<<<<<<<<<<<<< */ __pyx_v_state->interp->eval_frame = _PyEval_EvalFrameDefault; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":93 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":97 * state.interp.eval_frame = get_bytecode_while_frame_eval * * def stop_frame_eval(): # <<<<<<<<<<<<<< @@ -2925,9 +3009,11 @@ static struct PyModuleDef __pyx_moduledef = { static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_AVOID_RECURSION, __pyx_k_AVOID_RECURSION, sizeof(__pyx_k_AVOID_RECURSION), 0, 0, 1, 1}, {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1}, + {&__pyx_n_s_CMD_THREAD_SUSPEND, __pyx_k_CMD_THREAD_SUSPEND, sizeof(__pyx_k_CMD_THREAD_SUSPEND), 0, 0, 1, 1}, {&__pyx_n_s_DONT_TRACE, __pyx_k_DONT_TRACE, sizeof(__pyx_k_DONT_TRACE), 0, 0, 1, 1}, {&__pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER, __pyx_k_NORM_PATHS_AND_BASE_CONTAINER, sizeof(__pyx_k_NORM_PATHS_AND_BASE_CONTAINER), 0, 0, 1, 1}, {&__pyx_n_s_PyDBAdditionalThreadInfo, __pyx_k_PyDBAdditionalThreadInfo, sizeof(__pyx_k_PyDBAdditionalThreadInfo), 0, 0, 1, 1}, + {&__pyx_n_s_STATE_SUSPEND, __pyx_k_STATE_SUSPEND, sizeof(__pyx_k_STATE_SUSPEND), 0, 0, 1, 1}, {&__pyx_n_s_SetTrace, __pyx_k_SetTrace, sizeof(__pyx_k_SetTrace), 0, 0, 1, 1}, {&__pyx_n_s_additional_info, __pyx_k_additional_info, sizeof(__pyx_k_additional_info), 0, 0, 1, 1}, {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1}, @@ -2953,12 +3039,15 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_is_tracing, __pyx_k_is_tracing, sizeof(__pyx_k_is_tracing), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_plugin, __pyx_k_plugin, sizeof(__pyx_k_plugin), 0, 0, 1, 1}, + {&__pyx_n_s_process_internal_commands, __pyx_k_process_internal_commands, sizeof(__pyx_k_process_internal_commands), 0, 0, 1, 1}, {&__pyx_n_s_pydev_do_not_trace, __pyx_k_pydev_do_not_trace, sizeof(__pyx_k_pydev_do_not_trace), 0, 0, 1, 1}, {&__pyx_n_s_pydev_imps__pydev_saved_modules, __pyx_k_pydev_imps__pydev_saved_modules, sizeof(__pyx_k_pydev_imps__pydev_saved_modules), 0, 0, 1, 1}, + {&__pyx_n_s_pydev_state, __pyx_k_pydev_state, sizeof(__pyx_k_pydev_state), 0, 0, 1, 1}, {&__pyx_n_s_pydev_trace_code_wrapper, __pyx_k_pydev_trace_code_wrapper, sizeof(__pyx_k_pydev_trace_code_wrapper), 0, 0, 1, 1}, {&__pyx_kp_s_pydevd_additional_thread_info_re, __pyx_k_pydevd_additional_thread_info_re, sizeof(__pyx_k_pydevd_additional_thread_info_re), 0, 0, 1, 0}, {&__pyx_n_s_pydevd_bundle_pydevd_additional, __pyx_k_pydevd_bundle_pydevd_additional, sizeof(__pyx_k_pydevd_bundle_pydevd_additional), 0, 0, 1, 1}, {&__pyx_n_s_pydevd_bundle_pydevd_comm, __pyx_k_pydevd_bundle_pydevd_comm, sizeof(__pyx_k_pydevd_bundle_pydevd_comm), 0, 0, 1, 1}, + {&__pyx_n_s_pydevd_bundle_pydevd_constants, __pyx_k_pydevd_bundle_pydevd_constants, sizeof(__pyx_k_pydevd_bundle_pydevd_constants), 0, 0, 1, 1}, {&__pyx_n_s_pydevd_bundle_pydevd_dont_trace, __pyx_k_pydevd_bundle_pydevd_dont_trace, sizeof(__pyx_k_pydevd_bundle_pydevd_dont_trace), 0, 0, 1, 1}, {&__pyx_n_s_pydevd_file_utils, __pyx_k_pydevd_file_utils, sizeof(__pyx_k_pydevd_file_utils), 0, 0, 1, 1}, {&__pyx_n_s_pydevd_frame_eval_pydevd_frame, __pyx_k_pydevd_frame_eval_pydevd_frame, sizeof(__pyx_k_pydevd_frame_eval_pydevd_frame), 0, 0, 1, 1}, @@ -2967,6 +3056,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_set_trace_for_frame_and_parents, __pyx_k_set_trace_for_frame_and_parents, sizeof(__pyx_k_set_trace_for_frame_and_parents), 0, 0, 1, 1}, {&__pyx_n_s_state, __pyx_k_state, sizeof(__pyx_k_state), 0, 0, 1, 1}, {&__pyx_n_s_stop_frame_eval, __pyx_k_stop_frame_eval, sizeof(__pyx_k_stop_frame_eval), 0, 0, 1, 1}, + {&__pyx_n_s_stop_reason, __pyx_k_stop_reason, sizeof(__pyx_k_stop_reason), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_threading, __pyx_k_threading, sizeof(__pyx_k_threading), 0, 0, 1, 1}, {&__pyx_kp_s_threading_py, __pyx_k_threading_py, sizeof(__pyx_k_threading_py), 0, 0, 1, 0}, @@ -2976,7 +3066,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 40, __pyx_L1_error) + __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 41, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; @@ -2986,29 +3076,29 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":89 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":93 * return _PyEval_EvalFrameDefault(frame_obj, exc) * * def frame_eval_func(): # <<<<<<<<<<<<<< * cdef PyThreadState *state = PyThreadState_Get() * state.interp.eval_frame = get_bytecode_while_frame_eval */ - __pyx_tuple_ = PyTuple_Pack(1, __pyx_n_s_state); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 89, __pyx_L1_error) + __pyx_tuple_ = PyTuple_Pack(1, __pyx_n_s_state); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 93, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); - __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_user_work_ultimate_communi, __pyx_n_s_frame_eval_func, 89, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 89, __pyx_L1_error) + __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_user_work_ultimate_communi, __pyx_n_s_frame_eval_func, 93, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 93, __pyx_L1_error) - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":93 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":97 * state.interp.eval_frame = get_bytecode_while_frame_eval * * def stop_frame_eval(): # <<<<<<<<<<<<<< * cdef PyThreadState *state = PyThreadState_Get() * state.interp.eval_frame = _PyEval_EvalFrameDefault */ - __pyx_tuple__3 = PyTuple_Pack(1, __pyx_n_s_state); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 93, __pyx_L1_error) + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_n_s_state); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); - __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_user_work_ultimate_communi, __pyx_n_s_stop_frame_eval, 93, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 93, __pyx_L1_error) + __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_user_work_ultimate_communi, __pyx_n_s_stop_frame_eval, 97, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -3130,7 +3220,7 @@ PyMODINIT_FUNC PyInit_pydevd_frame_evaluator(void) * import dis * from _pydev_imps._pydev_saved_modules import threading # <<<<<<<<<<<<<< * from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo - * from _pydevd_bundle.pydevd_comm import get_global_debugger + * from _pydevd_bundle.pydevd_comm import get_global_debugger, CMD_THREAD_SUSPEND */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); @@ -3150,8 +3240,8 @@ PyMODINIT_FUNC PyInit_pydevd_frame_evaluator(void) * import dis * from _pydev_imps._pydev_saved_modules import threading * from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo # <<<<<<<<<<<<<< - * from _pydevd_bundle.pydevd_comm import get_global_debugger - * from _pydevd_bundle.pydevd_dont_trace_files import DONT_TRACE + * from _pydevd_bundle.pydevd_comm import get_global_debugger, CMD_THREAD_SUSPEND + * from _pydevd_bundle.pydevd_constants import STATE_SUSPEND */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); @@ -3170,15 +3260,18 @@ PyMODINIT_FUNC PyInit_pydevd_frame_evaluator(void) /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":4 * from _pydev_imps._pydev_saved_modules import threading * from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo - * from _pydevd_bundle.pydevd_comm import get_global_debugger # <<<<<<<<<<<<<< + * from _pydevd_bundle.pydevd_comm import get_global_debugger, CMD_THREAD_SUSPEND # <<<<<<<<<<<<<< + * from _pydevd_bundle.pydevd_constants import STATE_SUSPEND * from _pydevd_bundle.pydevd_dont_trace_files import DONT_TRACE - * from _pydevd_frame_eval.pydevd_frame_tracing import pydev_trace_code_wrapper, update_globals_dict */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error) + __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_get_global_debugger); __Pyx_GIVEREF(__pyx_n_s_get_global_debugger); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_get_global_debugger); + __Pyx_INCREF(__pyx_n_s_CMD_THREAD_SUSPEND); + __Pyx_GIVEREF(__pyx_n_s_CMD_THREAD_SUSPEND); + PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_CMD_THREAD_SUSPEND); __pyx_t_2 = __Pyx_Import(__pyx_n_s_pydevd_bundle_pydevd_comm, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -3186,175 +3279,200 @@ PyMODINIT_FUNC PyInit_pydevd_frame_evaluator(void) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_global_debugger, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_CMD_THREAD_SUSPEND); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_CMD_THREAD_SUSPEND, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":5 * from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo - * from _pydevd_bundle.pydevd_comm import get_global_debugger - * from _pydevd_bundle.pydevd_dont_trace_files import DONT_TRACE # <<<<<<<<<<<<<< + * from _pydevd_bundle.pydevd_comm import get_global_debugger, CMD_THREAD_SUSPEND + * from _pydevd_bundle.pydevd_constants import STATE_SUSPEND # <<<<<<<<<<<<<< + * from _pydevd_bundle.pydevd_dont_trace_files import DONT_TRACE * from _pydevd_frame_eval.pydevd_frame_tracing import pydev_trace_code_wrapper, update_globals_dict - * from _pydevd_frame_eval.pydevd_modify_bytecode import insert_code */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_n_s_DONT_TRACE); - __Pyx_GIVEREF(__pyx_n_s_DONT_TRACE); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_DONT_TRACE); - __pyx_t_1 = __Pyx_Import(__pyx_n_s_pydevd_bundle_pydevd_dont_trace, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error) + __Pyx_INCREF(__pyx_n_s_STATE_SUSPEND); + __Pyx_GIVEREF(__pyx_n_s_STATE_SUSPEND); + PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_STATE_SUSPEND); + __pyx_t_1 = __Pyx_Import(__pyx_n_s_pydevd_bundle_pydevd_constants, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_DONT_TRACE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error) + __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_STATE_SUSPEND); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_DONT_TRACE, __pyx_t_2) < 0) __PYX_ERR(0, 5, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_STATE_SUSPEND, __pyx_t_2) < 0) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":6 - * from _pydevd_bundle.pydevd_comm import get_global_debugger + * from _pydevd_bundle.pydevd_comm import get_global_debugger, CMD_THREAD_SUSPEND + * from _pydevd_bundle.pydevd_constants import STATE_SUSPEND + * from _pydevd_bundle.pydevd_dont_trace_files import DONT_TRACE # <<<<<<<<<<<<<< + * from _pydevd_frame_eval.pydevd_frame_tracing import pydev_trace_code_wrapper, update_globals_dict + * from _pydevd_frame_eval.pydevd_modify_bytecode import insert_code + */ + __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_n_s_DONT_TRACE); + __Pyx_GIVEREF(__pyx_n_s_DONT_TRACE); + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_DONT_TRACE); + __pyx_t_2 = __Pyx_Import(__pyx_n_s_pydevd_bundle_pydevd_dont_trace, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_DONT_TRACE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_DONT_TRACE, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":7 + * from _pydevd_bundle.pydevd_constants import STATE_SUSPEND * from _pydevd_bundle.pydevd_dont_trace_files import DONT_TRACE * from _pydevd_frame_eval.pydevd_frame_tracing import pydev_trace_code_wrapper, update_globals_dict # <<<<<<<<<<<<<< * from _pydevd_frame_eval.pydevd_modify_bytecode import insert_code * from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame, NORM_PATHS_AND_BASE_CONTAINER */ - __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_pydev_trace_code_wrapper); __Pyx_GIVEREF(__pyx_n_s_pydev_trace_code_wrapper); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_pydev_trace_code_wrapper); + PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_pydev_trace_code_wrapper); __Pyx_INCREF(__pyx_n_s_update_globals_dict); __Pyx_GIVEREF(__pyx_n_s_update_globals_dict); - PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_update_globals_dict); - __pyx_t_2 = __Pyx_Import(__pyx_n_s_pydevd_frame_eval_pydevd_frame, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_pydev_trace_code_wrapper); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) + PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_update_globals_dict); + __pyx_t_1 = __Pyx_Import(__pyx_n_s_pydevd_frame_eval_pydevd_frame, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_pydev_trace_code_wrapper, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_update_globals_dict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_update_globals_dict, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_pydev_trace_code_wrapper); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_pydev_trace_code_wrapper, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_update_globals_dict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_update_globals_dict, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":7 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":8 * from _pydevd_bundle.pydevd_dont_trace_files import DONT_TRACE * from _pydevd_frame_eval.pydevd_frame_tracing import pydev_trace_code_wrapper, update_globals_dict * from _pydevd_frame_eval.pydevd_modify_bytecode import insert_code # <<<<<<<<<<<<<< * from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame, NORM_PATHS_AND_BASE_CONTAINER * */ - __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_insert_code); __Pyx_GIVEREF(__pyx_n_s_insert_code); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_insert_code); - __pyx_t_1 = __Pyx_Import(__pyx_n_s_pydevd_frame_eval_pydevd_modify, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_insert_code); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_insert_code); + __pyx_t_2 = __Pyx_Import(__pyx_n_s_pydevd_frame_eval_pydevd_modify, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_insert_code, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_insert_code); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_insert_code, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":8 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":9 * from _pydevd_frame_eval.pydevd_frame_tracing import pydev_trace_code_wrapper, update_globals_dict * from _pydevd_frame_eval.pydevd_modify_bytecode import insert_code * from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame, NORM_PATHS_AND_BASE_CONTAINER # <<<<<<<<<<<<<< * * AVOID_RECURSION = [ */ - __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_get_abs_path_real_path_and_base); __Pyx_GIVEREF(__pyx_n_s_get_abs_path_real_path_and_base); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_get_abs_path_real_path_and_base); + PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_get_abs_path_real_path_and_base); __Pyx_INCREF(__pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); __Pyx_GIVEREF(__pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); - PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); - __pyx_t_2 = __Pyx_Import(__pyx_n_s_pydevd_file_utils, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_get_abs_path_real_path_and_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error) + PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); + __pyx_t_1 = __Pyx_Import(__pyx_n_s_pydevd_file_utils, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_abs_path_real_path_and_base, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_get_abs_path_real_path_and_base); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_abs_path_real_path_and_base, __pyx_t_2) < 0) __PYX_ERR(0, 9, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER, __pyx_t_2) < 0) __PYX_ERR(0, 9, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":10 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":11 * from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame, NORM_PATHS_AND_BASE_CONTAINER * * AVOID_RECURSION = [ # <<<<<<<<<<<<<< * 'pydevd_additional_thread_info_regular.py', * 'threading.py', */ - __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_kp_s_pydevd_additional_thread_info_re); __Pyx_GIVEREF(__pyx_kp_s_pydevd_additional_thread_info_re); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_kp_s_pydevd_additional_thread_info_re); + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_kp_s_pydevd_additional_thread_info_re); __Pyx_INCREF(__pyx_kp_s_threading_py); __Pyx_GIVEREF(__pyx_kp_s_threading_py); - PyList_SET_ITEM(__pyx_t_2, 1, __pyx_kp_s_threading_py); + PyList_SET_ITEM(__pyx_t_1, 1, __pyx_kp_s_threading_py); __Pyx_INCREF(__pyx_kp_s_weakrefset_py); __Pyx_GIVEREF(__pyx_kp_s_weakrefset_py); - PyList_SET_ITEM(__pyx_t_2, 2, __pyx_kp_s_weakrefset_py); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_AVOID_RECURSION, __pyx_t_2) < 0) __PYX_ERR(0, 10, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + PyList_SET_ITEM(__pyx_t_1, 2, __pyx_kp_s_weakrefset_py); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_AVOID_RECURSION, __pyx_t_1) < 0) __PYX_ERR(0, 11, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":16 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":17 * ] * * get_file_type = DONT_TRACE.get # <<<<<<<<<<<<<< * * cdef PyObject* get_bytecode_while_frame_eval(PyFrameObject *frame_obj, int exc): */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_DONT_TRACE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_DONT_TRACE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_file_type, __pyx_t_1) < 0) __PYX_ERR(0, 16, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_file_type, __pyx_t_2) < 0) __PYX_ERR(0, 17, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":89 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":93 * return _PyEval_EvalFrameDefault(frame_obj, exc) * * def frame_eval_func(): # <<<<<<<<<<<<<< * cdef PyThreadState *state = PyThreadState_Get() * state.interp.eval_frame = get_bytecode_while_frame_eval */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_1frame_eval_func, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 89, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_frame_eval_func, __pyx_t_1) < 0) __PYX_ERR(0, 89, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_1frame_eval_func, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_frame_eval_func, __pyx_t_2) < 0) __PYX_ERR(0, 93, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":93 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":97 * state.interp.eval_frame = get_bytecode_while_frame_eval * * def stop_frame_eval(): # <<<<<<<<<<<<<< * cdef PyThreadState *state = PyThreadState_Get() * state.interp.eval_frame = _PyEval_EvalFrameDefault */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_3stop_frame_eval, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_stop_frame_eval, __pyx_t_1) < 0) __PYX_ERR(0, 93, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_3stop_frame_eval, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_stop_frame_eval, __pyx_t_2) < 0) __PYX_ERR(0, 97, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":1 * import dis # <<<<<<<<<<<<<< * from _pydev_imps._pydev_saved_modules import threading * from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /*--- Wrapped vars code ---*/ diff --git a/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator.pyx b/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator.pyx index 4c7a9d468e69..bc8da6cdfefc 100644 --- a/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator.pyx +++ b/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator.pyx @@ -1,7 +1,8 @@ import dis from _pydev_imps._pydev_saved_modules import threading from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo -from _pydevd_bundle.pydevd_comm import get_global_debugger +from _pydevd_bundle.pydevd_comm import get_global_debugger, CMD_THREAD_SUSPEND +from _pydevd_bundle.pydevd_constants import STATE_SUSPEND from _pydevd_bundle.pydevd_dont_trace_files import DONT_TRACE from _pydevd_frame_eval.pydevd_frame_tracing import pydev_trace_code_wrapper, update_globals_dict from _pydevd_frame_eval.pydevd_modify_bytecode import insert_code @@ -56,6 +57,9 @@ cdef PyObject* get_bytecode_while_frame_eval(PyFrameObject *frame_obj, int exc): return _PyEval_EvalFrameDefault(frame_obj, exc) main_debugger = get_global_debugger() + if additional_info.pydev_state == STATE_SUSPEND and t.stop_reason == CMD_THREAD_SUSPEND: + main_debugger.process_internal_commands() + breakpoints = main_debugger.breakpoints.get(abs_path_real_path_and_base[1]) if breakpoints: was_break = False diff --git a/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator_win32_36_32.cp36-win32.pyd b/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator_win32_36_32.cp36-win32.pyd index 1676601c7682..6a7a125d21ed 100644 Binary files a/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator_win32_36_32.cp36-win32.pyd and b/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator_win32_36_32.cp36-win32.pyd differ diff --git a/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator_win32_36_64.cp36-win_amd64.pyd b/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator_win32_36_64.cp36-win_amd64.pyd index 82079b332da0..dd2c227139ac 100644 Binary files a/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator_win32_36_64.cp36-win_amd64.pyd and b/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator_win32_36_64.cp36-win_amd64.pyd differ diff --git a/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_tracing.py b/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_tracing.py index 46ee91f9ce72..2cf662f63d59 100644 --- a/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_tracing.py +++ b/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_tracing.py @@ -12,10 +12,11 @@ def update_globals_dict(globals_dict): globals_dict.update(new_globals) -def handle_breakpoint(frame, info, global_debugger, breakpoint): +def handle_breakpoint(frame, thread, global_debugger, breakpoint): # ok, hit breakpoint, now, we have to discover if it is a conditional breakpoint new_frame = frame condition = breakpoint.condition + info = thread.additional_info if condition is not None: try: val = eval(condition, new_frame.f_globals, new_frame.f_locals) @@ -58,6 +59,10 @@ def handle_breakpoint(frame, info, global_debugger, breakpoint): finally: if val is not None: info.pydev_message = str(val) + + if breakpoint.suspend_policy == "ALL": + global_debugger.suspend_all_other_threads(thread) + return True @@ -94,7 +99,7 @@ def _pydev_stop_at_break(): except KeyError: pydev_log.debug("Couldn't find breakpoint in the file {} on line {}".format(frame.f_code.co_filename, line)) return - if breakpoint and handle_breakpoint(frame, t.additional_info, debugger, breakpoint): + if breakpoint and handle_breakpoint(frame, t, debugger, breakpoint): pydev_log.debug("Suspending at breakpoint in file: {} on line {}".format(frame.f_code.co_filename, line)) debugger.set_suspend(t, CMD_SET_BREAK) debugger.do_wait_suspend(t, frame, 'line', None) diff --git a/python/helpers/pydev/pydevd.py b/python/helpers/pydev/pydevd.py index bd390986603f..c9e990f64245 100644 --- a/python/helpers/pydev/pydevd.py +++ b/python/helpers/pydev/pydevd.py @@ -670,6 +670,11 @@ class PyDB: if stop_reason == CMD_SET_BREAK and self.suspend_on_breakpoint_exception: self._send_breakpoint_condition_exception(thread) + if self.frame_eval_func is not None and stop_reason == CMD_THREAD_SUSPEND: + thread_id = get_thread_id(thread) + int_cmd = InternalSetTracingThread(thread_id) + self.post_internal_command(int_cmd, thread_id) + def _send_breakpoint_condition_exception(self, thread): """If conditional breakpoint raises an exception during evaluation diff --git a/python/python-community-configure/src/com/jetbrains/python/newProject/steps/PythonBaseProjectGenerator.java b/python/python-community-configure/src/com/jetbrains/python/newProject/steps/PythonBaseProjectGenerator.java index d2c9d565e367..e3db007e52fc 100644 --- a/python/python-community-configure/src/com/jetbrains/python/newProject/steps/PythonBaseProjectGenerator.java +++ b/python/python-community-configure/src/com/jetbrains/python/newProject/steps/PythonBaseProjectGenerator.java @@ -74,7 +74,7 @@ public class PythonBaseProjectGenerator extends PythonProjectGeneratoralwaysTrue()); + return selectorAllExpressionsWithCurrentOffset(Conditions.alwaysTrue()); } public static PostfixTemplateExpressionSelector selectorTopmost() { - return selectorTopmost(Conditions.alwaysTrue()); + return selectorTopmost(Conditions.alwaysTrue()); } public static PostfixTemplateExpressionSelector selectorTopmost(Condition additionalFilter) { @@ -89,7 +90,7 @@ public class PyPostfixUtils { protected List getNonFilteredExpressions(@NotNull PsiElement context, @NotNull Document document, int offset) { PyExpressionStatement exprStatement = PsiTreeUtil.getNonStrictParentOfType(context, PyExpressionStatement.class); PyExpression expression = exprStatement != null ? PsiTreeUtil.getChildOfType(exprStatement, PyExpression.class) : null; - return ContainerUtil.createMaybeSingletonList(expression); + return ContainerUtil.createMaybeSingletonList(expression); } }; } @@ -99,6 +100,9 @@ public class PyPostfixUtils { @Override protected List getNonFilteredExpressions(@NotNull PsiElement context, @NotNull Document document, int offset) { PsiElement elementAtCaret = PsiUtilCore.getElementAtOffset(context.getContainingFile(), offset - 1); + if (elementAtCaret instanceof PsiComment) { + return Collections.emptyList(); + } while (elementAtCaret != null) { if (elementAtCaret instanceof PyStatement) { return Collections.singletonList(elementAtCaret); diff --git a/python/src/com/jetbrains/python/codeInsight/userSkeletons/PyUserSkeletonsUtil.java b/python/src/com/jetbrains/python/codeInsight/userSkeletons/PyUserSkeletonsUtil.java index 59993e6646e2..baf0bdfdbe2e 100644 --- a/python/src/com/jetbrains/python/codeInsight/userSkeletons/PyUserSkeletonsUtil.java +++ b/python/src/com/jetbrains/python/codeInsight/userSkeletons/PyUserSkeletonsUtil.java @@ -118,7 +118,7 @@ public class PyUserSkeletonsUtil { @Nullable public static PyFile getUserSkeletonForModuleQName(@NotNull String qName, @NotNull PsiElement foothold) { - final Sdk sdk = PythonSdkType.getSdk(foothold); + final Sdk sdk = PythonSdkType.findPythonSdk(foothold); if (sdk != null) { final Project project = foothold.getProject(); final PythonSdkPathCache cache = PythonSdkPathCache.getInstance(project, sdk); diff --git a/python/src/com/jetbrains/python/inspections/PyDeprecationInspection.java b/python/src/com/jetbrains/python/inspections/PyDeprecationInspection.java index 1c28413a740c..b755f3114455 100644 --- a/python/src/com/jetbrains/python/inspections/PyDeprecationInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyDeprecationInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -21,13 +21,16 @@ import com.intellij.codeInspection.ProblemsHolder; import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; -import com.intellij.psi.PsiPolyVariantReference; import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.psi.util.QualifiedName; import com.jetbrains.python.psi.*; +import com.jetbrains.python.psi.PyKnownDecoratorUtil.KnownDecorator; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Arrays; + /** * @author yole */ @@ -59,9 +62,7 @@ public class PyDeprecationInspection extends PyInspection { final PyExpression exceptClass = exceptPart.getExceptClass(); if (exceptClass != null && "ImportError".equals(exceptClass.getText())) return; } - final PsiPolyVariantReference reference = node.getReference(getResolveContext()); - if (reference == null) return; - final PsiElement resolveResult = reference.resolve(); + final PsiElement resolveResult = node.getReference(getResolveContext()).resolve(); final PyFromImportStatement importStatement = PsiTreeUtil.getParentOfType(node, PyFromImportStatement.class); if (importStatement != null) { final PsiElement element = importStatement.resolveImportSource(); @@ -79,5 +80,29 @@ public class PyDeprecationInspection extends PyInspection { registerProblem(nameElement == null ? node : nameElement.getPsi(), deprecationMessage, ProblemHighlightType.LIKE_DEPRECATED); } } + + @Override + public void visitPyFunction(PyFunction node) { + super.visitPyFunction(node); + + final PyDecoratorList decoratorList = node.getDecoratorList(); + if (LanguageLevel.forElement(node).isAtLeast(LanguageLevel.PYTHON33) && decoratorList != null) { + Arrays + .stream(decoratorList.getDecorators()) + .filter(decorator -> PyKnownDecoratorUtil.asKnownDecorator(decorator, myTypeEvalContext) == KnownDecorator.ABC_ABSTRACTPROPERTY) + .forEach( + decorator -> { + final QualifiedName abcAbsPropertyQName = KnownDecorator.ABC_ABSTRACTPROPERTY.getQualifiedName(); + final QualifiedName propertyQName = KnownDecorator.PROPERTY.getQualifiedName(); + final QualifiedName abcAbsMethodQName = KnownDecorator.ABC_ABSTRACTMETHOD.getQualifiedName(); + + final String message = "'" + abcAbsPropertyQName + "' is deprecated since Python 3.3. " + + "Use '" + propertyQName + "' with '" + abcAbsMethodQName + "' instead."; + + registerProblem(decorator, message, ProblemHighlightType.LIKE_DEPRECATED); + } + ); + } + } } } diff --git a/python/src/com/jetbrains/python/inspections/unresolvedReference/PyUnresolvedReferencesInspection.java b/python/src/com/jetbrains/python/inspections/unresolvedReference/PyUnresolvedReferencesInspection.java index a13f4bb95895..5bcec2e4273f 100644 --- a/python/src/com/jetbrains/python/inspections/unresolvedReference/PyUnresolvedReferencesInspection.java +++ b/python/src/com/jetbrains/python/inspections/unresolvedReference/PyUnresolvedReferencesInspection.java @@ -149,7 +149,7 @@ public class PyUnresolvedReferencesInspection extends PyInspection { myIsEnabled = false; } else if (isPyCharm) { - myIsEnabled = PythonSdkType.getSdk(anchor) != null || PyUtil.isInScratchFile(anchor); + myIsEnabled = PythonSdkType.findPythonSdk(anchor) != null || PyUtil.isInScratchFile(anchor); } else { myIsEnabled = true; diff --git a/python/src/com/jetbrains/python/psi/PyKnownDecoratorUtil.java b/python/src/com/jetbrains/python/psi/PyKnownDecoratorUtil.java index 583c41c53777..92039a77ec2b 100644 --- a/python/src/com/jetbrains/python/psi/PyKnownDecoratorUtil.java +++ b/python/src/com/jetbrains/python/psi/PyKnownDecoratorUtil.java @@ -22,6 +22,7 @@ import com.intellij.psi.util.QualifiedName; import com.intellij.util.containers.Convertor; import com.jetbrains.python.PyNames; import com.jetbrains.python.psi.types.TypeEvalContext; +import one.util.streamex.StreamEx; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -75,7 +76,11 @@ public class PyKnownDecoratorUtil { TYPING_OVERLOAD("typing.overload"), - REPRLIB_RECURSIVE_REPR("reprlib.recursive_repr"); + REPRLIB_RECURSIVE_REPR("reprlib.recursive_repr"), + + PYRAMID_DECORATOR_REIFY("pyramid.decorator.reify"), + DJANGO_UTILS_FUNCTIONAL_CACHED_PROPERTY("django.utils.functional.cached_property"), + KOMBU_UTILS_CACHED_PROPERTY("kombu.utils.cached_property"); private final QualifiedName myQualifiedName; @@ -101,6 +106,12 @@ public class PyKnownDecoratorUtil { ABC_ABSTRACTSTATICMETHOD, ABC_ABSTRACTCLASSMETHOD); + private static final Set PROPERTY_DECORATORS = EnumSet.of(PROPERTY, + ABC_ABSTRACTPROPERTY, + PYRAMID_DECORATOR_REIFY, + DJANGO_UTILS_FUNCTIONAL_CACHED_PROPERTY, + KOMBU_UTILS_CACHED_PROPERTY); + private static final Map ourByShortName = newMapFromValues(Iterators.forArray(values()), new Convertor() { @Override @@ -110,7 +121,7 @@ public class PyKnownDecoratorUtil { }); /** - * Map decorators of element to {@link com.jetbrains.python.psi.PyKnownDecoratorUtil.KnownDecorator}. + * Map decorators of element to {@link PyKnownDecoratorUtil.KnownDecorator}. * * @param element decoratable element to check * @param context type evaluation context. If it doesn't allow switch to AST, decorators will be compared by the text of the last component @@ -123,34 +134,41 @@ public class PyKnownDecoratorUtil { if (decoratorList == null) { return Collections.emptyList(); } - final List result = new ArrayList<>(); - final boolean allowResolve = context.maySwitchToAST((PsiElement)element); - for (PyDecorator decorator : decoratorList.getDecorators()) { - final QualifiedName qualifiedName = decorator.getQualifiedName(); - if (qualifiedName == null) { - continue; + + return StreamEx + .of(decoratorList.getDecorators()) + .map(decorator -> asKnownDecorator(decorator, context)) + .nonNull() + .toList(); + } + + @Nullable + public static KnownDecorator asKnownDecorator(@NotNull PyDecorator decorator, @NotNull TypeEvalContext context) { + final QualifiedName qualifiedName = decorator.getQualifiedName(); + if (qualifiedName == null) { + return null; + } + + if (context.maySwitchToAST(decorator)) { + PyQualifiedNameOwner resolved = as(resolveDecorator(decorator), PyQualifiedNameOwner.class); + if (resolved instanceof PyFunction && PyNames.INIT.equals(resolved.getName())) { + resolved = ((PyFunction)resolved).getContainingClass(); } - final KnownDecorator knownDecorator = ourByShortName.get(qualifiedName.getLastComponent()); - if (knownDecorator != null) { - if (allowResolve) { - PyQualifiedNameOwner resolved = as(resolveDecorator(decorator), PyQualifiedNameOwner.class); - if (resolved instanceof PyFunction && PyNames.INIT.equals(resolved.getName())) { - resolved = ((PyFunction)resolved).getContainingClass(); - } - if (resolved != null && resolved.getQualifiedName() != null) { - final QualifiedName resolvedName = QualifiedName.fromDottedString(resolved.getQualifiedName()); - if (resolvedName.equals(knownDecorator.getQualifiedName())) { - result.add(knownDecorator); - } - } - } - else { - result.add(knownDecorator); + if (resolved != null && resolved.getQualifiedName() != null) { + final QualifiedName resolvedName = QualifiedName.fromDottedString(resolved.getQualifiedName()); + final KnownDecorator knownDecorator = ourByShortName.get(resolvedName.getLastComponent()); + + if (knownDecorator != null && resolvedName.equals(knownDecorator.getQualifiedName())) { + return knownDecorator; } } } - return result; + else { + return ourByShortName.get(qualifiedName.getLastComponent()); + } + + return null; } @Nullable @@ -212,6 +230,10 @@ public class PyKnownDecoratorUtil { return !knownDecorators.isEmpty(); } + public static boolean isPropertyDecorator(@NotNull PyDecorator decorator, @NotNull TypeEvalContext context) { + return PROPERTY_DECORATORS.contains(asKnownDecorator(decorator, context)); + } + private static boolean allDecoratorsAreKnown(@NotNull PyDecoratable element, @NotNull List decorators) { final PyDecoratorList decoratorList = element.getDecoratorList(); return decoratorList == null ? decorators.isEmpty() : decoratorList.getDecorators().length == decorators.size(); diff --git a/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java b/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java index 92b824775901..1a93811238bd 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java @@ -764,7 +764,8 @@ public class PyClassImpl extends PyBaseElementImpl implements PyCla decoName = knownName; } } - if (PyNames.PROPERTY.equals(decoName)) { + if (PyNames.PROPERTY.equals(decoName) || + PyKnownDecoratorUtil.isPropertyDecorator(deco, TypeEvalContext.codeInsightFallback(getProject()))) { getter = new Maybe<>(method); } else if (useAdvancedSyntax && qname.matches(decoratorName, PyNames.GETTER)) { diff --git a/python/src/com/jetbrains/python/psi/resolve/PyResolveImportUtil.kt b/python/src/com/jetbrains/python/psi/resolve/PyResolveImportUtil.kt index f09c182811a2..302b8d3a121a 100644 --- a/python/src/com/jetbrains/python/psi/resolve/PyResolveImportUtil.kt +++ b/python/src/com/jetbrains/python/psi/resolve/PyResolveImportUtil.kt @@ -166,7 +166,7 @@ private fun relativeResultsFromSkeletons(name: QualifiedName, context: PyQualifi val containingName = QualifiedNameFinder.findCanonicalImportPath(containingDirectory, null) if (containingName != null && containingName.componentCount > 0) { val absoluteName = containingName.append(name) - val sdk = PythonSdkType.getSdk(footholdFile) ?: return emptyList() + val sdk = PythonSdkType.findPythonSdk(footholdFile) ?: return emptyList() val skeletonsVirtualFile = PySdkUtil.findSkeletonsDir(sdk) ?: return emptyList() val skeletonsDir = context.psiManager.findDirectory(skeletonsVirtualFile) return resolveModuleAt(absoluteName, skeletonsDir, context) diff --git a/python/src/com/jetbrains/python/refactoring/PyRefactoringUtil.java b/python/src/com/jetbrains/python/refactoring/PyRefactoringUtil.java index 1ecacabd1842..433305bfcde8 100644 --- a/python/src/com/jetbrains/python/refactoring/PyRefactoringUtil.java +++ b/python/src/com/jetbrains/python/refactoring/PyRefactoringUtil.java @@ -25,7 +25,6 @@ import com.intellij.psi.*; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtilCore; import com.intellij.usageView.UsageInfo; -import com.intellij.util.Processor; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.HashSet; import com.jetbrains.python.PyNames; @@ -204,16 +203,35 @@ public class PyRefactoringUtil { @NotNull public static PsiElement[] findStatementsInRange(@NotNull final PsiFile file, int startOffset, int endOffset) { + ArrayList array = new ArrayList<>(); + PsiElement element1 = file.findElementAt(startOffset); PsiElement element2 = file.findElementAt(endOffset - 1); + PsiElement endComment = null; + + boolean startsWithWhitespace = false; + boolean endsWithWhitespace = false; if (element1 instanceof PsiWhiteSpace) { startOffset = element1.getTextRange().getEndOffset(); element1 = file.findElementAt(startOffset); + startsWithWhitespace = true; } if (element2 instanceof PsiWhiteSpace) { - endOffset = element2.getTextRange().getStartOffset(); - element2 = file.findElementAt(endOffset - 1); + element2 = PsiTreeUtil.skipSiblingsBackward(element2, PsiWhiteSpace.class); + endsWithWhitespace = true; } + while (element2 instanceof PsiComment) { + endComment = element2; + element2 = PsiTreeUtil.skipSiblingsBackward(element2, PsiWhiteSpace.class, PsiComment.class); + endsWithWhitespace = true; + } + + while (element1 instanceof PsiComment) { + array.add(element1); + element1 = PsiTreeUtil.skipSiblingsForward(element1, PsiWhiteSpace.class); + startsWithWhitespace = true; + } + if (element1 == null || element2 == null) { return PsiElement.EMPTY_ARRAY; } @@ -242,7 +260,7 @@ public class PyRefactoringUtil { element1 = element1.getParent(); } } - if (startOffset != element1.getTextRange().getStartOffset()) { + if (startOffset != element1.getTextRange().getStartOffset() && !startsWithWhitespace) { return PsiElement.EMPTY_ARRAY; } @@ -251,7 +269,7 @@ public class PyRefactoringUtil { element2 = element2.getParent(); } } - if (endOffset != element2.getTextRange().getEndOffset()) { + if (endOffset != element2.getTextRange().getEndOffset() && !endsWithWhitespace) { return PsiElement.EMPTY_ARRAY; } @@ -263,7 +281,7 @@ public class PyRefactoringUtil { } PsiElement[] children = parent.getChildren(); - ArrayList array = new ArrayList<>(); + boolean flag = false; for (PsiElement child : children) { if (child.equals(element1)) { @@ -277,6 +295,11 @@ public class PyRefactoringUtil { } } + while (endComment instanceof PsiComment) { + array.add(endComment); + endComment = PsiTreeUtil.skipSiblingsForward(endComment, PsiWhiteSpace.class); + } + for (PsiElement element : array) { if (!(element instanceof PyStatement || element instanceof PsiWhiteSpace || element instanceof PsiComment)) { return PsiElement.EMPTY_ARRAY; diff --git a/python/src/com/jetbrains/python/sdk/PySdkUtil.java b/python/src/com/jetbrains/python/sdk/PySdkUtil.java index 0c362badc0c8..48210bbd82e7 100644 --- a/python/src/com/jetbrains/python/sdk/PySdkUtil.java +++ b/python/src/com/jetbrains/python/sdk/PySdkUtil.java @@ -199,7 +199,7 @@ public class PySdkUtil { if (file != null) { final VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile != null) { - final Sdk sdk = PythonSdkType.getSdk(element); + final Sdk sdk = PythonSdkType.findPythonSdk(element); if (sdk != null) { final VirtualFile skeletonsDir = findSkeletonsDir(sdk); if (skeletonsDir != null && VfsUtilCore.isAncestor(skeletonsDir, virtualFile, false)) { diff --git a/python/src/com/jetbrains/python/sdk/PythonSdkType.java b/python/src/com/jetbrains/python/sdk/PythonSdkType.java index ad437e20a644..173e4c8861d8 100644 --- a/python/src/com/jetbrains/python/sdk/PythonSdkType.java +++ b/python/src/com/jetbrains/python/sdk/PythonSdkType.java @@ -692,6 +692,11 @@ public final class PythonSdkType extends SdkType { return null; } + @Nullable + public static Sdk findPythonSdk(@NotNull final PsiElement element) { + return findPythonSdk(ModuleUtilCore.findModuleForPsiElement(element)); + } + @Nullable public static Sdk findSdkByPath(@Nullable String path) { if (path != null) { @@ -901,13 +906,10 @@ public final class PythonSdkType extends SdkType { return false; } + @Deprecated @Nullable public static Sdk getSdk(@NotNull final PsiElement element) { - Module module = ModuleUtilCore.findModuleForPsiElement(element); - if (module == null) { - return null; - } - return ModuleRootManager.getInstance(module).getSdk(); + return findPythonSdk(element); } @NotNull diff --git a/python/testData/MockSdk2.7/Lib/abc.py b/python/testData/MockSdk2.7/Lib/abc.py index ef4f2f69e838..ec9311814a02 100644 --- a/python/testData/MockSdk2.7/Lib/abc.py +++ b/python/testData/MockSdk2.7/Lib/abc.py @@ -5,4 +5,8 @@ class ABCMeta: def abstractmethod(foo): + pass + + +def abstractproperty(foo): pass \ No newline at end of file diff --git a/python/testData/debug/test_two_threads.py b/python/testData/debug/test_two_threads.py index 49d229678ec3..9d18dfb8fd4e 100644 --- a/python/testData/debug/test_two_threads.py +++ b/python/testData/debug/test_two_threads.py @@ -2,17 +2,20 @@ from threading import Thread from time import sleep +def print_with_pause(text, pause): + sleep(pause) + print(text) + + def fun1(n): while True: - sleep(0.01) - print("finished fun1()", n) + print_with_pause("Thread1", 0.1) def fun2(m): sleep(2) while True: - sleep(0.01) #breakpoint - print("finished fun2()", m) + print_with_pause("Thread2", 0.1) # breakpoint threads = [Thread(target=fun1, args=(24,), name="Thread1"), diff --git a/python/testData/deprecation/abcAbstractProperty.py b/python/testData/deprecation/abcAbstractProperty.py new file mode 100644 index 000000000000..f6511c793149 --- /dev/null +++ b/python/testData/deprecation/abcAbstractProperty.py @@ -0,0 +1,34 @@ +import abc + + +class A(metaclass=abc.ABCMeta): + @abc.abstractproperty + def prop(self): + pass + + +from abc import abstractproperty + + +class B(metaclass=abc.ABCMeta): + @abstractproperty + def prop(self): + pass + + +from abc import abstractproperty as ap + + +class C(metaclass=abc.ABCMeta): + @ap + def prop(self): + pass + + +import abc as foo + + +class D(metaclass=abc.ABCMeta): + @foo.abstractproperty + def prop(self): + pass \ No newline at end of file diff --git a/python/testData/inspections/PyPropertyAccessInspection/abcAbstractProperty.py b/python/testData/inspections/PyPropertyAccessInspection/abcAbstractProperty.py new file mode 100644 index 000000000000..a22163306c00 --- /dev/null +++ b/python/testData/inspections/PyPropertyAccessInspection/abcAbstractProperty.py @@ -0,0 +1,15 @@ +from abc import ABCMeta, abstractproperty + +class Upper(object): + __metaclass__ = ABCMeta + + @abstractproperty + def prop(self): + pass + + @prop.setter + def prop(self, prop): + pass + + def foo(self): + print self.prop \ No newline at end of file diff --git a/python/testData/inspections/PyPropertyDefinitionInspection26/test.py b/python/testData/inspections/PyPropertyDefinitionInspection26/test.py index 6dd8927c9788..0d7736ab126d 100644 --- a/python/testData/inspections/PyPropertyDefinitionInspection26/test.py +++ b/python/testData/inspections/PyPropertyDefinitionInspection26/test.py @@ -1,3 +1,6 @@ +import abc + + class A(object): def __init__(self): self._x = 1 @@ -65,7 +68,7 @@ class A(object): foo2 = property(get_foo2) @property - @abstractproperty + @abc.abstractproperty def abstract_property(self): pass diff --git a/python/testData/inspections/PyPropertyDefinitionInspection33/test.py b/python/testData/inspections/PyPropertyDefinitionInspection33/test.py index c34fd36671f4..aaf904a94de4 100644 --- a/python/testData/inspections/PyPropertyDefinitionInspection33/test.py +++ b/python/testData/inspections/PyPropertyDefinitionInspection33/test.py @@ -1,14 +1,17 @@ +import abc + + class A: @property def normal_property(self): pass @property - @abstractproperty + @abc.abstractproperty def abstract_property1(self): pass @property - @abstractmethod + @abc.abstractmethod def abstract_property2(self): pass diff --git a/python/testData/postfix/main/comment.py b/python/testData/postfix/main/comment.py new file mode 100644 index 000000000000..3de20ddc5eee --- /dev/null +++ b/python/testData/postfix/main/comment.py @@ -0,0 +1 @@ +print("I want to be inside main") #hello.main \ No newline at end of file diff --git a/python/testData/postfix/main/comment_after.py b/python/testData/postfix/main/comment_after.py new file mode 100644 index 000000000000..c74b41c9dab5 --- /dev/null +++ b/python/testData/postfix/main/comment_after.py @@ -0,0 +1 @@ +print("I want to be inside main") #hello.main \ No newline at end of file diff --git a/python/testData/surround/SurroundCommentAtEnd.py b/python/testData/surround/SurroundCommentAtEnd.py new file mode 100644 index 000000000000..ba1cd374efce --- /dev/null +++ b/python/testData/surround/SurroundCommentAtEnd.py @@ -0,0 +1,2 @@ +a = 1 +#comment line \ No newline at end of file diff --git a/python/testData/surround/SurroundCommentAtEnd_after.py b/python/testData/surround/SurroundCommentAtEnd_after.py new file mode 100644 index 000000000000..964b333ac905 --- /dev/null +++ b/python/testData/surround/SurroundCommentAtEnd_after.py @@ -0,0 +1,3 @@ +if True: + a = 1 + #comment line \ No newline at end of file diff --git a/python/testData/surround/SurroundCommentAtStart.py b/python/testData/surround/SurroundCommentAtStart.py new file mode 100644 index 000000000000..70f9ee427707 --- /dev/null +++ b/python/testData/surround/SurroundCommentAtStart.py @@ -0,0 +1,2 @@ +#comment line +a = 1 \ No newline at end of file diff --git a/python/testData/surround/SurroundCommentAtStart_after.py b/python/testData/surround/SurroundCommentAtStart_after.py new file mode 100644 index 000000000000..58b0d07e818e --- /dev/null +++ b/python/testData/surround/SurroundCommentAtStart_after.py @@ -0,0 +1,3 @@ +if True: + #comment line + a = 1 \ No newline at end of file diff --git a/python/testData/surround/SurroundNewline.py b/python/testData/surround/SurroundNewline.py new file mode 100644 index 000000000000..30f9fa7a6050 --- /dev/null +++ b/python/testData/surround/SurroundNewline.py @@ -0,0 +1,3 @@ +a = 1 + +a = 2 \ No newline at end of file diff --git a/python/testData/surround/SurroundNewline_after.py b/python/testData/surround/SurroundNewline_after.py new file mode 100644 index 000000000000..c07bad2792c8 --- /dev/null +++ b/python/testData/surround/SurroundNewline_after.py @@ -0,0 +1,4 @@ +if True: + a = 1 + +a = 2 \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java b/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java index 3f7a004aedb2..68a674c00ac6 100644 --- a/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java +++ b/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java @@ -1002,8 +1002,8 @@ public class PythonDebuggerTest extends PyEnvTestCase { @Override public void before() throws Exception { - toggleBreakpoint(getFilePath(getScriptName()), 12); - setBreakpointSuspendPolicy(getProject(), 12, SuspendPolicy.ALL); + toggleBreakpoint(getFilePath(getScriptName()), 17); + setBreakpointSuspendPolicy(getProject(), 17, SuspendPolicy.ALL); } @Override @@ -1056,8 +1056,8 @@ public class PythonDebuggerTest extends PyEnvTestCase { runPythonTest(new PyDebuggerTask("/debug", "test_two_threads.py") { @Override public void before() throws Exception { - toggleBreakpoint(getFilePath(getScriptName()), 12); - setBreakpointSuspendPolicy(getProject(), 12, SuspendPolicy.THREAD); + toggleBreakpoint(getFilePath(getScriptName()), 17); + setBreakpointSuspendPolicy(getProject(), 17, SuspendPolicy.THREAD); } @Override diff --git a/python/testSrc/com/jetbrains/python/PyDeprecationTest.java b/python/testSrc/com/jetbrains/python/PyDeprecationTest.java index 595a8bd9f462..7f88073d0cc0 100644 --- a/python/testSrc/com/jetbrains/python/PyDeprecationTest.java +++ b/python/testSrc/com/jetbrains/python/PyDeprecationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2016 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,6 +18,7 @@ package com.jetbrains.python; import com.intellij.testFramework.PlatformTestUtil; import com.jetbrains.python.fixtures.PyTestCase; import com.jetbrains.python.inspections.PyDeprecationInspection; +import com.jetbrains.python.psi.LanguageLevel; import com.jetbrains.python.psi.PyFile; import com.jetbrains.python.psi.PyFunction; @@ -77,6 +78,17 @@ public class PyDeprecationTest extends PyTestCase { myFixture.checkHighlighting(true, false, false); } + public void testAbsAbstractProperty() { + runWithLanguageLevel( + LanguageLevel.PYTHON33, + () -> { + myFixture.enableInspections(PyDeprecationInspection.class); + myFixture.configureByFile("deprecation/abcAbstractProperty.py"); + myFixture.checkHighlighting(true, false, false); + } + ); + } + public void testFileStub() { myFixture.configureByFile("deprecation/deprecatedModule.py"); PyFile file = (PyFile)myFixture.getFile(); diff --git a/python/testSrc/com/jetbrains/python/PySurroundWithTest.java b/python/testSrc/com/jetbrains/python/PySurroundWithTest.java index af9e2e6ee2d3..8c1d7fb68540 100644 --- a/python/testSrc/com/jetbrains/python/PySurroundWithTest.java +++ b/python/testSrc/com/jetbrains/python/PySurroundWithTest.java @@ -83,6 +83,18 @@ public class PySurroundWithTest extends PyTestCase { doTest(surrounder); } + public void testSurroundCommentAtStart() throws Exception { + doTest(new PyWithIfSurrounder()); + } + + public void testSurroundCommentAtEnd() throws Exception { + doTest(new PyWithIfSurrounder()); + } + + public void testSurroundNewline() throws Exception { + doTest(new PyWithIfSurrounder()); + } + private void doTest(final Surrounder surrounder) throws Exception { String baseName = "/surround/" + getTestName(false); myFixture.configureByFile(baseName + ".py"); diff --git a/python/testSrc/com/jetbrains/python/PyTypeTest.java b/python/testSrc/com/jetbrains/python/PyTypeTest.java index 7574e831071f..2f51068c9194 100644 --- a/python/testSrc/com/jetbrains/python/PyTypeTest.java +++ b/python/testSrc/com/jetbrains/python/PyTypeTest.java @@ -1461,6 +1461,38 @@ public class PyTypeTest extends PyTestCase { "expr = float.fromhex(\"0.5\")"); } + // PY-13159 + public void testAbsAbstractProperty() { + doTest("str", + "import abc\n" + + "class D:\n" + + " @abc.abstractproperty\n" + + " def foo(self):\n" + + " return 'foo'\n" + + "expr = D().foo"); + } + + public void testAbsAbstractPropertyWithFrom() { + doTest("str", + "from abc import abstractproperty\n" + + "class D:\n" + + " @abstractproperty\n" + + " def foo(self):\n" + + " return 'foo'\n" + + "expr = D().foo"); + } + + // TODO: enable this test when properties will be calculated with TypeEvalContext + public void ignoredTestAbsAbstractPropertyWithAs() { + doTest("str", + "from abc import abstractproperty as ap\n" + + "class D:\n" + + " @ap\n" + + " def foo(self):\n" + + " return 'foo'\n" + + "expr = D().foo"); + } + // PY-20409 public void testGetFromDictWithDefaultNoneValue() { doTest("Any", diff --git a/python/testSrc/com/jetbrains/python/inspections/PyPropertyAccessInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyPropertyAccessInspectionTest.java index 67848c045703..ac0a77e5aeb7 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyPropertyAccessInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyPropertyAccessInspectionTest.java @@ -31,6 +31,11 @@ public class PyPropertyAccessInspectionTest extends PyTestCase { doTest(); } + // PY-20322 + public void testAbcAbstractProperty() { + doTest(); + } + private void doTest() { setLanguageLevel(LanguageLevel.PYTHON26); myFixture.configureByFile("inspections/PyPropertyAccessInspection/" + getTestName(true) + ".py"); diff --git a/python/testSrc/com/jetbrains/python/postfix/PyMainPostfixTemplateTest.java b/python/testSrc/com/jetbrains/python/postfix/PyMainPostfixTemplateTest.java index a7d199e5081c..09eae87d8c01 100644 --- a/python/testSrc/com/jetbrains/python/postfix/PyMainPostfixTemplateTest.java +++ b/python/testSrc/com/jetbrains/python/postfix/PyMainPostfixTemplateTest.java @@ -25,6 +25,10 @@ public class PyMainPostfixTemplateTest extends PyPostfixTemplateTestCase { doTest(); } + public void testComment() { + doTest(); + } + @Override protected String getTestDataDir() { return "main/"; diff --git a/spellchecker/src/com/intellij/spellchecker/SpellCheckerSeveritiesProvider.java b/spellchecker/src/com/intellij/spellchecker/SpellCheckerSeveritiesProvider.java index d349a8344a97..dc54574907b6 100644 --- a/spellchecker/src/com/intellij/spellchecker/SpellCheckerSeveritiesProvider.java +++ b/spellchecker/src/com/intellij/spellchecker/SpellCheckerSeveritiesProvider.java @@ -50,7 +50,7 @@ public class SpellCheckerSeveritiesProvider extends SeveritiesProvider { return AllIcons.General.InspectionsTypos; } } - return Collections.singletonList(new T(TYPO, TYPO_KEY)); + return Collections.singletonList(new T(TYPO, TYPO_KEY)); } @Override diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomSaxParserTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomSaxParserTest.java index e9ab73077873..1d54400b1cd4 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomSaxParserTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomSaxParserTest.java @@ -16,15 +16,11 @@ package com.intellij.util.xml; import com.intellij.lang.xml.XMLLanguage; -import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiFileFactory; import com.intellij.psi.xml.XmlFile; import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import org.jetbrains.annotations.Nullable; -import org.xml.sax.SAXException; - -import java.io.IOException; /** * @author peter @@ -79,8 +75,9 @@ public class DomSaxParserTest extends LightPlatformCodeInsightFixtureTestCase { assertData("?xmlmas8v6708986>)elementDescriptor).validate(tag,this); } } - private void checkRequiredAttributes(XmlTag tag, String name, XmlElementDescriptor elementDescriptor) { - XmlAttributeDescriptor[] attributeDescriptors = elementDescriptor.getAttributesDescriptors(tag); - Set requiredAttributes = null; - - for (XmlAttributeDescriptor attribute : attributeDescriptors) { - if (attribute != null && attribute.isRequired()) { - if (requiredAttributes == null) { - requiredAttributes = new HashSet<>(); - } - requiredAttributes.add(attribute.getName(tag)); - } - } - - if (requiredAttributes != null) { - for (final String attrName : requiredAttributes) { - if (!hasAttribute(tag, attrName) && - !XmlExtension.getExtension(tag.getContainingFile()).isRequiredAttributeImplicitlyPresent(tag, attrName)) { - - IntentionAction insertRequiredAttributeIntention = XmlQuickFixFactory.getInstance().insertRequiredAttributeFix(tag, attrName); - final String localizedMessage = XmlErrorMessages.message("element.doesnt.have.required.attribute", name, attrName); - final InspectionProfile profile = InspectionProfileManager.getInstance(tag.getProject()).getCurrentProfile(); - RequiredAttributesInspectionBase inspection = - (RequiredAttributesInspectionBase)profile.getUnwrappedTool(XmlEntitiesInspection.REQUIRED_ATTRIBUTES_SHORT_NAME, tag); - if (inspection != null) { - reportOneTagProblem( - tag, - attrName, - localizedMessage, - insertRequiredAttributeIntention, - HighlightDisplayKey.find(XmlEntitiesInspection.REQUIRED_ATTRIBUTES_SHORT_NAME), - inspection, - RequiredAttributesInspectionBase.getIntentionAction(attrName) - ); - } - } - } - } - } - - private static boolean hasAttribute(XmlTag tag, String attrName) { - final XmlAttribute attribute = tag.getAttribute(attrName); - if (attribute == null) return false; - if (attribute.getValueElement() != null) return true; - if (!(tag instanceof HtmlTag)) return false; - final XmlAttributeDescriptor descriptor = attribute.getDescriptor(); - return descriptor != null && HtmlUtil.isBooleanAttribute(descriptor, tag); - } - - private void reportOneTagProblem(final XmlTag tag, - final String name, - @NotNull String localizedMessage, - final IntentionAction basicIntention, - final HighlightDisplayKey key, - final XmlEntitiesInspection inspection, - final IntentionAction addAttributeFix) { - boolean htmlTag = false; - - if (tag instanceof HtmlTag) { - htmlTag = true; - if(isAdditionallyDeclared(inspection.getAdditionalEntries(), name)) return; - } - - final InspectionProfile profile = InspectionProjectProfileManager.getInstance(tag.getProject()).getCurrentProfile(); - if (htmlTag && profile.isToolEnabled(key, tag)) { - addElementsForTagWithManyQuickFixes( - tag, - localizedMessage, - isInjectedWithoutValidation(tag) ? - HighlightInfoType.INFORMATION : - SeverityRegistrar.getSeverityRegistrar(tag.getProject()).getHighlightInfoTypeBySeverity(profile.getErrorLevel(key, tag).getSeverity()), - addAttributeFix, - basicIntention); - } else if (!htmlTag) { - addElementsForTag( - tag, - localizedMessage, - HighlightInfoType.ERROR, - basicIntention - ); - } - } - - private static boolean isAdditionallyDeclared(final String additional, String name) { - name = name.toLowerCase(); - if (!additional.contains(name)) return false; - - StringTokenizer tokenizer = new StringTokenizer(additional, ", "); - while (tokenizer.hasMoreTokens()) { - if (name.equals(tokenizer.nextToken())) { - return true; - } - } - - return false; - } - private static HighlightInfoType getTagProblemInfoType(XmlTag tag) { if (tag instanceof HtmlTag && XmlUtil.HTML_URI.equals(tag.getNamespace())) { if (isInjectedWithoutValidation(tag)) return HighlightInfoType.INFORMATION; diff --git a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/AddHtmlTagOrAttributeToCustomsIntention.java b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/AddHtmlTagOrAttributeToCustomsIntention.java index 2e4190451bce..86df279caac0 100644 --- a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/AddHtmlTagOrAttributeToCustomsIntention.java +++ b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/AddHtmlTagOrAttributeToCustomsIntention.java @@ -16,22 +16,20 @@ package com.intellij.codeInspection.htmlInspections; -import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInspection.InspectionProfile; import com.intellij.codeInspection.InspectionProfileEntry; -import com.intellij.openapi.editor.Editor; +import com.intellij.codeInspection.LocalQuickFix; +import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; import com.intellij.profile.codeInspection.InspectionProjectProfileManager; -import com.intellij.psi.PsiFile; -import com.intellij.util.IncorrectOperationException; import com.intellij.xml.XmlBundle; import org.jetbrains.annotations.NotNull; /** * @author Maxim.Mossienko */ -public class AddHtmlTagOrAttributeToCustomsIntention implements IntentionAction { +public class AddHtmlTagOrAttributeToCustomsIntention implements LocalQuickFix { private final String myName; private final String myText; private final Key myInspectionKey; @@ -42,9 +40,9 @@ public class AddHtmlTagOrAttributeToCustomsIntention implements IntentionAction myText = text; } - @Override @NotNull - public String getText() { + @Override + public String getName() { return myText; } @@ -55,14 +53,9 @@ public class AddHtmlTagOrAttributeToCustomsIntention implements IntentionAction } @Override - public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { - return true; - } - - @Override - public void invoke(@NotNull Project project, Editor editor, final PsiFile file) throws IncorrectOperationException { + public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile(); - profile.modifyToolSettings(myInspectionKey, file, entry -> { + profile.modifyToolSettings(myInspectionKey, descriptor.getPsiElement().getContainingFile(), entry -> { XmlEntitiesInspection xmlEntitiesInspection = (XmlEntitiesInspection) entry; xmlEntitiesInspection.addEntry(myName); }); diff --git a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/HtmlLocalInspectionTool.java b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/HtmlLocalInspectionTool.java index 97d95a41c9ac..d9dbac6c19c2 100644 --- a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/HtmlLocalInspectionTool.java +++ b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/HtmlLocalInspectionTool.java @@ -24,6 +24,7 @@ import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.PsiWhiteSpace; import com.intellij.psi.XmlElementVisitor; import com.intellij.psi.templateLanguages.OuterLanguageElement; +import com.intellij.psi.tree.IElementType; import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlTag; import com.intellij.psi.xml.XmlToken; @@ -61,7 +62,8 @@ public abstract class HtmlLocalInspectionTool extends XmlSuppressableInspectionT public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) { return new XmlElementVisitor() { @Override public void visitXmlToken(final XmlToken token) { - if (token.getTokenType() == XmlTokenType.XML_NAME) { + IElementType tokenType = token.getTokenType(); + if (tokenType == XmlTokenType.XML_NAME || tokenType == XmlTokenType.XML_TAG_NAME) { PsiElement element = token.getPrevSibling(); while(element instanceof PsiWhiteSpace) element = element.getPrevSibling(); diff --git a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/RequiredAttributesInspectionBase.java b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/RequiredAttributesInspectionBase.java index c2db291cfeb1..a9410ed55ec2 100644 --- a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/RequiredAttributesInspectionBase.java +++ b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/RequiredAttributesInspectionBase.java @@ -15,20 +15,33 @@ */ package com.intellij.codeInspection.htmlInspections; -import com.intellij.codeInsight.intention.IntentionAction; -import com.intellij.codeInspection.InspectionProfileEntry; -import com.intellij.codeInspection.InspectionsBundle; -import com.intellij.codeInspection.XmlInspectionGroupNames; -import com.intellij.codeInspection.XmlSuppressableInspectionTool; -import com.intellij.codeInspection.ex.UnfairLocalInspectionTool; +import com.intellij.codeInsight.daemon.XmlErrorMessages; +import com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightingAwareElementDescriptor; +import com.intellij.codeInspection.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Key; +import com.intellij.psi.html.HtmlTag; +import com.intellij.psi.xml.XmlAttribute; +import com.intellij.psi.xml.XmlTag; +import com.intellij.psi.xml.XmlToken; +import com.intellij.xml.XmlAttributeDescriptor; import com.intellij.xml.XmlBundle; +import com.intellij.xml.XmlElementDescriptor; +import com.intellij.xml.XmlExtension; +import com.intellij.xml.impl.schema.AnyXmlElementDescriptor; +import com.intellij.xml.util.HtmlUtil; +import com.intellij.xml.util.XmlTagUtil; +import com.intellij.xml.util.XmlUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; -public class RequiredAttributesInspectionBase extends XmlSuppressableInspectionTool - implements XmlEntitiesInspection, UnfairLocalInspectionTool { +import java.util.HashSet; +import java.util.Set; +import java.util.StringTokenizer; + +import static com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitor.isInjectedWithoutValidation; + +public class RequiredAttributesInspectionBase extends HtmlLocalInspectionTool implements XmlEntitiesInspection { @NonNls public static final Key SHORT_NAME_KEY = Key.create(REQUIRED_ATTRIBUTES_SHORT_NAME); protected static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.htmlInspections.RequiredAttributesInspection"); public String myAdditionalRequiredHtmlAttributes = ""; @@ -77,7 +90,129 @@ public class RequiredAttributesInspectionBase extends XmlSuppressableInspectionT return true; } - public static IntentionAction getIntentionAction(String name) { + public static LocalQuickFix getIntentionAction(String name) { return new AddHtmlTagOrAttributeToCustomsIntention(SHORT_NAME_KEY, name, XmlBundle.message("add.optional.html.attribute", name)); } + + @Override + protected void checkTag(@NotNull XmlTag tag, @NotNull ProblemsHolder holder, boolean isOnTheFly) { + + String name = tag.getName(); + XmlElementDescriptor elementDescriptor = XmlUtil.getDescriptorFromContext(tag); + if (elementDescriptor instanceof AnyXmlElementDescriptor || elementDescriptor == null) { + elementDescriptor = tag.getDescriptor(); + } + + if (elementDescriptor == null) return; + if ((elementDescriptor instanceof XmlHighlightingAwareElementDescriptor) && + !((XmlHighlightingAwareElementDescriptor)elementDescriptor).shouldCheckRequiredAttributes()) { + return; + } + + XmlAttributeDescriptor[] attributeDescriptors = elementDescriptor.getAttributesDescriptors(tag); + Set requiredAttributes = null; + + for (XmlAttributeDescriptor attribute : attributeDescriptors) { + if (attribute != null && attribute.isRequired()) { + if (requiredAttributes == null) { + requiredAttributes = new HashSet<>(); + } + requiredAttributes.add(attribute.getName(tag)); + } + } + + if (requiredAttributes != null) { + for (final String attrName : requiredAttributes) { + if (!hasAttribute(tag, attrName) && + !XmlExtension.getExtension(tag.getContainingFile()).isRequiredAttributeImplicitlyPresent(tag, attrName)) { + + LocalQuickFix insertRequiredAttributeIntention = XmlQuickFixFactory.getInstance().insertRequiredAttributeFix(tag, attrName); + final String localizedMessage = XmlErrorMessages.message("element.doesnt.have.required.attribute", name, attrName); + reportOneTagProblem( + tag, + attrName, + localizedMessage, + insertRequiredAttributeIntention, + holder, + getIntentionAction(attrName) + ); + } + } + } + } + + private static boolean hasAttribute(XmlTag tag, String attrName) { + final XmlAttribute attribute = tag.getAttribute(attrName); + if (attribute == null) return false; + if (attribute.getValueElement() != null) return true; + if (!(tag instanceof HtmlTag)) return false; + final XmlAttributeDescriptor descriptor = attribute.getDescriptor(); + return descriptor != null && HtmlUtil.isBooleanAttribute(descriptor, tag); + } + + private void reportOneTagProblem(final XmlTag tag, + final String name, + @NotNull String localizedMessage, + final LocalQuickFix basicIntention, + ProblemsHolder holder, + final LocalQuickFix addAttributeFix) { + boolean htmlTag = false; + + if (tag instanceof HtmlTag) { + htmlTag = true; + if(isAdditionallyDeclared(getAdditionalEntries(), name)) return; + } + + if (htmlTag) { + addElementsForTag( + tag, + localizedMessage, + isInjectedWithoutValidation(tag) ? ProblemHighlightType.INFORMATION : ProblemHighlightType.GENERIC_ERROR_OR_WARNING, + holder, + addAttributeFix, + basicIntention); + } + else { + addElementsForTag( + tag, + localizedMessage, + ProblemHighlightType.ERROR, + holder, + basicIntention + ); + } + } + + private static void addElementsForTag(XmlTag tag, + String message, + ProblemHighlightType error, + ProblemsHolder holder, + LocalQuickFix... fixes) { + registerProblem(message, error, holder, XmlTagUtil.getStartTagNameElement(tag), fixes); + registerProblem(message, error, holder, XmlTagUtil.getEndTagNameElement(tag), fixes); + } + + private static void registerProblem(String message, + ProblemHighlightType error, + ProblemsHolder holder, + XmlToken start, + LocalQuickFix[] fixes) { + if (start != null) { + holder.registerProblem(start, message, error, fixes); + } + } + + private static boolean isAdditionallyDeclared(final String additional, String name) { + name = name.toLowerCase(); + if (!additional.contains(name)) return false; + + StringTokenizer tokenizer = new StringTokenizer(additional, ", "); + while (tokenizer.hasMoreTokens()) { + if (name.equals(tokenizer.nextToken())) { + return true; + } + } + + return false; + } }