mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
facets removed from JPS model
This commit is contained in:
@@ -1,45 +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 org.jetbrains.jps.model.module;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.JpsNamedElement;
|
||||
import org.jetbrains.jps.model.JpsReferenceableElement;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
//todo[nik] I'm not sure that we really need separate interface for facets in the project model.
|
||||
//Perhaps facets should be replaced by extensions for module elements
|
||||
public interface JpsFacet extends JpsNamedElement, JpsReferenceableElement<JpsFacet> {
|
||||
|
||||
JpsModule getModule();
|
||||
|
||||
@NotNull
|
||||
JpsFacetType<?> getType();
|
||||
|
||||
void delete();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
JpsFacetReference createReference();
|
||||
|
||||
void setParentFacet(@NotNull JpsFacet facet);
|
||||
|
||||
@Nullable
|
||||
JpsFacet getParentFacet();
|
||||
}
|
||||
@@ -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 org.jetbrains.jps.model.module;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface JpsFacetListener extends EventListener {
|
||||
void facetAdded(JpsFacet facet);
|
||||
void facetRemoved(JpsFacet facet);
|
||||
}
|
||||
@@ -1,24 +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 org.jetbrains.jps.model.module;
|
||||
|
||||
import org.jetbrains.jps.model.JpsElementReference;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface JpsFacetReference extends JpsElementReference<JpsFacet> {
|
||||
}
|
||||
@@ -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 org.jetbrains.jps.model.module;
|
||||
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
//todo[nik] I'm not sure that we really need separate interface for facets in the project model.
|
||||
//Perhaps facets should be replaced by extensions for module elements
|
||||
public abstract class JpsFacetType<P extends JpsElement> {
|
||||
}
|
||||
@@ -54,13 +54,6 @@ public interface JpsModule extends JpsNamedElement, JpsReferenceableElement<JpsM
|
||||
|
||||
void removeSourceRoot(@NotNull String url, @NotNull JpsModuleSourceRootType rootType);
|
||||
|
||||
@NotNull
|
||||
<P extends JpsElement>
|
||||
JpsFacet addFacet(@NotNull String name, @NotNull JpsFacetType<P> type, @NotNull P properties);
|
||||
|
||||
@NotNull
|
||||
List<JpsFacet> getFacets();
|
||||
|
||||
JpsDependenciesList getDependenciesList();
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -1,88 +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 org.jetbrains.jps.model.module.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.JpsElementChildRole;
|
||||
import org.jetbrains.jps.model.JpsElementCollection;
|
||||
import org.jetbrains.jps.model.ex.JpsElementChildRoleBase;
|
||||
import org.jetbrains.jps.model.ex.JpsNamedCompositeElementBase;
|
||||
import org.jetbrains.jps.model.module.JpsFacet;
|
||||
import org.jetbrains.jps.model.module.JpsFacetReference;
|
||||
import org.jetbrains.jps.model.module.JpsFacetType;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsFacetImpl extends JpsNamedCompositeElementBase<JpsFacetImpl> implements JpsFacet {
|
||||
private static final JpsElementChildRole<JpsFacetReference> PARENT_FACET_REFERENCE = JpsElementChildRoleBase.create("parent facet");
|
||||
private final JpsFacetType<?> myFacetType;
|
||||
|
||||
public <P extends JpsElement>JpsFacetImpl(JpsFacetType<?> facetType, @NotNull String name, @NotNull P properties) {
|
||||
super(name);
|
||||
myFacetType = facetType;
|
||||
myContainer.setChild(JpsFacetRole.COLLECTION_ROLE);
|
||||
}
|
||||
|
||||
private JpsFacetImpl(JpsFacetImpl original) {
|
||||
super(original);
|
||||
myFacetType = original.myFacetType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsFacetImpl createCopy() {
|
||||
return new JpsFacetImpl(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JpsFacetType<?> getType() {
|
||||
return myFacetType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentFacet(@NotNull JpsFacet facet) {
|
||||
myContainer.setChild(PARENT_FACET_REFERENCE, facet.createReference());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JpsFacet getParentFacet() {
|
||||
final JpsFacetReference reference = myContainer.getChild(PARENT_FACET_REFERENCE);
|
||||
return reference != null ? reference.resolve() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpsModule getModule() {
|
||||
return myParent != null ? (JpsModule)myParent.getParent() : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsFacetReference createReference() {
|
||||
return new JpsFacetReferenceImpl(getName(), getModule().createReference());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
//noinspection unchecked
|
||||
((JpsElementCollection<JpsFacet>)myParent).removeChild(this);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +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 org.jetbrains.jps.model.module.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.impl.JpsNamedElementReferenceImpl;
|
||||
import org.jetbrains.jps.model.module.JpsFacet;
|
||||
import org.jetbrains.jps.model.module.JpsFacetReference;
|
||||
import org.jetbrains.jps.model.module.JpsModuleReference;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsFacetReferenceImpl extends JpsNamedElementReferenceImpl<JpsFacet, JpsFacetReferenceImpl> implements JpsFacetReference {
|
||||
public JpsFacetReferenceImpl(String facetName, JpsModuleReference moduleReference) {
|
||||
super(JpsFacetRole.COLLECTION_ROLE, facetName, moduleReference);
|
||||
}
|
||||
|
||||
private JpsFacetReferenceImpl(JpsFacetReferenceImpl original) {
|
||||
super(original);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsFacetReferenceImpl createCopy() {
|
||||
return new JpsFacetReferenceImpl(this);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +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 org.jetbrains.jps.model.module.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsEventDispatcher;
|
||||
import org.jetbrains.jps.model.ex.JpsElementCollectionRole;
|
||||
import org.jetbrains.jps.model.ex.JpsElementChildRoleBase;
|
||||
import org.jetbrains.jps.model.module.JpsFacet;
|
||||
import org.jetbrains.jps.model.module.JpsFacetListener;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsFacetRole extends JpsElementChildRoleBase<JpsFacet> {
|
||||
public static final JpsFacetRole INSTANCE = new JpsFacetRole();
|
||||
public static final JpsElementCollectionRole<JpsFacet> COLLECTION_ROLE = JpsElementCollectionRole.create(INSTANCE);
|
||||
|
||||
public JpsFacetRole() {
|
||||
super("facet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireElementAdded(@NotNull JpsEventDispatcher dispatcher, @NotNull JpsFacet element) {
|
||||
dispatcher.getPublisher(JpsFacetListener.class).facetAdded(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireElementRemoved(@NotNull JpsEventDispatcher dispatcher, @NotNull JpsFacet element) {
|
||||
dispatcher.getPublisher(JpsFacetListener.class).facetRemoved(element);
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,6 @@ public class JpsModuleImpl<P extends JpsElement> extends JpsNamedCompositeElemen
|
||||
myContainer.setChild(myModuleType.getPropertiesRole(), properties);
|
||||
myContainer.setChild(CONTENT_ROOTS_ROLE);
|
||||
myContainer.setChild(EXCLUDED_ROOTS_ROLE);
|
||||
myContainer.setChild(JpsFacetRole.COLLECTION_ROLE);
|
||||
myContainer.setChild(DEPENDENCIES_LIST_CHILD_ROLE, new JpsDependenciesListImpl());
|
||||
getDependenciesList().addModuleSourceDependency();
|
||||
myLibraryCollection = new JpsLibraryCollectionImpl(myContainer.setChild(JpsLibraryRole.LIBRARIES_COLLECTION_ROLE));
|
||||
@@ -136,18 +135,6 @@ public class JpsModuleImpl<P extends JpsElement> extends JpsNamedCompositeElemen
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <P extends JpsElement> JpsFacet addFacet(@NotNull String name, @NotNull JpsFacetType<P> type, @NotNull P properties) {
|
||||
return myContainer.getChild(JpsFacetRole.COLLECTION_ROLE).addChild(new JpsFacetImpl(type, name, properties));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<JpsFacet> getFacets() {
|
||||
return myContainer.getChild(JpsFacetRole.COLLECTION_ROLE).getElements();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsDependenciesList getDependenciesList() {
|
||||
|
||||
@@ -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 org.jetbrains.jps.model;
|
||||
|
||||
import org.jetbrains.jps.model.java.JpsJavaModuleType;
|
||||
import org.jetbrains.jps.model.module.JpsFacet;
|
||||
import org.jetbrains.jps.model.module.JpsFacetType;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsFacetTest extends JpsModelTestCase {
|
||||
public void testAddFacet() {
|
||||
final JpsModule m = myProject.addModule("m", JpsJavaModuleType.INSTANCE);
|
||||
m.addFacet("f", MY_FACET_TYPE, JpsElementFactory.getInstance().createDummyElement());
|
||||
assertEquals("f", assertOneElement(m.getFacets()).getName());
|
||||
}
|
||||
|
||||
public void testCreateReferenceByFacet() {
|
||||
final JpsFacet facet = myProject.addModule("m", JpsJavaModuleType.INSTANCE).addFacet("f", MY_FACET_TYPE, JpsElementFactory.getInstance().createDummyElement());
|
||||
final JpsElementReference<JpsFacet> reference = facet.createReference().asExternal(myModel);
|
||||
assertSame(facet, reference.resolve());
|
||||
}
|
||||
|
||||
private static final JpsFacetType<JpsDummyElement> MY_FACET_TYPE = new JpsFacetType<JpsDummyElement>() { };
|
||||
}
|
||||
Reference in New Issue
Block a user