From 517fffe8503ef29c5e1c06ac78f0a804266e1e57 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 11 Sep 2014 21:22:59 +0400 Subject: [PATCH] unused class removed --- .../impl/artifacts/ArtifactSortingUtil.java | 36 ---- .../artifacts/ArtifactSortingUtilImpl.java | 176 ------------------ resources/src/idea/RichPlatformPlugin.xml | 2 - 3 files changed, 214 deletions(-) delete mode 100644 java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactSortingUtil.java delete mode 100644 java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactSortingUtilImpl.java diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactSortingUtil.java b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactSortingUtil.java deleted file mode 100644 index b3fe7839836a..000000000000 --- a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactSortingUtil.java +++ /dev/null @@ -1,36 +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.packaging.impl.artifacts; - -import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; - -import java.util.List; -import java.util.Map; - -/** - * @author nik - */ -public abstract class ArtifactSortingUtil { - public static ArtifactSortingUtil getInstance(@NotNull Project project) { - return ServiceManager.getService(project, ArtifactSortingUtil.class); - } - - public abstract Map getArtifactToSelfIncludingNameMap(); - - public abstract List getArtifactsSortedByInclusion(); -} diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactSortingUtilImpl.java b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactSortingUtilImpl.java deleted file mode 100644 index e06f9de7df87..000000000000 --- a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactSortingUtilImpl.java +++ /dev/null @@ -1,176 +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.packaging.impl.artifacts; - -import com.intellij.openapi.project.Project; -import com.intellij.packaging.artifacts.Artifact; -import com.intellij.packaging.artifacts.ArtifactManager; -import com.intellij.packaging.elements.PackagingElementResolvingContext; -import com.intellij.packaging.impl.elements.ArtifactElementType; -import com.intellij.packaging.impl.elements.ArtifactPackagingElement; -import com.intellij.psi.util.CachedValue; -import com.intellij.psi.util.CachedValueProvider; -import com.intellij.psi.util.CachedValuesManager; -import com.intellij.util.graph.CachingSemiGraph; -import com.intellij.util.graph.DFSTBuilder; -import com.intellij.util.graph.GraphGenerator; -import gnu.trove.TIntArrayList; -import gnu.trove.TIntProcedure; -import org.jetbrains.annotations.NotNull; - -import java.util.*; - -/** - * @author nik - */ -public class ArtifactSortingUtilImpl extends ArtifactSortingUtil { - private final Project myProject; - private CachedValue> myArtifactToSelfIncludingName; - private CachedValue> mySortedArtifacts; - - public ArtifactSortingUtilImpl(Project project) { - myProject = project; - } - - @Override - public Map getArtifactToSelfIncludingNameMap() { - if (myArtifactToSelfIncludingName == null) { - myArtifactToSelfIncludingName = CachedValuesManager.getManager(myProject).createCachedValue(new CachedValueProvider>() { - public Result> compute() { - return Result.create(computeArtifactToSelfIncludingNameMap(), ArtifactManager.getInstance(myProject).getModificationTracker()); - } - }, false); - } - return myArtifactToSelfIncludingName.getValue(); - } - - @Override - public List getArtifactsSortedByInclusion() { - if (mySortedArtifacts == null) { - mySortedArtifacts = CachedValuesManager.getManager(myProject).createCachedValue(new CachedValueProvider>() { - @Override - public Result> compute() { - return Result.create(doGetSortedArtifacts(), ArtifactManager.getInstance(myProject).getModificationTracker()); - } - }, false); - } - return mySortedArtifacts.getValue(); - } - - private List doGetSortedArtifacts() { - GraphGenerator graph = createArtifactsGraph(); - DFSTBuilder builder = new DFSTBuilder(graph); - builder.buildDFST(); - List names = new ArrayList(); - names.addAll(graph.getNodes()); - Collections.sort(names, builder.comparator()); - return names; - } - - private Map computeArtifactToSelfIncludingNameMap() { - final Map result = new HashMap(); - final GraphGenerator graph = createArtifactsGraph(); - for (String artifactName : graph.getNodes()) { - final Iterator in = graph.getIn(artifactName); - while (in.hasNext()) { - String next = in.next(); - if (next.equals(artifactName)) { - result.put(artifactName, artifactName); - break; - } - } - } - - final DFSTBuilder builder = new DFSTBuilder(graph); - builder.buildDFST(); - if (builder.isAcyclic() && result.isEmpty()) return Collections.emptyMap(); - - final TIntArrayList sccs = builder.getSCCs(); - sccs.forEach(new TIntProcedure() { - int myTNumber = 0; - public boolean execute(int size) { - if (size > 1) { - for (int j = 0; j < size; j++) { - final String artifactName = builder.getNodeByTNumber(myTNumber + j); - result.put(artifactName, artifactName); - } - } - myTNumber += size; - return true; - } - }); - - for (int i = 0; i < graph.getNodes().size(); i++) { - final String artifactName = builder.getNodeByTNumber(i); - if (!result.containsKey(artifactName)) { - final Iterator in = graph.getIn(artifactName); - while (in.hasNext()) { - final String name = result.get(in.next()); - if (name != null) { - result.put(artifactName, name); - } - } - } - } - - return result; - } - - private GraphGenerator createArtifactsGraph() { - final ArtifactManager artifactManager = ArtifactManager.getInstance(myProject); - return GraphGenerator.create(CachingSemiGraph.create(new ArtifactsGraph(artifactManager))); - } - - private class ArtifactsGraph implements GraphGenerator.SemiGraph { - private final ArtifactManager myArtifactManager; - private final Set myArtifactNames; - - public ArtifactsGraph(ArtifactManager artifactManager) { - myArtifactManager = artifactManager; - myArtifactNames = new LinkedHashSet(); - for (Artifact artifact : myArtifactManager.getSortedArtifacts()) { - myArtifactNames.add(artifact.getName()); - } - } - - @Override - public Collection getNodes() { - return myArtifactNames; - } - - @Override - public Iterator getIn(String name) { - final Set included = new LinkedHashSet(); - final PackagingElementResolvingContext context = myArtifactManager.getResolvingContext(); - final Artifact artifact = context.getArtifactModel().findArtifact(name); - if (artifact != null) { - ArtifactUtil.processPackagingElements(artifact, ArtifactElementType.ARTIFACT_ELEMENT_TYPE, new PackagingElementProcessor() { - @Override - public boolean process(@NotNull ArtifactPackagingElement element, - @NotNull PackagingElementPath path) { - final String artifactName = element.getArtifactName(); - if (myArtifactNames.contains(artifactName)) { - included.add(artifactName); - } - return true; - } - }, context, false); - } - return included.iterator(); - } - } - -} diff --git a/resources/src/idea/RichPlatformPlugin.xml b/resources/src/idea/RichPlatformPlugin.xml index 485d07839866..509d22de08cf 100644 --- a/resources/src/idea/RichPlatformPlugin.xml +++ b/resources/src/idea/RichPlatformPlugin.xml @@ -165,8 +165,6 @@ serviceImplementation="com.intellij.packaging.impl.artifacts.ArtifactPointerManagerImpl"/> -