consulo.module.extension.ModuleExtension Java Examples
The following examples show how to use
consulo.module.extension.ModuleExtension.
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: Sand2PackageProvider.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull @Override public PsiPackage createPackage(@Nonnull PsiManager psiManager, @Nonnull PsiPackageManager packageManager, @Nonnull Class<? extends ModuleExtension> extensionClass, @Nonnull String packageName) { return new PsiPackageBase(psiManager, packageManager, extensionClass, packageName) { @Override protected ArrayFactory<? extends PsiPackage> getPackageArrayFactory() { return PsiPackage.ARRAY_FACTORY; } @RequiredReadAction @Nonnull @Override public Language getLanguage() { return SandLanguage.INSTANCE; } }; }
Example #2
Source File: ModuleExtensionConditionImpl.java From consulo with Apache License 2.0 | 6 votes |
public static ModuleExtensionCondition create(String ids) { String[] valuesOfVariableIfFound = ListOfElementsEP.getValuesOfVariableIfFound(ids); if (valuesOfVariableIfFound.length == 0) { return new ModuleExtensionCondition() { @Override public boolean value(ModuleExtension<?> rootModel) { return true; } @Override public boolean value(Project project) { return true; } }; } else { return new ModuleExtensionConditionImpl(valuesOfVariableIfFound); } }
Example #3
Source File: SdkComboBox.java From consulo with Apache License 2.0 | 6 votes |
@RequiredReadAction @SuppressWarnings("unchecked") public <T extends MutableModuleExtension<?>> void insertModuleItems(@Nonnull T moduleExtension, @Nonnull NullableFunction<T, MutableModuleInheritableNamedPointer<Sdk>> sdkPointerFunction) { for (Module module : ModuleManager.getInstance(moduleExtension.getModule().getProject()).getModules()) { // dont add self module if (module == moduleExtension.getModule()) { continue; } ModuleExtension extension = ModuleUtilCore.getExtension(module, moduleExtension.getId()); if (extension == null) { continue; } MutableModuleInheritableNamedPointer<Sdk> sdkPointer = sdkPointerFunction.fun((T)extension); if (sdkPointer != null) { // recursive depend if (sdkPointer.getModule() == moduleExtension.getModule()) { continue; } addItem(new ModuleExtensionSdkComboBoxItem(extension, sdkPointer)); } } }
Example #4
Source File: PsiPackageManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@RequiredReadAction @Nullable @Override public PsiPackage findPackage(@Nonnull String qualifiedName, @Nonnull Class<? extends ModuleExtension> extensionClass) { ConcurrentMap<String, Object> map = myPackageCache.get(extensionClass); if (map != null) { final Object value = map.get(qualifiedName); // if we processed - but not found package if (value == ObjectUtil.NULL) { return null; } else if (value != null) { return (PsiPackage)value; } } PsiPackage newPackage = createPackage(qualifiedName, extensionClass); Object valueForInsert = ObjectUtil.notNull(newPackage, ObjectUtil.NULL); myPackageCache.computeIfAbsent(extensionClass, aClass -> new ConcurrentHashMap<>()).putIfAbsent(qualifiedName, valueForInsert); return newPackage; }
Example #5
Source File: PsiPackageManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private PsiPackage createPackage(@Nonnull String qualifiedName, @Nonnull Class<? extends ModuleExtension> extensionClass) { Query<VirtualFile> dirs = myDirectoryIndex.getDirectoriesByPackageName(qualifiedName, true); if (dirs.findFirst() == null) { return null; } for (VirtualFile directory : dirs) { PsiPackage packageFromProviders = createPackageFromProviders(directory, extensionClass, qualifiedName); if (packageFromProviders != null) { return packageFromProviders; } PsiPackage packageFromLibrary = createPackageFromLibrary(directory, extensionClass, qualifiedName); if (packageFromLibrary != null) { return packageFromLibrary; } } return null; }
Example #6
Source File: PsiPackageManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private PsiPackage createPackageFromProviders(@Nonnull VirtualFile virtualFile, @Nonnull Class<? extends ModuleExtension> extensionClass, @Nonnull String qualifiedName) { final Module moduleForFile = ModuleUtil.findModuleForFile(virtualFile, myProject); if (moduleForFile == null) { return null; } ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(moduleForFile); final ModuleExtension extension = moduleRootManager.getExtension(extensionClass); if (extension == null) { return null; } for (PsiPackageSupportProvider p : PsiPackageSupportProvider.EP_NAME.getExtensionList()) { if (p.isSupported(extension) && p.acceptVirtualFile(moduleForFile, virtualFile)) { return p.createPackage(myPsiManager, this, extensionClass, qualifiedName); } } return null; }
Example #7
Source File: PsiPackageManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
private PsiPackage createPackageFromLibrary(@Nonnull VirtualFile virtualFile, @Nonnull Class<? extends ModuleExtension> extensionClass, @Nonnull String qualifiedName) { if (myProjectFileIndex.isInLibraryClasses(virtualFile)) { List<OrderEntry> orderEntriesForFile = myProjectFileIndex.getOrderEntriesForFile(virtualFile); for (OrderEntry orderEntry : orderEntriesForFile) { Module ownerModule = orderEntry.getOwnerModule(); ModuleExtension extension = ModuleUtilCore.getExtension(ownerModule, extensionClass); if (extension != null) { for (PsiPackageSupportProvider p : PsiPackageSupportProvider.EP_NAME.getExtensionList()) { if (p.isSupported(extension)) { return p.createPackage(myPsiManager, this, extensionClass, qualifiedName); } } } } } return null; }
Example #8
Source File: BundleBox.java From consulo with Apache License 2.0 | 6 votes |
@RequiredUIAccess @SuppressWarnings("unchecked") public <T extends MutableModuleExtension<?>> void addModuleExtensionItems(@Nonnull T moduleExtension, @Nonnull Function<T, MutableModuleInheritableNamedPointer<Sdk>> sdkPointerFunction) { MutableListModel<BundleBoxItem> listModel = (MutableListModel<BundleBoxItem>)myOriginalComboBox.getListModel(); for (Module module : ModuleManager.getInstance(moduleExtension.getModule().getProject()).getModules()) { // dont add self module if (module == moduleExtension.getModule()) { continue; } ModuleExtension extension = ModuleUtilCore.getExtension(module, moduleExtension.getId()); if (extension == null) { continue; } MutableModuleInheritableNamedPointer<Sdk> sdkPointer = sdkPointerFunction.apply((T)extension); if (sdkPointer != null) { // recursive depend if (sdkPointer.getModule() == moduleExtension.getModule()) { continue; } listModel.add(new ModuleExtensionBundleBoxItem(extension, sdkPointer)); } } }
Example #9
Source File: ModuleExtensionIndexCache.java From consulo with Apache License 2.0 | 6 votes |
private static void putToMap0(@Nonnull Map<Class<?>, int[]> map, Class<?> clazz, int index) { Class temp = clazz; do { if (temp == ModuleExtensionWithSdkImpl.class || temp == ModuleExtensionImpl.class || temp == ModuleExtension.class || temp == ModuleExtensionWithSdk.class) { break; } putToMapImpl(map, temp, index); Class[] interfaces = temp.getInterfaces(); for (Class intef : interfaces) { putToMap0(map, intef, index); } } while ((temp = temp.getSuperclass()) != null); }
Example #10
Source File: PsiPackageSupportProviders.java From consulo with Apache License 2.0 | 6 votes |
@RequiredReadAction public static boolean isPackageSupported(@Nonnull Project project) { return CachedValuesManager.getManager(project).getCachedValue(project, () -> { boolean result = false; PsiPackageSupportProvider[] extensions = PsiPackageSupportProvider.EP_NAME.getExtensions(); ModuleManager moduleManager = ModuleManager.getInstance(project); loop: for (Module module : moduleManager.getModules()) { ModuleRootManager rootManager = ModuleRootManager.getInstance(module); for (ModuleExtension moduleExtension : rootManager.getExtensions()) { for (PsiPackageSupportProvider extension : extensions) { if (extension.isSupported(moduleExtension)) { result = true; break loop; } } } } return CachedValueProvider.Result.create(result, ProjectRootManager.getInstance(project)); }); }
Example #11
Source File: ModuleUtil.java From consulo with Apache License 2.0 | 5 votes |
public static boolean hasModuleExtension(@Nonnull ModulesProvider modulesProvider, @Nonnull Class<? extends ModuleExtension> clazz) { for (Module module : modulesProvider.getModules()) { ModuleRootModel rootModel = modulesProvider.getRootModel(module); if (rootModel == null) { continue; } ModuleExtension extension = rootModel.getExtension(clazz); if (extension != null) { return true; } } return false; }
Example #12
Source File: CSharpFilePropertyPusher.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Override public void initExtra(@Nonnull Project project, @Nonnull MessageBus messageBus) { project.getMessageBus().connect().subscribe(ModuleExtension.CHANGE_TOPIC, (oldExtension, newExtension) -> { if(oldExtension instanceof CSharpSimpleModuleExtension && newExtension instanceof CSharpSimpleModuleExtension) { if(((CSharpSimpleModuleExtension) oldExtension).getLanguageVersion() != ((CSharpSimpleModuleExtension) newExtension).getLanguageVersion()) { addChanged(project, newExtension); } } if(oldExtension instanceof DotNetSimpleModuleExtension && newExtension instanceof DotNetSimpleModuleExtension) { if(!((DotNetSimpleModuleExtension) oldExtension).getVariables().equals(((DotNetSimpleModuleExtension) newExtension).getVariables())) { addChanged(project, newExtension); } } }); }
Example #13
Source File: CSharpFilePropertyPusher.java From consulo-csharp with Apache License 2.0 | 5 votes |
private void addChanged(Project project, ModuleExtension<?> newExtension) { Set<String> changedModules = project.getUserData(ourChangedModulesKey); if(changedModules == null) { changedModules = new HashSet<>(); } project.putUserData(ourChangedModulesKey, changedModules); changedModules.add(newExtension.getModule().getName()); }
Example #14
Source File: ModuleExtensionIndexCache.java From consulo with Apache License 2.0 | 5 votes |
private static void putToMapImpl(@Nonnull Map<Class<?>, int[]> map, Class<?> temp, int index) { if (temp == ModuleExtensionWithSdkImpl.class || temp == ModuleExtensionImpl.class || temp == ModuleExtension.class || temp == ModuleExtensionWithSdk.class) { return; } int[] ints = map.get(temp); if (ints == null) { map.put(temp, new int[]{index}); } else { map.put(temp, ArrayUtil.append(ints, index)); } }
Example #15
Source File: ModuleExtensionWithSdkOrderEntryImpl.java From consulo with Apache License 2.0 | 5 votes |
@javax.annotation.Nullable @Override public ModuleExtensionWithSdk<?> getModuleExtension() { ModuleExtension<?> extensionWithoutCheck = myModuleRootLayer.getExtensionWithoutCheck(myModuleExtensionId); if (!(extensionWithoutCheck instanceof ModuleExtensionWithSdk)) { return null; } return (ModuleExtensionWithSdk) extensionWithoutCheck; }
Example #16
Source File: ModuleExtensionConditionImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean value(Project project) { ModuleManager moduleManager = ModuleManager.getInstance(project); for (Module module : moduleManager.getModules()) { ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module); for (String extensionId : myExtensionIds) { ModuleExtension<?> extension = moduleRootManager.getExtension(extensionId); if(extension != null) { return true; } } } return false; }
Example #17
Source File: SetupUnitySDKProvider.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@Inject public SetupUnitySDKProvider(Project project, final EditorNotifications notifications) { myProject = project; myProject.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { @Override public void rootsChanged(ModuleRootEvent event) { notifications.updateAllNotifications(); } }); myProject.getMessageBus().connect().subscribe(ModuleExtension.CHANGE_TOPIC, (oldExtension, newExtension) -> notifications.updateAllNotifications()); }
Example #18
Source File: FileIsNotAttachedProvider.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@Inject public FileIsNotAttachedProvider(Project project, final EditorNotifications notifications) { myProject = project; myProject.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { @Override public void rootsChanged(ModuleRootEvent event) { notifications.updateAllNotifications(); } }); myProject.getMessageBus().connect().subscribe(ModuleExtension.CHANGE_TOPIC, (oldExtension, newExtension) -> notifications.updateAllNotifications()); }
Example #19
Source File: ModuleUtilCore.java From consulo with Apache License 2.0 | 5 votes |
@Nullable @RequiredReadAction public static <E extends ModuleExtension<E>> E getExtension(@Nonnull PsiElement element, @Nonnull Class<E> extensionClass) { Module moduleForPsiElement = findModuleForPsiElement(element); if (moduleForPsiElement == null) { return null; } return getExtension(moduleForPsiElement, extensionClass); }
Example #20
Source File: ModuleUtilCore.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public static <E extends ModuleExtension<E>> E getExtension(@Nonnull Project project, @Nonnull VirtualFile virtualFile, @Nonnull Class<E> extensionClass) { Module moduleForFile = findModuleForFile(virtualFile, project); if (moduleForFile == null) { return null; } return getExtension(moduleForFile, extensionClass); }
Example #21
Source File: ToolWindowManagerBase.java From consulo with Apache License 2.0 | 5 votes |
private static boolean checkCondition(ModuleExtension<?> extension, ToolWindowEP toolWindowEP) { Condition<Project> condition = toolWindowEP.getCondition(); if (condition != null && !condition.value(extension.getProject())) { return false; } ModuleExtensionCondition moduleExtensionCondition = toolWindowEP.getModuleExtensionCondition(); return moduleExtensionCondition.value(extension); }
Example #22
Source File: ExtensionCheckedTreeNode.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean isEnabled() { // if extension not found dont allow manage it if(myExtension == null) { return false; } if (myProviderEP != null && myProviderEP.allowMixin) { return true; } if(myProviderEP != null && myProviderEP.systemOnly) { return false; } final ModifiableRootModel rootModel = myState.getRootModel(); if (rootModel == null) { return false; } final ModuleExtensionProviderEP absoluteParent = findParentWithoutParent(myExtension.getId()); final ModuleExtension extension = rootModel.getExtension(absoluteParent.getKey()); if (extension != null) { return true; } // if no nodes checked - it enabled for (ModuleExtensionProviderEP ep : ModuleExtensionProviders.getProviders()) { if (ep.parentKey != null) { continue; } final ModuleExtension tempExtension = rootModel.getExtension(ep.getKey()); if (tempExtension != null) { return false; } } return true; }
Example #23
Source File: PackageNodeUtil.java From consulo with Apache License 2.0 | 5 votes |
/** * a directory is considered "empty" if it has at least one child and all its children are only directories * * @param strictlyEmpty if true, the package is considered empty if it has only 1 child and this child is a directory * otherwise the package is considered as empty if all direct children that it has are directories */ public static boolean isEmptyMiddlePackage(@Nonnull PsiDirectory dir, @Nullable Class<? extends ModuleExtension> moduleExtensionClass, boolean strictlyEmpty) { final VirtualFile[] files = dir.getVirtualFile().getChildren(); if (files.length == 0) { return false; } PsiManager manager = dir.getManager(); int subpackagesCount = 0; int directoriesCount = 0; for (VirtualFile file : files) { if (FileTypeManager.getInstance().isFileIgnored(file)) continue; if (!file.isDirectory()) return false; PsiDirectory childDir = manager.findDirectory(file); if (childDir != null) { directoriesCount++; if (strictlyEmpty && directoriesCount > 1) return false; final PsiPackageManager psiPackageManager = PsiPackageManager.getInstance(dir.getProject()); PsiPackage tempPackage = moduleExtensionClass == null ? psiPackageManager.findAnyPackage(childDir) : psiPackageManager.findPackage(dir, moduleExtensionClass); if (tempPackage != null) { subpackagesCount++; } } } if (strictlyEmpty) { return directoriesCount == subpackagesCount && directoriesCount == 1; } return directoriesCount == subpackagesCount && directoriesCount > 0; }
Example #24
Source File: ExtensionListenerByLayerListenerInvoker.java From consulo with Apache License 2.0 | 5 votes |
@Inject public ExtensionListenerByLayerListenerInvoker(@Nonnull Project project) { project.getMessageBus().connect().subscribe(ProjectTopics.MODULE_LAYERS, new ModuleRootLayerListener.Adapter() { @Override public void currentLayerChanged(@Nonnull final Module module, @Nonnull final String oldName, @Nonnull final ModuleRootLayer oldLayer, @Nonnull final String newName, @Nonnull final ModuleRootLayer newLayer) { final List<Couple<ModuleExtension>> list = new ArrayList<Couple<ModuleExtension>>(); for (ModuleExtensionProviderEP providerEP : ModuleExtensionProviders.getProviders()) { MutableModuleExtension oldExtension = oldLayer.getExtensionWithoutCheck(providerEP.getKey()); MutableModuleExtension newExtension = newLayer.getExtensionWithoutCheck(providerEP.getKey()); if(oldExtension == null || newExtension == null) { continue; } if(oldExtension.isModified(newExtension)) { list.add(Couple.<ModuleExtension>of(oldExtension, newExtension)); } } ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { ModuleExtensionChangeListener moduleExtensionChangeListener = project.getMessageBus().syncPublisher(ModuleExtension.CHANGE_TOPIC); for (Couple<ModuleExtension> couple : list) { moduleExtensionChangeListener.beforeExtensionChanged(couple.getFirst(), couple.getSecond()); } } }, ModalityState.NON_MODAL); } }); }
Example #25
Source File: CreateDirectoryOrPackageAction.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @RequiredUIAccess private static Trinity<ContentFolderTypeProvider, PsiDirectory, ChildType> getInfo(PsiDirectory d) { Project project = d.getProject(); ProjectFileIndex projectFileIndex = ProjectFileIndex.getInstance(project); Module moduleForPsiElement = ModuleUtilCore.findModuleForPsiElement(d); if (moduleForPsiElement != null) { boolean isPackageSupported = false; ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(moduleForPsiElement); List<PsiPackageSupportProvider> extensions = PsiPackageSupportProvider.EP_NAME.getExtensionList(); for (ModuleExtension moduleExtension : moduleRootManager.getExtensions()) { for (PsiPackageSupportProvider supportProvider : extensions) { if (supportProvider.isSupported(moduleExtension)) { isPackageSupported = true; break; } } } if (isPackageSupported) { ContentFolderTypeProvider contentFolderTypeForFile = projectFileIndex.getContentFolderTypeForFile(d.getVirtualFile()); if (contentFolderTypeForFile != null) { Image childPackageIcon = contentFolderTypeForFile.getChildPackageIcon(); return Trinity.create(contentFolderTypeForFile, d, childPackageIcon != null ? ChildType.Package : ChildType.Directory); } } } return Trinity.create(null, d, ChildType.Directory); }
Example #26
Source File: PsiPackageBase.java From consulo with Apache License 2.0 | 5 votes |
public PsiPackageBase(PsiManager manager, PsiPackageManager packageManager, Class<? extends ModuleExtension> extensionClass, String qualifiedName) { myManager = manager; myPackageManager = packageManager; myExtensionClass = extensionClass; myQualifiedName = qualifiedName; }
Example #27
Source File: ContentEntryTreeCellRenderer.java From consulo with Apache License 2.0 | 5 votes |
protected Image updateIcon(final ContentEntry entry, final VirtualFile file, Image originalIcon) { Image icon = originalIcon; VirtualFile currentRoot = null; for (ContentFolder contentFolder : entry.getFolders(ContentFolderScopes.all())) { final VirtualFile contentPath = contentFolder.getFile(); if (file.equals(contentPath)) { icon = contentFolder.getType().getIcon(contentFolder.getProperties()); } else if (contentPath != null && VfsUtilCore.isAncestor(contentPath, file, true)) { if (currentRoot != null && VfsUtilCore.isAncestor(contentPath, currentRoot, false)) { continue; } boolean hasSupport = false; for (ModuleExtension moduleExtension : myTreeEditor.getContentEntryEditor().getModel().getExtensions()) { for (PsiPackageSupportProvider supportProvider : PsiPackageSupportProvider.EP_NAME.getExtensions()) { if (supportProvider.isSupported(moduleExtension)) { hasSupport = true; break; } } } icon = hasSupport ? contentFolder.getType().getChildDirectoryIcon(null) : AllIcons.Nodes.TreeOpen; currentRoot = contentPath; } } return icon; }
Example #28
Source File: PsiPackageManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@RequiredReadAction @Nullable @Override public PsiPackage findPackage(@Nonnull PsiDirectory directory, @Nonnull Class<? extends ModuleExtension> extensionClass) { String packageName = myDirectoryIndex.getPackageName(directory.getVirtualFile()); if (packageName == null) { return null; } return findPackage(packageName, extensionClass); }
Example #29
Source File: PsiPackageManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nullable @RequiredReadAction private PsiPackage findForModule(String packageName, Module module) { ModuleRootManager rootManager = ModuleRootManager.getInstance(module); for (ModuleExtension<?> moduleExtension : rootManager.getExtensions()) { final PsiPackage aPackage = findPackage(packageName, moduleExtension.getClass()); if (aPackage != null) { return aPackage; } } return null; }
Example #30
Source File: PsiPackageManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@RequiredReadAction @Override public boolean isValidPackageName(@Nonnull Module module, @Nonnull String packageName) { List<PsiPackageSupportProvider> extensionList = PsiPackageSupportProvider.EP_NAME.getExtensionList(); ModuleRootManager rootManager = ModuleRootManager.getInstance(module); for (ModuleExtension<?> moduleExtension : rootManager.getExtensions()) { for (PsiPackageSupportProvider provider : extensionList) { if (provider.isSupported(moduleExtension)) { return provider.isValidPackageName(module, packageName); } } } return true; }