diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java index 639610151560..f63e5f704b62 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java @@ -528,10 +528,7 @@ public class GlobalInspectionContextImpl implements GlobalInspectionContext { if (virtualFile != null) { incrementJobDoneAmount(LOCAL_ANALYSIS, ProjectUtil.calcRelativeToProjectPath(virtualFile, myProject)); if (SingleRootFileViewProvider.isTooLarge(virtualFile)) return; - if (localScopeFiles != null) { - if (localScopeFiles.contains(virtualFile)) return; - localScopeFiles.add(virtualFile); - } + if (localScopeFiles != null && !localScopeFiles.add(virtualFile)) return; } final FileViewProvider viewProvider = psiManager.findViewProvider(virtualFile); diff --git a/platform/platform-api/src/com/intellij/codeStyle/CodeStyleFacade.java b/platform/platform-api/src/com/intellij/codeStyle/CodeStyleFacade.java index 00d91c29ef4c..26d492928524 100644 --- a/platform/platform-api/src/com/intellij/codeStyle/CodeStyleFacade.java +++ b/platform/platform-api/src/com/intellij/codeStyle/CodeStyleFacade.java @@ -32,7 +32,7 @@ public abstract class CodeStyleFacade { return ServiceManager.getService(CodeStyleFacade.class); } - public static CodeStyleFacade getInstance(Project project) { + public static CodeStyleFacade getInstance(@Nullable Project project) { if (project == null) return getInstance(); return ServiceManager.getService(project, CodeStyleFacade.class); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/IndentSelectionAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/IndentSelectionAction.java index efd25a2b2d54..9020e7a70aed 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/IndentSelectionAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/IndentSelectionAction.java @@ -57,7 +57,7 @@ public class IndentSelectionAction extends EditorAction { return editor.getSelectionModel().hasSelection() && !editor.isOneLineMode(); } - public static void indentSelection(Editor editor, Project project) { + private static void indentSelection(Editor editor, Project project) { if(!editor.getSelectionModel().hasSelection()) return; diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java index d158bae6c458..dca870258426 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java @@ -80,7 +80,7 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { private boolean myGuardsSuppressed = false; private boolean myEventsHandling = false; private final boolean myAssertWriteAccess; - private boolean myDoingBulkUpdate = false; + private volatile boolean myDoingBulkUpdate = false; private static final Key> ourSomeEditorSyntaxHighlighter = Key.create("some editor highlighter"); private boolean myAcceptSlashR = false; @@ -252,7 +252,7 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { public RangeMarker getRangeGuard(int start, int end) { for (RangeMarker block : myGuardedBlocks) { - if (rangesIntersect(start, block.getStartOffset(), end, block.getEndOffset(), true, block.isGreedyToLeft(), true, block.isGreedyToRight())) { + if (rangesIntersect(start, true, block.getStartOffset(), block.isGreedyToLeft(), end, true, block.getEndOffset(), block.isGreedyToRight())) { return block; } } @@ -273,14 +273,15 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { return start <= offset && offset < end; } - private static boolean rangesIntersect(int start0, int start1, int end0, int end1, boolean leftInclusive0, boolean leftInclusive1, boolean rightInclusive0, boolean rightInclusive1) { + private static boolean rangesIntersect(int start0, boolean leftInclusive0, + int start1, boolean leftInclusive1, + int end0, boolean rightInclusive0, + int end1, boolean rightInclusive1) { if (start0 > start1 || start0 == start1 && !leftInclusive0) { - return rangesIntersect(start1, start0, end1, end0, leftInclusive1, leftInclusive0, rightInclusive1, rightInclusive0); + return rangesIntersect(start1, leftInclusive1, start0, leftInclusive0, end1, rightInclusive1, end0, rightInclusive0); } - if (end0 < start1) return false; - if (end0 > start1) return true; - - return leftInclusive1 && rightInclusive0; + if (end0 == start1) return leftInclusive1 && rightInclusive0; + return end0 > start1; } @NotNull diff --git a/platform/usageView/src/com/intellij/usages/TextChunk.java b/platform/usageView/src/com/intellij/usages/TextChunk.java index 2ab65cc469dd..4fdf1a39b209 100644 --- a/platform/usageView/src/com/intellij/usages/TextChunk.java +++ b/platform/usageView/src/com/intellij/usages/TextChunk.java @@ -20,14 +20,13 @@ import com.intellij.openapi.editor.markup.TextAttributes; import org.jetbrains.annotations.NotNull; public class TextChunk { - - public static final TextChunk[] EMPTY_ARRAY = new TextChunk[0]; + public static final TextChunk[] EMPTY_ARRAY = new TextChunk[0]; private final AttributesFlyweight myAttributes; private final String myText; - public TextChunk(@NotNull TextAttributes attributesKey, @NotNull String text) { - myAttributes = attributesKey.getFlyweight(); + public TextChunk(@NotNull TextAttributes attributes, @NotNull String text) { + myAttributes = attributes.getFlyweight(); myText = text; } diff --git a/platform/util/src/com/intellij/openapi/util/Comparing.java b/platform/util/src/com/intellij/openapi/util/Comparing.java index 86e7531b8bcf..f87f848cd1b3 100644 --- a/platform/util/src/com/intellij/openapi/util/Comparing.java +++ b/platform/util/src/com/intellij/openapi/util/Comparing.java @@ -28,7 +28,7 @@ import java.util.Set; public class Comparing { private Comparing() { } - public static boolean equal(T arg1, T arg2){ + public static boolean equal(T arg1, T arg2){ if (arg1 == null || arg2 == null){ return arg1 == arg2; } diff --git a/platform/util/src/com/intellij/util/UniqueResultsQuery.java b/platform/util/src/com/intellij/util/UniqueResultsQuery.java index a4c39b84f767..e4d98866d809 100644 --- a/platform/util/src/com/intellij/util/UniqueResultsQuery.java +++ b/platform/util/src/com/intellij/util/UniqueResultsQuery.java @@ -30,20 +30,14 @@ public class UniqueResultsQuery implements Query { private final TObjectHashingStrategy myHashingStrategy; private final Function myMapper; - public static final Function ID = new Function() { - public Object fun(Object o) { - return o; - } - }; - public UniqueResultsQuery(final Query original) { //noinspection unchecked - this(original, TObjectHashingStrategy.CANONICAL, ID); + this(original, TObjectHashingStrategy.CANONICAL, Function.ID); } public UniqueResultsQuery(final Query original, TObjectHashingStrategy hashingStrategy) { //noinspection unchecked - this(original, hashingStrategy, ID); + this(original, hashingStrategy, Function.ID); } public UniqueResultsQuery(final Query original, TObjectHashingStrategy hashingStrategy, Function mapper) { @@ -70,7 +64,7 @@ public class UniqueResultsQuery implements Query { @NotNull public Collection findAll() { - if (myMapper == ID) { + if (myMapper == Function.ID) { Set set = new THashSet(myHashingStrategy); process(CommonProcessors.alwaysTrue(), Collections.synchronizedSet(set)); //noinspection unchecked diff --git a/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java b/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java index 6eb70208d301..b9ab7b09acd2 100644 --- a/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java +++ b/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java @@ -53,7 +53,7 @@ public class BooleanMethodIsAlwaysInvertedInspection extends GlobalJavaInspectio RefMethod refMethod = (RefMethod)refEntity; if (!refMethod.isReferenced()) return null; if (hasNonInvertedCalls(refMethod)) return null; - if (refMethod.getSuperMethods().size() > 0) return null; + if (!refMethod.getSuperMethods().isEmpty()) return null; final PsiMethod psiMethod = (PsiMethod)refMethod.getElement(); final PsiIdentifier psiIdentifier = psiMethod.getNameIdentifier(); if (psiIdentifier != null) { @@ -114,7 +114,7 @@ public class BooleanMethodIsAlwaysInvertedInspection extends GlobalJavaInspectio final PsiElement psiElement = refMethod.getElement(); if (!(psiElement instanceof PsiMethod)) return; final PsiMethod psiMethod = (PsiMethod)psiElement; - if (!(PsiType.BOOLEAN.equals(psiMethod.getReturnType()))) return; + if (!PsiType.BOOLEAN.equals(psiMethod.getReturnType())) return; element.accept(new JavaRecursiveElementVisitor() { @Override public void visitMethodCallExpression(PsiMethodCallExpression call) { super.visitMethodCallExpression(call);