consulo.roots.ModuleRootLayer Java Examples

The following examples show how to use consulo.roots.ModuleRootLayer. 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: OrderEntrySerializationUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
public static OrderEntry loadOrderEntry(@Nonnull Element element, @Nonnull ModuleRootLayer moduleRootLayer) {
  String type = element.getAttributeValue(ORDER_ENTRY_TYPE_ATTR);
  if(type == null) {
    return null;
  }
  OrderEntryType orderEntryType = getProvidersAsMap().get(type);
  if(orderEntryType == null) {
    return new UnknownOrderEntryImpl(new UnknownOrderEntryType(type, element), (ModuleRootLayerImpl)moduleRootLayer);
  }

  try {
    return orderEntryType.loadOrderEntry(element, moduleRootLayer);
  }
  catch (InvalidDataException e) {
    return new UnknownOrderEntryImpl(new UnknownOrderEntryType(type, element), (ModuleRootLayerImpl)moduleRootLayer);
  }
}
 
Example #2
Source File: ExcludeCompilerOutputPolicy.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public VirtualFilePointer[] getExcludeRootsForModule(@Nonnull final ModuleRootLayer moduleRootLayer) {
  ModuleCompilerPathsManager manager = ModuleCompilerPathsManager.getInstance(moduleRootLayer.getModule());
  List<VirtualFilePointer> result = new ArrayList<VirtualFilePointer>(3);

  if (manager.isInheritedCompilerOutput()) {
    final VirtualFilePointer compilerOutputPointer = CompilerConfiguration.getInstance(myProject).getCompilerOutputPointer();
    for (ContentEntry contentEntry : moduleRootLayer.getContentEntries()) {
      if (compilerOutputPointer.getUrl().contains(contentEntry.getUrl())) {
        result.add(compilerOutputPointer);
      }
    }
  }
  else {
    if (!manager.isExcludeOutput()) {
      return VirtualFilePointer.EMPTY_ARRAY;
    }

    for (ContentFolderTypeProvider contentFolderType : ContentFolderTypeProvider.filter(ContentFolderScopes.productionAndTest())) {
      result.add(manager.getCompilerOutputPointer(contentFolderType));
    }
  }
  return result.isEmpty() ? VirtualFilePointer.EMPTY_ARRAY : result.toArray(new VirtualFilePointer[result.size()]);
}
 
Example #3
Source File: ModuleLayerWidget.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
protected WidgetState getWidgetState(@Nullable VirtualFile file) {
  if (file == null) {
    return WidgetState.HIDDEN;
  }

  Module module = ModuleUtilCore.findModuleForFile(file, getProject());
  if (module == null) {
    return WidgetState.HIDDEN;
  }
  ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
  Map<String, ModuleRootLayer> layers = moduleRootManager.getLayers();
  if (layers.size() == 1) {
    return WidgetState.HIDDEN;
  }

  String currentLayerName = moduleRootManager.getCurrentLayerName();
  return new WidgetState("Module Layer: " + currentLayerName, currentLayerName, true);
}
 
Example #4
Source File: ModuleLayerWidget.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
private ListWithSelection<String> getLayers() {
  VirtualFile file = getSelectedFile();
  Project project = getProject();

  Module moduleForFile = file == null ? null : ModuleUtilCore.findModuleForFile(file, project);
  if (moduleForFile == null) {
    return null;
  }

  ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(moduleForFile);
  Map<String, ModuleRootLayer> layers = moduleRootManager.getLayers();
  if (layers.size() == 1) {
    return null;
  }
  String currentLayerName = moduleRootManager.getCurrentLayerName();

  return new ListWithSelection<>(layers.keySet(), currentLayerName);
}
 
Example #5
Source File: ModuleExtensionWithSdkOrderEntryType.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public ModuleExtensionWithSdkOrderEntryImpl loadOrderEntry(@Nonnull Element element, @Nonnull ModuleRootLayer moduleRootLayer) throws InvalidDataException {
  String moduleExtensionId = element.getAttributeValue(EXTENSION_ID_ATTRIBUTE);
  if (moduleExtensionId == null) {
    throw new InvalidDataException();
  }
  return new ModuleExtensionWithSdkOrderEntryImpl(moduleExtensionId, (ModuleRootLayerImpl)moduleRootLayer, false);
}
 
Example #6
Source File: ModuleExtensionProviderEP.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private <E> Pair<Class<E>, Constructor<E>> resolveFor(String className) {
  Class<E> value = findClassNoExceptions(className);
  if (value == null) {
    return null;
  }
  try {
    return Pair.create(value, value.getConstructor(String.class, ModuleRootLayer.class));
  }
  catch (NoSuchMethodException e) {
    ModuleExtensionProviderEP.LOGGER.error(e);
  }
  return null;
}
 
Example #7
Source File: ModuleExtensionProviderEP.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public ModuleExtension<?> createImmutable(@Nonnull ModuleRootLayer modifiableRootModel) {
  try {
    Pair<Class<ModuleExtension>, Constructor<ModuleExtension>> value = myImmutableValue.getValue();
    if (value != null) {
      return ReflectionUtil.createInstance(value.getSecond(), key, modifiableRootModel);
    }
  }
  catch (Error e) {
    ModuleExtensionProviderEP.LOGGER.error("Problem with module extension: " + key, e);
  }
  return null;
}
 
Example #8
Source File: ModuleExtensionProviderEP.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public MutableModuleExtension<?> createMutable(@Nonnull ModuleRootLayer modifiableRootModel) {
  try {
    Pair<Class<MutableModuleExtension>, Constructor<MutableModuleExtension>> value = myMutableValue.getValue();
    if (value != null) {
      return ReflectionUtil.createInstance(value.getSecond(), key, modifiableRootModel);
    }
  }
  catch (Error e) {
    ModuleExtensionProviderEP.LOGGER.error("Problem with module extension: " + key, e);
  }
  return null;
}
 
Example #9
Source File: ModuleLibraryOrderEntryType.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public ModuleLibraryOrderEntryImpl loadOrderEntry(@Nonnull Element element, @Nonnull ModuleRootLayer moduleRootLayer) throws InvalidDataException {
  boolean exported = element.getAttributeValue(EXPORTED_ATTR) != null;
  DependencyScope scope = DependencyScope.readExternal(element);
  Library library = LibraryTableImplUtil.loadLibrary(element, (ModuleRootLayerImpl)moduleRootLayer);
  return new ModuleLibraryOrderEntryImpl(library, (ModuleRootLayerImpl)moduleRootLayer, exported, scope, false);
}
 
Example #10
Source File: ModuleOrderEntryType.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public ModuleOrderEntryImpl loadOrderEntry(@Nonnull Element element, @Nonnull ModuleRootLayer moduleRootLayer) throws InvalidDataException {
  String moduleName = element.getAttributeValue(MODULE_NAME_ATTR);
  if (moduleName == null) {
    throw new InvalidDataException();
  }
  DependencyScope dependencyScope = DependencyScope.readExternal(element);
  boolean exported = element.getAttributeValue(EXPORTED_ATTR) != null;
  boolean productionOnTestDependency = element.getAttributeValue(PRODUCTION_ON_TEST_ATTRIBUTE) != null;
  return new ModuleOrderEntryImpl(moduleName, (ModuleRootLayerImpl)moduleRootLayer, dependencyScope, exported, productionOnTestDependency);
}
 
Example #11
Source File: Unity3dPackageOrderEntryType.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public Unity3dPackageOrderEntry loadOrderEntry(@Nonnull Element element, @Nonnull ModuleRootLayer moduleRootLayer) throws InvalidDataException
{
	String name = element.getAttributeValue("name");
	return new Unity3dPackageOrderEntry((ModuleRootLayerImpl) moduleRootLayer, name);
}
 
Example #12
Source File: LibraryOrderEntryType.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public LibraryOrderEntryImpl loadOrderEntry(@Nonnull Element element, @Nonnull ModuleRootLayer moduleRootLayer) throws InvalidDataException {
  String name = element.getAttributeValue(NAME_ATTR);
  if (name == null) {
    throw new InvalidDataException();
  }

  String level = element.getAttributeValue(LEVEL_ATTR, LibraryTablesRegistrar.PROJECT_LEVEL);
  DependencyScope dependencyScope = DependencyScope.readExternal(element);
  boolean exported = element.getAttributeValue(EXPORTED_ATTR) != null;
  return new LibraryOrderEntryImpl(name, level, (ModuleRootLayerImpl)moduleRootLayer, dependencyScope, exported, false);
}
 
Example #13
Source File: ModuleExtension.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
ModuleRootLayer getModuleRootLayer();
 
Example #14
Source File: ModuleRootManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public ModuleRootLayer getCurrentLayer() {
  return myRootModel.getCurrentLayer();
}
 
Example #15
Source File: ExternalSystemMutableModuleExtensionImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ExternalSystemMutableModuleExtensionImpl(@Nonnull String id, @Nonnull ModuleRootLayer moduleRootLayer) {
  super(id, moduleRootLayer);
}
 
Example #16
Source File: UnknownOrderEntryType.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public UnknownOrderEntryImpl loadOrderEntry(@Nonnull Element element, @Nonnull ModuleRootLayer moduleRootLayer) throws InvalidDataException {
  throw new IllegalArgumentException("this method ill never call");
}
 
Example #17
Source File: ModuleDependencyTabFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isAvailable(@Nonnull ModuleRootLayer layer) {
  return true;
}
 
Example #18
Source File: ProjectLibraryTabFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isAvailable(@Nonnull ModuleRootLayer layer) {
  return true;
}
 
Example #19
Source File: FileOrDirectoryDependencyTabFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isAvailable(@Nonnull ModuleRootLayer layer) {
  return true;
}
 
Example #20
Source File: Sand2MutableModuleExtension.java    From consulo with Apache License 2.0 4 votes vote down vote up
public Sand2MutableModuleExtension(@Nonnull String id, @Nonnull ModuleRootLayer moduleRootLayer) {
  super(id, moduleRootLayer);
}
 
Example #21
Source File: SandMutableModuleExtension.java    From consulo with Apache License 2.0 4 votes vote down vote up
public SandMutableModuleExtension(@Nonnull String id, @Nonnull ModuleRootLayer rootModel) {
  super(id, rootModel);
}
 
Example #22
Source File: SandModuleExtension.java    From consulo with Apache License 2.0 4 votes vote down vote up
public SandModuleExtension(@Nonnull String id, @Nonnull ModuleRootLayer rootModel) {
  super(id, rootModel);
}
 
Example #23
Source File: Sand2ModuleExtension.java    From consulo with Apache License 2.0 4 votes vote down vote up
public Sand2ModuleExtension(@Nonnull String id, @Nonnull ModuleRootLayer moduleRootLayer) {
  super(id, moduleRootLayer);
}
 
Example #24
Source File: ModuleRootModel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@javax.annotation.Nullable
ModuleRootLayer findLayerByName(@Nonnull String name);
 
Example #25
Source File: OrderEnumeratorBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected void processEntries(final ModuleRootLayer rootModel,
                              Processor<OrderEntry> processor,
                              Set<Module> processed, boolean firstLevel) {
  if (processed != null && !processed.add(rootModel.getModule())) return;

  for (OrderEntry entry : rootModel.getOrderEntries()) {
    if (myCondition != null && !myCondition.value(entry)) continue;

    if (myWithoutJdk && entry instanceof ModuleExtensionWithSdkOrderEntry) continue;
    if (myWithoutLibraries && entry instanceof LibraryOrderEntry) continue;
    if (myWithoutDepModules) {
      if (!myRecursively && entry instanceof ModuleOrderEntry) continue;
      if (entry instanceof ModuleSourceOrderEntry && !isRootModuleModel(((ModuleSourceOrderEntry)entry).getRootModel())) continue;
    }
    if (myWithoutModuleSourceEntries && entry instanceof ModuleSourceOrderEntry) continue;

    OrderEnumerationHandler.AddDependencyType shouldAdd = OrderEnumerationHandler.AddDependencyType.DEFAULT;
    for (OrderEnumerationHandler handler : myCustomHandlers) {
      shouldAdd = handler.shouldAddDependency(entry, this);
      if (shouldAdd != OrderEnumerationHandler.AddDependencyType.DEFAULT) break;
    }
    if (shouldAdd == OrderEnumerationHandler.AddDependencyType.DO_NOT_ADD) continue;

    boolean exported = !(entry instanceof ModuleExtensionWithSdkOrderEntry);

    if (entry instanceof ExportableOrderEntry) {
      ExportableOrderEntry exportableEntry = (ExportableOrderEntry)entry;
      if (shouldAdd == OrderEnumerationHandler.AddDependencyType.DEFAULT) {
        final DependencyScope scope = exportableEntry.getScope();
        boolean forTestCompile = scope.isForTestCompile() || scope == DependencyScope.RUNTIME && shouldAddRuntimeDependenciesToTestCompilationClasspath();
        if (myCompileOnly && !scope.isForProductionCompile() && !forTestCompile) continue;
        if (myRuntimeOnly && !scope.isForProductionRuntime() && !scope.isForTestRuntime()) continue;
        if (myProductionOnly) {
          if (!scope.isForProductionCompile() && !scope.isForProductionRuntime()
              || myCompileOnly && !scope.isForProductionCompile()
              || myRuntimeOnly && !scope.isForProductionRuntime()) {
            continue;
          }
        }
      }
      exported = exportableEntry.isExported();
    }
    if (!exported) {
      if (myExportedOnly) continue;
      if (myRecursivelyExportedOnly && !firstLevel) continue;
    }

    if (myRecursively && entry instanceof ModuleOrderEntry) {
      ModuleOrderEntry moduleOrderEntry = (ModuleOrderEntry)entry;
      final Module module = moduleOrderEntry.getModule();
      if (module != null && shouldProcessRecursively()) {
        processEntries(getRootModel(module), processor, processed, false);
        continue;
      }
    }

    if (myWithoutDepModules && entry instanceof ModuleOrderEntry) continue;
    if (!processor.process(entry)) {
      return;
    }
  }
}
 
Example #26
Source File: RootModelImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public ModuleRootLayer findLayerByName(@Nonnull String name) {
  return myLayers.get(name);
}
 
Example #27
Source File: RootModelImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public Map<String, ModuleRootLayer> getLayers() {
  return Collections.<String, ModuleRootLayer>unmodifiableSortedMap(myLayers);
}
 
Example #28
Source File: ExternalSystemModuleExtensionImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ExternalSystemModuleExtensionImpl(@Nonnull String id, @Nonnull ModuleRootLayer moduleRootLayer) {
  super(id, moduleRootLayer);
}
 
Example #29
Source File: ModuleRootManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public Map<String, ModuleRootLayer> getLayers() {
  LOGGER.assertTrue(!myIsDisposed);
  return myRootModel.getLayers();
}
 
Example #30
Source File: ModuleRootManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public ModuleRootLayer findLayerByName(@Nonnull String name) {
  LOGGER.assertTrue(!myIsDisposed);
  return myRootModel.findLayerByName(name);
}