diff --git a/.idea/libraries/http_client.xml b/.idea/libraries/http_client.xml index 4a83f9ad3f68..f94d8f0845dc 100644 --- a/.idea/libraries/http_client.xml +++ b/.idea/libraries/http_client.xml @@ -13,8 +13,9 @@ - - + + \ No newline at end of file diff --git a/java/execution/impl/src/com/intellij/execution/util/JavaParametersUtil.java b/java/execution/impl/src/com/intellij/execution/util/JavaParametersUtil.java index eede2edda506..0fe20076493b 100644 --- a/java/execution/impl/src/com/intellij/execution/util/JavaParametersUtil.java +++ b/java/execution/impl/src/com/intellij/execution/util/JavaParametersUtil.java @@ -68,6 +68,7 @@ public class JavaParametersUtil { parameters.getVMParametersList().addParametersString(vmParameters); } + @MagicConstant(valuesFromClass = JavaParameters.class) public static int getClasspathType(final RunConfigurationModule configurationModule, final String mainClassName, final boolean classMustHaveSource) throws CantRunException { final Module module = configurationModule.getModule(); diff --git a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/FileHeaderChecker.java b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/FileHeaderChecker.java index d3a707544a49..4b3da3805ee5 100644 --- a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/FileHeaderChecker.java +++ b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/FileHeaderChecker.java @@ -26,7 +26,6 @@ import com.intellij.psi.JavaPsiFacade; import com.intellij.psi.PsiComment; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; -import com.intellij.psi.javadoc.PsiDocComment; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.containers.ContainerUtil; import gnu.trove.TIntObjectHashMap; @@ -110,7 +109,7 @@ public class FileHeaderChecker { } if (!newText.isEmpty()) { - PsiDocComment newComment = JavaPsiFacade.getElementFactory(project).createDocCommentFromText(newText); + PsiComment newComment = JavaPsiFacade.getElementFactory(project).createCommentFromText(newText, null); element.replace(newComment); } else { diff --git a/java/java-impl/src/com/intellij/codeInspection/java18StreamApi/StaticPseudoFunctionalStyleMethodInspection.java b/java/java-impl/src/com/intellij/codeInspection/java18StreamApi/StaticPseudoFunctionalStyleMethodInspection.java index 650603cb4814..47ff9eb5e6fa 100644 --- a/java/java-impl/src/com/intellij/codeInspection/java18StreamApi/StaticPseudoFunctionalStyleMethodInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/java18StreamApi/StaticPseudoFunctionalStyleMethodInspection.java @@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.codeStyle.JavaCodeStyleManager; import com.intellij.psi.search.GlobalSearchScope; @@ -74,10 +75,7 @@ public class StaticPseudoFunctionalStyleMethodInspection extends BaseJavaBatchLo if (qName == null) { return; } - final int dotIndex = qName.lastIndexOf('.'); - if (dotIndex >= 0) { - qName = qName.substring(dotIndex + 1); - } + qName = StringUtil.getShortName(qName); final Collection handlerInfos = myOptions.findElementsByMethodName(qName); if (handlerInfos.isEmpty()) { return; diff --git a/java/java-impl/src/com/intellij/lang/java/JavaFormattingModelBuilder.java b/java/java-impl/src/com/intellij/lang/java/JavaFormattingModelBuilder.java index 2f53bdec3282..91b6a723b6c0 100644 --- a/java/java-impl/src/com/intellij/lang/java/JavaFormattingModelBuilder.java +++ b/java/java-impl/src/com/intellij/lang/java/JavaFormattingModelBuilder.java @@ -54,7 +54,7 @@ public class JavaFormattingModelBuilder implements FormattingModelBuilder { LOG.assertTrue(fileElement != null, "File element should not be null for " + element); CommonCodeStyleSettings commonSettings = settings.getCommonSettings(JavaLanguage.INSTANCE); JavaCodeStyleSettings customJavaSettings = settings.getCustomSettings(JavaCodeStyleSettings.class); - Block block = AbstractJavaBlock.createJavaBlock(fileElement, commonSettings, customJavaSettings); + Block block = AbstractJavaBlock.newJavaBlock(fileElement, commonSettings, customJavaSettings); FormattingDocumentModelImpl model = FormattingDocumentModelImpl.createOn(element.getContainingFile()); return new PsiBasedFormatterModelWithShiftIndentInside (element.getContainingFile(), block, model); } diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/AbstractJavaBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/AbstractJavaBlock.java index d4d008dd1476..fff50d1c41ab 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/AbstractJavaBlock.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/AbstractJavaBlock.java @@ -89,6 +89,18 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo this(node, wrap, indent, settings, javaSettings, JavaWrapManager.INSTANCE, alignmentStrategy); } + private AbstractJavaBlock(@NotNull ASTNode ignored, + @NotNull CommonCodeStyleSettings commonSettings, + @NotNull JavaCodeStyleSettings javaSettings) { + super(ignored, null, null); + mySettings = commonSettings; + myJavaSettings = javaSettings; + myIndentSettings = commonSettings.getIndentOptions(); + myIndent = null; + myWrapManager = JavaWrapManager.INSTANCE; + myAlignmentStrategy = AlignmentStrategy.getNullStrategy(); + } + protected AbstractJavaBlock(@NotNull final ASTNode node, final Wrap wrap, final Indent indent, @@ -116,33 +128,33 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo } @NotNull - public static Block createJavaBlock(@NotNull ASTNode child, - @NotNull CommonCodeStyleSettings settings, - @NotNull JavaCodeStyleSettings javaSettings, - @Nullable Indent indent, - @Nullable Wrap wrap, - Alignment alignment) { + public Block createJavaBlock(@NotNull ASTNode child, + @NotNull CommonCodeStyleSettings settings, + @NotNull JavaCodeStyleSettings javaSettings, + @Nullable Indent indent, + @Nullable Wrap wrap, + Alignment alignment) { return createJavaBlock(child, settings, javaSettings,indent, wrap, AlignmentStrategy.wrap(alignment)); } @NotNull - public static Block createJavaBlock(@NotNull ASTNode child, - @NotNull CommonCodeStyleSettings settings, - @NotNull JavaCodeStyleSettings javaSettings, - final Indent indent, - @Nullable Wrap wrap, - @NotNull AlignmentStrategy alignmentStrategy) { + public Block createJavaBlock(@NotNull ASTNode child, + @NotNull CommonCodeStyleSettings settings, + @NotNull JavaCodeStyleSettings javaSettings, + final Indent indent, + @Nullable Wrap wrap, + @NotNull AlignmentStrategy alignmentStrategy) { return createJavaBlock(child, settings, javaSettings, indent, wrap, alignmentStrategy, -1); } @NotNull - private static Block createJavaBlock(@NotNull ASTNode child, - @NotNull CommonCodeStyleSettings settings, - @NotNull JavaCodeStyleSettings javaSettings, - @Nullable Indent indent, - Wrap wrap, - @NotNull AlignmentStrategy alignmentStrategy, - int startOffset) { + private Block createJavaBlock(@NotNull ASTNode child, + @NotNull CommonCodeStyleSettings settings, + @NotNull JavaCodeStyleSettings javaSettings, + @Nullable Indent indent, + Wrap wrap, + @NotNull AlignmentStrategy alignmentStrategy, + int startOffset) { Indent actualIndent = indent == null ? getDefaultSubtreeIndent(child, getJavaIndentOptions(settings)) : indent; final IElementType elementType = child.getElementType(); Alignment alignment = alignmentStrategy.getAlignment(elementType); @@ -164,7 +176,8 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo if (isStatement(child, child.getTreeParent())) { return new CodeBlockBlock(child, wrap, alignment, actualIndent, settings, javaSettings); } - if (child instanceof PsiComment && + if (isBuildInjectedBlocks() && + child instanceof PsiComment && child instanceof PsiLanguageInjectionHost && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)child)) { return new CommentWithInjectionBlock(child, wrap, alignment, indent, settings, javaSettings); @@ -194,12 +207,26 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo } @NotNull - public static Block createJavaBlock(@NotNull ASTNode child, + public static Block newJavaBlock(@NotNull ASTNode child, @NotNull CommonCodeStyleSettings settings, @NotNull JavaCodeStyleSettings javaSettings) { - return createJavaBlock( - child, settings, javaSettings, getDefaultSubtreeIndent(child, getJavaIndentOptions(settings)), null, AlignmentStrategy.getNullStrategy() - ); + final Indent indent = getDefaultSubtreeIndent(child, getJavaIndentOptions(settings)); + return newJavaBlock(child, settings, javaSettings, indent, null, AlignmentStrategy.getNullStrategy()); + } + + @NotNull + public static Block newJavaBlock(@NotNull ASTNode child, + @NotNull CommonCodeStyleSettings settings, + @NotNull JavaCodeStyleSettings javaSettings, + @Nullable Indent indent, + @Nullable Wrap wrap, + @NotNull AlignmentStrategy strategy) { + return new AbstractJavaBlock(child, settings, javaSettings) { + @Override + protected List buildChildren() { + return null; + } + }.createJavaBlock(child, settings, javaSettings, indent, wrap, strategy); } @NotNull diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/SyntheticBlockBuilder.java b/java/java-impl/src/com/intellij/psi/formatter/java/SyntheticBlockBuilder.java index bd5a262ecb01..797c04e2846b 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/SyntheticBlockBuilder.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/SyntheticBlockBuilder.java @@ -51,7 +51,7 @@ public class SyntheticBlockBuilder { final ASTNode firstNode = subNodes.get(0); if (firstNode.getElementType() == JavaTokenType.DOT) { AlignmentStrategy strategy = AlignmentStrategy.getNullStrategy(); - Block block = createJavaBlock(firstNode, mySettings, myJavaSettings, Indent.getNoneIndent(), null, strategy); + Block block = newJavaBlock(firstNode, mySettings, myJavaSettings, Indent.getNoneIndent(), null, strategy); subBlocks.add(block); subNodes.remove(0); if (!subNodes.isEmpty()) { @@ -67,7 +67,7 @@ public class SyntheticBlockBuilder { final ArrayList result = new ArrayList(); for (ASTNode node : subNodes) { Indent indent = Indent.getContinuationWithoutFirstIndent(myIndentSettings.USE_RELATIVE_INDENTS); - result.add(createJavaBlock(node, mySettings, myJavaSettings, indent, null, AlignmentStrategy.getNullStrategy())); + result.add(newJavaBlock(node, mySettings, myJavaSettings, indent, null, AlignmentStrategy.getNullStrategy())); } return result; } diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/wrap/impl/JavaChildWrapArranger.java b/java/java-impl/src/com/intellij/psi/formatter/java/wrap/impl/JavaChildWrapArranger.java index 0d05bd6aa79e..23914cb5fce8 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/wrap/impl/JavaChildWrapArranger.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/wrap/impl/JavaChildWrapArranger.java @@ -31,6 +31,7 @@ import com.intellij.psi.impl.source.tree.ChildRole; import com.intellij.psi.impl.source.tree.CompositeElement; import com.intellij.psi.impl.source.tree.JavaElementType; import com.intellij.psi.tree.IElementType; +import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -268,6 +269,8 @@ public class JavaChildWrapArranger { private static boolean isTypeAnnotationOrFalseIfDumb(@NotNull ASTNode child) { PsiElement node = child.getPsi(); + PsiElement next = PsiTreeUtil.skipSiblingsForward(node, PsiWhiteSpace.class, PsiAnnotation.class); + if (next instanceof PsiKeyword) return false; return !DumbService.isDumb(node.getProject()) && isTypeAnnotation(node); } diff --git a/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java b/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java index 1ad78b799a19..3eea64f740fa 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java @@ -812,26 +812,13 @@ public final class PsiUtil extends PsiUtilCore { } } - if (glb != null) { - if (!((PsiWildcardType)substituted).isSuper()) { - substituted = glb instanceof PsiCapturedWildcardType ? ((PsiCapturedWildcardType)glb).getWildcard() - : PsiWildcardType.createExtends(manager, glb); - } - else { - if (captureContext != null) { - final PsiCapturedWildcardType capturedWildcardType = oldSubstituted instanceof PsiCapturedWildcardType - ? (PsiCapturedWildcardType)oldSubstituted - : (PsiCapturedWildcardType)captureSubstitutor.substitute(typeParameter); - LOG.assertTrue(capturedWildcardType != null); - capturedWildcardType.setUpperBound(glb); - return capturedWildcardType; - } - } + if (glb != null && !((PsiWildcardType)substituted).isSuper()) { + substituted = glb instanceof PsiCapturedWildcardType ? ((PsiCapturedWildcardType)glb).getWildcard() + : PsiWildcardType.createExtends(manager, glb); } } if (captureContext != null) { - LOG.assertTrue(substituted instanceof PsiWildcardType, substituted); substituted = oldSubstituted instanceof PsiCapturedWildcardType && substituted.equals(((PsiCapturedWildcardType)oldSubstituted).getWildcard()) ? oldSubstituted diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java index 514c54ecf9b0..9343717276d4 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java @@ -164,10 +164,7 @@ public class PsiSubstitutorImpl implements PsiSubstitutor { } if (newBound instanceof PsiCapturedWildcardType) { final PsiWildcardType wildcard = ((PsiCapturedWildcardType)newBound).getWildcard(); - if (wildcardType.isExtends() != wildcard.isExtends()) { - return !wildcard.isBounded() ? newBound : rebound(wildcardType, newBound); - } - if (wildcard.isBounded()) { + if (wildcard.isBounded() && wildcardType.isExtends() == wildcard.isExtends()) { return newBound; } } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeEqualityConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeEqualityConstraint.java index f3fc0c725b12..efda4514e2ed 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeEqualityConstraint.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeEqualityConstraint.java @@ -96,7 +96,7 @@ public class TypeEqualityConstraint implements ConstraintFormula { final PsiSubstitutor sSubstitutor = sResult.getSubstitutor(); for (PsiTypeParameter typeParameter : tClass.getTypeParameters()) { final PsiType tSubstituted = tSubstitutor.substitute(typeParameter); - final PsiType sSubstituted = sSubstitutor.substitute(typeParameter); + final PsiType sSubstituted = sSubstitutor.substituteWithBoundsPromotion(typeParameter); if (tSubstituted != null && sSubstituted != null) { constraints.add(new TypeEqualityConstraint(tSubstituted, sSubstituted)); } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java index 60b3b5f9bcee..19bee165ef67 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java @@ -519,6 +519,6 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase @Nullable @Override public Icon getIcon(int flags) { - return AllIcons.Nodes.AnonymousClass; + return AllIcons.Nodes.MethodReference; } } diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java index 1452d08eb0cd..9d00594d9b51 100644 --- a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java +++ b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java @@ -15,6 +15,7 @@ */ package com.intellij.psi.scope.conflictResolvers; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.projectRoots.JavaSdkVersion; @@ -71,12 +72,14 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ @Override public final CandidateInfo resolveConflict(@NotNull final List conflicts){ + /* + //non-default policies final MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(myArgumentsList); if (properties != null) { final PsiMethod method = properties.getMethod(); LOG.error("Recursive conflict resolution for:" + method + "; " + myArgumentsList.getText() + "; file=" + (method == null ? "" : method.getContainingFile())); - } + }*/ return MethodCandidateInfo.ourOverloadGuard.doPreventingRecursion(myArgumentsList, true, new Computable() { @Override public CandidateInfo compute() { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57286.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57286.java index f26c784ba40f..a2053074f2e2 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57286.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57286.java @@ -1,6 +1,6 @@ class A { > void foo(){} void bar(A a){ - a.<A>foo(); + a.<A>foo(); } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57311.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57311.java index 2be9a4f1e4ff..0d22f7e06ac6 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57311.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57311.java @@ -4,7 +4,7 @@ class A { } void bar(A x){ - baz(x.foo()); + baz(x.foo()); } void baz(A> x){} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57508.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57508.java index 07ec320b4dd2..673c7b26c933 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57508.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57508.java @@ -5,6 +5,6 @@ abstract class X { abstract void copy(List dest, List src); void foo(List x, List y){ - copy(x, y); + copy(x, y); } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57533.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57533.java index 4e37c9763b2e..2d77121a4baf 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57533.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57533.java @@ -1,6 +1,6 @@ class C>>{ void foo(C x){ - bar(x); + bar(x); } > void bar(C x){} } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SubstituteTypeParameterOfCapturedWildcardOnSubstitution.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SubstituteTypeParameterOfCapturedWildcardOnSubstitution.java index 6bd8b7a192cf..12233e9333a0 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SubstituteTypeParameterOfCapturedWildcardOnSubstitution.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SubstituteTypeParameterOfCapturedWildcardOnSubstitution.java @@ -9,7 +9,7 @@ abstract class A { void baz7(B a) {} abstract B foo7(); void bar7(A a) { - baz7(a.foo7()); + baz7(a.foo7()); } void baz9(B a) {} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SubstitutorCaptureBoundComposition.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SubstitutorCaptureBoundComposition.java index 8cfa716454b9..c22333a5395d 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SubstitutorCaptureBoundComposition.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SubstitutorCaptureBoundComposition.java @@ -22,7 +22,7 @@ class Test { traverser.filter(filter); traverser.filter1(filter); - traverser.filter2(filter); //"'filter2(Predicate>)' in 'NodeTraverser' cannot be applied to '(Predicate>)'" + traverser.filter2(filter); //"'filter2(Predicate>)' in 'NodeTraverser' cannot be applied to '(Predicate>)'" traverser1.filter(filter); traverser1.filter1(filter); @@ -36,7 +36,7 @@ class Test { traverser.filter(filter1); traverser.filter1(filter1); - traverser.filter2(filter1);// "'filter2(Predicate>)' in 'NodeTraverser' cannot be applied to '(Predicate>)'" + traverser.filter2(filter1);// "'filter2(Predicate>)' in 'NodeTraverser' cannot be applied to '(Predicate>)'" traverser1.filter(filter1); traverser1.filter1(filter1); @@ -50,7 +50,7 @@ class Test { traverser.filter(filter2); traverser.filter1(filter2); - traverser.filter2(filter2);// "'filter2(Predicate>)' in 'NodeTraverser' cannot be applied to '(Predicate>)'" + traverser.filter2(filter2);// "'filter2(Predicate>)' in 'NodeTraverser' cannot be applied to '(Predicate>)'" traverser1.filter(filter2); traverser1.filter1(filter2); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Variance.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Variance.java index 382214326fef..c9594c41bc2b 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Variance.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Variance.java @@ -242,7 +242,7 @@ class Use99n extends Use99,Double> { class IDEA79360 { public static void main(Map map, Map test) { - map.putAll(test); + map.putAll(test); map.put("", ""); map.put(new Object(), new Object()); map = new HashMap(test); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57286.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57286.java index 737870579aaa..cc1eeac27d3c 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57286.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57286.java @@ -1,6 +1,6 @@ class A { > void foo(){} void bar(A a){ - a.<A>foo(); + a.<A>foo(); } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57311.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57311.java index a566b5b0cf60..f51997bb58e3 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57311.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57311.java @@ -4,7 +4,7 @@ class A { } void bar(A x){ - baz(x.foo()); + baz(x.foo()); } void baz(A> x){} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57320.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57320.java index eefaeee41c81..01eb8ce51f73 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57320.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57320.java @@ -4,6 +4,6 @@ class B { return null; } - void bar(B b){ baz(b.foo()); } + void bar(B b){ baz(b.foo()); } void baz(A a) {} } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57533.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57533.java index 476897f1e9e4..fd80fabafec2 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57533.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57533.java @@ -1,6 +1,6 @@ class C>>{ void foo(C x){ - bar(x); + bar(x); } > void bar(C x){} } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/RejectEqualsBoundsContradictingLowerBound.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/RejectEqualsBoundsContradictingLowerBound.java index 4e48a1f48b3c..a9b829f574e7 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/RejectEqualsBoundsContradictingLowerBound.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/RejectEqualsBoundsContradictingLowerBound.java @@ -4,7 +4,7 @@ abstract class A { void baz37(B a) {} abstract B foo37(); void bar37(A a){ - baz37(a.foo37()); + baz37(a.foo37()); } void baz39(B a) {} @@ -16,7 +16,7 @@ abstract class A { void baz52(B a) {} abstract B foo52(); void bar52(A a){ - baz52(a.foo52()); + baz52(a.foo52()); } void baz54(B a) {} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/SuperWildcardCapturedSuperExtendsWildcardCapturedExtends.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/SuperWildcardCapturedSuperExtendsWildcardCapturedExtends.java index 97a85808d872..4b5533fad7b0 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/SuperWildcardCapturedSuperExtendsWildcardCapturedExtends.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/SuperWildcardCapturedSuperExtendsWildcardCapturedExtends.java @@ -18,7 +18,7 @@ abstract class A { void baz256(B a) {} abstract B foo256(); void bar256(A a) { - baz256(a.foo256()); + baz256(a.foo256()); } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Variance.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Variance.java index e0a57a1e07a8..f49c6b07d247 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Variance.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Variance.java @@ -242,7 +242,7 @@ class Use99n extends Use99,Double> { class IDEA79360 { public static void main(Map map, Map test) { - map.putAll(test); + map.putAll(test); map.put("", ""); map.put(new Object(), new Object()); map = new HashMap(test); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlightingGenerated8/UnrelatedClasses.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlightingGenerated8/UnrelatedClasses.java index 2eef14e9dc59..a1160f0722ad 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlightingGenerated8/UnrelatedClasses.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlightingGenerated8/UnrelatedClasses.java @@ -47,7 +47,7 @@ abstract class A { void baz7(B a) {} abstract B foo7(); void bar7(A a){ - baz7(a.foo7()); + baz7(a.foo7()); } @@ -110,7 +110,7 @@ abstract class A { void baz16(B a) {} abstract B foo16(); void bar16(A a){ - baz16(a.foo16()); + baz16(a.foo16()); } @@ -152,7 +152,7 @@ abstract class A { void baz22(B a) {} abstract B foo22(); void bar22(A a){ - baz22(a.foo22()); + baz22(a.foo22()); } @@ -173,7 +173,7 @@ abstract class A { void baz25(B a) {} abstract B foo25(); void bar25(A a){ - baz25(a.foo25()); + baz25(a.foo25()); } @@ -257,7 +257,7 @@ abstract class A { void baz37(B a) {} abstract B foo37(); void bar37(A a){ - baz37(a.foo37()); + baz37(a.foo37()); } @@ -320,7 +320,7 @@ abstract class A { void baz46(B a) {} abstract B foo46(); void bar46(A a){ - baz46(a.foo46()); + baz46(a.foo46()); } @@ -362,7 +362,7 @@ abstract class A { void baz52(B a) {} abstract B foo52(); void bar52(A a){ - baz52(a.foo52()); + baz52(a.foo52()); } @@ -383,7 +383,7 @@ abstract class A { void baz55(B a) {} abstract B foo55(); void bar55(A a){ - baz55(a.foo55()); + baz55(a.foo55()); } @@ -467,7 +467,7 @@ abstract class A { void baz67(B a) {} abstract B foo67(); void bar67(A a){ - baz67(a.foo67()); + baz67(a.foo67()); } @@ -530,7 +530,7 @@ abstract class A { void baz76(B a) {} abstract B foo76(); void bar76(A a){ - baz76(a.foo76()); + baz76(a.foo76()); } @@ -572,7 +572,7 @@ abstract class A { void baz82(B a) {} abstract B foo82(); void bar82(A a){ - baz82(a.foo82()); + baz82(a.foo82()); } @@ -593,7 +593,7 @@ abstract class A { void baz85(B a) {} abstract B foo85(); void bar85(A a){ - baz85(a.foo85()); + baz85(a.foo85()); } @@ -1097,7 +1097,7 @@ abstract class A { void baz157(B a) {} abstract B foo157(); void bar157(A a){ - baz157(a.foo157()); + baz157(a.foo157()); } @@ -1160,7 +1160,7 @@ abstract class A { void baz166(B a) {} abstract B foo166(); void bar166(A a){ - baz166(a.foo166()); + baz166(a.foo166()); } @@ -1202,7 +1202,7 @@ abstract class A { void baz172(B a) {} abstract B foo172(); void bar172(A a){ - baz172(a.foo172()); + baz172(a.foo172()); } @@ -1223,7 +1223,7 @@ abstract class A { void baz175(B a) {} abstract B foo175(); void bar175(A a){ - baz175(a.foo175()); + baz175(a.foo175()); } @@ -1517,7 +1517,7 @@ abstract class A { void baz217(B a) {} abstract B foo217(); void bar217(A a){ - baz217(a.foo217()); + baz217(a.foo217()); } @@ -1580,7 +1580,7 @@ abstract class A { void baz226(B a) {} abstract B foo226(); void bar226(A a){ - baz226(a.foo226()); + baz226(a.foo226()); } @@ -1622,7 +1622,7 @@ abstract class A { void baz232(B a) {} abstract B foo232(); void bar232(A a){ - baz232(a.foo232()); + baz232(a.foo232()); } @@ -1643,7 +1643,7 @@ abstract class A { void baz235(B a) {} abstract B foo235(); void bar235(A a){ - baz235(a.foo235()); + baz235(a.foo235()); } @@ -1727,7 +1727,7 @@ abstract class A { void baz247(B a) {} abstract B foo247(); void bar247(A a){ - baz247(a.foo247()); + baz247(a.foo247()); } @@ -1790,7 +1790,7 @@ abstract class A { void baz256(B a) {} abstract B foo256(); void bar256(A a){ - baz256(a.foo256()); + baz256(a.foo256()); } @@ -1832,7 +1832,7 @@ abstract class A { void baz262(B a) {} abstract B foo262(); void bar262(A a){ - baz262(a.foo262()); + baz262(a.foo262()); } @@ -1853,7 +1853,7 @@ abstract class A { void baz265(B a) {} abstract B foo265(); void bar265(A a){ - baz265(a.foo265()); + baz265(a.foo265()); } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlightingGenerated8/UnrelatedClassesExtendsTypeParams.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlightingGenerated8/UnrelatedClassesExtendsTypeParams.java new file mode 100644 index 000000000000..a32f9b746293 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlightingGenerated8/UnrelatedClassesExtendsTypeParams.java @@ -0,0 +1,2146 @@ +class B {} +abstract class A { + + + void baz1(B a) {} + abstract B foo1(); + void bar1(A a){ + baz1(a.foo1()); + } + + + void baz2(B a) {} + abstract B foo2(); + void bar2(A a){ + baz2(a.foo2()); + } + + + void baz3(B a) {} + abstract B foo3(); + void bar3(A a){ + baz3(a.foo3()); + } + + + void baz4(B a) {} + abstract B foo4(); + void bar4(A a){ + baz4(a.foo4()); + } + + + void baz5(B a) {} + abstract B foo5(); + void bar5(A a){ + baz5(a.foo5()); + } + + + void baz6(B a) {} + abstract B foo6(); + void bar6(A a){ + baz6(a.foo6()); + } + + + void baz7(B a) {} + abstract B foo7(); + void bar7(A a){ + baz7(a.foo7()); + } + + + void baz8(B a) {} + abstract B foo8(); + void bar8(A a){ + baz8(a.foo8()); + } + + + void baz9(B a) {} + abstract B foo9(); + void bar9(A a){ + baz9(a.foo9()); + } + + + void baz10(B a) {} + abstract B foo10(); + void bar10(A a){ + baz10(a.foo10()); + } + + + void baz11(B a) {} + abstract B foo11(); + void bar11(A a){ + baz11(a.foo11()); + } + + + void baz12(B a) {} + abstract B foo12(); + void bar12(A a){ + baz12(a.foo12()); + } + + + void baz13(B a) {} + abstract B foo13(); + void bar13(A a){ + baz13(a.foo13()); + } + + + void baz14(B a) {} + abstract B foo14(); + void bar14(A a){ + baz14(a.foo14()); + } + + + void baz15(B a) {} + abstract B foo15(); + void bar15(A a){ + baz15(a.foo15()); + } + + + void baz16(B a) {} + abstract B foo16(); + void bar16(A a){ + baz16(a.foo16()); + } + + + void baz17(B a) {} + abstract B foo17(); + void bar17(A a){ + baz17(a.foo17()); + } + + + void baz18(B a) {} + abstract B foo18(); + void bar18(A a){ + baz18(a.foo18()); + } + + + void baz19(B a) {} + abstract B foo19(); + void bar19(A a){ + baz19(a.foo19()); + } + + + void baz20(B a) {} + abstract B foo20(); + void bar20(A a){ + baz20(a.foo20()); + } + + + void baz21(B a) {} + abstract B foo21(); + void bar21(A a){ + baz21(a.foo21()); + } + + + void baz22(B a) {} + abstract B foo22(); + void bar22(A a){ + baz22(a.foo22()); + } + + + void baz23(B a) {} + abstract B foo23(); + void bar23(A a){ + baz23(a.foo23()); + } + + + void baz24(B a) {} + abstract B foo24(); + void bar24(A a){ + baz24(a.foo24()); + } + + + void baz25(B a) {} + abstract B foo25(); + void bar25(A a){ + baz25(a.foo25()); + } + + + void baz26(B a) {} + abstract B foo26(); + void bar26(A a){ + baz26(a.foo26()); + } + + + void baz27(B a) {} + abstract B foo27(); + void bar27(A a){ + baz27(a.foo27()); + } + + + void baz28(B a) {} + abstract B foo28(); + void bar28(A a){ + baz28(a.foo28()); + } + + + void baz29(B a) {} + abstract B foo29(); + void bar29(A a){ + baz29(a.foo29()); + } + + + void baz30(B a) {} + abstract B foo30(); + void bar30(A a){ + baz30(a.foo30()); + } + + + void baz31(B a) {} + abstract B foo31(); + void bar31(A a){ + baz31(a.foo31()); + } + + + void baz32(B a) {} + abstract B foo32(); + void bar32(A a){ + baz32(a.foo32()); + } + + + void baz33(B a) {} + abstract B foo33(); + void bar33(A a){ + baz33(a.foo33()); + } + + + void baz34(B a) {} + abstract B foo34(); + void bar34(A a){ + baz34(a.foo34()); + } + + + void baz35(B a) {} + abstract B foo35(); + void bar35(A a){ + baz35(a.foo35()); + } + + + void baz36(B a) {} + abstract B foo36(); + void bar36(A a){ + baz36(a.foo36()); + } + + + void baz37(B a) {} + abstract B foo37(); + void bar37(A a){ + baz37(a.foo37()); + } + + + void baz38(B a) {} + abstract B foo38(); + void bar38(A a){ + baz38(a.foo38()); + } + + + void baz39(B a) {} + abstract B foo39(); + void bar39(A a){ + baz39(a.foo39()); + } + + + void baz40(B a) {} + abstract B foo40(); + void bar40(A a){ + baz40(a.foo40()); + } + + + void baz41(B a) {} + abstract B foo41(); + void bar41(A a){ + baz41(a.foo41()); + } + + + void baz42(B a) {} + abstract B foo42(); + void bar42(A a){ + baz42(a.foo42()); + } + + + void baz43(B a) {} + abstract B foo43(); + void bar43(A a){ + baz43(a.foo43()); + } + + + void baz44(B a) {} + abstract B foo44(); + void bar44(A a){ + baz44(a.foo44()); + } + + + void baz45(B a) {} + abstract B foo45(); + void bar45(A a){ + baz45(a.foo45()); + } + + + void baz46(B a) {} + abstract B foo46(); + void bar46(A a){ + baz46(a.foo46()); + } + + + void baz47(B a) {} + abstract B foo47(); + void bar47(A a){ + baz47(a.foo47()); + } + + + void baz48(B a) {} + abstract B foo48(); + void bar48(A a){ + baz48(a.foo48()); + } + + + void baz49(B a) {} + abstract B foo49(); + void bar49(A a){ + baz49(a.foo49()); + } + + + void baz50(B a) {} + abstract B foo50(); + void bar50(A a){ + baz50(a.foo50()); + } + + + void baz51(B a) {} + abstract B foo51(); + void bar51(A a){ + baz51(a.foo51()); + } + + + void baz52(B a) {} + abstract B foo52(); + void bar52(A a){ + baz52(a.foo52()); + } + + + void baz53(B a) {} + abstract B foo53(); + void bar53(A a){ + baz53(a.foo53()); + } + + + void baz54(B a) {} + abstract B foo54(); + void bar54(A a){ + baz54(a.foo54()); + } + + + void baz55(B a) {} + abstract B foo55(); + void bar55(A a){ + baz55(a.foo55()); + } + + + void baz56(B a) {} + abstract B foo56(); + void bar56(A a){ + baz56(a.foo56()); + } + + + void baz57(B a) {} + abstract B foo57(); + void bar57(A a){ + baz57(a.foo57()); + } + + + void baz58(B a) {} + abstract B foo58(); + void bar58(A a){ + baz58(a.foo58()); + } + + + void baz59(B a) {} + abstract B foo59(); + void bar59(A a){ + baz59(a.foo59()); + } + + + void baz60(B a) {} + abstract B foo60(); + void bar60(A a){ + baz60(a.foo60()); + } + + + void baz61(B a) {} + abstract B foo61(); + void bar61(A a){ + baz61(a.foo61()); + } + + + void baz62(B a) {} + abstract B foo62(); + void bar62(A a){ + baz62(a.foo62()); + } + + + void baz63(B a) {} + abstract B foo63(); + void bar63(A a){ + baz63(a.foo63()); + } + + + void baz64(B a) {} + abstract B foo64(); + void bar64(A a){ + baz64(a.foo64()); + } + + + void baz65(B a) {} + abstract B foo65(); + void bar65(A a){ + baz65(a.foo65()); + } + + + void baz66(B a) {} + abstract B foo66(); + void bar66(A a){ + baz66(a.foo66()); + } + + + void baz67(B a) {} + abstract B foo67(); + void bar67(A a){ + baz67(a.foo67()); + } + + + void baz68(B a) {} + abstract B foo68(); + void bar68(A a){ + baz68(a.foo68()); + } + + + void baz69(B a) {} + abstract B foo69(); + void bar69(A a){ + baz69(a.foo69()); + } + + + void baz70(B a) {} + abstract B foo70(); + void bar70(A a){ + baz70(a.foo70()); + } + + + void baz71(B a) {} + abstract B foo71(); + void bar71(A a){ + baz71(a.foo71()); + } + + + void baz72(B a) {} + abstract B foo72(); + void bar72(A a){ + baz72(a.foo72()); + } + + + void baz73(B a) {} + abstract B foo73(); + void bar73(A a){ + baz73(a.foo73()); + } + + + void baz74(B a) {} + abstract B foo74(); + void bar74(A a){ + baz74(a.foo74()); + } + + + void baz75(B a) {} + abstract B foo75(); + void bar75(A a){ + baz75(a.foo75()); + } + + + void baz76(B a) {} + abstract B foo76(); + void bar76(A a){ + baz76(a.foo76()); + } + + + void baz77(B a) {} + abstract B foo77(); + void bar77(A a){ + baz77(a.foo77()); + } + + + void baz78(B a) {} + abstract B foo78(); + void bar78(A a){ + baz78(a.foo78()); + } + + + void baz79(B a) {} + abstract B foo79(); + void bar79(A a){ + baz79(a.foo79()); + } + + + void baz80(B a) {} + abstract B foo80(); + void bar80(A a){ + baz80(a.foo80()); + } + + + void baz81(B a) {} + abstract B foo81(); + void bar81(A a){ + baz81(a.foo81()); + } + + + void baz82(B a) {} + abstract B foo82(); + void bar82(A a){ + baz82(a.foo82()); + } + + + void baz83(B a) {} + abstract B foo83(); + void bar83(A a){ + baz83(a.foo83()); + } + + + void baz84(B a) {} + abstract B foo84(); + void bar84(A a){ + baz84(a.foo84()); + } + + + void baz85(B a) {} + abstract B foo85(); + void bar85(A a){ + baz85(a.foo85()); + } + + + void baz86(B a) {} + abstract B foo86(); + void bar86(A a){ + baz86(a.foo86()); + } + + + void baz87(B a) {} + abstract B foo87(); + void bar87(A a){ + baz87(a.foo87()); + } + + + void baz88(B a) {} + abstract B foo88(); + void bar88(A a){ + baz88(a.foo88()); + } + + + void baz89(B a) {} + abstract B foo89(); + void bar89(A a){ + baz89(a.foo89()); + } + + + void baz90(B a) {} + abstract B foo90(); + void bar90(A a){ + baz90(a.foo90()); + } + + + void baz91(B a) {} + abstract B foo91(); + void bar91(A a){ + baz91(a.foo91()); + } + + + void baz92(B a) {} + abstract B foo92(); + void bar92(A a){ + baz92(a.foo92()); + } + + + void baz93(B a) {} + abstract B foo93(); + void bar93(A a){ + baz93(a.foo93()); + } + + + void baz94(B a) {} + abstract B foo94(); + void bar94(A a){ + baz94(a.foo94()); + } + + + void baz95(B a) {} + abstract B foo95(); + void bar95(A a){ + baz95(a.foo95()); + } + + + void baz96(B a) {} + abstract B foo96(); + void bar96(A a){ + baz96(a.foo96()); + } + + + void baz97(B a) {} + abstract B foo97(); + void bar97(A a){ + baz97(a.foo97()); + } + + + void baz98(B a) {} + abstract B foo98(); + void bar98(A a){ + baz98(a.foo98()); + } + + + void baz99(B a) {} + abstract B foo99(); + void bar99(A a){ + baz99(a.foo99()); + } + + + void baz100(B a) {} + abstract B foo100(); + void bar100(A a){ + baz100(a.foo100()); + } + + + void baz101(B a) {} + abstract B foo101(); + void bar101(A a){ + baz101(a.foo101()); + } + + + void baz102(B a) {} + abstract B foo102(); + void bar102(A a){ + baz102(a.foo102()); + } + + + void baz103(B a) {} + abstract B foo103(); + void bar103(A a){ + baz103(a.foo103()); + } + + + void baz104(B a) {} + abstract B foo104(); + void bar104(A a){ + baz104(a.foo104()); + } + + + void baz105(B a) {} + abstract B foo105(); + void bar105(A a){ + baz105(a.foo105()); + } + + + void baz106(B a) {} + abstract B foo106(); + void bar106(A a){ + baz106(a.foo106()); + } + + + void baz107(B a) {} + abstract B foo107(); + void bar107(A a){ + baz107(a.foo107()); + } + + + void baz108(B a) {} + abstract B foo108(); + void bar108(A a){ + baz108(a.foo108()); + } + + + void baz109(B a) {} + abstract B foo109(); + void bar109(A a){ + baz109(a.foo109()); + } + + + void baz110(B a) {} + abstract B foo110(); + void bar110(A a){ + baz110(a.foo110()); + } + + + void baz111(B a) {} + abstract B foo111(); + void bar111(A a){ + baz111(a.foo111()); + } + + + void baz112(B a) {} + abstract B foo112(); + void bar112(A a){ + baz112(a.foo112()); + } + + + void baz113(B a) {} + abstract B foo113(); + void bar113(A a){ + baz113(a.foo113()); + } + + + void baz114(B a) {} + abstract B foo114(); + void bar114(A a){ + baz114(a.foo114()); + } + + + void baz115(B a) {} + abstract B foo115(); + void bar115(A a){ + baz115(a.foo115()); + } + + + void baz116(B a) {} + abstract B foo116(); + void bar116(A a){ + baz116(a.foo116()); + } + + + void baz117(B a) {} + abstract B foo117(); + void bar117(A a){ + baz117(a.foo117()); + } + + + void baz118(B a) {} + abstract B foo118(); + void bar118(A a){ + baz118(a.foo118()); + } + + + void baz119(B a) {} + abstract B foo119(); + void bar119(A a){ + baz119(a.foo119()); + } + + + void baz120(B a) {} + abstract B foo120(); + void bar120(A a){ + baz120(a.foo120()); + } + + + void baz121(B a) {} + abstract B foo121(); + void bar121(A a){ + baz121(a.foo121()); + } + + + void baz122(B a) {} + abstract B foo122(); + void bar122(A a){ + baz122(a.foo122()); + } + + + void baz123(B a) {} + abstract B foo123(); + void bar123(A a){ + baz123(a.foo123()); + } + + + void baz124(B a) {} + abstract B foo124(); + void bar124(A a){ + baz124(a.foo124()); + } + + + void baz125(B a) {} + abstract B foo125(); + void bar125(A a){ + baz125(a.foo125()); + } + + + void baz126(B a) {} + abstract B foo126(); + void bar126(A a){ + baz126(a.foo126()); + } + + + void baz127(B a) {} + abstract B foo127(); + void bar127(A a){ + baz127(a.foo127()); + } + + + void baz128(B a) {} + abstract B foo128(); + void bar128(A a){ + baz128(a.foo128()); + } + + + void baz129(B a) {} + abstract B foo129(); + void bar129(A a){ + baz129(a.foo129()); + } + + + void baz130(B a) {} + abstract B foo130(); + void bar130(A a){ + baz130(a.foo130()); + } + + + void baz131(B a) {} + abstract B foo131(); + void bar131(A a){ + baz131(a.foo131()); + } + + + void baz132(B a) {} + abstract B foo132(); + void bar132(A a){ + baz132(a.foo132()); + } + + + void baz133(B a) {} + abstract B foo133(); + void bar133(A a){ + baz133(a.foo133()); + } + + + void baz134(B a) {} + abstract B foo134(); + void bar134(A a){ + baz134(a.foo134()); + } + + + void baz135(B a) {} + abstract B foo135(); + void bar135(A a){ + baz135(a.foo135()); + } + + + void baz136(B a) {} + abstract B foo136(); + void bar136(A a){ + baz136(a.foo136()); + } + + + void baz137(B a) {} + abstract B foo137(); + void bar137(A a){ + baz137(a.foo137()); + } + + + void baz138(B a) {} + abstract B foo138(); + void bar138(A a){ + baz138(a.foo138()); + } + + + void baz139(B a) {} + abstract B foo139(); + void bar139(A a){ + baz139(a.foo139()); + } + + + void baz140(B a) {} + abstract B foo140(); + void bar140(A a){ + baz140(a.foo140()); + } + + + void baz141(B a) {} + abstract B foo141(); + void bar141(A a){ + baz141(a.foo141()); + } + + + void baz142(B a) {} + abstract B foo142(); + void bar142(A a){ + baz142(a.foo142()); + } + + + void baz143(B a) {} + abstract B foo143(); + void bar143(A a){ + baz143(a.foo143()); + } + + + void baz144(B a) {} + abstract B foo144(); + void bar144(A a){ + baz144(a.foo144()); + } + + + void baz145(B a) {} + abstract B foo145(); + void bar145(A a){ + baz145(a.foo145()); + } + + + void baz146(B a) {} + abstract B foo146(); + void bar146(A a){ + baz146(a.foo146()); + } + + + void baz147(B a) {} + abstract B foo147(); + void bar147(A a){ + baz147(a.foo147()); + } + + + void baz148(B a) {} + abstract B foo148(); + void bar148(A a){ + baz148(a.foo148()); + } + + + void baz149(B a) {} + abstract B foo149(); + void bar149(A a){ + baz149(a.foo149()); + } + + + void baz150(B a) {} + abstract B foo150(); + void bar150(A a){ + baz150(a.foo150()); + } + + + void baz151(B a) {} + abstract B foo151(); + void bar151(A a){ + baz151(a.foo151()); + } + + + void baz152(B a) {} + abstract B foo152(); + void bar152(A a){ + baz152(a.foo152()); + } + + + void baz153(B a) {} + abstract B foo153(); + void bar153(A a){ + baz153(a.foo153()); + } + + + void baz154(B a) {} + abstract B foo154(); + void bar154(A a){ + baz154(a.foo154()); + } + + + void baz155(B a) {} + abstract B foo155(); + void bar155(A a){ + baz155(a.foo155()); + } + + + void baz156(B a) {} + abstract B foo156(); + void bar156(A a){ + baz156(a.foo156()); + } + + + void baz157(B a) {} + abstract B foo157(); + void bar157(A a){ + baz157(a.foo157()); + } + + + void baz158(B a) {} + abstract B foo158(); + void bar158(A a){ + baz158(a.foo158()); + } + + + void baz159(B a) {} + abstract B foo159(); + void bar159(A a){ + baz159(a.foo159()); + } + + + void baz160(B a) {} + abstract B foo160(); + void bar160(A a){ + baz160(a.foo160()); + } + + + void baz161(B a) {} + abstract B foo161(); + void bar161(A a){ + baz161(a.foo161()); + } + + + void baz162(B a) {} + abstract B foo162(); + void bar162(A a){ + baz162(a.foo162()); + } + + + void baz163(B a) {} + abstract B foo163(); + void bar163(A a){ + baz163(a.foo163()); + } + + + void baz164(B a) {} + abstract B foo164(); + void bar164(A a){ + baz164(a.foo164()); + } + + + void baz165(B a) {} + abstract B foo165(); + void bar165(A a){ + baz165(a.foo165()); + } + + + void baz166(B a) {} + abstract B foo166(); + void bar166(A a){ + baz166(a.foo166()); + } + + + void baz167(B a) {} + abstract B foo167(); + void bar167(A a){ + baz167(a.foo167()); + } + + + void baz168(B a) {} + abstract B foo168(); + void bar168(A a){ + baz168(a.foo168()); + } + + + void baz169(B a) {} + abstract B foo169(); + void bar169(A a){ + baz169(a.foo169()); + } + + + void baz170(B a) {} + abstract B foo170(); + void bar170(A a){ + baz170(a.foo170()); + } + + + void baz171(B a) {} + abstract B foo171(); + void bar171(A a){ + baz171(a.foo171()); + } + + + void baz172(B a) {} + abstract B foo172(); + void bar172(A a){ + baz172(a.foo172()); + } + + + void baz173(B a) {} + abstract B foo173(); + void bar173(A a){ + baz173(a.foo173()); + } + + + void baz174(B a) {} + abstract B foo174(); + void bar174(A a){ + baz174(a.foo174()); + } + + + void baz175(B a) {} + abstract B foo175(); + void bar175(A a){ + baz175(a.foo175()); + } + + + void baz176(B a) {} + abstract B foo176(); + void bar176(A a){ + baz176(a.foo176()); + } + + + void baz177(B a) {} + abstract B foo177(); + void bar177(A a){ + baz177(a.foo177()); + } + + + void baz178(B a) {} + abstract B foo178(); + void bar178(A a){ + baz178(a.foo178()); + } + + + void baz179(B a) {} + abstract B foo179(); + void bar179(A a){ + baz179(a.foo179()); + } + + + void baz180(B a) {} + abstract B foo180(); + void bar180(A a){ + baz180(a.foo180()); + } + + + void baz181(B a) {} + abstract B foo181(); + void bar181(A a){ + baz181(a.foo181()); + } + + + void baz182(B a) {} + abstract B foo182(); + void bar182(A a){ + baz182(a.foo182()); + } + + + void baz183(B a) {} + abstract B foo183(); + void bar183(A a){ + baz183(a.foo183()); + } + + + void baz184(B a) {} + abstract B foo184(); + void bar184(A a){ + baz184(a.foo184()); + } + + + void baz185(B a) {} + abstract B foo185(); + void bar185(A a){ + baz185(a.foo185()); + } + + + void baz186(B a) {} + abstract B foo186(); + void bar186(A a){ + baz186(a.foo186()); + } + + + void baz187(B a) {} + abstract B foo187(); + void bar187(A a){ + baz187(a.foo187()); + } + + + void baz188(B a) {} + abstract B foo188(); + void bar188(A a){ + baz188(a.foo188()); + } + + + void baz189(B a) {} + abstract B foo189(); + void bar189(A a){ + baz189(a.foo189()); + } + + + void baz190(B a) {} + abstract B foo190(); + void bar190(A a){ + baz190(a.foo190()); + } + + + void baz191(B a) {} + abstract B foo191(); + void bar191(A a){ + baz191(a.foo191()); + } + + + void baz192(B a) {} + abstract B foo192(); + void bar192(A a){ + baz192(a.foo192()); + } + + + void baz193(B a) {} + abstract B foo193(); + void bar193(A a){ + baz193(a.foo193()); + } + + + void baz194(B a) {} + abstract B foo194(); + void bar194(A a){ + baz194(a.foo194()); + } + + + void baz195(B a) {} + abstract B foo195(); + void bar195(A a){ + baz195(a.foo195()); + } + + + void baz196(B a) {} + abstract B foo196(); + void bar196(A a){ + baz196(a.foo196()); + } + + + void baz197(B a) {} + abstract B foo197(); + void bar197(A a){ + baz197(a.foo197()); + } + + + void baz198(B a) {} + abstract B foo198(); + void bar198(A a){ + baz198(a.foo198()); + } + + + void baz199(B a) {} + abstract B foo199(); + void bar199(A a){ + baz199(a.foo199()); + } + + + void baz200(B a) {} + abstract B foo200(); + void bar200(A a){ + baz200(a.foo200()); + } + + + void baz201(B a) {} + abstract B foo201(); + void bar201(A a){ + baz201(a.foo201()); + } + + + void baz202(B a) {} + abstract B foo202(); + void bar202(A a){ + baz202(a.foo202()); + } + + + void baz203(B a) {} + abstract B foo203(); + void bar203(A a){ + baz203(a.foo203()); + } + + + void baz204(B a) {} + abstract B foo204(); + void bar204(A a){ + baz204(a.foo204()); + } + + + void baz205(B a) {} + abstract B foo205(); + void bar205(A a){ + baz205(a.foo205()); + } + + + void baz206(B a) {} + abstract B foo206(); + void bar206(A a){ + baz206(a.foo206()); + } + + + void baz207(B a) {} + abstract B foo207(); + void bar207(A a){ + baz207(a.foo207()); + } + + + void baz208(B a) {} + abstract B foo208(); + void bar208(A a){ + baz208(a.foo208()); + } + + + void baz209(B a) {} + abstract B foo209(); + void bar209(A a){ + baz209(a.foo209()); + } + + + void baz210(B a) {} + abstract B foo210(); + void bar210(A a){ + baz210(a.foo210()); + } + + + void baz211(B a) {} + abstract B foo211(); + void bar211(A a){ + baz211(a.foo211()); + } + + + void baz212(B a) {} + abstract B foo212(); + void bar212(A a){ + baz212(a.foo212()); + } + + + void baz213(B a) {} + abstract B foo213(); + void bar213(A a){ + baz213(a.foo213()); + } + + + void baz214(B a) {} + abstract B foo214(); + void bar214(A a){ + baz214(a.foo214()); + } + + + void baz215(B a) {} + abstract B foo215(); + void bar215(A a){ + baz215(a.foo215()); + } + + + void baz216(B a) {} + abstract B foo216(); + void bar216(A a){ + baz216(a.foo216()); + } + + + void baz217(B a) {} + abstract B foo217(); + void bar217(A a){ + baz217(a.foo217()); + } + + + void baz218(B a) {} + abstract B foo218(); + void bar218(A a){ + baz218(a.foo218()); + } + + + void baz219(B a) {} + abstract B foo219(); + void bar219(A a){ + baz219(a.foo219()); + } + + + void baz220(B a) {} + abstract B foo220(); + void bar220(A a){ + baz220(a.foo220()); + } + + + void baz221(B a) {} + abstract B foo221(); + void bar221(A a){ + baz221(a.foo221()); + } + + + void baz222(B a) {} + abstract B foo222(); + void bar222(A a){ + baz222(a.foo222()); + } + + + void baz223(B a) {} + abstract B foo223(); + void bar223(A a){ + baz223(a.foo223()); + } + + + void baz224(B a) {} + abstract B foo224(); + void bar224(A a){ + baz224(a.foo224()); + } + + + void baz225(B a) {} + abstract B foo225(); + void bar225(A a){ + baz225(a.foo225()); + } + + + void baz226(B a) {} + abstract B foo226(); + void bar226(A a){ + baz226(a.foo226()); + } + + + void baz227(B a) {} + abstract B foo227(); + void bar227(A a){ + baz227(a.foo227()); + } + + + void baz228(B a) {} + abstract B foo228(); + void bar228(A a){ + baz228(a.foo228()); + } + + + void baz229(B a) {} + abstract B foo229(); + void bar229(A a){ + baz229(a.foo229()); + } + + + void baz230(B a) {} + abstract B foo230(); + void bar230(A a){ + baz230(a.foo230()); + } + + + void baz231(B a) {} + abstract B foo231(); + void bar231(A a){ + baz231(a.foo231()); + } + + + void baz232(B a) {} + abstract B foo232(); + void bar232(A a){ + baz232(a.foo232()); + } + + + void baz233(B a) {} + abstract B foo233(); + void bar233(A a){ + baz233(a.foo233()); + } + + + void baz234(B a) {} + abstract B foo234(); + void bar234(A a){ + baz234(a.foo234()); + } + + + void baz235(B a) {} + abstract B foo235(); + void bar235(A a){ + baz235(a.foo235()); + } + + + void baz236(B a) {} + abstract B foo236(); + void bar236(A a){ + baz236(a.foo236()); + } + + + void baz237(B a) {} + abstract B foo237(); + void bar237(A a){ + baz237(a.foo237()); + } + + + void baz238(B a) {} + abstract B foo238(); + void bar238(A a){ + baz238(a.foo238()); + } + + + void baz239(B a) {} + abstract B foo239(); + void bar239(A a){ + baz239(a.foo239()); + } + + + void baz240(B a) {} + abstract B foo240(); + void bar240(A a){ + baz240(a.foo240()); + } + + + void baz241(B a) {} + abstract B foo241(); + void bar241(A a){ + baz241(a.foo241()); + } + + + void baz242(B a) {} + abstract B foo242(); + void bar242(A a){ + baz242(a.foo242()); + } + + + void baz243(B a) {} + abstract B foo243(); + void bar243(A a){ + baz243(a.foo243()); + } + + + void baz244(B a) {} + abstract B foo244(); + void bar244(A a){ + baz244(a.foo244()); + } + + + void baz245(B a) {} + abstract B foo245(); + void bar245(A a){ + baz245(a.foo245()); + } + + + void baz246(B a) {} + abstract B foo246(); + void bar246(A a){ + baz246(a.foo246()); + } + + + void baz247(B a) {} + abstract B foo247(); + void bar247(A a){ + baz247(a.foo247()); + } + + + void baz248(B a) {} + abstract B foo248(); + void bar248(A a){ + baz248(a.foo248()); + } + + + void baz249(B a) {} + abstract B foo249(); + void bar249(A a){ + baz249(a.foo249()); + } + + + void baz250(B a) {} + abstract B foo250(); + void bar250(A a){ + baz250(a.foo250()); + } + + + void baz251(B a) {} + abstract B foo251(); + void bar251(A a){ + baz251(a.foo251()); + } + + + void baz252(B a) {} + abstract B foo252(); + void bar252(A a){ + baz252(a.foo252()); + } + + + void baz253(B a) {} + abstract B foo253(); + void bar253(A a){ + baz253(a.foo253()); + } + + + void baz254(B a) {} + abstract B foo254(); + void bar254(A a){ + baz254(a.foo254()); + } + + + void baz255(B a) {} + abstract B foo255(); + void bar255(A a){ + baz255(a.foo255()); + } + + + void baz256(B a) {} + abstract B foo256(); + void bar256(A a){ + baz256(a.foo256()); + } + + + void baz257(B a) {} + abstract B foo257(); + void bar257(A a){ + baz257(a.foo257()); + } + + + void baz258(B a) {} + abstract B foo258(); + void bar258(A a){ + baz258(a.foo258()); + } + + + void baz259(B a) {} + abstract B foo259(); + void bar259(A a){ + baz259(a.foo259()); + } + + + void baz260(B a) {} + abstract B foo260(); + void bar260(A a){ + baz260(a.foo260()); + } + + + void baz261(B a) {} + abstract B foo261(); + void bar261(A a){ + baz261(a.foo261()); + } + + + void baz262(B a) {} + abstract B foo262(); + void bar262(A a){ + baz262(a.foo262()); + } + + + void baz263(B a) {} + abstract B foo263(); + void bar263(A a){ + baz263(a.foo263()); + } + + + void baz264(B a) {} + abstract B foo264(); + void bar264(A a){ + baz264(a.foo264()); + } + + + void baz265(B a) {} + abstract B foo265(); + void bar265(A a){ + baz265(a.foo265()); + } + + + void baz266(B a) {} + abstract B foo266(); + void bar266(A a){ + baz266(a.foo266()); + } + + + void baz267(B a) {} + abstract B foo267(); + void bar267(A a){ + baz267(a.foo267()); + } + + + void baz268(B a) {} + abstract B foo268(); + void bar268(A a){ + baz268(a.foo268()); + } + + + void baz269(B a) {} + abstract B foo269(); + void bar269(A a){ + baz269(a.foo269()); + } + + + void baz270(B a) {} + abstract B foo270(); + void bar270(A a){ + baz270(a.foo270()); + } + + + void baz271(B a) {} + abstract B foo271(); + void bar271(A a){ + baz271(a.foo271()); + } + + + void baz272(B a) {} + abstract B foo272(); + void bar272(A a){ + baz272(a.foo272()); + } + + + void baz273(B a) {} + abstract B foo273(); + void bar273(A a){ + baz273(a.foo273()); + } + + + void baz274(B a) {} + abstract B foo274(); + void bar274(A a){ + baz274(a.foo274()); + } + + + void baz275(B a) {} + abstract B foo275(); + void bar275(A a){ + baz275(a.foo275()); + } + + + void baz276(B a) {} + abstract B foo276(); + void bar276(A a){ + baz276(a.foo276()); + } + + + void baz277(B a) {} + abstract B foo277(); + void bar277(A a){ + baz277(a.foo277()); + } + + + void baz278(B a) {} + abstract B foo278(); + void bar278(A a){ + baz278(a.foo278()); + } + + + void baz279(B a) {} + abstract B foo279(); + void bar279(A a){ + baz279(a.foo279()); + } + + + void baz280(B a) {} + abstract B foo280(); + void bar280(A a){ + baz280(a.foo280()); + } + + + void baz281(B a) {} + abstract B foo281(); + void bar281(A a){ + baz281(a.foo281()); + } + + + void baz282(B a) {} + abstract B foo282(); + void bar282(A a){ + baz282(a.foo282()); + } + + + void baz283(B a) {} + abstract B foo283(); + void bar283(A a){ + baz283(a.foo283()); + } + + + void baz284(B a) {} + abstract B foo284(); + void bar284(A a){ + baz284(a.foo284()); + } + + + void baz285(B a) {} + abstract B foo285(); + void bar285(A a){ + baz285(a.foo285()); + } + + + void baz286(B a) {} + abstract B foo286(); + void bar286(A a){ + baz286(a.foo286()); + } + + + void baz287(B a) {} + abstract B foo287(); + void bar287(A a){ + baz287(a.foo287()); + } + + + void baz288(B a) {} + abstract B foo288(); + void bar288(A a){ + baz288(a.foo288()); + } + + + void baz289(B a) {} + abstract B foo289(); + void bar289(A a){ + baz289(a.foo289()); + } + + + void baz290(B a) {} + abstract B foo290(); + void bar290(A a){ + baz290(a.foo290()); + } + + + void baz291(B a) {} + abstract B foo291(); + void bar291(A a){ + baz291(a.foo291()); + } + + + void baz292(B a) {} + abstract B foo292(); + void bar292(A a){ + baz292(a.foo292()); + } + + + void baz293(B a) {} + abstract B foo293(); + void bar293(A a){ + baz293(a.foo293()); + } + + + void baz294(B a) {} + abstract B foo294(); + void bar294(A a){ + baz294(a.foo294()); + } + + + void baz295(B a) {} + abstract B foo295(); + void bar295(A a){ + baz295(a.foo295()); + } + + + void baz296(B a) {} + abstract B foo296(); + void bar296(A a){ + baz296(a.foo296()); + } + + + void baz297(B a) {} + abstract B foo297(); + void bar297(A a){ + baz297(a.foo297()); + } + + + void baz298(B a) {} + abstract B foo298(); + void bar298(A a){ + baz298(a.foo298()); + } + + + void baz299(B a) {} + abstract B foo299(); + void bar299(A a){ + baz299(a.foo299()); + } + + + void baz300(B a) {} + abstract B foo300(); + void bar300(A a){ + baz300(a.foo300()); + } + + /* + //generation method + public static void main(String[] args) { + String prefix = "class B {}\n" + + "abstract class A {\n"; + String template = " void baz$N$(B<$K1$, $K2$> a) {}\n" + + " abstract B<$T1$,$T2$> foo$N$();\n" + + " void bar$N$(A<$A1$> a){\n" + + " baz$N$(a.foo$N$());\n" + + " }\n"; + String suffix = "}"; + + String[] k = {"K", "? extends K", "? super K", "?"}; + String[] t = {"T", "? extends T", "? super T", "?"}; + String[] a = {"? extends T", "? super T", "?"}; + + System.out.println(prefix); + int n = 1; + for (int ki = 0; ki < k.length; ki++) { + String k1 = k[ki]; + for (int kki = ki; kki < k.length; kki++) { + String k2 = k[kki]; + for (int i = 0; i < t.length; i++) { + String t1 = t[i]; + for (int it = i; it < t.length; it++) { + String t2 = t[it]; + for (String a1 : a) { + System.out.println(); + System.out.println( + template.replaceAll("\\$K1\\$", k1) + .replaceAll("\\$K2\\$", k2) + .replaceAll("\\$T1\\$", t1) + .replaceAll("\\$T2\\$", t2) + .replaceAll("\\$A1\\$", a1) + .replaceAll("\\$N\\$", String.valueOf(n++))); + } + } + } + } + } + System.out.println(suffix); + }*/ +} diff --git a/platform/platform-tests/testData/codeStyle/autodetect/bigFileWithIndent2.java b/java/java-tests/testData/psi/autodetect/bigFileWithIndent2.java similarity index 100% rename from platform/platform-tests/testData/codeStyle/autodetect/bigFileWithIndent2.java rename to java/java-tests/testData/psi/autodetect/bigFileWithIndent2.java diff --git a/platform/platform-tests/testData/codeStyle/autodetect/bigFileWithIndent4.java b/java/java-tests/testData/psi/autodetect/bigFileWithIndent4.java similarity index 100% rename from platform/platform-tests/testData/codeStyle/autodetect/bigFileWithIndent4.java rename to java/java-tests/testData/psi/autodetect/bigFileWithIndent4.java diff --git a/platform/platform-tests/testData/codeStyle/autodetect/bigFileWithIndent8.java b/java/java-tests/testData/psi/autodetect/bigFileWithIndent8.java similarity index 100% rename from platform/platform-tests/testData/codeStyle/autodetect/bigFileWithIndent8.java rename to java/java-tests/testData/psi/autodetect/bigFileWithIndent8.java diff --git a/platform/platform-tests/testData/codeStyle/autodetect/fileWithTabs.java b/java/java-tests/testData/psi/autodetect/fileWithTabs.java similarity index 100% rename from platform/platform-tests/testData/codeStyle/autodetect/fileWithTabs.java rename to java/java-tests/testData/psi/autodetect/fileWithTabs.java diff --git a/platform/platform-tests/testData/codeStyle/autodetect/manyComments.java b/java/java-tests/testData/psi/autodetect/manyComments.java similarity index 100% rename from platform/platform-tests/testData/codeStyle/autodetect/manyComments.java rename to java/java-tests/testData/psi/autodetect/manyComments.java diff --git a/platform/platform-tests/testData/codeStyle/autodetect/manyZeroIndents.java b/java/java-tests/testData/psi/autodetect/manyZeroIndents.java similarity index 100% rename from platform/platform-tests/testData/codeStyle/autodetect/manyZeroIndents.java rename to java/java-tests/testData/psi/autodetect/manyZeroIndents.java diff --git a/platform/platform-tests/testData/codeStyle/autodetect/manyZeroRelativeIndent.java b/java/java-tests/testData/psi/autodetect/manyZeroRelativeIndent.java similarity index 100% rename from platform/platform-tests/testData/codeStyle/autodetect/manyZeroRelativeIndent.java rename to java/java-tests/testData/psi/autodetect/manyZeroRelativeIndent.java diff --git a/platform/platform-tests/testData/codeStyle/autodetect/noIndentsUseLanguageSpecificSettings.java b/java/java-tests/testData/psi/autodetect/noIndentsUseLanguageSpecificSettings.java similarity index 100% rename from platform/platform-tests/testData/codeStyle/autodetect/noIndentsUseLanguageSpecificSettings.java rename to java/java-tests/testData/psi/autodetect/noIndentsUseLanguageSpecificSettings.java diff --git a/platform/platform-tests/testData/codeStyle/autodetect/noZeroIndentsInStats.java b/java/java-tests/testData/psi/autodetect/noZeroIndentsInStats.java similarity index 100% rename from platform/platform-tests/testData/codeStyle/autodetect/noZeroIndentsInStats.java rename to java/java-tests/testData/psi/autodetect/noZeroIndentsInStats.java diff --git a/platform/platform-tests/testData/codeStyle/autodetect/simpleIndent.java b/java/java-tests/testData/psi/autodetect/simpleIndent.java similarity index 100% rename from platform/platform-tests/testData/codeStyle/autodetect/simpleIndent.java rename to java/java-tests/testData/psi/autodetect/simpleIndent.java diff --git a/platform/platform-tests/testData/codeStyle/autodetect/smallFileWithIndent8.java b/java/java-tests/testData/psi/autodetect/smallFileWithIndent8.java similarity index 100% rename from platform/platform-tests/testData/codeStyle/autodetect/smallFileWithIndent8.java rename to java/java-tests/testData/psi/autodetect/smallFileWithIndent8.java diff --git a/platform/platform-tests/testData/codeStyle/autodetect/smallFileWithTabs.java b/java/java-tests/testData/psi/autodetect/smallFileWithTabs.java similarity index 100% rename from platform/platform-tests/testData/codeStyle/autodetect/smallFileWithTabs.java rename to java/java-tests/testData/psi/autodetect/smallFileWithTabs.java diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlightingGenerated8Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlightingGenerated8Test.java index 168ee299af61..42f50a3adb75 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlightingGenerated8Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlightingGenerated8Test.java @@ -37,6 +37,10 @@ public class GenericsHighlightingGenerated8Test extends LightDaemonAnalyzerTestC doTest(); } + public void _testUnrelatedClassesExtendsTypeParams() throws Exception { + doTest(); + } + private void doTest() { LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_8); IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), myTestRootDisposable); diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DefaultFileTemplateUsageInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DefaultFileTemplateUsageInspectionTest.java index 87c1cdf58390..1fa60554f971 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/DefaultFileTemplateUsageInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/DefaultFileTemplateUsageInspectionTest.java @@ -34,8 +34,4 @@ public class DefaultFileTemplateUsageInspectionTest extends LightCodeInsightFixt myFixture.enableInspections(new DefaultFileTemplateUsageInspection()); myFixture.testHighlighting(true, false, true, getTestName(false) + ".java"); } - - public void testWtf() throws Exception { - - } } diff --git a/java/java-tests/testSrc/com/intellij/psi/autodetect/JavaAutoDetectIndentTest.java b/java/java-tests/testSrc/com/intellij/psi/autodetect/JavaAutoDetectIndentTest.java index 5deb2f990b93..f1b90dced63d 100644 --- a/java/java-tests/testSrc/com/intellij/psi/autodetect/JavaAutoDetectIndentTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/autodetect/JavaAutoDetectIndentTest.java @@ -16,7 +16,14 @@ package com.intellij.psi.autodetect; import com.intellij.JavaTestUtil; +import com.intellij.openapi.fileTypes.PlainTextLanguage; +import com.intellij.psi.codeStyle.CommonCodeStyleSettings; +import com.intellij.psi.codeStyle.autodetect.LineIndentInfo; +import com.intellij.psi.codeStyle.autodetect.LineIndentInfoBuilder; import org.jetbrains.annotations.NotNull; +import org.junit.Assert; + +import java.util.List; public class JavaAutoDetectIndentTest extends AbstractIndentAutoDetectionTest { @@ -49,4 +56,105 @@ public class JavaAutoDetectIndentTest extends AbstractIndentAutoDetectionTest { doTestIndentSize(4); } + public void testBigFileWithIndent2() { + doTestIndentSize(2); + } + + public void testBigFileWithIndent8() { + doTestIndentSize(8); + } + + public void testBigFileWithIndent4() { + doTestIndentSize(4); + } + + public void testFileWithTabs() { + doTestTabsUsed(); + } + + public void testSimpleIndent() { + doTestMaxUsedIndent(2, 6); + } + + public void testManyComments() { + doTestMaxUsedIndent(2, 6); + } + + public void testManyZeroRelativeIndent() { + doTestMaxUsedIndent(2); + } + + public void testSmallFileWithIndent8() { + doTestMaxUsedIndent(8); + } + + public void testSmallFileWithTabs() { + doTestTabsUsed(); + } + + public void testNoIndentsUseLanguageSpecificSettings() { + CommonCodeStyleSettings.IndentOptions options = new CommonCodeStyleSettings.IndentOptions(); + options.USE_TAB_CHARACTER = true; + + doTestTabsUsed(options); + } + + public void testSpacesToNumbers() throws Exception { + String text = " i\n" + + " a\n" + + " t\n"; + doTestLineToIndentMapping(text, 5, 4, 10); + } + + public void testEmptyLines() throws Exception { + doTestLineToIndentMapping(" \n\n\n", -1, -1, -1); + } + + public void testSpacesInSimpleClass() { + doTestLineToIndentMapping( + "public class A {\n" + + "\n" + + " public void test() {\n" + + " int a = 2;\n" + + " }\n" + + "\n" + + " public void a() {\n" + + " }\n" + + "}", + 0, -1, 4, 6, 4, -1, 4, 4, 0 + ); + } + + public void testComplexIndents() { + doTestLineToIndentMapping( + "class Test\n" + + "{\n" + + " int a;\n" + + " int b;\n" + + " \n" + + " public void test() {\n" + + " int c;\n" + + " }\n" + + " \n" + + " public void run() {\n" + + " Runnable runnable = new Runnable() {\n" + + " @Override\n" + + " public void run() {\n" + + " System.out.println(\"Hello!\");\n" + + " }\n" + + " };\n" + + " }\n" + + "}", + 0, 0, 2, 2, -1, 2, 4, 2, -1, 2, 4, 6, 6, 8, 6, 4, 2, 0 + ); + } + + private static void doTestLineToIndentMapping(@NotNull CharSequence text, int... spacesForLine) { + List list = new LineIndentInfoBuilder(text, PlainTextLanguage.INSTANCE).build(); + Assert.assertEquals(list.size(), spacesForLine.length); + for (int i = 0; i < spacesForLine.length; i++) { + int indentSize = list.get(i).getIndentSize(); + Assert.assertEquals("Mismatch on line " + i, spacesForLine[i], indentSize); + } + } } diff --git a/java/manifest/manifest.iml b/java/manifest/manifest.iml index 1c394ddffd93..212982b8ac5c 100644 --- a/java/manifest/manifest.iml +++ b/java/manifest/manifest.iml @@ -17,6 +17,6 @@ + - - + \ No newline at end of file diff --git a/java/manifest/src/org/jetbrains/lang/manifest/ManifestBundle.properties b/java/manifest/src/org/jetbrains/lang/manifest/ManifestBundle.properties index 845c88d11741..7fe98d7431e7 100644 --- a/java/manifest/src/org/jetbrains/lang/manifest/ManifestBundle.properties +++ b/java/manifest/src/org/jetbrains/lang/manifest/ManifestBundle.properties @@ -1,4 +1,3 @@ -manifest.unexpected.token=Unexpected token manifest.colon.expected=':' expected manifest.whitespace.expected=Whitespace expected manifest.header.expected=Header expected @@ -11,4 +10,6 @@ inspection.group=Manifest inspection.newline.message=Manifest file doesn't end with a final newline inspection.newline.fix=Add newline inspection.header.message=Header name is unknown or spelled incorrectly -inspection.header.fix=Change to ''{0}'' +inspection.header.ui.label=Custom headers: +inspection.header.rename.fix=Change to ''{0}'' +inspection.header.remember.fix=Add ''{0}'' to custom headers diff --git a/java/manifest/src/org/jetbrains/lang/manifest/header/HeaderNameMatch.java b/java/manifest/src/org/jetbrains/lang/manifest/header/HeaderNameMatch.java deleted file mode 100644 index 8ab3669ac539..000000000000 --- a/java/manifest/src/org/jetbrains/lang/manifest/header/HeaderNameMatch.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2007-2009, Osmorc Development Team - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * * Neither the name of 'Osmorc Development Team' nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.jetbrains.lang.manifest.header; - -import org.jetbrains.annotations.NotNull; - -/** - * A match describes how good a header known to a particular header provider matches a given header. - * The name of the given header may contain typos and so there may be no perfect match. A perfect match will - * have a Levenshtein distance of 0. Worse matches will have greater Levenshtein distances. - * - * @author Robert F. Beeger (robert@beeger.net) - */ -public class HeaderNameMatch implements Comparable { - private final int myDistance; - private final String myHeaderName; - - public HeaderNameMatch(int distance, @NotNull String headerName) { - myDistance = distance; - myHeaderName = headerName; - } - - public int getDistance() { - return myDistance; - } - - public String getHeaderName() { - return myHeaderName; - } - - /** - * Matches are compared based on their distance. - */ - @Override - public int compareTo(@NotNull HeaderNameMatch o) { - return getDistance() - o.getDistance(); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - HeaderNameMatch that = (HeaderNameMatch)o; - - return myDistance == that.myDistance && myHeaderName.equals(that.myHeaderName); - } - - @Override - public int hashCode() { - int result = myDistance; - result = 31 * result + myHeaderName.hashCode(); - return result; - } -} diff --git a/java/manifest/src/org/jetbrains/lang/manifest/header/HeaderParserRepository.java b/java/manifest/src/org/jetbrains/lang/manifest/header/HeaderParserRepository.java index 27b80df35e1e..caab71dbf65a 100644 --- a/java/manifest/src/org/jetbrains/lang/manifest/header/HeaderParserRepository.java +++ b/java/manifest/src/org/jetbrains/lang/manifest/header/HeaderParserRepository.java @@ -27,19 +27,17 @@ package org.jetbrains.lang.manifest.header; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.util.NotNullLazyValue; -import com.intellij.openapi.util.text.LevenshteinDistance; import com.intellij.psi.PsiReference; import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.text.CaseInsensitiveStringHashingStrategy; +import gnu.trove.THashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.lang.manifest.psi.Header; import org.jetbrains.lang.manifest.psi.HeaderValuePart; -import java.util.Collection; import java.util.Map; import java.util.Set; -import java.util.TreeSet; /** * @author Robert F. Beeger (robert@beeger.net) @@ -53,7 +51,7 @@ public class HeaderParserRepository { @NotNull @Override protected Map compute() { - Map map = ContainerUtil.newHashMap(); + Map map = new THashMap(CaseInsensitiveStringHashingStrategy.INSTANCE); for (HeaderParserProvider provider : Extensions.getExtensions(HeaderParserProvider.EP_NAME)) { map.putAll(provider.getHeaderParsers()); } @@ -66,23 +64,6 @@ public class HeaderParserRepository { return myParsers.getValue().get(headerName); } - @NotNull - public Collection getMatches(@NotNull String headerName) { - HeaderParser parser = myParsers.getValue().get(headerName); - if (parser != null) { - return ContainerUtil.emptyList(); - } - - LevenshteinDistance distance = new LevenshteinDistance(); - Set result = new TreeSet(); - for (Map.Entry entry : myParsers.getValue().entrySet()) { - String otherName = entry.getKey(); - int dist = distance.calculateMetrics(headerName, otherName); - result.add(new HeaderNameMatch(dist, otherName)); - } - return result; - } - @NotNull public Set getAllHeaderNames() { return myParsers.getValue().keySet(); diff --git a/java/manifest/src/org/jetbrains/lang/manifest/highlighting/AbstractManifestQuickFix.java b/java/manifest/src/org/jetbrains/lang/manifest/highlighting/AbstractManifestQuickFix.java new file mode 100644 index 000000000000..c548ff918d1a --- /dev/null +++ b/java/manifest/src/org/jetbrains/lang/manifest/highlighting/AbstractManifestQuickFix.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.lang.manifest.highlighting; + +import com.intellij.codeInspection.LocalQuickFixOnPsiElement; +import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.lang.manifest.ManifestBundle; + +public abstract class AbstractManifestQuickFix extends LocalQuickFixOnPsiElement { + protected AbstractManifestQuickFix(@NotNull PsiElement element) { + super(element); + } + + @NotNull + @Override + public final String getFamilyName() { + return ManifestBundle.message("inspection.group"); + } +} diff --git a/java/manifest/src/org/jetbrains/lang/manifest/highlighting/MissingFinalNewlineInspection.java b/java/manifest/src/org/jetbrains/lang/manifest/highlighting/MissingFinalNewlineInspection.java index 60bfce5fd13c..3bdf451f8623 100644 --- a/java/manifest/src/org/jetbrains/lang/manifest/highlighting/MissingFinalNewlineInspection.java +++ b/java/manifest/src/org/jetbrains/lang/manifest/highlighting/MissingFinalNewlineInspection.java @@ -61,7 +61,7 @@ public class MissingFinalNewlineInspection extends LocalInspectionTool { return null; } - private static class AddNewlineQuickFix extends LocalQuickFixOnPsiElement { + private static class AddNewlineQuickFix extends AbstractManifestQuickFix { private AddNewlineQuickFix(Section section) { super(section); } @@ -72,12 +72,6 @@ public class MissingFinalNewlineInspection extends LocalInspectionTool { return ManifestBundle.message("inspection.newline.fix"); } - @NotNull - @Override - public String getFamilyName() { - return ManifestBundle.message("inspection.group"); - } - @Override public void invoke(@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement) { PsiElement lastChild = startElement.getLastChild(); diff --git a/java/manifest/src/org/jetbrains/lang/manifest/highlighting/MisspelledHeaderInspection.java b/java/manifest/src/org/jetbrains/lang/manifest/highlighting/MisspelledHeaderInspection.java index 75f41764fe5c..98065392b352 100644 --- a/java/manifest/src/org/jetbrains/lang/manifest/highlighting/MisspelledHeaderInspection.java +++ b/java/manifest/src/org/jetbrains/lang/manifest/highlighting/MisspelledHeaderInspection.java @@ -26,25 +26,42 @@ package org.jetbrains.lang.manifest.highlighting; import com.intellij.codeInspection.*; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.profile.codeInspection.InspectionProfileManager; +import com.intellij.profile.codeInspection.InspectionProjectProfileManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.PsiFile; +import com.intellij.spellchecker.engine.Suggestion; +import com.intellij.ui.DocumentAdapter; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.text.CaseInsensitiveStringHashingStrategy; +import com.intellij.util.text.EditDistance; +import com.intellij.util.xmlb.annotations.AbstractCollection; +import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.lang.manifest.ManifestBundle; -import org.jetbrains.lang.manifest.header.HeaderNameMatch; import org.jetbrains.lang.manifest.header.HeaderParserRepository; import org.jetbrains.lang.manifest.psi.Header; -import java.util.Collection; +import javax.swing.*; +import javax.swing.event.DocumentEvent; +import java.awt.*; +import java.util.*; import java.util.List; /** * @author Robert F. Beeger (robert@beeger.net) */ public class MisspelledHeaderInspection extends LocalInspectionTool { - private static final int MAX_SUGGESTIONS = 10; + private static final int MAX_SUGGESTIONS = 5; + private static final int MAX_DISTANCE = 4; + private static final int TYPO_DISTANCE = 2; - private HeaderParserRepository myRepository; + @AbstractCollection(surroundWithTag = false, elementTag = "header") + public final Set CUSTOM_HEADERS = new THashSet(CaseInsensitiveStringHashingStrategy.INSTANCE); + + private final HeaderParserRepository myRepository; public MisspelledHeaderInspection() { myRepository = HeaderParserRepository.getInstance(); @@ -58,49 +75,117 @@ public class MisspelledHeaderInspection extends LocalInspectionTool { public void visitElement(PsiElement element) { if (element instanceof Header) { Header header = (Header)element; - Collection matches = myRepository.getMatches(header.getName()); - if (!matches.isEmpty()) { - List fixes = ContainerUtil.newArrayListWithCapacity(MAX_SUGGESTIONS); - for (HeaderNameMatch match : matches) { - fixes.add(new HeaderNameSpellingQuickFix(header, match)); - if (fixes.size() == MAX_SUGGESTIONS) { - break; - } - } - holder.registerProblem( - header.getNameElement(), ManifestBundle.message("inspection.header.message"), - ProblemHighlightType.GENERIC_ERROR_OR_WARNING, fixes.toArray(new HeaderNameSpellingQuickFix[fixes.size()]) - ); + String headerName = header.getName(); + + SortedSet matches = new TreeSet(); + addMatches(headerName, CUSTOM_HEADERS, matches); + addMatches(headerName, myRepository.getAllHeaderNames(), matches); + + Suggestion bestMatch = ContainerUtil.getFirstItem(matches); + if (bestMatch != null && headerName.equals(bestMatch.getWord())) { + return; + } + + List fixes = new ArrayList(); + for (Suggestion match : matches) { + fixes.add(new HeaderRenameQuickFix(header, match.getWord())); + if (fixes.size() == MAX_SUGGESTIONS) break; + } + if (bestMatch == null || bestMatch.getMetrics() > TYPO_DISTANCE) { + fixes.add(new CustomHeaderQuickFix(header, CUSTOM_HEADERS)); + } + holder.registerProblem( + header.getNameElement(), ManifestBundle.message("inspection.header.message"), + ProblemHighlightType.GENERIC_ERROR_OR_WARNING, fixes.toArray(new LocalQuickFix[fixes.size()]) + ); + } + } + + private void addMatches(String headerName, Collection headers, SortedSet matches) { + for (String candidate : headers) { + int distance = EditDistance.optimalAlignment(headerName, candidate, false); + if (distance <= MAX_DISTANCE) { + matches.add(new Suggestion(candidate, distance)); } } } }; } - private static class HeaderNameSpellingQuickFix implements LocalQuickFix { - private final Header myHeader; + @Override + public JComponent createOptionsPanel() { + return new OptionsPanel(CUSTOM_HEADERS); + } + + private static class OptionsPanel extends JPanel { + public OptionsPanel(final Set headers) { + super(new BorderLayout(5, 5)); + + add(new JLabel(ManifestBundle.message("inspection.header.ui.label")), BorderLayout.NORTH); + + final JTextArea area = new JTextArea(""); + add(area, BorderLayout.CENTER); + if (!headers.isEmpty()) { + area.setText(StringUtil.join(new TreeSet(headers), "\n")); + } + + area.getDocument().addDocumentListener(new DocumentAdapter() { + @Override + protected void textChanged(DocumentEvent e) { + headers.clear(); + for (String line : StringUtil.split(area.getText(), "\n")) { + String header = line.trim(); + if (!header.isEmpty()) { + headers.add(header); + } + } + } + }); + } + } + + private static class HeaderRenameQuickFix extends AbstractManifestQuickFix { private final String myNewName; - private HeaderNameSpellingQuickFix(Header header, HeaderNameMatch match) { - myHeader = header; - myNewName = match.getHeaderName(); + private HeaderRenameQuickFix(Header header, String newName) { + super(header); + myNewName = newName; } @NotNull @Override - public String getName() { - return ManifestBundle.message("inspection.header.fix", myNewName); + public String getText() { + return ManifestBundle.message("inspection.header.rename.fix", myNewName); + } + + @Override + public void invoke(@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement) { + ((Header)startElement).setName(myNewName); + } + } + + private static class CustomHeaderQuickFix extends AbstractManifestQuickFix { + private final String myHeaderName; + private final Collection myHeaders; + + private CustomHeaderQuickFix(Header header, Collection headers) { + super(header); + myHeaderName = header.getName(); + myHeaders = headers; } @NotNull @Override - public String getFamilyName() { - return ManifestBundle.message("inspection.group"); + public String getText() { + return ManifestBundle.message("inspection.header.remember.fix", myHeaderName); } @Override - public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { - myHeader.setName(myNewName); + public void invoke(@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement) { + myHeaders.add(myHeaderName); + + InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile(); + InspectionProfileManager.getInstance().fireProfileChanged(profile); } } } diff --git a/java/manifest/test/org/jetbrains/lang/manifest/ManifestPsiTest.java b/java/manifest/test/org/jetbrains/lang/manifest/ManifestPsiTest.java index 64d8fc27b1ed..7a82126508ee 100644 --- a/java/manifest/test/org/jetbrains/lang/manifest/ManifestPsiTest.java +++ b/java/manifest/test/org/jetbrains/lang/manifest/ManifestPsiTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package org.jetbrains.lang.manifest; import com.intellij.psi.PsiFile; import com.intellij.testFramework.LightIdeaTestCase; import com.intellij.testFramework.LightPlatformTestCase; -import junit.framework.Assert; import org.jetbrains.annotations.Nullable; import org.jetbrains.lang.manifest.psi.Header; import org.jetbrains.lang.manifest.psi.HeaderValue; @@ -27,16 +26,16 @@ import org.jetbrains.lang.manifest.psi.ManifestFile; public class ManifestPsiTest extends LightIdeaTestCase { public void testFile() { ManifestFile file = createFile(""); - Assert.assertEquals(0, file.getSections().size()); - Assert.assertNull(file.getMainSection()); - Assert.assertEquals(0, file.getHeaders().size()); + assertEquals(0, file.getSections().size()); + assertNull(file.getMainSection()); + assertEquals(0, file.getHeaders().size()); file = createFile("Header: value\n\nAnother-Header: another value\n"); - Assert.assertEquals(2, file.getSections().size()); - Assert.assertNotNull(file.getMainSection()); - Assert.assertEquals(1, file.getHeaders().size()); - Assert.assertNotNull(file.getHeader("Header")); - Assert.assertNull(file.getHeader("Another-Header")); + assertEquals(2, file.getSections().size()); + assertNotNull(file.getMainSection()); + assertEquals(1, file.getHeaders().size()); + assertNotNull(file.getHeader("Header")); + assertNull(file.getHeader("Another-Header")); } public void testHeader() { @@ -54,15 +53,15 @@ public class ManifestPsiTest extends LightIdeaTestCase { private static void assertHeaderValue(ManifestFile file, String name, @Nullable String expected) { Header header = file.getHeader(name); - Assert.assertNotNull(header); + assertNotNull(header); HeaderValue value = header.getHeaderValue(); if (expected == null) { - Assert.assertNull(value); + assertNull(value); } else { - Assert.assertNotNull(value); - Assert.assertEquals(expected, value.getUnwrappedText()); + assertNotNull(value); + assertEquals(expected, value.getUnwrappedText()); } } } diff --git a/java/manifest/test/org/jetbrains/lang/manifest/MisspelledHeaderInspectionTest.java b/java/manifest/test/org/jetbrains/lang/manifest/MisspelledHeaderInspectionTest.java index c86149f15ca4..9ef828aefd61 100644 --- a/java/manifest/test/org/jetbrains/lang/manifest/MisspelledHeaderInspectionTest.java +++ b/java/manifest/test/org/jetbrains/lang/manifest/MisspelledHeaderInspectionTest.java @@ -19,25 +19,61 @@ import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; import org.jetbrains.lang.manifest.highlighting.MisspelledHeaderInspection; +import java.util.Collections; import java.util.List; public class MisspelledHeaderInspectionTest extends LightCodeInsightFixtureTestCase { - @Override - protected void setUp() throws Exception { - super.setUp(); - myFixture.enableInspections(new MisspelledHeaderInspection()); + public void testNoProblem() { + doTest("Manifest-Version: 1.0", 0); } - public void testNoProblem() { - myFixture.configureByText(ManifestFileTypeFactory.MANIFEST, "Manifest-Version: 1.0\n"); - assertEquals(0, myFixture.getAvailableIntentions().size()); + public void testMixedCase() { + doTest("manifest-version: 1.0", 1); + } + + public void testMissedDash() { + doTest("ManifestVersion: 1.0", 1); + } + + public void testMisspelled() { + doTest("MainFestVersion: 1.0", 1); + } + + public void testTotallyIncorrect() { + doTest("some_totally_impossible_header: -", 0); } public void testFix() { + myFixture.enableInspections(new MisspelledHeaderInspection()); myFixture.configureByText(ManifestFileTypeFactory.MANIFEST, "ManifestVersion: 1.0\n"); List intentions = myFixture.filterAvailableIntentions("Change to"); - assertTrue(intentions.size() > 0); + assertEquals(1, intentions.size()); myFixture.launchAction(intentions.get(0)); myFixture.checkResult("Manifest-Version: 1.0\n"); } + + public void testCustomHeader() { + MisspelledHeaderInspection inspection = new MisspelledHeaderInspection(); + inspection.CUSTOM_HEADERS.add("Custom-Header"); + myFixture.enableInspections(inspection); + myFixture.configureByText(ManifestFileTypeFactory.MANIFEST, "Custom-Header: -\n"); + myFixture.checkHighlighting(); + } + + public void testCustomHeaderFix() { + MisspelledHeaderInspection inspection = new MisspelledHeaderInspection(); + myFixture.enableInspections(inspection); + myFixture.configureByText(ManifestFileTypeFactory.MANIFEST, "Custom-Header: -\n"); + List intentions = myFixture.filterAvailableIntentions("Add "); + assertEquals(1, intentions.size()); + myFixture.launchAction(intentions.get(0)); + assertEquals(Collections.singleton("Custom-Header"), inspection.CUSTOM_HEADERS); + } + + private void doTest(String text, int expected) { + myFixture.enableInspections(new MisspelledHeaderInspection()); + myFixture.configureByText(ManifestFileTypeFactory.MANIFEST, text + "\n"); + myFixture.checkHighlighting(); + assertEquals(expected, myFixture.filterAvailableIntentions("Change to").size()); + } } diff --git a/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaReplaceHandler.java b/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaReplaceHandler.java index b95b01fe08d0..2ae17d8756a9 100644 --- a/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaReplaceHandler.java +++ b/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaReplaceHandler.java @@ -269,7 +269,7 @@ public class JavaReplaceHandler extends StructuralReplaceHandler { if (firstChild instanceof PsiModifierList) { final PsiModifierList modifierList = (PsiModifierList)firstChild; for (PsiElement child : modifierList.getChildren()) { - elementParent.add(child); + elementParent.addBefore(child, elementToReplace); } } } diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java index 7535dee36786..8ed53b35f830 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java @@ -81,7 +81,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel, private final ExternalInfo myExternalInfo = new ExternalInfo(); protected InspectionProfileImpl mySource; private Map myTools = new THashMap(); - private Map myDisplayLevelMap; + private volatile Map myDisplayLevelMap; @Attribute("is_locked") private boolean myLockedProfile; private final InspectionProfileImpl myBaseProfile; @@ -933,10 +933,17 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel, private Map getDisplayLevelMap() { if (myBaseProfile == null) return null; if (myDisplayLevelMap == null) { - initInspectionTools(null); - myDisplayLevelMap = new TreeMap(); - for (String toolId : myTools.keySet()) { - myDisplayLevelMap.put(toolId, toolSettingsAreEqual(toolId, myBaseProfile, this)); + // Synchronizing on myExternalInfo as initInspectionTools() synchronizes on it internally. + synchronized (myExternalInfo) { + if (myDisplayLevelMap == null) { + initInspectionTools(null); + TreeMap map = new TreeMap(); + for (String toolId : myTools.keySet()) { + map.put(toolId, toolSettingsAreEqual(toolId, myBaseProfile, this)); + } + myDisplayLevelMap = map; + return map; + } } } return myDisplayLevelMap; diff --git a/platform/analysis-impl/src/com/intellij/packageDependencies/BackwardDependenciesBuilder.java b/platform/analysis-impl/src/com/intellij/packageDependencies/BackwardDependenciesBuilder.java index b48cd3a6d092..828096c4930f 100644 --- a/platform/analysis-impl/src/com/intellij/packageDependencies/BackwardDependenciesBuilder.java +++ b/platform/analysis-impl/src/com/intellij/packageDependencies/BackwardDependenciesBuilder.java @@ -24,11 +24,14 @@ import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.ProjectFileIndex; +import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.util.Computable; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import com.intellij.psi.PsiRecursiveElementVisitor; +import com.intellij.util.Processor; import org.jetbrains.annotations.Nullable; import java.util.HashSet; @@ -85,35 +88,45 @@ public class BackwardDependenciesBuilder extends DependenciesBuilder { psiManager.startBatchFilesProcessingMode(); try { final int fileCount = getScope().getFileCount(); - getScope().accept(new PsiRecursiveElementVisitor() { - @Override public void visitFile(final PsiFile file) { + final boolean includeTestSource = getScope().isIncludeTestSource(); + final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(getProject()).getFileIndex(); + getScope().accept(new Processor() { + @Override + public boolean process(final VirtualFile virtualFile) { + if (!includeTestSource && fileIndex.isInTestSourceContent(virtualFile)) { + return true; + } ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); if (indicator != null) { if (indicator.isCanceled()) { throw new ProcessCanceledException(); } indicator.setText(AnalysisScopeBundle.message("package.dependencies.progress.text")); - final VirtualFile virtualFile = file.getVirtualFile(); - if (virtualFile != null) { - indicator.setText2(getRelativeToProjectPath(virtualFile)); - } + indicator.setText2(getRelativeToProjectPath(virtualFile)); if (fileCount > 0) { indicator.setFraction(((double)++myFileCount) / myTotalFileCount); } } - final Map> dependencies = builder.getDependencies(); - for (final PsiFile psiFile : dependencies.keySet()) { - if (dependencies.get(psiFile).contains(file)) { - Set fileDeps = getDependencies().get(file); - if (fileDeps == null) { - fileDeps = new HashSet(); - getDependencies().put(file, fileDeps); + ApplicationManager.getApplication().runReadAction(new Runnable() { + public void run() { + final PsiFile file = psiManager.findFile(virtualFile); + if (file != null) { + final Map> dependencies = builder.getDependencies(); + for (final PsiFile psiFile : dependencies.keySet()) { + if (dependencies.get(psiFile).contains(file)) { + Set fileDeps = getDependencies().get(file); + if (fileDeps == null) { + fileDeps = new HashSet(); + getDependencies().put(file, fileDeps); + } + fileDeps.add(psiFile); + } + } + psiManager.dropResolveCaches(); } - fileDeps.add(psiFile); } - } - psiManager.dropResolveCaches(); - InjectedLanguageManager.getInstance(file.getProject()).dropFileCaches(file); + }); + return true; } }); } diff --git a/platform/analysis-impl/src/com/intellij/packageDependencies/ForwardDependenciesBuilder.java b/platform/analysis-impl/src/com/intellij/packageDependencies/ForwardDependenciesBuilder.java index dd0dbac4ff14..f4078c1a2829 100644 --- a/platform/analysis-impl/src/com/intellij/packageDependencies/ForwardDependenciesBuilder.java +++ b/platform/analysis-impl/src/com/intellij/packageDependencies/ForwardDependenciesBuilder.java @@ -138,7 +138,8 @@ public class ForwardDependenciesBuilder extends DependenciesBuilder { (fileIndex.isInContent(virtualFile) || fileIndex.isInLibraryClasses(virtualFile) || fileIndex.isInLibrarySource(virtualFile))) { - found.add(dependencyFile); + final PsiElement navigationElement = dependencyFile.getNavigationElement(); + found.add(navigationElement instanceof PsiFile ? (PsiFile)navigationElement : dependencyFile); } } } diff --git a/platform/built-in-server/src/org/jetbrains/builtInWebServer/BuiltInWebServer.java b/platform/built-in-server/src/org/jetbrains/builtInWebServer/BuiltInWebServer.java index 220279e98509..ce9454b3d657 100644 --- a/platform/built-in-server/src/org/jetbrains/builtInWebServer/BuiltInWebServer.java +++ b/platform/built-in-server/src/org/jetbrains/builtInWebServer/BuiltInWebServer.java @@ -15,6 +15,7 @@ */ package org.jetbrains.builtInWebServer; +import com.google.common.net.InetAddresses; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; @@ -106,7 +107,7 @@ public final class BuiltInWebServer extends HttpRequestHandler { host = host.substring(1, host.length() - 1); } - if (isIpv6 || Character.digit(host.charAt(0), 10) != -1 || host.charAt(0) == ':' || isOwnHostName(host)) { + if (isIpv6 || InetAddresses.isInetAddress(host) || isOwnHostName(host) || host.endsWith(".ngrok.io")) { if (urlDecoder.path().length() < 2) { return false; } diff --git a/platform/core-api/src/com/intellij/openapi/vfs/impl/ArchiveHandler.java b/platform/core-api/src/com/intellij/openapi/vfs/impl/ArchiveHandler.java index 985b2416678f..12cecfb58bff 100644 --- a/platform/core-api/src/com/intellij/openapi/vfs/impl/ArchiveHandler.java +++ b/platform/core-api/src/com/intellij/openapi/vfs/impl/ArchiveHandler.java @@ -44,6 +44,14 @@ public abstract class ArchiveHandler { public final long length; public final long timestamp; + @Deprecated + /** + * Please use the {@link EntryInfo#EntryInfo(ArchiveHandler.EntryInfo, CharSequence, boolean, long, long)} instead + */ + public EntryInfo(EntryInfo parent, @NotNull String shortName, boolean isDirectory, long length, long timestamp) { + this(parent, (CharSequence) shortName, isDirectory, length, timestamp); + } + public EntryInfo(EntryInfo parent, @NotNull CharSequence shortName, boolean isDirectory, long length, long timestamp) { this.parent = parent; this.shortName = shortName; diff --git a/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java index 74354e30a14a..ea6834e5695e 100644 --- a/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java +++ b/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,6 +82,7 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { private boolean myEventsHandling = false; private final boolean myAssertThreading; private volatile boolean myDoingBulkUpdate = false; + private boolean myUpdatingBulkModeStatus; private volatile boolean myAcceptSlashR = false; private boolean myChangeInProgress; private volatile int myBufferSize; @@ -971,12 +972,21 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { // do not fire listeners or otherwise updateStarted() will be called more times than updateFinished() return; } - myDoingBulkUpdate = value; - if (value) { - getPublisher().updateStarted(this); + if (myUpdatingBulkModeStatus) { + throw new IllegalStateException("Detected bulk mode status update from DocumentBulkUpdateListener"); } - else { - getPublisher().updateFinished(this); + myUpdatingBulkModeStatus = true; + try { + myDoingBulkUpdate = value; + if (value) { + getPublisher().updateStarted(this); + } + else { + getPublisher().updateFinished(this); + } + } + finally { + myUpdatingBulkModeStatus = false; } } diff --git a/platform/core-impl/src/com/intellij/openapi/fileEditor/impl/LoadTextUtil.java b/platform/core-impl/src/com/intellij/openapi/fileEditor/impl/LoadTextUtil.java index 1a833a063fe4..9b9ff2e84ff1 100644 --- a/platform/core-impl/src/com/intellij/openapi/fileEditor/impl/LoadTextUtil.java +++ b/platform/core-impl/src/com/intellij/openapi/fileEditor/impl/LoadTextUtil.java @@ -407,7 +407,7 @@ public final class LoadTextUtil { return text; } - throw new IllegalArgumentException("Attempt to load text for binary file which doesn't have a decompiler plugged in: " + file.getPresentableUrl()); + throw new IllegalArgumentException("Attempt to load text for binary file which doesn't have a decompiler plugged in: " + file.getPresentableUrl() + ". File type: " + fileType.getName()); } try { diff --git a/platform/core-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorBase.java b/platform/core-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorBase.java index af8546cb6147..2cf43d397fd4 100644 --- a/platform/core-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorBase.java +++ b/platform/core-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorBase.java @@ -23,6 +23,7 @@ import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.util.UserDataHolderBase; +import com.intellij.ui.mac.foundation.MacUtil; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.DoubleArrayList; import com.intellij.util.containers.Stack; @@ -43,6 +44,7 @@ public class AbstractProgressIndicatorBase extends UserDataHolderBase implements private volatile boolean myFinished; private volatile boolean myIndeterminate; + private volatile Object myMacActivity; private Stack myTextStack; private DoubleArrayList myFractionStack; @@ -68,6 +70,7 @@ public class AbstractProgressIndicatorBase extends UserDataHolderBase implements myText = ""; myFraction = 0; myText2 = ""; + myMacActivity = MacUtil.wakeUpNeo(toString()); myRunning = true; } @@ -82,6 +85,8 @@ public class AbstractProgressIndicatorBase extends UserDataHolderBase implements LOG.assertTrue(myRunning, "stop() should be called only if start() called before"); myRunning = false; myFinished = true; + MacUtil.matrixHasYou(myMacActivity); + myMacActivity = null; } @Override diff --git a/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java b/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java index f8f9ae914f53..1105ac29ab56 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java +++ b/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java @@ -54,7 +54,7 @@ import javax.swing.*; import java.util.*; public abstract class PsiDocumentManagerBase extends PsiDocumentManager implements DocumentListener, DocumentBulkUpdateListener { - protected static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.PsiDocumentManagerImpl"); + static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.PsiDocumentManagerImpl"); private static final Key HARD_REF_TO_DOCUMENT = Key.create("HARD_REFERENCE_TO_DOCUMENT"); private static final Key HARD_REF_TO_PSI = Key.create("HARD_REFERENCE_TO_PSI"); private static final Key> ACTION_AFTER_COMMIT = Key.create("ACTION_AFTER_COMMIT"); @@ -73,11 +73,11 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen private final List myListeners = ContainerUtil.createLockFreeCopyOnWriteList(); private final SmartPointerManagerImpl mySmartPointerManager; - public PsiDocumentManagerBase(@NotNull final Project project, - @NotNull PsiManager psiManager, - @NotNull SmartPointerManager smartPointerManager, - @NotNull MessageBus bus, - @NonNls @NotNull final DocumentCommitProcessor documentCommitProcessor) { + protected PsiDocumentManagerBase(@NotNull final Project project, + @NotNull PsiManager psiManager, + @NotNull SmartPointerManager smartPointerManager, + @NotNull MessageBus bus, + @NonNls @NotNull final DocumentCommitProcessor documentCommitProcessor) { myProject = project; myPsiManager = psiManager; myDocumentCommitProcessor = documentCommitProcessor; @@ -132,7 +132,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen } @Nullable - public FileViewProvider getCachedViewProvider(@NotNull Document document) { + FileViewProvider getCachedViewProvider(@NotNull Document document) { final VirtualFile virtualFile = getVirtualFile(document); if (virtualFile == null) return null; return getCachedViewProvider(virtualFile); @@ -149,7 +149,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen } @Nullable - protected PsiFile getCachedPsiFile(@NotNull VirtualFile virtualFile) { + PsiFile getCachedPsiFile(@NotNull VirtualFile virtualFile) { return ((PsiManagerEx)myPsiManager).getFileManager().getCachedPsiFile(virtualFile); } @@ -543,7 +543,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen public void doPostponedOperationsAndUnblockDocument(@NotNull Document doc) { } - protected void fireDocumentCreated(@NotNull Document document, PsiFile file) { + void fireDocumentCreated(@NotNull Document document, PsiFile file) { for (Listener listener : myListeners) { listener.documentCreated(document, file); } @@ -611,7 +611,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen boolean isBulk = document instanceof DocumentEx && ((DocumentEx)document).isInBulkUpdate(); boolean isRelevant = virtualFile != null && isRelevant(virtualFile); - if (!isBulk && isRelevant) { + if (!isBulk && isRelevant && shouldNotifySmartPointers(virtualFile)) { mySmartPointerManager.fastenBelts(virtualFile, event.getOffset(), null); } @@ -652,7 +652,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen boolean isBulk = document instanceof DocumentEx && ((DocumentEx)document).isInBulkUpdate(); boolean isRelevant = virtualFile != null && isRelevant(virtualFile); - if (!isBulk && isRelevant) { + if (!isBulk && isRelevant && shouldNotifySmartPointers(virtualFile)) { mySmartPointerManager.unfastenBelts(virtualFile, event.getOffset()); } @@ -711,19 +711,20 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen @Override public void updateStarted(@NotNull Document document) { final VirtualFile virtualFile = getVirtualFile(document); - if (virtualFile == null || !isRelevant(virtualFile)) return; - - mySmartPointerManager.fastenBelts(virtualFile, 0, null); + if (virtualFile != null && isRelevant(virtualFile) && shouldNotifySmartPointers(virtualFile)) { + mySmartPointerManager.fastenBelts(virtualFile, 0, null); + } } @Override public void updateFinished(@NotNull Document document) { final VirtualFile virtualFile = getVirtualFile(document); - if (virtualFile == null || !isRelevant(virtualFile)) return; - mySmartPointerManager.unfastenBelts(virtualFile, 0); + if (virtualFile != null && isRelevant(virtualFile) && shouldNotifySmartPointers(virtualFile)) { + mySmartPointerManager.unfastenBelts(virtualFile, 0); + } } - public void handleCommitWithoutPsi(@NotNull Document document) { + void handleCommitWithoutPsi(@NotNull Document document) { final Pair prevPair = myLastCommittedTexts.remove(document); if (prevPair == null) { return; @@ -770,6 +771,10 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen return !virtualFile.getFileType().isBinary() && !myProject.isDisposed(); } + boolean shouldNotifySmartPointers(@NotNull VirtualFile virtualFile) { + return true; + } + public static boolean checkConsistency(@NotNull PsiFile psiFile, @NotNull Document document) { //todo hack if (psiFile.getVirtualFile() == null) return true; diff --git a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SelfElementInfo.java b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SelfElementInfo.java index c1fafb9aff17..952bf067bfbd 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SelfElementInfo.java +++ b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SelfElementInfo.java @@ -68,7 +68,7 @@ public class SelfElementInfo implements SmartPointerElementInfo { } } - protected void setRange(@NotNull Segment range) { + void setRange(@NotNull Segment range) { mySyncStartOffset = range.getStartOffset(); mySyncEndOffset = range.getEndOffset(); } @@ -267,11 +267,13 @@ public class SelfElementInfo implements SmartPointerElementInfo { } int getSyncEndOffset() { - return mySyncEndOffset; + RangeMarker marker = myRangeMarker; + return marker == null || !marker.isValid() ? mySyncEndOffset : marker.getEndOffset(); } int getSyncStartOffset() { - return mySyncStartOffset; + RangeMarker marker = myRangeMarker; + return marker == null || !marker.isValid() ? mySyncStartOffset : marker.getStartOffset(); } @Override @@ -288,8 +290,8 @@ public class SelfElementInfo implements SmartPointerElementInfo { && myType == otherInfo.myType && mySyncMarkerIsValid && otherInfo.mySyncMarkerIsValid - && mySyncStartOffset == otherInfo.mySyncStartOffset - && mySyncEndOffset == otherInfo.mySyncEndOffset + && getSyncStartOffset() == otherInfo.getSyncStartOffset() + && getSyncEndOffset() == otherInfo.getSyncEndOffset() ; } return ApplicationManager.getApplication().runReadAction(new Computable() { diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/ex/util/LexerEditorHighlighter.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/ex/util/LexerEditorHighlighter.java index e51f2f81c7ea..84119ad2f0ec 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/ex/util/LexerEditorHighlighter.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/ex/util/LexerEditorHighlighter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,9 +78,7 @@ public class LexerEditorHighlighter implements EditorHighlighter, PrioritizedDoc public final synchronized boolean checkContentIsEqualTo(CharSequence sequence) { final Document document = getDocument(); - return document instanceof DocumentEx && - Comparing.equal(document.getImmutableCharSequence(), sequence) && - !((DocumentEx)document).isInBulkUpdate(); + return document != null && isInSyncWithDocument() && Comparing.equal(document.getImmutableCharSequence(), sequence); } public EditorColorsScheme getScheme() { @@ -107,13 +105,12 @@ public class LexerEditorHighlighter implements EditorHighlighter, PrioritizedDoc @Override public HighlighterIterator createIterator(int startOffset) { synchronized (this) { - final Document document = getDocument(); - if(document instanceof DocumentEx && ((DocumentEx)document).isInBulkUpdate()) { - ((DocumentEx)document).setInBulkUpdate(false); // bulk mode failed - } - - if (mySegments.getSegmentCount() == 0 && document != null && document.getTextLength() > 0) { - // bulk mode was reset + if (!isInSyncWithDocument()) { + final Document document = getDocument(); + assert document != null; + if(document instanceof DocumentEx && ((DocumentEx)document).isInBulkUpdate()) { + ((DocumentEx)document).setInBulkUpdate(false); // bulk mode failed + } doSetText(document.getCharsSequence()); } @@ -131,6 +128,11 @@ public class LexerEditorHighlighter implements EditorHighlighter, PrioritizedDoc Project project = myEditor.getProject(); return project != null && !project.isDisposed(); } + + private boolean isInSyncWithDocument() { + Document document = getDocument(); + return document == null || document.getTextLength() == 0 || mySegments.getSegmentCount() > 0; + } private static boolean isInitialState(int data) { return data >= 0; diff --git a/platform/icons/src/nodes/methodReference.png b/platform/icons/src/nodes/methodReference.png new file mode 100644 index 000000000000..8deeecbb0004 Binary files /dev/null and b/platform/icons/src/nodes/methodReference.png differ diff --git a/platform/icons/src/nodes/methodReference@2x.png b/platform/icons/src/nodes/methodReference@2x.png new file mode 100644 index 000000000000..2ee6214333f4 Binary files /dev/null and b/platform/icons/src/nodes/methodReference@2x.png differ diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/EditorTracker.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/EditorTracker.java index b43099cc2f75..7f1e1fa99948 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/EditorTracker.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/EditorTracker.java @@ -29,11 +29,14 @@ import com.intellij.openapi.fileEditor.FileEditorManagerEvent; import com.intellij.openapi.fileEditor.FileEditorManagerListener; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.WindowManager; import com.intellij.openapi.wm.ex.WindowManagerEx; import com.intellij.openapi.wm.impl.IdeFrameImpl; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; +import com.intellij.psi.SmartPointerManager; +import com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl; import com.intellij.util.EventDispatcher; import com.intellij.util.SmartList; import org.jetbrains.annotations.NonNls; @@ -50,6 +53,7 @@ public class EditorTracker extends AbstractProjectComponent { private final WindowManager myWindowManager; private final EditorFactory myEditorFactory; + private final SmartPointerManagerImpl mySmartPointerManager; private final Map> myWindowToEditorsMap = new HashMap>(); private final Map myWindowToWindowFocusListenerMap = new HashMap(); @@ -63,10 +67,12 @@ public class EditorTracker extends AbstractProjectComponent { public EditorTracker(Project project, final WindowManager windowManager, - final EditorFactory editorFactory) { + final EditorFactory editorFactory, + SmartPointerManager manager) { super(project); myWindowManager = windowManager; myEditorFactory = editorFactory; + mySmartPointerManager = (SmartPointerManagerImpl)manager; } @Override @@ -85,7 +91,7 @@ public class EditorTracker extends AbstractProjectComponent { Disposer.register(myProject, new Disposable() { @Override public void dispose() { - myEditorFactoryListener.dispose(null); + myEditorFactoryListener.executeOnRelease(null); } }); } @@ -225,7 +231,7 @@ public class EditorTracker extends AbstractProjectComponent { myDispatcher.getMulticaster().activeEditorsChanged(editors); } - public void addEditorTrackerListener(@NotNull EditorTrackerListener listener, @NotNull Disposable parentDisposable) { + void addEditorTrackerListener(@NotNull EditorTrackerListener listener, @NotNull Disposable parentDisposable) { myDispatcher.addListener(listener,parentDisposable); } @@ -236,7 +242,7 @@ public class EditorTracker extends AbstractProjectComponent { public void editorCreated(@NotNull EditorFactoryEvent event) { final Editor editor = event.getEditor(); if (editor.getProject() != null && editor.getProject() != myProject) return; - PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument()); + final PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument()); if (psiFile == null) return; final JComponent component = editor.getComponent(); @@ -244,7 +250,7 @@ public class EditorTracker extends AbstractProjectComponent { final HierarchyListener hierarchyListener = new HierarchyListener() { @Override - public void hierarchyChanged(HierarchyEvent e) { + public void hierarchyChanged(@NotNull HierarchyEvent e) { registerEditor(editor); } }; @@ -252,23 +258,32 @@ public class EditorTracker extends AbstractProjectComponent { final FocusListener focusListener = new FocusListener() { @Override - public void focusGained(FocusEvent e) { + public void focusGained(@NotNull FocusEvent e) { editorFocused(editor); } @Override - public void focusLost(FocusEvent e) { + public void focusLost(@NotNull FocusEvent e) { } }; contentComponent.addFocusListener(focusListener); + final VirtualFile virtualFile = psiFile.getVirtualFile(); myExecuteOnEditorRelease.put(event.getEditor(), new Runnable() { @Override public void run() { component.removeHierarchyListener(hierarchyListener); contentComponent.removeFocusListener(focusListener); + // allow range markers in smart pointers to be collected + if (virtualFile != null) { + mySmartPointerManager.unfastenBelts(virtualFile, 0); + } } }); + // materialize all range markers and do not let them to be collected to improve responsiveness + if (virtualFile != null) { + mySmartPointerManager.fastenBelts(virtualFile, 0, null); + } } @Override @@ -276,10 +291,10 @@ public class EditorTracker extends AbstractProjectComponent { final Editor editor = event.getEditor(); if (editor.getProject() != null && editor.getProject() != myProject) return; unregisterEditor(editor); - dispose(editor); + executeOnRelease(editor); } - private void dispose(Editor editor) { + private void executeOnRelease(Editor editor) { if (editor == null) { for (Runnable r : myExecuteOnEditorRelease.values()) { r.run(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/BackgroundUpdaterTask.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/BackgroundUpdaterTask.java index 4fb9dc21fb06..397889c8e1cf 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/BackgroundUpdaterTask.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/BackgroundUpdaterTask.java @@ -34,6 +34,7 @@ import com.intellij.util.Alarm; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -102,7 +103,8 @@ public abstract class BackgroundUpdaterTask extends Task.Backgroundable { } if (myCanceled) return false; - if (myPopup.isDisposed()) return false; + final JComponent content = myPopup.getContent(); + if (content == null || myPopup.isDisposed()) return false; synchronized (lock) { if (myData.contains(element)) return true; @@ -126,7 +128,7 @@ public abstract class BackgroundUpdaterTask extends Task.Backgroundable { myPopup.setCaption(getCaption(getCurrentSize())); myPopup.pack(true, true); } - }, 200, ModalityState.stateForComponent(myPopup.getContent())); + }, 200, ModalityState.stateForComponent(content)); return true; } diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java index c9e5b8885010..2852b19e080c 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java @@ -22,7 +22,6 @@ import com.intellij.execution.configurations.*; import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.Disposable; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.Extensions; @@ -39,7 +38,6 @@ import com.intellij.util.Function; import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.HashMap; -import com.intellij.util.containers.WeakHashMap; import gnu.trove.THashMap; import gnu.trove.THashSet; import org.jdom.Element; @@ -66,7 +64,7 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo private final Map myConfigurations = new LinkedHashMap(); // template configurations are not included here private final Map mySharedConfigurations = new THashMap(); - private final Map> myConfigurationToBeforeTasksMap = new WeakHashMap>(); + private final Map> myConfigurationToBeforeTasksMap = ContainerUtil.createConcurrentWeakMap(); // When readExternal not all configuration may be loaded, so we need to remember the selected configuration // so that when it is eventually loaded, we can mark is as a selected. @@ -155,7 +153,6 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo @NotNull public RunnerAndConfigurationSettings createConfiguration(@NotNull final RunConfiguration runConfiguration, @NotNull final ConfigurationFactory factory) { - assertDispatchThread(); RunnerAndConfigurationSettings template = getConfigurationTemplate(factory); RunnerAndConfigurationSettingsImpl settings = new RunnerAndConfigurationSettingsImpl(this, runConfiguration, false); settings.importRunnerAndConfigurationSettings((RunnerAndConfigurationSettingsImpl)template); @@ -165,12 +162,6 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo return settings; } - private void assertDispatchThread() { - if (myProject.isInitialized()) { - ApplicationManager.getApplication().assertIsDispatchThread(); - } - } - @Override public void dispose() { myTemplateConfigurationsMap.clear(); @@ -344,7 +335,6 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo public void addConfiguration(RunnerAndConfigurationSettings settings, boolean shared, List tasks, boolean addEnabledTemplateTasksIfAbsent) { - assertDispatchThread(); String existingId = findExistingConfigurationId(settings); String newId = settings.getUniqueID(); RunnerAndConfigurationSettings existingSettings = null; @@ -425,7 +415,6 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo @Override public void removeConfiguration(@Nullable RunnerAndConfigurationSettings settings) { - assertDispatchThread(); if (settings == null) return; for (Iterator it = getSortedConfigurations().iterator(); it.hasNext(); ) { @@ -818,7 +807,6 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo } private void clear(boolean allConfigurations) { - assertDispatchThread(); List configurations; if (allConfigurations) { myConfigurations.clear(); @@ -1147,7 +1135,6 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo @NotNull @Override public List getBeforeRunTasks(RunConfiguration settings, Key taskProviderID) { - assertDispatchThread(); if (settings instanceof WrappingRunConfiguration) { return getBeforeRunTasks(((WrappingRunConfiguration)settings).getPeer(), taskProviderID); } @@ -1169,7 +1156,6 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo @Override @NotNull public List getBeforeRunTasks(final RunConfiguration settings) { - assertDispatchThread(); if (settings instanceof WrappingRunConfiguration) { return getBeforeRunTasks(((WrappingRunConfiguration)settings).getPeer()); } @@ -1225,7 +1211,6 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo @Override public final void setBeforeRunTasks(final RunConfiguration runConfiguration, @NotNull List tasks, boolean addEnabledTemplateTasksIfAbsent) { - assertDispatchThread(); List result = new SmartList(tasks); if (addEnabledTemplateTasksIfAbsent) { List templates = getTemplateBeforeRunTasks(runConfiguration); @@ -1246,7 +1231,6 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo } public final void resetBeforeRunTasks(final RunConfiguration runConfiguration) { - assertDispatchThread(); myConfigurationToBeforeTasksMap.remove(runConfiguration); fireBeforeRunTasksUpdated(); } diff --git a/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java b/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java index e095d661e685..7142d8f52001 100644 --- a/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java +++ b/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java @@ -41,7 +41,7 @@ import org.jetbrains.annotations.Nullable; import java.util.*; -class FormatProcessor { +public class FormatProcessor { private static final Map ALIGNMENT_PROCESSORS = new EnumMap(Alignment.Anchor.class); diff --git a/platform/lang-impl/src/com/intellij/formatting/IndentImpl.java b/platform/lang-impl/src/com/intellij/formatting/IndentImpl.java index 04c806f3407f..7e35e84e4dbf 100644 --- a/platform/lang-impl/src/com/intellij/formatting/IndentImpl.java +++ b/platform/lang-impl/src/com/intellij/formatting/IndentImpl.java @@ -18,7 +18,7 @@ package com.intellij.formatting; import org.jetbrains.annotations.NonNls; -class IndentImpl extends Indent { +public class IndentImpl extends Indent { private final boolean myIsAbsolute; private final boolean myRelativeToDirectParent; @@ -38,7 +38,7 @@ class IndentImpl extends Indent { myEnforceIndentToChildren = enforceIndentToChildren; } - Type getType() { + public Type getType() { return myType; } diff --git a/platform/lang-impl/src/com/intellij/packageDependencies/FindDependencyUtil.java b/platform/lang-impl/src/com/intellij/packageDependencies/FindDependencyUtil.java index 606754643019..b4f0234c4bca 100644 --- a/platform/lang-impl/src/com/intellij/packageDependencies/FindDependencyUtil.java +++ b/platform/lang-impl/src/com/intellij/packageDependencies/FindDependencyUtil.java @@ -99,6 +99,12 @@ public class FindDependencyUtil { @Override public void process(PsiElement place, PsiElement dependency) { PsiFile dependencyFile = dependency.getContainingFile(); + if (dependencyFile != null) { + final PsiElement navigationElement = dependencyFile.getNavigationElement(); + if (navigationElement instanceof PsiFile) { + dependencyFile = (PsiFile)navigationElement; + } + } if (searchFor.contains(dependencyFile)) { usages.add(new UsageInfo(place)); } diff --git a/platform/lang-impl/src/com/intellij/psi/codeStyle/autodetect/FormatterBasedLineIndentInfoBuilder.java b/platform/lang-impl/src/com/intellij/psi/codeStyle/autodetect/FormatterBasedLineIndentInfoBuilder.java new file mode 100644 index 000000000000..86ce3c6ab763 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/psi/codeStyle/autodetect/FormatterBasedLineIndentInfoBuilder.java @@ -0,0 +1,105 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.codeStyle.autodetect; + +import com.intellij.formatting.*; +import com.intellij.lang.LanguageFormatting; +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Condition; +import com.intellij.psi.PsiComment; +import com.intellij.psi.PsiDocumentManager; +import com.intellij.psi.PsiFile; +import com.intellij.psi.codeStyle.CodeStyleSettings; +import com.intellij.psi.codeStyle.CodeStyleSettingsManager; +import com.intellij.psi.formatter.common.NewLineBlocksIterator; +import com.intellij.util.Function; +import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.text.CharArrayUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; + +public class FormatterBasedLineIndentInfoBuilder { + private static final int MAX_NEW_LINE_BLOCKS_TO_PROCESS = 500; + + private final PsiFile myFile; + private final Document myDocument; + private final CharSequence myText; + private final CodeStyleSettings mySettings; + private final FormattingModelBuilder myFormattingModelBuilder; + + public FormatterBasedLineIndentInfoBuilder(@NotNull PsiFile file) { + Project project = file.getProject(); + + myFile = file; + myDocument = PsiDocumentManager.getInstance(project).getDocument(file); + myText = myDocument != null ? myDocument.getCharsSequence() : null; + mySettings = CodeStyleSettingsManager.getSettings(project); + myFormattingModelBuilder = LanguageFormatting.INSTANCE.forContext(myFile); + } + + public List build() { + if (myText == null || myFormattingModelBuilder == null) return null; + + List normallyIndentedBlocks = ContainerUtil.filter(getBlocksStartingNewLine(), new Condition() { + @Override + public boolean value(Block block) { + Indent.Type type = block.getIndent() instanceof IndentImpl ? ((IndentImpl)block.getIndent()).getType() : null; + return type == Indent.Type.NONE || type == Indent.Type.NORMAL; + } + }); + + return ContainerUtil.map(normallyIndentedBlocks, new Function() { + @Override + public LineIndentInfo fun(Block newLineBlock) { + int blockStartOffset = newLineBlock.getTextRange().getStartOffset(); + int lineStartOffset = myDocument.getLineStartOffset(myDocument.getLineNumber(blockStartOffset)); + return createLineIndentInfo(lineStartOffset, blockStartOffset); + } + }); + } + + @NotNull + private List getBlocksStartingNewLine() { + FormattingModel model = myFormattingModelBuilder.createModel(myFile, mySettings); + Block root = model.getRootBlock(); + NewLineBlocksIterator newLineBlocksIterator = new NewLineBlocksIterator(root, myDocument); + + List newLineBlocks = new ArrayList(); + int currentLine = 0; + while (newLineBlocksIterator.hasNext() && currentLine < MAX_NEW_LINE_BLOCKS_TO_PROCESS) { + Block next = newLineBlocksIterator.next(); + if (next instanceof ASTBlock && ((ASTBlock)next).getNode() instanceof PsiComment) { + continue; + } + newLineBlocks.add(next); + currentLine++; + } + + return newLineBlocks; + } + + @NotNull + private LineIndentInfo createLineIndentInfo(int lineStartOffset, int textStartOffset) { + if (CharArrayUtil.indexOf(myText, "\t", lineStartOffset, textStartOffset) > 0) { + return LineIndentInfo.LINE_WITH_TABS; + } + return LineIndentInfo.newWhiteSpaceIndent(textStartOffset - lineStartOffset); + } + +} diff --git a/platform/lang-impl/src/com/intellij/psi/codeStyle/autodetect/IndentOptionsDetectorImpl.java b/platform/lang-impl/src/com/intellij/psi/codeStyle/autodetect/IndentOptionsDetectorImpl.java index 5f56ecc9b264..a0ed4174e22d 100644 --- a/platform/lang-impl/src/com/intellij/psi/codeStyle/autodetect/IndentOptionsDetectorImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/codeStyle/autodetect/IndentOptionsDetectorImpl.java @@ -19,6 +19,7 @@ import com.intellij.lang.Language; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.registry.Registry; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; @@ -26,7 +27,7 @@ import org.jetbrains.annotations.NotNull; import java.util.List; -import static com.intellij.psi.codeStyle.CommonCodeStyleSettings.*; +import static com.intellij.psi.codeStyle.CommonCodeStyleSettings.IndentOptions; public class IndentOptionsDetectorImpl implements IndentOptionsDetector { private static Logger LOG = Logger.getInstance("#com.intellij.psi.codeStyle.CommonCodeStyleSettings.IndentOptionsDetector"); @@ -38,12 +39,14 @@ public class IndentOptionsDetectorImpl implements IndentOptionsDetector { private final Project myProject; private final Document myDocument; private final Language myLanguage; + private final boolean myUseFormatterBasedLineIndentBuilder; public IndentOptionsDetectorImpl(@NotNull PsiFile file) { myFile = file; myLanguage = file.getLanguage(); myProject = file.getProject(); myDocument = PsiDocumentManager.getInstance(myProject).getDocument(myFile); + myUseFormatterBasedLineIndentBuilder = Registry.is("editor.detect.indent.by.formatter"); } @Override @@ -51,8 +54,12 @@ public class IndentOptionsDetectorImpl implements IndentOptionsDetector { public IndentOptions getIndentOptions() { IndentOptions indentOptions = (IndentOptions)CodeStyleSettingsManager.getSettings(myProject).getIndentOptions(myFile.getFileType()).clone(); - if (myDocument != null) { - List linesInfo = new LineIndentInfoBuilder(myDocument.getCharsSequence(), myLanguage).build(); + long start = System.currentTimeMillis(); + List linesInfo = calcLineIndentInfo(); + long end = System.currentTimeMillis(); + LOG.info("Formatter-based: " + myUseFormatterBasedLineIndentBuilder + ". Line info building time: " + (end - start)); + + if (linesInfo != null) { IndentUsageStatistics stats = new IndentUsageStatisticsImpl(linesInfo); adjustIndentOptions(indentOptions, stats); } @@ -60,6 +67,14 @@ public class IndentOptionsDetectorImpl implements IndentOptionsDetector { return indentOptions; } + private List calcLineIndentInfo() { + if (myDocument == null) return null; + if (myUseFormatterBasedLineIndentBuilder) { + return new FormatterBasedLineIndentInfoBuilder(myFile).build(); + } + return new LineIndentInfoBuilder(myDocument.getCharsSequence(), myLanguage).build(); + } + private void adjustIndentOptions(@NotNull IndentOptions indentOptions, @NotNull IndentUsageStatistics stats) { int linesWithTabs = stats.getTotalLinesWithLeadingTabs(); int linesWithWhiteSpaceIndent = stats.getTotalLinesWithLeadingSpaces(); diff --git a/platform/lang-impl/src/com/intellij/psi/formatter/common/AbstractBlock.java b/platform/lang-impl/src/com/intellij/psi/formatter/common/AbstractBlock.java index 726006defceb..d74cffa32d07 100644 --- a/platform/lang-impl/src/com/intellij/psi/formatter/common/AbstractBlock.java +++ b/platform/lang-impl/src/com/intellij/psi/formatter/common/AbstractBlock.java @@ -37,8 +37,10 @@ public abstract class AbstractBlock implements ASTBlock { @NotNull protected final ASTNode myNode; @Nullable protected final Wrap myWrap; @Nullable protected final Alignment myAlignment; - private List mySubBlocks; - private Boolean myIncomplete; + + private List mySubBlocks; + private Boolean myIncomplete; + private boolean myBuildInjectedBlocks = true; protected AbstractBlock(@NotNull ASTNode node, @Nullable Wrap wrap, @Nullable Alignment alignment) { myNode = node; @@ -66,8 +68,23 @@ public abstract class AbstractBlock implements ASTBlock { return mySubBlocks; } + /** + * Prevents from building injected blocks, which allows to build blocks faster + * Initially was made for formatting-based indent detector + */ + protected void setBuildInjectedBlocks(boolean value) { + myBuildInjectedBlocks = value; + } + + protected boolean isBuildInjectedBlocks() { + return myBuildInjectedBlocks; + } + @NotNull private List buildInjectedBlocks() { + if (!myBuildInjectedBlocks) { + return EMPTY; + } if (!(this instanceof SettingsAwareBlock)) { return EMPTY; } diff --git a/platform/lang-impl/src/com/intellij/psi/formatter/common/NewLineBlocksIterator.java b/platform/lang-impl/src/com/intellij/psi/formatter/common/NewLineBlocksIterator.java new file mode 100644 index 000000000000..9ec55edcb104 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/psi/formatter/common/NewLineBlocksIterator.java @@ -0,0 +1,109 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.formatter.common; + +import com.intellij.formatting.Block; +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.util.TextRange; + +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Stack; + + +public class NewLineBlocksIterator implements Iterator { + private final Document myDocument; + private final int myTotalLines; + + private int myCurrentLineStartOffset; + private int myCurrentDocumentLine; + private Stack myStack = new Stack(); + + public NewLineBlocksIterator(Block root, Document document) { + myStack.add(root); + myDocument = document; + myTotalLines = myDocument.getLineCount(); + + myCurrentDocumentLine = 0; + myCurrentLineStartOffset = 0; + } + + @Override + public boolean hasNext() { + if (myCurrentDocumentLine < myTotalLines) { + popUntilTopBlockStartOffsetGreaterOrEqual(myCurrentLineStartOffset); + return !myStack.isEmpty(); + } + return false; + } + + @Override + public Block next() { + popUntilTopBlockStartOffsetGreaterOrEqual(myCurrentLineStartOffset); + + Block current = myStack.peek(); + TextRange currentBlockRange = current.getTextRange(); + + myCurrentDocumentLine = myDocument.getLineNumber(currentBlockRange.getStartOffset()); + myCurrentDocumentLine++; + if (myCurrentDocumentLine < myTotalLines) { + myCurrentLineStartOffset = myDocument.getLineStartOffset(myCurrentDocumentLine); + if (currentBlockRange.getEndOffset() < myCurrentLineStartOffset) { + myStack.pop(); + } + else { + pushAll(current); + } + } + + return current; + } + + private void popUntilTopBlockStartOffsetGreaterOrEqual(final int lineStartOffset) { + if (myStack.isEmpty()) return; + + Block current = myStack.peek(); + TextRange range = current.getTextRange(); + int currentStartOffset = range.getStartOffset(); + int currentEndOffset = range.getEndOffset(); + + if (currentStartOffset < lineStartOffset) { + myStack.pop(); + if (currentEndOffset > lineStartOffset) { + pushAll(current); + } + popUntilTopBlockStartOffsetGreaterOrEqual(lineStartOffset); + } + } + + private void pushAll(Block current) { + if (current instanceof AbstractBlock) { + //building blocks as fast as possible + ((AbstractBlock)current).setBuildInjectedBlocks(false); + } + + List blocks = current.getSubBlocks(); + Collections.reverse(blocks); + for (Block block : blocks) { + myStack.push(block); + } + } + + @Override + public void remove() { + } +} diff --git a/platform/lang-impl/src/com/intellij/psi/impl/PsiDocumentManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/PsiDocumentManagerImpl.java index dd88dddcc23e..e1efb0079ead 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/PsiDocumentManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/PsiDocumentManagerImpl.java @@ -27,6 +27,7 @@ import com.intellij.openapi.editor.event.DocumentEvent; import com.intellij.openapi.editor.ex.DocumentBulkUpdateListener; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter; +import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectLocator; @@ -123,6 +124,12 @@ public class PsiDocumentManagerImpl extends PsiDocumentManagerBase implements Se } } + @Override + boolean shouldNotifySmartPointers(@NotNull VirtualFile virtualFile) { + // for an open file do not do fasten/unfasten, they should always stay fastened to improve responsiveness + return !myProject.isDefault() && !FileEditorManager.getInstance(myProject).isFileOpen(virtualFile); + } + @Override protected void beforeDocumentChangeOnUnlockedDocument(@NotNull final FileViewProvider viewProvider) { PostprocessReformattingAspect.getInstance(myProject).beforeDocumentChanged(viewProvider); diff --git a/platform/lang-impl/src/com/intellij/util/ui/tree/AbstractFileTreeTable.java b/platform/lang-impl/src/com/intellij/util/ui/tree/AbstractFileTreeTable.java index 416d584441b0..5287db9087ce 100644 --- a/platform/lang-impl/src/com/intellij/util/ui/tree/AbstractFileTreeTable.java +++ b/platform/lang-impl/src/com/intellij/util/ui/tree/AbstractFileTreeTable.java @@ -48,7 +48,7 @@ import java.awt.*; import java.util.*; import java.util.List; -public abstract class AbstractFileTreeTable extends TreeTable { +public class AbstractFileTreeTable extends TreeTable { private final MyModel myModel; private final Project myProject; @@ -57,9 +57,19 @@ public abstract class AbstractFileTreeTable extends TreeTable { @NotNull String valueTitle, @NotNull VirtualFileFilter filter, boolean showProjectNode) { - super(new MyModel(project, valueClass, valueTitle, filter)); + this(project, valueClass, valueTitle, filter, showProjectNode, true); + } + + public AbstractFileTreeTable(@NotNull Project project, + @NotNull Class valueClass, + @NotNull String valueTitle, + @NotNull VirtualFileFilter filter, + boolean showProjectNode, + boolean filterNonContentFiles) { + super(new MyModel(project, valueClass, valueTitle, filterNonContentFiles ? new NonContentFileFilter(project, filter) : filter)); myProject = project; + //noinspection unchecked myModel = (MyModel)getTableModel(); myModel.setTreeTable(this); @@ -84,6 +94,7 @@ public abstract class AbstractFileTreeTable extends TreeTable { getTree().setShowsRootHandles(true); getTree().setLineStyleAngled(); getTree().setRootVisible(showProjectNode); + final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); getTree().setCellRenderer(new DefaultTreeCellRenderer() { @Override public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded, @@ -96,21 +107,18 @@ public abstract class AbstractFileTreeTable extends TreeTable { } FileNode fileNode = (FileNode)value; VirtualFile file = fileNode.getObject(); - if (fileNode.getParent() instanceof FileNode) { - setText(file.getName()); + setText(fileNode.getParent() instanceof FileNode ? file.getName() : file.getPresentableUrl()); + if (file.isDirectory()) { + setIcon(fileIndex.isExcluded(file) ? AllIcons.Modules.ExcludeRoot : PlatformIcons.DIRECTORY_CLOSED_ICON); } else { - setText(file.getPresentableUrl()); + setIcon(IconUtil.getIcon(file, 0, null)); } - - Icon icon = file.isDirectory() ? PlatformIcons.DIRECTORY_CLOSED_ICON : IconUtil.getIcon(file, 0, null); - setIcon(icon); return this; } }); getTableHeader().setReorderingAllowed(false); - setSelectionMode(ListSelectionModel.SINGLE_SELECTION); setPreferredScrollableViewportSize(new Dimension(300, getRowHeight() * 10)); @@ -140,8 +148,7 @@ public abstract class AbstractFileTreeTable extends TreeTable { public static void press(final Container comboComponent) { if (comboComponent instanceof JButton) { - final JButton button = (JButton)comboComponent; - button.doClick(); + ((JButton)comboComponent).doClick(); } else { for (int i = 0; i < comboComponent.getComponentCount(); i++) { @@ -191,8 +198,7 @@ public abstract class AbstractFileTreeTable extends TreeTable { public void reset(@NotNull Map mappings) { myModel.reset(mappings); - final TreeNode root = (TreeNode)myModel.getRoot(); - myModel.nodeChanged(root); + myModel.nodeChanged((TreeNode)myModel.getRoot()); getTree().setModel(null); getTree().setModel(myModel); TreeUtil.expandRootChildIfOnlyOne(getTree()); @@ -223,7 +229,6 @@ public abstract class AbstractFileTreeTable extends TreeTable { } } - private static class MyModel extends DefaultTreeModel implements TreeTableModel { private final Map myCurrentMapping = new HashMap(); private final Class myValueClass; @@ -310,11 +315,14 @@ public abstract class AbstractFileTreeTable extends TreeTable { @Override public void setValueAt(final Object aValue, final Object node, final int column) { - final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)node; - final Object userObject = treeNode.getUserObject(); - if (userObject instanceof Project) return; + final Object userObject = ((DefaultMutableTreeNode)node).getUserObject(); + if (userObject instanceof Project) { + return; + } + final VirtualFile file = (VirtualFile)userObject; - final T t = (T)aValue; + @SuppressWarnings("unchecked") + T t = (T)aValue; if (t == null || myTreeTable.isNullObject(t)) { myCurrentMapping.remove(file); } @@ -426,8 +434,8 @@ public abstract class AbstractFileTreeTable extends TreeTable { public void clearCachedChildren() { if (children != null) { for (Object child : children) { - ConvenientNode node = (ConvenientNode)child; - node.clearCachedChildren(); + //noinspection unchecked + ((ConvenientNode)child).clearCachedChildren(); } } removeAllChildren(); @@ -451,14 +459,11 @@ public abstract class AbstractFileTreeTable extends TreeTable { @Override protected void appendChildrenTo(@NotNull final Collection children) { - VirtualFile[] childrenf = getObject().getChildren(); - ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); - for (VirtualFile child : childrenf) { - if (myFilter.accept(child) && fileIndex.isInContent(child)) { + for (VirtualFile child : getObject().getChildren()) { + if (myFilter.accept(child)) { children.add(new FileNode(child, myProject, myFilter)); } } } } - } diff --git a/platform/lang-impl/src/com/intellij/util/ui/tree/NonContentFileFilter.java b/platform/lang-impl/src/com/intellij/util/ui/tree/NonContentFileFilter.java new file mode 100644 index 000000000000..3eeef5869217 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/util/ui/tree/NonContentFileFilter.java @@ -0,0 +1,47 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.util.ui.tree; + +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.ProjectFileIndex; +import com.intellij.openapi.roots.ProjectRootManager; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.VirtualFileFilter; +import org.jetbrains.annotations.NotNull; + +public class NonContentFileFilter implements VirtualFileFilter { + private final Project project; + private final VirtualFileFilter filter; + + private ProjectFileIndex fileIndex; + + public NonContentFileFilter(@NotNull Project project, @NotNull VirtualFileFilter filter) { + this.project = project; + this.filter = filter; + } + + @Override + public boolean accept(@NotNull VirtualFile file) { + if (!filter.accept(file)) { + return false; + } + + if (fileIndex == null) { + fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); + } + return fileIndex.isInContent(file); + } +} diff --git a/platform/platform-impl/src/com/intellij/execution/impl/EditorHyperlinkSupport.java b/platform/platform-impl/src/com/intellij/execution/impl/EditorHyperlinkSupport.java index 36da53448c7b..00aba68c73db 100644 --- a/platform/platform-impl/src/com/intellij/execution/impl/EditorHyperlinkSupport.java +++ b/platform/platform-impl/src/com/intellij/execution/impl/EditorHyperlinkSupport.java @@ -135,8 +135,9 @@ public class EditorHyperlinkSupport { @Override public void run() { if (hyperlinkInfo instanceof HyperlinkInfoBase) { - RelativePoint point = new RelativePoint(myEditor.getContentComponent(), myEditor.logicalPositionToXY(logical)); - ((HyperlinkInfoBase)hyperlinkInfo).navigate(myProject, point); + final Point point = myEditor.logicalPositionToXY(logical); + final MouseEvent event = new MouseEvent(myEditor.getContentComponent(), 0, 0, 0, point.x, point.y, 1, false); + ((HyperlinkInfoBase)hyperlinkInfo).navigate(myProject, new RelativePoint(event)); } else { hyperlinkInfo.navigate(myProject); diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/IntelliJLaf.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/IntelliJLaf.java index 363e46d03ffa..ab038a3f386a 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/IntelliJLaf.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/IntelliJLaf.java @@ -22,6 +22,7 @@ import javax.swing.*; import javax.swing.plaf.FontUIResource; import javax.swing.plaf.metal.DefaultMetalTheme; import java.awt.*; +import java.util.HashSet; /** * @author Konstantin Bulenkov @@ -52,11 +53,23 @@ public class IntelliJLaf extends DarculaLaf { } private static void installMacOSXFonts(UIDefaults defaults) { - FontUIResource font = new FontUIResource("HelveticaNeue-CondensedBlack", Font.PLAIN, 13); - defaults.put("Label.font", font); - defaults.put("CheckBox.font", font); - defaults.put("RadioButton.font", font); - defaults.put("ComboBox.font", font); + String face = "HelveticaNeue-CondensedBlack"; + LafManagerImpl.initFontDefaults(defaults, face, 13); + for (Object key : new HashSet(defaults.keySet())) { + Object value = defaults.get(key); + if (value instanceof FontUIResource) { + FontUIResource font = (FontUIResource)value; + if (font.getFamily().equals("Lucida Grande") || font.getFamily().equals("Serif")) { + if (!key.toString().contains("Menu")) { + defaults.put(key, new FontUIResource(face, font.getStyle(), font.getSize())); + } + } + } + } + Font menuFont = new Font("Lucida Grande", Font.PLAIN, 14); + defaults.put("Menu.font", menuFont); + defaults.put("MenuItem.font", menuFont); + defaults.put("MenuItem.acceleratorFont", menuFont); } public static boolean isGraphite() { diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaComboBoxUI.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaComboBoxUI.java index ea36ede553c8..1d129e4beb0c 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaComboBoxUI.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaComboBoxUI.java @@ -342,6 +342,9 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border { g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); final int R = JBUI.scale(5); + if (hasFocus) { + g.setClip(2, 2, comboBox.getWidth()- 4, comboBox.getHeight() - 4); //todo[kb] check HiDPI + } if (editor != null && comboBox.isEditable()) { ((JComponent)editor).setBorder(null); g.setColor(editor.getBackground()); @@ -351,11 +354,11 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border { g.setColor(editor.getBackground()); g.fillRect(xxx, y + 1, 5, H); } else { - g.setColor(comboBox.getBackground()); + g.setColor(UIUtil.getPanelBackground()); g.fillRoundRect(x + 1, y + 1, W, H, R, R); g.setColor(getArrowButtonFillColor(arrowButton.getBackground())); g.fillRoundRect(xxx, y + 1, width - xxx, H, R, R); - g.setColor(comboBox.getBackground()); + g.setColor(UIUtil.getPanelBackground()); g.fillRect(xxx, y + 1, 5, H); } final Color borderColor = getBorderColor();//ColorUtil.shift(UIUtil.getBorderColor(), 4); @@ -368,6 +371,7 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border { paintCurrentValue(g, r, false); if (hasFocus) { + g.setClip(0, 0, comboBox.getWidth(), comboBox.getHeight()); DarculaUIUtil.paintFocusRing(g, JBUI.scale(2), JBUI.scale(2), width - JBUI.scale(4), height - JBUI.scale(4)); } else { diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/MacIntelliJComboBoxUI.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/MacIntelliJComboBoxUI.java index 4a48ffdcfe82..975fdf129803 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/MacIntelliJComboBoxUI.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/MacIntelliJComboBoxUI.java @@ -189,6 +189,7 @@ public class MacIntelliJComboBoxUI extends BasicComboBoxUI implements Border, UI @Override protected Rectangle rectangleForCurrentValue() { Rectangle rect = super.rectangleForCurrentValue(); + rect.height=Math.min(rect.height, COMBOBOX.getIconHeight()); rect.y+=2; rect.x+=5; rect.height-=4; @@ -257,17 +258,21 @@ public class MacIntelliJComboBoxUI extends BasicComboBoxUI implements Border, UI g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); } + public void paintCurrentValue(Graphics g,Rectangle bounds,boolean hasFocus) { + super.paintCurrentValue(g, bounds, comboBox.isPopupVisible()); + } @Override public void paint(Graphics g, JComponent c) { super.paint(g, c); - int stop = arrowButton.getBounds().x; + Rectangle r = arrowButton.getBounds(); + int stop = r.x; g.setClip(0,0, stop, COMBOBOX.getIconHeight()); - COMBOBOX_LEFT.paintIcon(c,g,0,0); + COMBOBOX_LEFT.paintIcon(c,g,0,r.y); int x = COMBOBOX_LEFT.getIconWidth(); while (x < stop) { - COMBOBOX_TOP_BOTTOM.paintIcon(c, g, x, 0); + COMBOBOX_TOP_BOTTOM.paintIcon(c, g, x, r.y); x+=COMBOBOX_TOP_BOTTOM.getIconWidth(); } ((Graphics2D)g).scale(0.5d, 0.5d); diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf_mac.properties b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf_mac.properties index a193b504a3f4..07d3d6747b99 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf_mac.properties +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf_mac.properties @@ -1,4 +1,7 @@ +# suppress inspection "UnusedProperty" for whole file intellijlaf.background=ececec +intellijlaf.selectionBackgroundInactive=dcdcdc +intellijlaf.selectionInactiveBackground=dcdcdc window=ececec CheckBoxUI=com.intellij.ide.ui.laf.intellij.MacIntelliJCheckBoxUI @@ -9,6 +12,10 @@ Spinner.background=ececec Spinner.darcula.disabledButtonColor=ececec ComboBoxUI=com.intellij.ide.ui.laf.intellij.MacIntelliJComboBoxUI +MenuItem.acceleratorSelectionForeground=ffffff +PopupMenu.background=f6f6f6 +MenuItem.background=f6f6f6 +Menu.background=f6f6f6 SplitPane.highlight=ececec diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/LineOrientedDocumentChangeAdapter.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/LineOrientedDocumentChangeAdapter.java deleted file mode 100644 index 3a715233d044..000000000000 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/LineOrientedDocumentChangeAdapter.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2000-2010 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.editor.impl.softwrap; - -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.editor.event.DocumentEvent; -import com.intellij.openapi.editor.event.DocumentListener; -import com.intellij.openapi.editor.ex.PrioritizedDocumentListener; - -/** - * Adapter class for {@link DocumentListener} interface that allows to represent document change events - * in terms of logical lines affected by it. - * - * @author Denis Zhdanov - * @since Jul 7, 2010 4:24:52 PM - */ -public abstract class LineOrientedDocumentChangeAdapter implements PrioritizedDocumentListener { - - @Override - public void beforeDocumentChange(DocumentEvent event) { - Document document = event.getDocument(); - int startLine = document.getLineNumber(normalize(event.getDocument(), event.getOffset())); - int endLine = document.getLineNumber(normalize(event.getDocument(), event.getOffset() + event.getOldLength())); - int symbolsDifference = event.getNewLength() - event.getOldLength(); - beforeDocumentChange(startLine, endLine, symbolsDifference); - } - - @Override - public void documentChanged(DocumentEvent event) { - Document document = event.getDocument(); - int startLine = document.getLineNumber(normalize(event.getDocument(), event.getOffset())); - int endLine = document.getLineNumber(normalize(event.getDocument(), event.getOffset() + event.getNewLength())); - int symbolsDifference = event.getNewLength() - event.getOldLength(); - afterDocumentChange(startLine, endLine, symbolsDifference); - } - - @Override - public int getPriority() { - return Integer.MAX_VALUE; - } - - /** - * Callback adapter method for {@link DocumentListener#beforeDocumentChange(DocumentEvent)} event. - * - * @param startLine first logical document line affected by the target event (inclusive) - * @param endLine old last logical document line affected by the target event (inclusive) - * @param symbolsDifference difference in number in symbols applied to the target document - */ - public abstract void beforeDocumentChange(int startLine, int endLine, int symbolsDifference); - - /** - * Callback adapter method for {@link DocumentListener#documentChanged(DocumentEvent)} event. - * - * @param startLine first logical document line affected by the target event (inclusive) - * @param endLine new last logical document line affected by the target event (inclusive) - * @param symbolsDifference difference in number in symbols applied to the target document - */ - public abstract void afterDocumentChange(int startLine, int endLine, int symbolsDifference); - - private static int normalize(Document document, int offset) { - if (offset < 0) { - return 0; - } - - if (offset >= document.getTextLength()) { - return Math.max(document.getTextLength() - 1, 0); - } - return offset; - } -} diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/CachingSoftWrapDataMapper.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/CachingSoftWrapDataMapper.java index 67923b0e49a0..a2cda73530a4 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/CachingSoftWrapDataMapper.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/CachingSoftWrapDataMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -566,7 +566,8 @@ public class CachingSoftWrapDataMapper implements SoftWrapAwareDocumentParsingLi int borderSoftWrapColumnDiff = 0; int borderSoftWrapLinesBeforeDiff = 0; int borderSoftWrapLinesCurrentDiff = 0; - for (int i = 0; i < myAffectedByUpdateCacheEntries.size(); i++) { + int affectedEntriesCount = myAffectedByUpdateCacheEntries.size(); + for (int i = 0; i < affectedEntriesCount; i++) { CacheEntry entry = myAffectedByUpdateCacheEntries.get(i); if (firstIndex < 0) { if (entry.startOffset < recalcEndOffsetTranslated) { @@ -574,15 +575,12 @@ public class CachingSoftWrapDataMapper implements SoftWrapAwareDocumentParsingLi continue; } firstIndex = i; - if (lastEntry != null) { - borderLogicalLine = lastEntry.endLogicalLine; - if (entry.startLogicalLine + logicalLinesDiff == borderLogicalLine) { - borderColumnDiff = lastEntry.endLogicalColumn - entry.startLogicalColumn; - borderSoftWrapLinesBeforeDiff = lastEntry.endSoftWrapLinesBefore - entry.startSoftWrapLinesBefore; - borderSoftWrapLinesCurrentDiff = lastEntry.endSoftWrapLinesCurrent - entry.startSoftWrapLinesCurrent + 1; - borderFoldedColumnDiff = lastEntry.endFoldingColumnDiff - entry.startFoldingColumnDiff; - borderSoftWrapColumnDiff = - borderColumnDiff - borderFoldedColumnDiff; - } + if (lastEntry != null && entry.startLogicalLine + logicalLinesDiff == borderLogicalLine) { + borderColumnDiff = lastEntry.endLogicalColumn - entry.startLogicalColumn; + borderSoftWrapLinesBeforeDiff = lastEntry.endSoftWrapLinesBefore - entry.startSoftWrapLinesBefore; + borderSoftWrapLinesCurrentDiff = lastEntry.endSoftWrapLinesCurrent - entry.startSoftWrapLinesCurrent + 1; + borderFoldedColumnDiff = lastEntry.endFoldingColumnDiff - entry.startFoldingColumnDiff; + borderSoftWrapColumnDiff = -borderColumnDiff - borderFoldedColumnDiff; } if (lengthDiff == 0 && logicalLinesDiff == 0 && foldedLinesDiff == 0 && softWrappedLinesDiff == 0 && borderColumnDiff == 0 && borderSoftWrapColumnDiff == 0 && borderFoldedColumnDiff == 0 @@ -626,6 +624,9 @@ public class CachingSoftWrapDataMapper implements SoftWrapAwareDocumentParsingLi LOG.error("Invalid soft wrap cache update", new Attachment("state.txt", myEditor.getSoftWrapModel().toString())); } } + if (myAffectedByUpdateCacheEntries.get(affectedEntriesCount - 1).endOffset > myEditor.getDocument().getTextLength()) { + LOG.error("Invalid soft wrap cache entries emerged", new Attachment("state.txt", myEditor.getSoftWrapModel().toString())); + } myCache.addAll(myAffectedByUpdateCacheEntries.subList(firstIndex, myAffectedByUpdateCacheEntries.size())); } myAffectedByUpdateCacheEntries.clear(); diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/util/ColorProgressBar.java b/platform/platform-impl/src/com/intellij/openapi/progress/util/ColorProgressBar.java index ca6a973668b4..b307177e154b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/util/ColorProgressBar.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/util/ColorProgressBar.java @@ -37,7 +37,7 @@ public class ColorProgressBar extends JComponent { private static final Dimension PREFERRED_SIZE = new Dimension(146, 17); public static final Color GREEN = new JBColor(new Color(0x6cad74), new Color(0x4a8c53)); - public static final Color RED = new JBColor(new Color(0xd67b76), new Color(0xb25050)); + public static final Color RED = new JBColor(new Color(0xd67b76), new Color(0xe55757)); public static final Color BLUE = new JBColor(new Color(1, 68, 208), JBColor.blue); public static final Color YELLOW = new JBColor(new Color(0xa67a21), new Color(0x91703a)); private static final Color SHADOW1 = new JBColor(Gray._190, UIUtil.getBorderColor()) ; diff --git a/platform/platform-impl/src/com/intellij/util/UrlImpl.java b/platform/platform-impl/src/com/intellij/util/UrlImpl.java index 023865164405..6876998e0a03 100644 --- a/platform/platform-impl/src/com/intellij/util/UrlImpl.java +++ b/platform/platform-impl/src/com/intellij/util/UrlImpl.java @@ -44,7 +44,7 @@ public final class UrlImpl implements Url { public UrlImpl(@Nullable String scheme, @Nullable String authority, @Nullable String path, @Nullable String parameters) { this.scheme = scheme; this.authority = authority; - this.path = StringUtil.isEmpty(path) && !StringUtil.isEmpty(authority) ? "/" : StringUtil.notNullize(path); + this.path = StringUtil.notNullize(path); this.parameters = StringUtil.nullize(parameters); } @@ -112,7 +112,7 @@ public final class UrlImpl implements Url { // relative path - special url, encoding is not required // authority is null in case of URI - if ((path.charAt(0) != '/' || authority == null) && !isInLocalFileSystem()) { + if ((authority == null || (!path.isEmpty() && path.charAt(0) != '/')) && !isInLocalFileSystem()) { return toDecodedForm(); } diff --git a/platform/platform-impl/src/org/jetbrains/io/ChannelBufferToString.java b/platform/platform-impl/src/org/jetbrains/io/ChannelBufferToString.java index df61a92f987e..9bf08d705a4e 100644 --- a/platform/platform-impl/src/org/jetbrains/io/ChannelBufferToString.java +++ b/platform/platform-impl/src/org/jetbrains/io/ChannelBufferToString.java @@ -1,6 +1,5 @@ package org.jetbrains.io; -import com.intellij.util.text.CharArrayCharSequence; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufUtil; import io.netty.buffer.ByteBufUtilEx; @@ -13,13 +12,13 @@ import java.nio.CharBuffer; public final class ChannelBufferToString { @NotNull public static CharSequence readChars(@NotNull ByteBuf buffer) throws IOException { - return new MyCharArrayCharSequence(readIntoCharBuffer(buffer, buffer.readableBytes(), null)); + return new JsonReaderEx.CharSequenceBackedByChars(readIntoCharBuffer(buffer, buffer.readableBytes(), null)); } @SuppressWarnings("unused") @NotNull public static CharSequence readChars(@NotNull ByteBuf buffer, int byteCount) throws IOException { - return new MyCharArrayCharSequence(readIntoCharBuffer(buffer, byteCount, null)); + return new JsonReaderEx.CharSequenceBackedByChars(readIntoCharBuffer(buffer, byteCount, null)); } @NotNull @@ -34,16 +33,4 @@ public final class ChannelBufferToString { public static void writeIntAsAscii(int value, @NotNull ByteBuf buffer) { ByteBufUtil.writeAscii(buffer, new StringBuilder().append(value)); } - - // we must return string on subSequence() - JsonReaderEx will call toString in any case - public static final class MyCharArrayCharSequence extends CharArrayCharSequence { - public MyCharArrayCharSequence(@NotNull CharBuffer charBuffer) { - super(charBuffer.array(), charBuffer.arrayOffset(), charBuffer.position()); - } - - @Override - public CharSequence subSequence(int start, int end) { - return start == 0 && end == length() ? this : new String(myChars, myStart + start, end - start); - } - } } \ No newline at end of file diff --git a/platform/platform-impl/src/org/jetbrains/io/JsonReaderEx.java b/platform/platform-impl/src/org/jetbrains/io/JsonReaderEx.java index 37cf6bf7066c..b0fb40448885 100644 --- a/platform/platform-impl/src/org/jetbrains/io/JsonReaderEx.java +++ b/platform/platform-impl/src/org/jetbrains/io/JsonReaderEx.java @@ -17,10 +17,12 @@ package org.jetbrains.io; import com.google.gson.JsonParseException; import com.google.gson.stream.JsonToken; +import com.intellij.util.text.CharArrayCharSequence; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.Closeable; +import java.nio.CharBuffer; import java.util.Arrays; public final class JsonReaderEx implements Closeable { @@ -116,6 +118,26 @@ public final class JsonReaderEx implements Closeable { this.stack = stack; } + // we must return string on subSequence() - JsonReaderEx will call toString in any case + public static final class CharSequenceBackedByChars extends CharArrayCharSequence { + public CharSequenceBackedByChars(@NotNull CharBuffer charBuffer) { + super(charBuffer.array(), charBuffer.arrayOffset(), charBuffer.position()); + } + + public CharSequenceBackedByChars(@NotNull char[] chars, int start, int end) { + super(chars, start, end); + } + + public CharSequenceBackedByChars(@NotNull char[] chars) { + super(chars); + } + + @Override + public CharSequence subSequence(int start, int end) { + return start == 0 && end == length() ? this : new String(myChars, myStart + start, end - start); + } + } + private final static class JsonScope { /** * An array with no elements requires no separators or newlines before diff --git a/platform/platform-impl/src/org/jetbrains/io/MessageDecoder.java b/platform/platform-impl/src/org/jetbrains/io/MessageDecoder.java index 6746a4c1d2f1..3f672c3916d6 100644 --- a/platform/platform-impl/src/org/jetbrains/io/MessageDecoder.java +++ b/platform/platform-impl/src/org/jetbrains/io/MessageDecoder.java @@ -44,7 +44,7 @@ public abstract class MessageDecoder extends Decoder { chunkedContent = null; consumedContentByteCount = 0; } - return new ChannelBufferToString.MyCharArrayCharSequence(ChannelBufferToString.readIntoCharBuffer(input, required, charBuffer)); + return new JsonReaderEx.CharSequenceBackedByChars(ChannelBufferToString.readIntoCharBuffer(input, required, charBuffer)); } } diff --git a/platform/platform-resources-en/src/messages/XmlBundle.properties b/platform/platform-resources-en/src/messages/XmlBundle.properties index f1f562b21bb8..aa754f09f720 100644 --- a/platform/platform-resources-en/src/messages/XmlBundle.properties +++ b/platform/platform-resources-en/src/messages/XmlBundle.properties @@ -164,6 +164,15 @@ html.add.table.column.after.action=Add a new column to the table after the curre html.add.table.column.before.action=Add a new column to the table before the current one xml.javadoc.enumeration.value.message=Enumeration value +xml.inspections.unused.schema=Unused XML schema declaration +xml.inspections.unused.schema.location=Namespace location is never used +xml.inspections.unused.schema.declaration=Namespace declaration is never used +xml.inspections.unused.schema.remove=Remove unused namespace declaration + +xml.inspections.path.resolve=File path resolving in XML + +xml.inspections.global=XML highlighting + #xsd2xml and xml2xsd url.is.empty.validation.problem=Url is empty invalid.number.validation.problem=Invalid number diff --git a/platform/platform-resources/src/META-INF/XmlPlugin.xml b/platform/platform-resources/src/META-INF/XmlPlugin.xml index 345fb6259d99..ddd9cb54eb26 100644 --- a/platform/platform-resources/src/META-INF/XmlPlugin.xml +++ b/platform/platform-resources/src/META-INF/XmlPlugin.xml @@ -390,64 +390,85 @@ - - - - - + - - - - - - - - - - - - - + + + + + + + + + - - - diff --git a/platform/platform-resources/src/brokenPlugins.txt b/platform/platform-resources/src/brokenPlugins.txt index 294725d5755a..49301d4a4d4a 100644 --- a/platform/platform-resources/src/brokenPlugins.txt +++ b/platform/platform-resources/src/brokenPlugins.txt @@ -13,7 +13,7 @@ org.jetbrains.kannotator 0.2.420 org.jetbrains.kotlin 0.10.555 0.10.4 0.8.1615 0.7.1360 0.7.1376 0.8.7 SBT 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.4.0 1.5.0 1.5.1 1.6.0 1.6.1 "JSTestDriver Plugin" 140.2109 140.1669 140.727 138.317 138.21 136.1141 134.1163 134.686 134.31 134.307 134.1039 -AngularJS 141.2 140.1968 139.1112 139.12 134.1243 134.1341 134.1444 135.1063 135.565 135.831 135.937 138.1242 138.1988 134.1094 0.1.8 0.1.9 +AngularJS 142.1935 141.2 140.1968 139.1112 139.12 134.1243 134.1341 134.1444 135.1063 135.565 135.831 135.937 138.1242 138.1988 134.1094 0.1.8 0.1.9 com.jetbrains.plugins.ini4idea 0.4 0.5 0.6 0.7 0.8 0.8.1 0.9 0.9.1 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 130.1176 org.jetbrains.plugins.vagrant 0.1 0.2 org.intellij.clojure 0.2.1.178 diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorImplTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorImplTest.java index 388b349b30a7..f97ea942da7f 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorImplTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -141,4 +141,14 @@ public class EditorImplTest extends AbstractEditorTest { assertEquals(new LogicalPosition(0, 3), myEditor.getCaretModel().getLogicalPosition()); assertEquals(new VisualPosition(0, 3), myEditor.getCaretModel().getVisualPosition()); } + + public void testSoftWrapModeUpdateDuringBulkModeChange() throws Exception { + initText("long long line"); + configureSoftWraps(12); + DocumentEx document = (DocumentEx)myEditor.getDocument(); + document.setInBulkUpdate(true); + document.replaceString(4, 5, "-"); + document.setInBulkUpdate(false); + assertEquals(new VisualPosition(1, 5), myEditor.getCaretModel().getVisualPosition()); + } } diff --git a/platform/platform-tests/testSrc/com/intellij/psi/autodetect/IndentAutoDetectionTest.java b/platform/platform-tests/testSrc/com/intellij/psi/autodetect/IndentAutoDetectionTest.java deleted file mode 100644 index 1d97170c2cea..000000000000 --- a/platform/platform-tests/testSrc/com/intellij/psi/autodetect/IndentAutoDetectionTest.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.psi.autodetect; - -import com.intellij.openapi.fileTypes.PlainTextLanguage; -import com.intellij.psi.codeStyle.CommonCodeStyleSettings; -import com.intellij.psi.codeStyle.autodetect.LineIndentInfo; -import com.intellij.psi.codeStyle.autodetect.LineIndentInfoBuilder; -import com.intellij.testFramework.PlatformTestUtil; -import org.jetbrains.annotations.NotNull; -import org.junit.Assert; - -import java.io.File; -import java.util.List; - -public class IndentAutoDetectionTest extends AbstractIndentAutoDetectionTest { - - @NotNull - @Override - protected String getTestDataPath() { - return PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') - + "/platform/platform-tests/testData/" - + "codeStyle/autodetect/"; - } - - @NotNull - protected String getFileNameWithExtension() { - return getTestName(true) + ".java"; - } - - - public void testBigFileWithIndent2() { - doTestIndentSize(2); - } - - public void testBigFileWithIndent8() { - doTestIndentSize(8); - } - - public void testBigFileWithIndent4() { - doTestIndentSize(4); - } - - public void testFileWithTabs() { - doTestTabsUsed(); - } - - public void testSimpleIndent() { - doTestMaxUsedIndent(2, 6); - } - - public void testManyComments() { - doTestMaxUsedIndent(2, 6); - } - - public void testManyZeroRelativeIndent() { - doTestMaxUsedIndent(2); - } - - public void testSmallFileWithIndent8() { - doTestMaxUsedIndent(8); - } - - public void testSmallFileWithTabs() { - doTestTabsUsed(); - } - - public void testNoZeroIndentsInStats() { - doTestIndentSize(4); - } - - public void testNoIndentsUseLanguageSpecificSettings() { - CommonCodeStyleSettings.IndentOptions options = new CommonCodeStyleSettings.IndentOptions(); - options.USE_TAB_CHARACTER = true; - - doTestTabsUsed(options); - } - - public void testManyZeroIndents() { doTestIndentSize(2); } - - public void testSpacesToNumbers() throws Exception { - String text = " i\n" + - " a\n" + - " t\n"; - doTestLineToIndentMapping(text, 5, 4, 10); - } - - public void testEmptyLines() throws Exception { - doTestLineToIndentMapping(" \n\n\n", -1, -1, -1); - } - - public void testSpacesInSimpleClass() { - doTestLineToIndentMapping( - "public class A {\n" + - "\n" + - " public void test() {\n" + - " int a = 2;\n" + - " }\n" + - "\n" + - " public void a() {\n" + - " }\n" + - "}", - 0, -1, 4, 6, 4, -1, 4, 4, 0 - ); - } - - public void testComplexIndents() { - doTestLineToIndentMapping( - "class Test\n" + - "{\n" + - " int a;\n" + - " int b;\n" + - " \n" + - " public void test() {\n" + - " int c;\n" + - " }\n" + - " \n" + - " public void run() {\n" + - " Runnable runnable = new Runnable() {\n" + - " @Override\n" + - " public void run() {\n" + - " System.out.println(\"Hello!\");\n" + - " }\n" + - " };\n" + - " }\n" + - "}", - 0, 0, 2, 2, -1, 2, 4, 2, -1, 2, 4, 6, 6, 8, 6, 4, 2, 0 - ); - } - - private static void doTestLineToIndentMapping(@NotNull CharSequence text, int... spacesForLine) { - List list = new LineIndentInfoBuilder(text, PlainTextLanguage.INSTANCE).build(); - Assert.assertEquals(list.size(), spacesForLine.length); - for (int i = 0; i < spacesForLine.length; i++) { - int indentSize = list.get(i).getIndentSize(); - Assert.assertEquals("Mismatch on line " + i, spacesForLine[i], indentSize); - } - } -} diff --git a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentLoggingHandler.java b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentLoggingHandler.java index 33613616c403..0121843b13ff 100644 --- a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentLoggingHandler.java +++ b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentLoggingHandler.java @@ -16,6 +16,7 @@ package com.intellij.remoteServer.agent.util; import com.intellij.remoteServer.agent.util.log.LogListener; +import com.intellij.remoteServer.agent.util.log.TerminalListener; import java.io.InputStream; import java.io.OutputStream; @@ -35,5 +36,5 @@ public interface CloudAgentLoggingHandler { boolean isTtySupported(); - void createTerminal(String pipeName, OutputStream terminalInput, InputStream terminalOutput); + TerminalListener createTerminal(String pipeName, OutputStream terminalInput, InputStream terminalOutput); } diff --git a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/TerminalListener.java b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/TerminalListener.java new file mode 100644 index 000000000000..bd1590b00cb8 --- /dev/null +++ b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/TerminalListener.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.remoteServer.agent.util.log; + +public interface TerminalListener { + + void close(); + + static TerminalListener NULL = new TerminalListener() { + + public void close() { + + } + }; +} diff --git a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/TerminalPipe.java b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/TerminalPipe.java index 9802bc61d12c..ec29fdb69c52 100644 --- a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/TerminalPipe.java +++ b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/TerminalPipe.java @@ -24,20 +24,22 @@ public abstract class TerminalPipe extends LogPipeBase { private final String myLogPipeName; private final CloudAgentLoggingHandler myLoggingHandler; + private TerminalListener myTerminalListener; public TerminalPipe(String logPipeName, CloudAgentLoggingHandler loggingHandler) { myLogPipeName = logPipeName; myLoggingHandler = loggingHandler; + myTerminalListener = TerminalListener.NULL; } @Override public void open() { - myLoggingHandler.createTerminal(myLogPipeName, getOutputStream(), getInputStream()); + myTerminalListener = myLoggingHandler.createTerminal(myLogPipeName, getOutputStream(), getInputStream()); } @Override public void close() { - + myTerminalListener.close(); } protected abstract OutputStream getOutputStream(); diff --git a/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/deployment/DeploymentLogManager.java b/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/deployment/DeploymentLogManager.java index d04f7d1bdb19..d69ef80dc1f4 100644 --- a/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/deployment/DeploymentLogManager.java +++ b/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/deployment/DeploymentLogManager.java @@ -16,6 +16,7 @@ package com.intellij.remoteServer.runtime.deployment; import com.intellij.remoteServer.runtime.log.LoggingHandler; +import com.intellij.remoteServer.runtime.log.TerminalHandler; import org.jetbrains.annotations.NotNull; import java.io.InputStream; @@ -33,5 +34,5 @@ public interface DeploymentLogManager { boolean isTtySupported(); - void addTerminal(@NotNull String presentableName, InputStream terminalOutput, OutputStream terminalInput); + TerminalHandler addTerminal(@NotNull String presentableName, InputStream terminalOutput, OutputStream terminalInput); } diff --git a/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/log/TerminalHandler.java b/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/log/TerminalHandler.java new file mode 100644 index 000000000000..dbeb989e32de --- /dev/null +++ b/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/log/TerminalHandler.java @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.remoteServer.runtime.log; + +public interface TerminalHandler { + + void close(); +} diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/CloudTerminalProvider.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/CloudTerminalProvider.java index ed2b1259a30a..da1a522129fa 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/CloudTerminalProvider.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/CloudTerminalProvider.java @@ -26,10 +26,10 @@ public interface CloudTerminalProvider { ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.remoteServer.CloudTerminalProvider"); - LoggingHandlerBase createTerminal(@NotNull String presentableName, - @NotNull Project project, - @NotNull InputStream terminalOutput, - @NotNull OutputStream terminalInput); + TerminalHandlerBase createTerminal(@NotNull String presentableName, + @NotNull Project project, + @NotNull InputStream terminalOutput, + @NotNull OutputStream terminalInput); boolean isTtySupported(); } diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/ConsoleTerminalHandlerImpl.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/ConsoleTerminalHandlerImpl.java index da41e8d0e820..e77efca79dbf 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/ConsoleTerminalHandlerImpl.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/ConsoleTerminalHandlerImpl.java @@ -26,17 +26,17 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.io.*; -public class ConsoleTerminalHandlerImpl extends LoggingHandlerBase { +public class ConsoleTerminalHandlerImpl extends TerminalHandlerBase { private static final Logger LOG = Logger.getInstance("#" + ConsoleTerminalHandlerImpl.class.getName()); public static final CloudTerminalProvider PROVIDER = new CloudTerminalProvider() { @Override - public LoggingHandlerBase createTerminal(@NotNull String presentableName, - @NotNull Project project, - @NotNull InputStream terminalOutput, - @NotNull OutputStream terminalInput) { + public TerminalHandlerBase createTerminal(@NotNull String presentableName, + @NotNull Project project, + @NotNull InputStream terminalOutput, + @NotNull OutputStream terminalInput) { return new ConsoleTerminalHandlerImpl(presentableName, project, terminalOutput, terminalInput); } @@ -86,7 +86,7 @@ public class ConsoleTerminalHandlerImpl extends LoggingHandlerBase { public void run() { BufferedReader outputReader = new BufferedReader(new InputStreamReader(terminalOutput)); try { - while (true) { + while (!isClosed()) { String line = outputReader.readLine(); if (line == null) { break; diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/DeploymentLogManagerImpl.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/DeploymentLogManagerImpl.java index ebc1a39c5ef3..4e125c0f944c 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/DeploymentLogManagerImpl.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/DeploymentLogManagerImpl.java @@ -20,6 +20,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; import com.intellij.remoteServer.runtime.deployment.DeploymentLogManager; import com.intellij.remoteServer.runtime.log.LoggingHandler; +import com.intellij.remoteServer.runtime.log.TerminalHandler; import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NotNull; @@ -80,9 +81,10 @@ public class DeploymentLogManagerImpl implements DeploymentLogManager { } @Override - public void addTerminal(@NotNull final String presentableName, InputStream terminalOutput, OutputStream terminalInput) { - LoggingHandlerBase handler = getTerminalProvider().createTerminal(presentableName, myProject, terminalOutput, terminalInput); + public TerminalHandler addTerminal(@NotNull final String presentableName, InputStream terminalOutput, OutputStream terminalInput) { + TerminalHandlerBase handler = getTerminalProvider().createTerminal(presentableName, myProject, terminalOutput, terminalInput); addAdditionalLoggingHandler(handler); + return handler; } private static CloudTerminalProvider getTerminalProvider() { diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/LoggingHandlerBase.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/LoggingHandlerBase.java index 71be3380b3f0..121dc55dd48d 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/LoggingHandlerBase.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/LoggingHandlerBase.java @@ -33,6 +33,8 @@ public abstract class LoggingHandlerBase implements Disposable { public abstract JComponent getComponent(); + public abstract boolean isClosed(); + @Override public void dispose() { diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/LoggingHandlerImpl.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/LoggingHandlerImpl.java index 5fb9b88b6e0e..9ee9d2a8b36f 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/LoggingHandlerImpl.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/LoggingHandlerImpl.java @@ -63,4 +63,9 @@ public class LoggingHandlerImpl extends LoggingHandlerBase implements LoggingHan public void clear() { myConsole.clear(); } + + @Override + public boolean isClosed() { + return false; + } } diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/TerminalHandlerBase.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/TerminalHandlerBase.java new file mode 100644 index 000000000000..c1892c9c2374 --- /dev/null +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/TerminalHandlerBase.java @@ -0,0 +1,42 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.remoteServer.impl.runtime.log; + +import com.intellij.remoteServer.runtime.log.TerminalHandler; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; + +public abstract class TerminalHandlerBase extends LoggingHandlerBase implements TerminalHandler { + + private boolean myClosed = false; + + public TerminalHandlerBase(@NotNull String presentableName) { + super(presentableName); + } + + @Override + public abstract JComponent getComponent(); + + @Override + public boolean isClosed() { + return myClosed; + } + + public void close() { + myClosed = true; + } +} diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudLoggingHandlerImpl.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudLoggingHandlerImpl.java index 41ad5e1c59eb..89a8f5f27395 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudLoggingHandlerImpl.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudLoggingHandlerImpl.java @@ -18,8 +18,10 @@ package com.intellij.remoteServer.util; import com.intellij.execution.process.ProcessHandler; import com.intellij.remoteServer.agent.util.CloudAgentLoggingHandler; import com.intellij.remoteServer.agent.util.log.LogListener; +import com.intellij.remoteServer.agent.util.log.TerminalListener; import com.intellij.remoteServer.runtime.deployment.DeploymentLogManager; import com.intellij.remoteServer.runtime.log.LoggingHandler; +import com.intellij.remoteServer.runtime.log.TerminalHandler; import org.jetbrains.annotations.Nullable; import java.io.InputStream; @@ -108,8 +110,15 @@ public class CloudLoggingHandlerImpl implements CloudAgentLoggingHandler { } @Override - public void createTerminal(final String pipeName, OutputStream terminalInput, InputStream terminalOutput) { - myLogManager.addTerminal(pipeName, terminalOutput, terminalInput); + public TerminalListener createTerminal(final String pipeName, OutputStream terminalInput, InputStream terminalOutput) { + final TerminalHandler terminalHandler = myLogManager.addTerminal(pipeName, terminalOutput, terminalInput); + return new TerminalListener() { + + @Override + public void close() { + terminalHandler.close(); + } + }; } private static class LogListenerImpl implements LogListener { diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudSilentLoggingHandlerImpl.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudSilentLoggingHandlerImpl.java index 02219bbfffb6..4e37d444d9b6 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudSilentLoggingHandlerImpl.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudSilentLoggingHandlerImpl.java @@ -3,6 +3,7 @@ package com.intellij.remoteServer.util; import com.intellij.openapi.diagnostic.Logger; import com.intellij.remoteServer.agent.util.CloudAgentLoggingHandler; import com.intellij.remoteServer.agent.util.log.LogListener; +import com.intellij.remoteServer.agent.util.log.TerminalListener; import java.io.InputStream; import java.io.OutputStream; @@ -40,7 +41,7 @@ public class CloudSilentLoggingHandlerImpl implements CloudAgentLoggingHandler { } @Override - public void createTerminal(String pipeName, OutputStream terminalInput, InputStream terminalOutput) { - + public TerminalListener createTerminal(String pipeName, OutputStream terminalInput, InputStream terminalOutput) { + return TerminalListener.NULL; } } diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/DebugEventAdapter.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/DebugEventAdapter.java index 3ee0bb525532..f81d56b5fad9 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/DebugEventAdapter.java +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/DebugEventAdapter.java @@ -18,7 +18,7 @@ public abstract class DebugEventAdapter implements DebugEventListener { } @Override - public void scriptAdded(@NotNull Script script, @Nullable String sourceMapData) { + public void scriptAdded(@NotNull Script script, @Nullable String sourceMapUrl) { } @Override diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/DebugEventListener.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/DebugEventListener.java index 7a523229adc7..7086ffc8706c 100755 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/DebugEventListener.java +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/DebugEventListener.java @@ -29,7 +29,7 @@ public interface DebugEventListener extends EventListener { /** * Reports that a new script has been loaded. */ - void scriptAdded(@NotNull Script script, @Nullable String sourceMapData); + void scriptAdded(@NotNull Script script, @Nullable String sourceMapUrl); void sourceMapFound(@NotNull Script script, @Nullable Url sourceMapUrl, @NotNull String sourceMapData); diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/Script.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/Script.java index fd09ff059e37..c70806f2c06b 100755 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/Script.java +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/Script.java @@ -7,8 +7,6 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.debugger.sourcemap.SourceMap; public interface Script extends UserDataHolderEx, HasUrl { - void setSourceMap(SourceMap sourceMap); - enum Type { /** A native, internal JavaScript VM script */ NATIVE, @@ -25,6 +23,8 @@ public interface Script extends UserDataHolderEx, HasUrl { @Nullable SourceMap getSourceMap(); + void setSourceMap(@Nullable SourceMap sourceMap); + @Override @NotNull Url getUrl(); diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/ScriptManager.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/ScriptManager.java index 1132b284e16d..4b3a20e0f6ec 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/ScriptManager.java +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/ScriptManager.java @@ -2,6 +2,7 @@ package org.jetbrains.debugger; import com.intellij.util.CommonProcessors; import com.intellij.util.Processor; +import com.intellij.util.Url; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.concurrency.Promise; @@ -37,6 +38,9 @@ public interface ScriptManager { @Nullable Script findScriptByUrl(@NotNull String rawUrl); + @Nullable + Script findScriptByUrl(@NotNull Url url); + @Nullable Script findScriptById(@NotNull String id); diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/ScriptManagerBaseEx.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/ScriptManagerBaseEx.java index 05cca7fd4317..b8286f77b15c 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/ScriptManagerBaseEx.java +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/ScriptManagerBaseEx.java @@ -35,7 +35,12 @@ public abstract class ScriptManagerBaseEx