From cac7ae616a123bb461a392360b2792fda4b077df Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 24 Aug 2016 17:43:59 +0300 Subject: [PATCH] Cleanup (suppressions; dead code; formatting) --- .../CyclicDependenciesUtil.java | 164 ------------------ .../core/JavaCoreProjectEnvironment.java | 13 +- .../application/impl/ModalityStateEx.java | 5 +- 3 files changed, 11 insertions(+), 171 deletions(-) delete mode 100644 java/java-impl/src/com/intellij/cyclicDependencies/CyclicDependenciesUtil.java diff --git a/java/java-impl/src/com/intellij/cyclicDependencies/CyclicDependenciesUtil.java b/java/java-impl/src/com/intellij/cyclicDependencies/CyclicDependenciesUtil.java deleted file mode 100644 index 5cf1b66ceed3..000000000000 --- a/java/java-impl/src/com/intellij/cyclicDependencies/CyclicDependenciesUtil.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * 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.cyclicDependencies; - -import com.intellij.util.Chunk; -import com.intellij.util.graph.DFSTBuilder; -import com.intellij.util.graph.Graph; -import gnu.trove.TIntArrayList; -import gnu.trove.TIntProcedure; - -import java.util.*; - -/** - * User: anna - * Date: Feb 10, 2005 - */ -public class CyclicDependenciesUtil{ - public static List> buildChunks(Graph graph) { - final DFSTBuilder dfstBuilder = new DFSTBuilder<>(graph); - final TIntArrayList sccs = dfstBuilder.getSCCs(); - final List> chunks = new ArrayList<>(); - sccs.forEach(new TIntProcedure() { - int myTNumber; - public boolean execute(int size) { - Set packs = new LinkedHashSet<>(); - for (int j = 0; j < size; j++) { - packs.add(dfstBuilder.getNodeByTNumber(myTNumber + j)); - } - chunks.add(new Chunk<>(packs)); - myTNumber += size; - return true; - } - }); - - return chunks; - } - - - public static class Path { - private ArrayList myPath = new ArrayList<>(); - - public Path() { - } - - public Path(Path path) { - myPath = new ArrayList<>(path.myPath); - } - - public Node getBeg() { - return myPath.get(0); - } - - public Node getEnd() { - return myPath.get(myPath.size() - 1); - } - - public boolean contains(Node node) { - return myPath.contains(node); - } - - public List getNextNodes(Node node) { - List result = new ArrayList<>(); - for (int i = 0; i < myPath.size() - 1; i++) { - Node nodeN = myPath.get(i); - if (nodeN == node) { - result.add(myPath.get(i + 1)); - } - } - return result; - } - - public void add(Node node) { - myPath.add(node); - } - - public ArrayList getPath() { - return myPath; - } - } - - public static class GraphTraverser { - private final List> myCurrentPaths = new ArrayList<>(); - private final Node myBegin; - private final Chunk myChunk; - private final int myMaxPathsCount; - private final Graph myGraph; - - public GraphTraverser(final Node begin, final Chunk chunk, final int maxPathsCount, final Graph graph) { - myBegin = begin; - myChunk = chunk; - myMaxPathsCount = maxPathsCount; - myGraph = graph; - } - - public Set> traverse() { - Set> result = new HashSet<>(); - Path firstPath = new Path<>(); - firstPath.add(myBegin); - myCurrentPaths.add(firstPath); - while (!myCurrentPaths.isEmpty() && result.size() < myMaxPathsCount) { - final Path path = myCurrentPaths.get(0); - final Set nextNodes = getNextNodes(path.getEnd()); - nextStep(nextNodes, path, result); - } - return result; - } - - public Set> convert(Set> paths) { - Set> result = new HashSet<>(); - for (Path path : paths) { - result.add(path.getPath()); - } - return result; - } - - private void nextStep(final Set nextNodes, final Path path, Set> result) { - myCurrentPaths.remove(path); - for (Node node : nextNodes) { - if (path.getEnd() == node) { - continue; - } - if (path.getBeg() == node) { - result.add(path); - continue; - } - Path newPath = new Path<>(path); - newPath.add(node); - if (path.contains(node)) { - final Set nodesAfterInnerCycle = getNextNodes(node); - nodesAfterInnerCycle.removeAll(path.getNextNodes(node)); - nextStep(nodesAfterInnerCycle, newPath, result); - } - else { - myCurrentPaths.add(newPath); - } - } - } - - private Set getNextNodes(Node node) { - Set result = new HashSet<>(); - final Iterator in = myGraph.getIn(node); - for (; in.hasNext();) { - final Node inNode = in.next(); - if (myChunk.containsNode(inNode)) { - result.add(inNode); - } - } - return result; - } - } -} diff --git a/java/java-psi-impl/src/com/intellij/core/JavaCoreProjectEnvironment.java b/java/java-psi-impl/src/com/intellij/core/JavaCoreProjectEnvironment.java index be9562f77995..eff11c980183 100644 --- a/java/java-psi-impl/src/com/intellij/core/JavaCoreProjectEnvironment.java +++ b/java/java-psi-impl/src/com/intellij/core/JavaCoreProjectEnvironment.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,11 @@ import org.jetbrains.annotations.NotNull; import java.io.File; -public class JavaCoreProjectEnvironment extends CoreProjectEnvironment { +/** + * Used in Kotlin. + */ +@SuppressWarnings("unused") +public class JavaCoreProjectEnvironment extends CoreProjectEnvironment { private final JavaFileManager myFileManager; private final PackageIndex myPackageIndex; @@ -72,8 +76,7 @@ public class JavaCoreProjectEnvironment extends CoreProjectEnvironment { return new CorePackageIndex(); } - @SuppressWarnings("UnusedDeclaration") - public void addJarToClassPath (File path) { + public void addJarToClassPath(File path) { assert path.isFile(); final VirtualFile root = getEnvironment().getJarFileSystem().findFileByPath(path + "!/"); @@ -90,4 +93,4 @@ public class JavaCoreProjectEnvironment extends CoreProjectEnvironment { ((CorePackageIndex)myPackageIndex).addToClasspath(root); ((MockFileIndexFacade)myFileIndexFacade).addLibraryRoot(root); } -} +} \ No newline at end of file diff --git a/platform/core-impl/src/com/intellij/openapi/application/impl/ModalityStateEx.java b/platform/core-impl/src/com/intellij/openapi/application/impl/ModalityStateEx.java index 313998d39405..6636b9696e03 100644 --- a/platform/core-impl/src/com/intellij/openapi/application/impl/ModalityStateEx.java +++ b/platform/core-impl/src/com/intellij/openapi/application/impl/ModalityStateEx.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import java.util.List; public class ModalityStateEx extends ModalityState { private final WeakList myModalEntities = new WeakList(); + @SuppressWarnings("unused") public ModalityStateEx() { } // used by reflection to initialize NON_MODAL public ModalityStateEx(@NotNull Object[] modalEntities) { @@ -93,4 +94,4 @@ public class ModalityStateEx extends ModalityState { void removeModality(Object modalEntity) { myModalEntities.remove(modalEntity); } -} +} \ No newline at end of file