cleanup: remove implementations of root model elements which delegate to JpsModel

These implementations were never used, and we don't plan to replace the project model in IntelliJ Platform by JPS anymore.
This commit is contained in:
nik
2018-11-20 13:17:35 +03:00
parent 26670fb1d6
commit 32e2a00be5
9 changed files with 0 additions and 649 deletions
@@ -1,26 +0,0 @@
/*
* Copyright 2000-2012 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.project.model;
import com.intellij.openapi.roots.libraries.Library;
import org.jetbrains.jps.model.library.JpsLibrary;
/**
* @author nik
*/
public interface JpsLibraryManager {
Library getLibrary(JpsLibrary library);
}
@@ -1,40 +0,0 @@
/*
* Copyright 2000-2012 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.project.model;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.JpsEventDispatcher;
/**
* @author nik
*/
public abstract class JpsModelManager {
@NotNull
public abstract JpsModuleManager getModuleManager();
public abstract void startModification(JpsEventDispatcher eventDispatcher);
public abstract void commitChanges();
@NotNull
public abstract JpsLibraryManager getLibraryManager();
public static JpsModelManager getInstance(@NotNull Project project) {
return ServiceManager.getService(project, JpsModelManager.class);
}
}
@@ -1,26 +0,0 @@
/*
* Copyright 2000-2012 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.project.model;
import com.intellij.openapi.module.Module;
import org.jetbrains.jps.model.module.JpsModule;
/**
* @author nik
*/
public interface JpsModuleManager {
Module getModule(JpsModule jpsModule);
}
@@ -1,77 +0,0 @@
/*
* Copyright 2000-2012 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.project.model.impl;
import com.intellij.project.model.JpsLibraryManager;
import com.intellij.project.model.JpsModelManager;
import com.intellij.project.model.JpsModuleManager;
import com.intellij.project.model.impl.library.JpsLibraryManagerImpl;
import com.intellij.project.model.impl.module.JpsModuleManagerImpl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.JpsElement;
import org.jetbrains.jps.model.JpsEventDispatcher;
import org.jetbrains.jps.model.JpsModel;
import org.jetbrains.jps.model.JpsNamedElement;
import org.jetbrains.jps.model.impl.JpsEventDispatcherBase;
import org.jetbrains.jps.model.impl.JpsModelImpl;
/**
* @author nik
*/
public class JpsModelManagerImpl extends JpsModelManager {
private final JpsModel myModel;
private JpsModel myModifiableModel;
private final JpsModuleManagerImpl myModuleManager;
private final JpsLibraryManagerImpl myLibraryManager;
public JpsModelManagerImpl() {
myModel = new JpsModelImpl(new MyJpsEventDispatcher());
myModuleManager = new JpsModuleManagerImpl();
myLibraryManager = new JpsLibraryManagerImpl();
}
@NotNull
@Override
public JpsModuleManager getModuleManager() {
return myModuleManager;
}
@Override
@NotNull
public JpsLibraryManager getLibraryManager() {
return myLibraryManager;
}
@Override
public void startModification(JpsEventDispatcher eventDispatcher) {
myModifiableModel = myModel.createModifiableModel(eventDispatcher);
}
@Override
public void commitChanges() {
myModifiableModel.commit();
}
private static class MyJpsEventDispatcher extends JpsEventDispatcherBase implements JpsEventDispatcher {
@Override
public void fireElementChanged(@NotNull JpsElement element) {
}
@Override
public void fireElementRenamed(@NotNull JpsNamedElement element, @NotNull String oldName, @NotNull String newName) {
}
}
}
@@ -1,183 +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.project.model.impl.library;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.roots.ProjectModelExternalSource;
import com.intellij.openapi.roots.RootProvider;
import com.intellij.openapi.roots.impl.RootProviderBaseImpl;
import com.intellij.openapi.roots.impl.libraries.LibraryEx;
import com.intellij.openapi.roots.libraries.LibraryProperties;
import com.intellij.openapi.roots.libraries.LibraryTable;
import com.intellij.openapi.roots.libraries.PersistentLibraryKind;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ArrayUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.library.JpsLibrary;
import org.jetbrains.jps.model.library.JpsLibraryRoot;
import org.jetbrains.jps.model.library.JpsOrderRootType;
import java.util.*;
/**
* @author nik
*/
public class JpsLibraryDelegate implements LibraryEx {
private final JpsLibrary myJpsLibrary;
private final JpsLibraryTableImpl myLibraryTable;
private final RootProviderBaseImpl myRootProvider = new MyRootProvider();
public JpsLibraryDelegate(JpsLibrary library, JpsLibraryTableImpl table) {
myJpsLibrary = library;
myLibraryTable = table;
}
@Override
public String getName() {
return myJpsLibrary.getName();
}
@Override
public PersistentLibraryKind<?> getKind() {
return null;
}
@Override
public LibraryProperties getProperties() {
return null;
}
@NotNull
@Override
public String[] getUrls(@NotNull OrderRootType rootType) {
return ArrayUtil.EMPTY_STRING_ARRAY;
}
@NotNull
@Override
public VirtualFile[] getFiles(@NotNull OrderRootType rootType) {
return VirtualFile.EMPTY_ARRAY;
}
@NotNull
@Override
public List<String> getInvalidRootUrls(@NotNull OrderRootType type) {
return Collections.emptyList();
}
@Override
public boolean isDisposed() {
return false;
}
@Override
public LibraryTable getTable() {
return myLibraryTable;
}
@NotNull
@Override
public RootProvider getRootProvider() {
return myRootProvider;
}
@Nullable
@Override
public ProjectModelExternalSource getExternalSource() {
return null;
}
@Override
public void dispose() {
}
@NotNull
@Override
public ModifiableModelEx getModifiableModel() {
throw new UnsupportedOperationException("'getModifiableModel' not implemented in " + getClass().getName());
}
@NotNull
@Override
public String[] getExcludedRootUrls() {
return ArrayUtil.EMPTY_STRING_ARRAY;
}
@NotNull
@Override
public VirtualFile[] getExcludedRoots() {
return VirtualFile.EMPTY_ARRAY;
}
@Override
public void readExternal(Element element) throws InvalidDataException {
throw new UnsupportedOperationException();
}
@Override
public void writeExternal(Element element) throws WriteExternalException {
throw new UnsupportedOperationException();
}
@Override
public boolean isJarDirectory(@NotNull String url) {
return isJarDirectory(url, OrderRootType.CLASSES);
}
@Override
public boolean isJarDirectory(@NotNull String url, @NotNull OrderRootType rootType) {
for (JpsLibraryRoot root : myJpsLibrary.getRoots(getJpsRootType(rootType))) {
if (url.equals(root.getUrl()) && root.getInclusionOptions() != JpsLibraryRoot.InclusionOptions.ROOT_ITSELF) {
return true;
}
}
return false;
}
@Override
public boolean isValid(@NotNull String url, @NotNull OrderRootType rootType) {
return false;
}
private static JpsOrderRootType getJpsRootType(OrderRootType type) {
if (type == OrderRootType.CLASSES) return JpsOrderRootType.COMPILED;
if (type == OrderRootType.SOURCES) return JpsOrderRootType.SOURCES;
if (type == OrderRootType.DOCUMENTATION) return JpsOrderRootType.DOCUMENTATION;
return JpsOrderRootType.COMPILED;
}
private class MyRootProvider extends RootProviderBaseImpl {
@NotNull
@Override
public String[] getUrls(@NotNull OrderRootType rootType) {
Set<String> originalUrls = new LinkedHashSet<>(Arrays.asList(JpsLibraryDelegate.this.getUrls(rootType)));
for (VirtualFile file : getFiles(rootType)) { // Add those expanded with jar directories.
originalUrls.add(file.getUrl());
}
return ArrayUtil.toStringArray(originalUrls);
}
@NotNull
@Override
public VirtualFile[] getFiles(@NotNull OrderRootType rootType) {
return JpsLibraryDelegate.this.getFiles(rootType);
}
}
}
@@ -1,30 +0,0 @@
/*
* Copyright 2000-2012 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.project.model.impl.library;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.project.model.JpsLibraryManager;
import org.jetbrains.jps.model.library.JpsLibrary;
/**
* @author nik
*/
public class JpsLibraryManagerImpl implements JpsLibraryManager {
@Override
public Library getLibrary(JpsLibrary library) {
return null;
}
}
@@ -1,202 +0,0 @@
/*
* Copyright 2000-2017 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.project.model.impl.library;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.roots.ProjectModelExternalSource;
import com.intellij.openapi.roots.impl.libraries.LibraryTableBase;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.LibraryTable;
import com.intellij.openapi.roots.libraries.LibraryTablePresentation;
import com.intellij.openapi.roots.libraries.PersistentLibraryKind;
import com.intellij.openapi.util.Disposer;
import com.intellij.util.EventDispatcher;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.library.JpsLibrary;
import org.jetbrains.jps.model.library.JpsLibraryCollection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/**
* @author nik
*/
public class JpsLibraryTableImpl implements LibraryTable, Disposable {
private final JpsLibrariesModel myModel;
private final EventDispatcher<Listener> myDispatcher = EventDispatcher.create(Listener.class);
private final String myTableLevel;
private LibraryTablePresentation myPresentation;
public JpsLibraryTableImpl(JpsLibraryCollection libraryCollection, String level) {
myTableLevel = level;
myModel = new JpsLibrariesModel(libraryCollection);
}
@NotNull
@Override
public Library[] getLibraries() {
return myModel.getLibraries();
}
@NotNull
@Override
public Iterator<Library> getLibraryIterator() {
return myModel.getLibraryIterator();
}
@Override
public Library getLibraryByName(@NotNull String name) {
return myModel.getLibraryByName(name);
}
@Override
public void addListener(@NotNull Listener listener) {
myDispatcher.addListener(listener);
}
@Override
public void addListener(@NotNull Listener listener, @NotNull Disposable parentDisposable) {
myDispatcher.addListener(listener, parentDisposable);
}
@Override
public void removeListener(@NotNull Listener listener) {
myDispatcher.removeListener(listener);
}
@NotNull
@Override
public Library createLibrary() {
return createLibrary(null);
}
@NotNull
@Override
public Library createLibrary(@NonNls String name) {
final ModifiableModel model = getModifiableModel();
final Library library = model.createLibrary(name);
model.commit();
return library;
}
@Override
public void removeLibrary(@NotNull Library library) {
final ModifiableModel model = getModifiableModel();
model.removeLibrary(library);
model.commit();
}
@Override
public void dispose() {
for (Library library : getLibraries()) {
Disposer.dispose(library);
}
}
@NotNull
@Override
public ModifiableModel getModifiableModel() {
return new JpsLibrariesModel(myModel.myJpsLibraries);
}
@NotNull
@Override
public String getTableLevel() {
return myTableLevel;
}
@NotNull
@Override
public LibraryTablePresentation getPresentation() {
return myPresentation;
}
private class JpsLibrariesModel implements LibraryTableBase.ModifiableModel {
private final JpsLibraryCollection myJpsLibraries;
private final List<JpsLibraryDelegate> myLibraries;
private JpsLibrariesModel(JpsLibraryCollection libraryCollection) {
myLibraries = new ArrayList<>();
myJpsLibraries = libraryCollection;
for (JpsLibrary library : libraryCollection.getLibraries()) {
myLibraries.add(new JpsLibraryDelegate(library, JpsLibraryTableImpl.this));
}
}
@NotNull
@Override
public Library createLibrary(String name) {
return createLibrary(name, null);
}
@NotNull
@Override
public Library createLibrary(String name, @Nullable PersistentLibraryKind type) {
return createLibrary(name, type, null);
}
@NotNull
@Override
public Library createLibrary(String name, @Nullable PersistentLibraryKind type, @Nullable ProjectModelExternalSource externalSource) {
throw new UnsupportedOperationException("'createLibrary' not implemented in " + getClass().getName());
}
@NotNull
@Override
public Iterator<Library> getLibraryIterator() {
return Collections.<Library>unmodifiableList(myLibraries).iterator();
}
@Override
public void removeLibrary(@NotNull Library library) {
throw new UnsupportedOperationException();
}
@NotNull
@Override
public Library[] getLibraries() {
return myLibraries.toArray(Library.EMPTY_ARRAY);
}
@Override
public Library getLibraryByName(@NotNull String name) {
for (JpsLibraryDelegate library : myLibraries) {
if (name.equals(library.getName())) {
return library;
}
}
return null;
}
@Override
public void commit() {
throw new UnsupportedOperationException();
}
@Override
public void dispose() {
}
@Override
public boolean isChanged() {
return false;
}
}
}
@@ -1,30 +0,0 @@
/*
* Copyright 2000-2012 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.project.model.impl.module;
import com.intellij.openapi.module.Module;
import com.intellij.project.model.JpsModuleManager;
import org.jetbrains.jps.model.module.JpsModule;
/**
* @author nik
*/
public class JpsModuleManagerImpl implements JpsModuleManager {
@Override
public Module getModule(JpsModule jpsModule) {
return null;
}
}
@@ -1,35 +0,0 @@
/*
* Copyright 2000-2012 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.project.model.impl.sdk;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.project.model.JpsSdkManager;
import org.jetbrains.jps.model.library.JpsLibrary;
import java.util.HashMap;
import java.util.Map;
/**
* @author nik
*/
public class JpsSdkManagerImpl extends JpsSdkManager {
private final Map<JpsLibrary, Sdk> mySdks = new HashMap<>();
@Override
public Sdk getSdk(JpsLibrary library) {
return mySdks.get(library);
}
}