From b69a5d57e61647a8b9d4234c5aab932a9b96dc3b Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 11 Nov 2014 13:18:20 +0300 Subject: [PATCH] cleanup --- .../visibility/VisibilityInspection.java | 7 +- .../findUsages/JavaFindUsagesHandler.java | 22 ++--- .../impl/light/LightEmptyImplementsList.java | 5 +- .../psi/impl/light/LightParameter.java | 7 +- .../psi/impl/light/LightVariableBuilder.java | 7 +- .../tree/java/PsiTypeParameterImpl.java | 18 +--- .../codeInspection/LocalInspectionTool.java | 6 +- ...efaultHighlightVisitorBasedInspection.java | 83 +++++++------------ .../intellij/lang/FCTSBackedLighterAST.java | 3 +- .../src/com/intellij/lang/LighterAST.java | 4 +- .../src/com/intellij/ui/LayeredIcon.java | 23 ++--- .../psi/impl/DocumentCommitProcessor.java | 6 +- .../intellij/psi/impl/light/LightElement.java | 5 +- .../OfflineProblemDescriptorNode.java | 14 ++-- .../injected/InjectedLanguageManagerImpl.java | 1 + .../fileTypes/impl/FileTypeManagerImpl.java | 11 ++- .../spellchecker/compress/Alphabet.java | 10 ++- .../compress/CompressedDictionary.java | 3 +- .../spellchecker/compress/Encoder.java | 7 +- 19 files changed, 103 insertions(+), 139 deletions(-) diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/visibility/VisibilityInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/visibility/VisibilityInspection.java index fd66f2806cb9..112add434e6b 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/visibility/VisibilityInspection.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/visibility/VisibilityInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,6 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.usageView.UsageViewTypeLocation; import com.intellij.util.IncorrectOperationException; -import com.intellij.util.VisibilityUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -222,7 +221,7 @@ public class VisibilityInspection extends GlobalJavaBatchInspectionTool { @Nullable @PsiModifier.ModifierConstant - public String getPossibleAccess(@Nullable RefJavaElement refElement) { + private String getPossibleAccess(@Nullable RefJavaElement refElement) { if (refElement == null) return null; String curAccess = refElement.getAccessModifier(); String weakestAccess = PsiModifier.PRIVATE; @@ -553,7 +552,7 @@ public class VisibilityInspection extends GlobalJavaBatchInspectionTool { private static class AcceptSuggestedAccess implements LocalQuickFix{ private final RefManager myManager; @PsiModifier.ModifierConstant private final String myHint; - private String myName; + private final String myName; private AcceptSuggestedAccess(final RefManager manager, @PsiModifier.ModifierConstant String hint, String name) { myManager = manager; diff --git a/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java b/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java index c8bc09984ac3..16c7fec221c7 100644 --- a/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java +++ b/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java @@ -22,13 +22,14 @@ import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.util.*; +import com.intellij.openapi.util.Condition; import com.intellij.psi.*; import com.intellij.psi.codeStyle.JavaCodeStyleManager; import com.intellij.psi.codeStyle.VariableKind; import com.intellij.psi.impl.search.ThrowSearchUtil; -import com.intellij.psi.search.*; -import com.intellij.psi.search.searches.*; +import com.intellij.psi.search.SearchScope; +import com.intellij.psi.search.searches.MethodReferencesSearch; +import com.intellij.psi.search.searches.OverridingMethodsSearch; import com.intellij.psi.util.PropertyUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.psi.util.PsiUtilCore; @@ -41,7 +42,10 @@ import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Set; /** * @author peter @@ -94,8 +98,7 @@ public class JavaFindUsagesHandler extends FindUsagesHandler{ } @NotNull - private static PsiElement[] getParameterElementsToSearch(@NotNull PsiParameter parameter) { - final PsiMethod method = (PsiMethod)parameter.getDeclarationScope(); + private static PsiElement[] getParameterElementsToSearch(@NotNull PsiParameter parameter, @NotNull PsiMethod method) { PsiMethod[] overrides = OverridingMethodsSearch.search(method, true).toArray(PsiMethod.EMPTY_ARRAY); for (int i = 0; i < overrides.length; i++) { final PsiElement navigationElement = overrides[i].getNavigationElement(); @@ -131,7 +134,7 @@ public class JavaFindUsagesHandler extends FindUsagesHandler{ boolean hasOverridden = OverridingMethodsSearch.search(method).findFirst() != null; if (hasOverridden && askWhetherShouldSearchForParameterInOverridingMethods(element, parameter)) { - return getParameterElementsToSearch(parameter); + return getParameterElementsToSearch(parameter, method); } } } @@ -221,9 +224,8 @@ public class JavaFindUsagesHandler extends FindUsagesHandler{ @Override protected boolean isSearchForTextOccurencesAvailable(@NotNull PsiElement psiElement, boolean isSingleFile) { - if (isSingleFile) return false; - return new JavaNonCodeSearchElementDescriptionProvider().getElementDescription(psiElement, NonCodeSearchDescriptionLocation.NON_JAVA) != null; - + return !isSingleFile && + new JavaNonCodeSearchElementDescriptionProvider().getElementDescription(psiElement, NonCodeSearchDescriptionLocation.NON_JAVA) != null; } @NotNull diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/light/LightEmptyImplementsList.java b/java/java-psi-impl/src/com/intellij/psi/impl/light/LightEmptyImplementsList.java index 6e35f12ac2f0..d172e0349bc1 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/light/LightEmptyImplementsList.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/light/LightEmptyImplementsList.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,10 +23,11 @@ import org.jetbrains.annotations.NotNull; * @author max */ public class LightEmptyImplementsList extends LightElement implements PsiReferenceList { - public LightEmptyImplementsList(PsiManager manager) { + public LightEmptyImplementsList(@NotNull PsiManager manager) { super(manager, JavaLanguage.INSTANCE); } + @Override public String toString() { return "PsiReferenceList"; } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/light/LightParameter.java b/java/java-psi-impl/src/com/intellij/psi/impl/light/LightParameter.java index 44834f7999e9..e9e1866efb3a 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/light/LightParameter.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/light/LightParameter.java @@ -23,16 +23,14 @@ import org.jetbrains.annotations.NotNull; * @author peter */ public class LightParameter extends LightVariableBuilder implements PsiParameter { - public static final LightParameter[] EMPTY_ARRAY = new LightParameter[0]; - private final PsiElement myDeclarationScope; private final boolean myVarArgs; - public LightParameter(@NotNull String name, @NotNull PsiType type, PsiElement declarationScope, Language language) { + public LightParameter(@NotNull String name, @NotNull PsiType type, @NotNull PsiElement declarationScope, @NotNull Language language) { this(name, type, declarationScope, language, type instanceof PsiEllipsisType); } - public LightParameter(@NotNull String name, @NotNull PsiType type, PsiElement declarationScope, Language language, boolean isVarArgs) { + public LightParameter(@NotNull String name, @NotNull PsiType type, @NotNull PsiElement declarationScope, @NotNull Language language, boolean isVarArgs) { super(declarationScope.getManager(), name, type, language); myDeclarationScope = declarationScope; myVarArgs = isVarArgs; @@ -51,6 +49,7 @@ public class LightParameter extends LightVariableBuilder i } } + @Override public String toString() { return "Light Parameter"; } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/light/LightVariableBuilder.java b/java/java-psi-impl/src/com/intellij/psi/impl/light/LightVariableBuilder.java index 38696d83d401..a6713063497e 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/light/LightVariableBuilder.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/light/LightVariableBuilder.java @@ -48,7 +48,7 @@ public class LightVariableBuilder extends LightE setNavigationElement(navigationElement); } - public LightVariableBuilder(PsiManager manager, @NotNull String name, @NotNull PsiType type, Language language) { + public LightVariableBuilder(PsiManager manager, @NotNull String name, @NotNull PsiType type, @NotNull Language language) { super(manager, language); myName = name; myType = type; @@ -152,9 +152,4 @@ public class LightVariableBuilder extends LightE public void setOriginInfo(@Nullable String originInfo) { myOriginInfo = originInfo; } - - @Override - public boolean equals(Object obj) { - return super.equals(obj); - } } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiTypeParameterImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiTypeParameterImpl.java index f03b44e8adb9..986930701f5f 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiTypeParameterImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiTypeParameterImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,10 +26,8 @@ import com.intellij.psi.impl.java.stubs.JavaStubElementTypes; import com.intellij.psi.impl.java.stubs.PsiTypeParameterListStub; import com.intellij.psi.impl.java.stubs.PsiTypeParameterStub; import com.intellij.psi.impl.light.LightEmptyImplementsList; -import com.intellij.psi.impl.meta.MetaRegistry; import com.intellij.psi.impl.source.JavaStubPsiElement; import com.intellij.psi.javadoc.PsiDocComment; -import com.intellij.psi.meta.PsiMetaData; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.psi.search.SearchScope; import com.intellij.psi.util.PsiTreeUtil; @@ -46,13 +44,6 @@ import java.util.List; * @author dsl */ public class PsiTypeParameterImpl extends JavaStubPsiElement implements PsiTypeParameter { - private final LightEmptyImplementsList myLightEmptyImplementsList = new LightEmptyImplementsList(null) { - @Override - public PsiManager getManager() { - return PsiTypeParameterImpl.this.getManager(); - } - }; - public PsiTypeParameterImpl(final PsiTypeParameterStub stub) { super(stub, JavaStubElementTypes.TYPE_PARAMETER); } @@ -245,7 +236,7 @@ public class PsiTypeParameterImpl extends JavaStubPsiElement processFile(@NotNull PsiFile file, - @NotNull InspectionManager manager) { + public List processFile(@NotNull PsiFile file, @NotNull InspectionManager manager) { final ProblemsHolder holder = new ProblemsHolder(manager, file, false); LocalInspectionToolSession session = new LocalInspectionToolSession(file, 0, file.getTextLength()); final PsiElementVisitor customVisitor = buildVisitor(holder, false, session); @@ -200,6 +200,4 @@ public abstract class LocalInspectionTool extends InspectionProfileEntry { return holder.getResults(); } - - } diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/DefaultHighlightVisitorBasedInspection.java b/platform/analysis-impl/src/com/intellij/codeInspection/DefaultHighlightVisitorBasedInspection.java index bb376dc83eb7..39c59a853474 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/DefaultHighlightVisitorBasedInspection.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/DefaultHighlightVisitorBasedInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -162,65 +162,38 @@ public abstract class DefaultHighlightVisitorBasedInspection extends GlobalSimpl final Project project = file.getProject(); Document document = PsiDocumentManager.getInstance(project).getDocument(file); if (document == null) return; - //final HighlightInfoFilter[] filters = ApplicationManager.getApplication().getExtensions(HighlightInfoFilter.EXTENSION_POINT_NAME); DaemonProgressIndicator progress = new DaemonProgressIndicator(); progress.start(); - TextEditorHighlightingPassRegistrarEx passRegistrarEx = TextEditorHighlightingPassRegistrarEx.getInstanceEx(project); - List passes = passRegistrarEx.instantiateMainPasses(file, document, HighlightInfoProcessor.getEmpty()); - List gpasses = ContainerUtil.collect(passes.iterator(), FilteringIterator.instanceOf(GeneralHighlightingPass.class)); - for (final GeneralHighlightingPass gpass : gpasses) { - gpass.setHighlightVisitorProducer(new NotNullProducer() { - @NotNull - @Override - public HighlightVisitor[] produce() { - gpass.incVisitorUsageCount(1); - return new HighlightVisitor[]{new DefaultHighlightVisitor(project, highlightErrorElements, runAnnotators, true)}; + try { + TextEditorHighlightingPassRegistrarEx passRegistrarEx = TextEditorHighlightingPassRegistrarEx.getInstanceEx(project); + List passes = passRegistrarEx.instantiateMainPasses(file, document, HighlightInfoProcessor.getEmpty()); + List gpasses = ContainerUtil.collect(passes.iterator(), FilteringIterator.instanceOf(GeneralHighlightingPass.class)); + for (final GeneralHighlightingPass gpass : gpasses) { + gpass.setHighlightVisitorProducer(new NotNullProducer() { + @NotNull + @Override + public HighlightVisitor[] produce() { + gpass.incVisitorUsageCount(1); + return new HighlightVisitor[]{new DefaultHighlightVisitor(project, highlightErrorElements, runAnnotators, true)}; + } + }); + } + + + for (TextEditorHighlightingPass pass : gpasses) { + pass.doCollectInformation(progress); + List infos = pass.getInfos(); + for (HighlightInfo info : infos) { + if (info == null) continue; + //if (info.type == HighlightInfoType.INJECTED_LANGUAGE_FRAGMENT) continue; + if (info.getSeverity().compareTo(HighlightSeverity.INFORMATION) <= 0) continue; + result.add(Pair.create(file, info)); } - }); - } - - - for (TextEditorHighlightingPass pass : gpasses) { - pass.doCollectInformation(progress); - List infos = pass.getInfos(); - for (HighlightInfo info : infos) { - if (info == null) continue; - //if (info.type == HighlightInfoType.INJECTED_LANGUAGE_FRAGMENT) continue; - if (info.getSeverity().compareTo(HighlightSeverity.INFORMATION) <= 0) continue; - result.add(Pair.create(file, info)); } } - //GeneralHighlightingPass pass = - // new GeneralHighlightingPass(project, file, document, 0, file.getTextLength(), true, new ProperTextRange(0, document.getTextLength()), null, HighlightInfoProcessor.getEmpty()) { - // @NotNull - // @Override - // protected HighlightVisitor[] createHighlightVisitors() { - // return new HighlightVisitor[]{new DefaultHighlightVisitor(project, highlightErrorElements, runAnnotators, true)}; - // } - // - // @Override - // protected HighlightInfoHolder createInfoHolder(final PsiFile file) { - // return new CustomHighlightInfoHolder(file, getColorsScheme(), filters) { - // @Override - // public boolean add(@Nullable HighlightInfo info) { - // if (info == null) return true; - // if (info.type == HighlightInfoType.INJECTED_LANGUAGE_FRAGMENT) return true; - // if (info.getSeverity() == HighlightSeverity.INFORMATION) return true; - // - // result.add(Pair.create(file, info)); - // - // return true; - // } - // }; - // } - // - // @Override - // protected boolean isFailFastOnAcquireReadAction() { - // return myOnTheFly; - // } - // }; - //progress.start(); - //pass.collectInformation(progress); + finally { + progress.stop(); + } } } } diff --git a/platform/core-api/src/com/intellij/lang/FCTSBackedLighterAST.java b/platform/core-api/src/com/intellij/lang/FCTSBackedLighterAST.java index 2702e9480584..dc241b519872 100644 --- a/platform/core-api/src/com/intellij/lang/FCTSBackedLighterAST.java +++ b/platform/core-api/src/com/intellij/lang/FCTSBackedLighterAST.java @@ -24,9 +24,10 @@ import org.jetbrains.annotations.NotNull; import java.util.List; public class FCTSBackedLighterAST extends LighterAST { + @NotNull private final FlyweightCapableTreeStructure myTreeStructure; - public FCTSBackedLighterAST(final CharTable charTable, final FlyweightCapableTreeStructure treeStructure) { + public FCTSBackedLighterAST(@NotNull CharTable charTable, @NotNull FlyweightCapableTreeStructure treeStructure) { super(charTable); myTreeStructure = treeStructure; } diff --git a/platform/core-api/src/com/intellij/lang/LighterAST.java b/platform/core-api/src/com/intellij/lang/LighterAST.java index de2c44aa1299..73bedde677e9 100644 --- a/platform/core-api/src/com/intellij/lang/LighterAST.java +++ b/platform/core-api/src/com/intellij/lang/LighterAST.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import java.util.List; public abstract class LighterAST { private final CharTable myCharTable; - public LighterAST(final CharTable charTable) { + public LighterAST(@NotNull CharTable charTable) { myCharTable = charTable; } diff --git a/platform/core-api/src/com/intellij/ui/LayeredIcon.java b/platform/core-api/src/com/intellij/ui/LayeredIcon.java index feb46c81f358..920adbccd1af 100644 --- a/platform/core-api/src/com/intellij/ui/LayeredIcon.java +++ b/platform/core-api/src/com/intellij/ui/LayeredIcon.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package com.intellij.ui; import com.intellij.openapi.diagnostic.Logger; +import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.awt.*; @@ -40,27 +41,28 @@ public class LayeredIcon implements Icon { myVShifts = new int[layerCount]; } - public LayeredIcon(Icon... icons) { + public LayeredIcon(@NotNull Icon... icons) { this(icons.length); for (int i = 0; i < icons.length; i++) { setIcon(icons[i], i); } } - public static LayeredIcon createHorizontalIcon(Icon... icons) { - LayeredIcon icon = new LayeredIcon(icons.length); - int hShift = 0; + public static LayeredIcon createHorizontalIcon(@NotNull Icon... icons) { + LayeredIcon result = new LayeredIcon(icons.length); int maxHeight = 0; - for (int i = 0; i < icons.length; i++) { - maxHeight = Math.max(maxHeight, icons[i].getIconHeight()); + for (Icon icon : icons) { + maxHeight = Math.max(maxHeight, icon.getIconHeight()); } + int hShift = 0; for (int i = 0; i < icons.length; i++) { - icon.setIcon(icons[i], i, hShift, (maxHeight - icons[i].getIconHeight()) / 2); + result.setIcon(icons[i], i, hShift, (maxHeight - icons[i].getIconHeight()) / 2); hShift +=icons[i].getIconWidth() + 1; } - return icon; + return result; } + @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof LayeredIcon)) return false; @@ -78,6 +80,7 @@ public class LayeredIcon implements Icon { return true; } + @Override public int hashCode() { return 0; } @@ -104,7 +107,7 @@ public class LayeredIcon implements Icon { recalculateSize(); } - private void checkIHaventIconInsideMe(final Icon icon) { + private void checkIHaventIconInsideMe(Icon icon) { LOG.assertTrue(icon != this); for (Icon child : myIcons) { if (child instanceof LayeredIcon) ((LayeredIcon)child).checkIHaventIconInsideMe(icon); diff --git a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitProcessor.java b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitProcessor.java index 3a863c9330ad..664bd925fd70 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitProcessor.java +++ b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitProcessor.java @@ -101,9 +101,9 @@ public abstract class DocumentCommitProcessor { } @Nullable("returns runnable to execute under write action in AWT to finish the commit") - public Processor doCommit(@NotNull final CommitTask task, - @NotNull final PsiFile file, - final boolean synchronously) { + Processor doCommit(@NotNull final CommitTask task, + @NotNull final PsiFile file, + final boolean synchronously) { Document document = task.document; final long startDocModificationTimeStamp = document.getModificationStamp(); final FileElement myTreeElementBeingReparsedSoItWontBeCollected = ((PsiFileImpl)file).calcTreeElement(); diff --git a/platform/core-impl/src/com/intellij/psi/impl/light/LightElement.java b/platform/core-impl/src/com/intellij/psi/impl/light/LightElement.java index 2b42f57377b3..915f832cee94 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/light/LightElement.java +++ b/platform/core-impl/src/com/intellij/psi/impl/light/LightElement.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ public abstract class LightElement extends PsiElementBase { private final Language myLanguage; private volatile PsiElement myNavigationElement = this; - protected LightElement(PsiManager manager, final Language language) { + protected LightElement(@NotNull PsiManager manager, @NotNull Language language) { myManager = manager; myLanguage = language; } @@ -126,6 +126,7 @@ public abstract class LightElement extends PsiElementBase { return false; } + @Override public abstract String toString(); @Override diff --git a/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java b/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java index c664f0398f51..c0a0b72dbdea 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java @@ -47,9 +47,9 @@ import java.util.List; import java.util.Set; public class OfflineProblemDescriptorNode extends ProblemDescriptionNode { - public OfflineProblemDescriptorNode(@NotNull OfflineProblemDescriptor descriptor, - @NotNull LocalInspectionToolWrapper toolWrapper, - @NotNull InspectionToolPresentation presentation) { + OfflineProblemDescriptorNode(@NotNull OfflineProblemDescriptor descriptor, + @NotNull LocalInspectionToolWrapper toolWrapper, + @NotNull InspectionToolPresentation presentation) { super(descriptor, toolWrapper, presentation); } @@ -141,11 +141,9 @@ public class OfflineProblemDescriptorNode extends ProblemDescriptionNode { LocalInspectionToolSession session = new LocalInspectionToolSession(containingFile, startOffset, endOffset); final PsiElementVisitor visitor = localTool.buildVisitor(holder, false, session); localTool.inspectionStarted(session, false); - final PsiElement[] elementsInRange = getElementsIntersectingRange(containingFile, - startOffset, - endOffset); - for (PsiElement el : elementsInRange) { - el.accept(visitor); + final PsiElement[] elementsInRange = getElementsIntersectingRange(containingFile, startOffset, endOffset); + for (PsiElement element : elementsInRange) { + element.accept(visitor); } localTool.inspectionFinished(session, holder); if (holder.hasResults()) { diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java index a8bd76a3eb6c..34b8f9b06ef8 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java @@ -113,6 +113,7 @@ public class InjectedLanguageManagerImpl extends InjectedLanguageManager impleme @Override public void dispose() { + myProgress.cancel(); EditorWindowImpl.disposeInvalidEditors(); } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java index 1891e59711bd..9b1fd384dfa3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java @@ -22,7 +22,9 @@ import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.application.impl.TransferToPooledThreadQueue; -import com.intellij.openapi.components.*; +import com.intellij.openapi.components.ExportableApplicationComponent; +import com.intellij.openapi.components.RoamingType; +import com.intellij.openapi.components.StoragePathMacros; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileEditor.impl.LoadTextUtil; @@ -275,7 +277,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME reDetectQueue.drain(); } @TestOnly - public void reDetectAsync(boolean enable) { + void reDetectAsync(boolean enable) { RE_DETECT_ASYNC = enable; } @@ -1237,11 +1239,12 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME return PlatformUtils.isIdeaCommunity() ? "CommunityFileTypes" : "FileTypeManager"; } - public FileTypeAssocTable getExtensionMap() { + @NotNull + FileTypeAssocTable getExtensionMap() { return myPatternsTable; } - public void setPatternsTable(@NotNull Set fileTypes, @NotNull FileTypeAssocTable assocTable) { + void setPatternsTable(@NotNull Set fileTypes, @NotNull FileTypeAssocTable assocTable) { fireBeforeFileTypesChanged(); for (FileType existing : getRegisteredFileTypes()) { if (!fileTypes.contains(existing)) { diff --git a/spellchecker/src/com/intellij/spellchecker/compress/Alphabet.java b/spellchecker/src/com/intellij/spellchecker/compress/Alphabet.java index d3560f0ca3b4..0b322e0e86d3 100644 --- a/spellchecker/src/com/intellij/spellchecker/compress/Alphabet.java +++ b/spellchecker/src/com/intellij/spellchecker/compress/Alphabet.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,11 +16,11 @@ package com.intellij.spellchecker.compress; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; public final class Alphabet { - private final char[] letters; - private int lastIndexUsed = 0; + private int lastIndexUsed; private static final int MAX_INDEX = UnitBitSet.MAX_UNIT_VALUE; public char getLetter(int position) { @@ -57,7 +57,7 @@ public final class Alphabet { return lastIndexUsed; } - public int add(char c) { + private int add(char c) { if(lastIndexUsed>=letters.length-1) return -1; lastIndexUsed++; letters[lastIndexUsed] = c; @@ -75,8 +75,10 @@ public final class Alphabet { } // TODO: this should be ONLY way to create it to sped up getIndex + @TestOnly Alphabet(@NotNull CharSequence alphabet) { this(alphabet.length() + 1); + assert alphabet.length() != 0; for (int i = 0; i < alphabet.length(); i++) { add(alphabet.charAt(i)); } diff --git a/spellchecker/src/com/intellij/spellchecker/compress/CompressedDictionary.java b/spellchecker/src/com/intellij/spellchecker/compress/CompressedDictionary.java index dc3a90f70ad0..16ca7ca8b92a 100644 --- a/spellchecker/src/com/intellij/spellchecker/compress/CompressedDictionary.java +++ b/spellchecker/src/com/intellij/spellchecker/compress/CompressedDictionary.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -162,6 +162,7 @@ public final class CompressedDictionary implements Dictionary { } + @Override public String toString() { return "CompressedDictionary" + "{wordsCount=" + wordsCount + ", name='" + name + '\'' + '}'; } diff --git a/spellchecker/src/com/intellij/spellchecker/compress/Encoder.java b/spellchecker/src/com/intellij/spellchecker/compress/Encoder.java index d2b1e41139c7..0e79ef2e1f8c 100644 --- a/spellchecker/src/com/intellij/spellchecker/compress/Encoder.java +++ b/spellchecker/src/com/intellij/spellchecker/compress/Encoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,17 +20,16 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public final class Encoder { - private final Alphabet alphabet; private static final int offset = 0; static final UnitBitSet WORD_OF_ENTIRELY_UNKNOWN_LETTERS = new UnitBitSet(new byte[1],new Alphabet()); private static final Logger LOG = Logger.getInstance("#com.intellij.spellchecker.compress"); public Encoder() { - alphabet = new Alphabet(); + this(new Alphabet()); } - public Encoder(Alphabet alphabet) { + public Encoder(@NotNull Alphabet alphabet) { this.alphabet = alphabet; }