Java Code Examples for com.intellij.openapi.module.ModuleUtilCore#createPointer()

The following examples show how to use com.intellij.openapi.module.ModuleUtilCore#createPointer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModulePointerTest.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void testCreateByModule() throws Exception {
  final Module module = addModule("x");
  final NamedPointer<Module> pointer = ModuleUtilCore.createPointer(module);
  assertSame(pointer, ModuleUtilCore.createPointer(module));
  assertSame(pointer, ModuleUtilCore.createPointer(getProject(), "x"));
  assertSame(module, pointer.get());
  assertEquals("x", pointer.getName());

  ModifiableModuleModel model = getModuleManager().getModifiableModel();
  model.disposeModule(module);
  commitModel(model);

  assertNull(pointer.get());
  assertEquals("x", pointer.getName());

  final Module newModule = addModule("x");
  assertSame(pointer, ModuleUtilCore.createPointer(newModule));
}
 
Example 2
Source File: ModulePointerTest.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void testDisposePointerFromUncommitedModifiableModel() throws Exception {
  final NamedPointer<Module> pointer = ModuleUtilCore.createPointer(getProject(), "xxx");

  final ModifiableModuleModel modifiableModel = getModuleManager().getModifiableModel();
  final Module module = modifiableModel.newModule("xxx", myProject.getBaseDir().getPath());
  assertSame(pointer, ModuleUtilCore.createPointer(module));
  assertSame(pointer, ModuleUtilCore.createPointer(getProject(), "xxx"));

  assertSame(module, pointer.get());
  assertEquals("xxx", pointer.getName());

  modifiableModel.dispose();

  assertNull(pointer.get());
  assertEquals("xxx", pointer.getName());
}
 
Example 3
Source File: ModuleOrderEntryImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ModuleOrderEntryImpl(@Nonnull String moduleName, @Nonnull ModuleRootLayerImpl rootLayer, @Nonnull DependencyScope dependencyScope, boolean exported,
                            boolean productionOnTestDependency) {
  super(ModuleOrderEntryType.getInstance(), rootLayer);
  myModulePointer = ModuleUtilCore.createPointer(rootLayer.getProject(), moduleName);
  myScope = dependencyScope;
  myExported = exported;
  myProductionOnTestDependency = productionOnTestDependency;
}
 
Example 4
Source File: ModuleOrderEntryImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private ModuleOrderEntryImpl(ModuleOrderEntryImpl that, ModuleRootLayerImpl rootLayer) {
  super(ModuleOrderEntryType.getInstance(), rootLayer);
  final NamedPointer<Module> thatModule = that.myModulePointer;
  myModulePointer = ModuleUtilCore.createPointer(rootLayer.getProject(), thatModule.getName());
  myExported = that.myExported;
  myProductionOnTestDependency = that.myProductionOnTestDependency;
  myScope = that.myScope;
}
 
Example 5
Source File: ModulePointerTest.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void testCreateByName() throws Exception {
  final NamedPointer<Module> pointer = ModuleUtilCore.createPointer(getProject(), "m");
  assertSame(pointer, ModuleUtilCore.createPointer(getProject(), "m"));
  assertNull(pointer.get());
  assertEquals("m", pointer.getName());

  final Module module = addModule("m");

  assertSame(module, pointer.get());
  assertEquals("m", pointer.getName());
}
 
Example 6
Source File: ModulePointerTest.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void testRenameModule() throws Exception {
  final NamedPointer<Module> pointer = ModuleUtilCore.createPointer(getProject(), "abc");
  final Module module = addModule("abc");
  ModifiableModuleModel model = getModuleManager().getModifiableModel();
  model.renameModule(module, "xyz");
  commitModel(model);
  assertSame(module, pointer.get());
  assertEquals("xyz", pointer.getName());
}
 
Example 7
Source File: ModuleOutputSourceItem.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public SourceItemPresentation createPresentation(@Nonnull ArtifactEditorContext context) {
  final NamedPointer<Module> modulePointer = ModuleUtilCore.createPointer(myModule);
  return new DelegatedSourceItemPresentation(new ModuleElementPresentation(modulePointer, context, myModuleOutputType.getContentFolderType())) {
    @Override
    public int getWeight() {
      return SourceItemWeights.MODULE_OUTPUT_WEIGHT;
    }
  };
}
 
Example 8
Source File: ModuleOutputSourceItem.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public List<? extends PackagingElement<?>> createElements(@Nonnull ArtifactEditorContext context) {
  final NamedPointer<Module> modulePointer = ModuleUtilCore.createPointer(myModule);

  return Collections.singletonList(myModuleOutputType.createElement(context.getProject(), modulePointer));
}
 
Example 9
Source File: ModuleOrderEntryImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ModuleOrderEntryImpl(@Nonnull Module module, @Nonnull ModuleRootLayerImpl rootLayer) {
  super(ModuleOrderEntryType.getInstance(), rootLayer);
  myModulePointer = ModuleUtilCore.createPointer(module);
}
 
Example 10
Source File: RootConfigurationAccessor.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@RequiredReadAction
public NamedPointer<Module> getModulePointer(Project project, String name) {
  return ModuleUtilCore.createPointer(project, name);
}
 
Example 11
Source File: ModuleDeploymentSourceType.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public ModuleDeploymentSource load(@Nonnull Element tag, @Nonnull Project project) {
  return new ModuleDeploymentSourceImpl(ModuleUtilCore.createPointer(project, tag.getAttributeValue(NAME_ATTRIBUTE)));
}