當前位置: 首頁>>代碼示例>>Java>>正文


Java ModuleUtil.findModuleForPsiElement方法代碼示例

本文整理匯總了Java中com.intellij.openapi.module.ModuleUtil.findModuleForPsiElement方法的典型用法代碼示例。如果您正苦於以下問題:Java ModuleUtil.findModuleForPsiElement方法的具體用法?Java ModuleUtil.findModuleForPsiElement怎麽用?Java ModuleUtil.findModuleForPsiElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.module.ModuleUtil的用法示例。


在下文中一共展示了ModuleUtil.findModuleForPsiElement方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getIjModule

import com.intellij.openapi.module.ModuleUtil; //導入方法依賴的package包/類
public static Module getIjModule( PsiElement element )
{
  Module module = ModuleUtil.findModuleForPsiElement( element );
  if( module != null )
  {
    return module;
  }

  ManifoldPsiClass javaFacadePsiClass = element.getContainingFile().getUserData( ManifoldPsiClass.KEY_MANIFOLD_PSI_CLASS );
  if( javaFacadePsiClass != null )
  {
    return javaFacadePsiClass.getModule();
  }

  return null;
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:17,代碼來源:ManProject.java

示例2: getSearchScope

import com.intellij.openapi.module.ModuleUtil; //導入方法依賴的package包/類
@NotNull
public static GlobalSearchScope getSearchScope(@NotNull PsiElement element) {
  Project project = element.getProject();
  // ignore scopes in test mode. Todo: set up tests properly and remove this hack
  if (ApplicationManager.getApplication().isUnitTestMode()) return GlobalSearchScope.projectScope(project);

  PsiFile psiFile = element.getContainingFile();
  VirtualFile virtualFile = VirtualFileUtil.getOriginalVirtualFile(psiFile);

  if (!SchemaFileIndexUtil.isSchemaSourceFile(project, virtualFile))
    return GlobalSearchScope.fileScope(psiFile);

  Module module = ModuleUtil.findModuleForPsiElement(element);

  if (module == null)
    return GlobalSearchScope.projectScope(project); // or file scope?

  ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();

  boolean inTestSourceContent = fileIndex.isInTestSourceContent(virtualFile);
  return module.getModuleWithDependenciesAndLibrariesScope(inTestSourceContent);
}
 
開發者ID:SumoLogic,項目名稱:epigraph,代碼行數:23,代碼來源:SchemaSearchScopeUtil.java

示例3: getReferenceType

import com.intellij.openapi.module.ModuleUtil; //導入方法依賴的package包/類
@Nullable
public PyType getReferenceType(@NotNull final PsiElement referenceTarget, TypeEvalContext context, @Nullable PsiElement anchor) {
  if (referenceTarget instanceof PsiClass) {
    return new PyJavaClassType((PsiClass) referenceTarget, true);
  }
  if (referenceTarget instanceof PsiPackage) {
    return new PyJavaPackageType((PsiPackage) referenceTarget, anchor == null ? null : ModuleUtil.findModuleForPsiElement(anchor));
  }
  if (referenceTarget instanceof PsiMethod) {
    PsiMethod method = (PsiMethod) referenceTarget;
    return new PyJavaMethodType(method);
  }
  if (referenceTarget instanceof PsiField) {
    return asPyType(((PsiField)referenceTarget).getType());
  }
  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:PyJavaTypeProvider.java

示例4: modify

import com.intellij.openapi.module.ModuleUtil; //導入方法依賴的package包/類
@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
  if (!ApplicationManager.getApplication().isInternal()) {
    return children;
  }

  if (parent instanceof PsiDirectoryNode) {
    PsiDirectory directory = ((PsiDirectoryNode)parent).getValue();
    if (!directory.getName().equals("res")) {
      return children;
    }
    Module module = ModuleUtil.findModuleForPsiElement(directory);
    AndroidFacet facet = AndroidFacet.getInstance(module);
    if (facet == null) {
      return children;
    }
    return mergeResourceDirectories(children, settings);
  }
  return children;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:ResourceMergerTreeStructureProvider.java

示例5: getStringTableXml

import com.intellij.openapi.module.ModuleUtil; //導入方法依賴的package包/類
@Nullable
public XmlFile getStringTableXml(@NotNull PsiElement elementFromModule) {
	Module module = ModuleUtil.findModuleForPsiElement(elementFromModule);
	if (module == null) {
		return null;
	}
	ArmaPluginModuleData data = moduleMap.computeIfAbsent(module, module1 -> {
		return new ArmaPluginModuleData(module);
	});
	XmlFile f = data.getStringTableXmlFile();
	if (f == null) {
		VirtualFile virtFile = ArmaPluginUtil.getStringTableXmlFile(module);
		if (virtFile == null) {
			return null;
		}
		XmlFile file = (XmlFile) PsiManager.getInstance(elementFromModule.getProject()).findFile(virtFile);
		data.setStringTableXmlFile(file);
		return file;
	} else {
		if (!f.getVirtualFile().exists()) {
			data.setStringTableXmlFile(null);
			return null;
		}
		return f;
	}
}
 
開發者ID:kayler-renslow,項目名稱:arma-intellij-plugin,代碼行數:27,代碼來源:ArmaPluginUserData.java

示例6: resolveLayoutResourceFile

import com.intellij.openapi.module.ModuleUtil; //導入方法依賴的package包/類
private static PsiFile resolveLayoutResourceFile(PsiElement element, Project project, String name) {
    // restricting the search to the current module - searching the whole project could return wrong layouts
    Module module = ModuleUtil.findModuleForPsiElement(element);
    PsiFile[] files = null;
    if (module != null) {
        GlobalSearchScope moduleScope = module.getModuleWithDependenciesAndLibrariesScope(false);
        files = FilenameIndex.getFilesByName(project, name, moduleScope);
    }
    if (files == null || files.length <= 0) {
        // fallback to search through the whole project
        // useful when the project is not properly configured - when the resource directory is not configured
        files = FilenameIndex.getFilesByName(project, name, new EverythingGlobalScope(project));
        if (files.length <= 0) {
            return null; //no matching files
        }
    }

    // TODO - we have a problem here - we still can have multiple layouts (some coming from a dependency)
    // we need to resolve R class properly and find the proper layout for the R class
    return files[0];
}
 
開發者ID:laobie,項目名稱:FindViewByMe,代碼行數:22,代碼來源:Utils.java

示例7: doFindFileModule

import com.intellij.openapi.module.ModuleUtil; //導入方法依賴的package包/類
@SuppressWarnings({"unchecked"})
@Nullable
private static <T extends OCamlStructuredBinding> T doFindFileModule(@NotNull final PsiFile sourceFile,
                                                                     @NotNull final String moduleName,
                                                                     @NotNull final FileType fileType,
                                                                     @NotNull final Class<T> type) {
    final Project project = sourceFile.getProject();

    final Module module = ModuleUtil.findModuleForPsiElement(sourceFile);
    if (module == null) return null;

    final String fileName = OCamlFileUtil.getFileName(moduleName, fileType);
    final GlobalSearchScope scope = getScopeRestrictedByFileTypes(moduleWithDependenciesAndLibrariesScope(module), fileType);
    final T file = findFileModuleByFileName(project, scope, type, fileName);
    return file == null ? findFileModuleByFileName(project, scope, type, OCamlStringUtil.changeFirstLetterCase(fileName)) : file;
}
 
開發者ID:traff,項目名稱:intellij-ocaml,代碼行數:17,代碼來源:OCamlResolvingUtil.java

示例8: getAllTypeAlias2

import com.intellij.openapi.module.ModuleUtil; //導入方法依賴的package包/類
/**
 * get all type alias in all iBATIS SQL Map files
 *
 * @param psiElement requested psi element
 * @return type alias map
 */
public Map<String, XmlTag> getAllTypeAlias2(PsiElement psiElement) {
    Map<String, XmlTag> typeAlias = new HashMap<String, XmlTag>();
    Module module = ModuleUtil.findModuleForPsiElement(psiElement);
    IbatisProjectComponent projectComponent = IbatisProjectComponent.getInstance(module.getProject());
    List<IbatisConfigurationModel> configurationModels = projectComponent.getConfigurationModelFactory().getAllModels(module);
    for (IbatisConfigurationModel configurationModel : configurationModels) {
        typeAlias.putAll(configurationModel.getTypeAlias2());
    }
    List<IbatisSqlMapModel> models = getAllSqlMapModel(psiElement);
    for (IbatisSqlMapModel model : models) {
        List<TypeAlias> typeAliases = model.getMergedModel().getTypeAlias();
        for (TypeAlias alias : typeAliases) {
            XmlTag xmlTag = alias.getXmlTag();
            if (xmlTag != null) {
                typeAlias.put(alias.getAlias().getValue(), xmlTag);
            }
        }
    }
    return typeAlias;
}
 
開發者ID:code4craft,項目名稱:ibatis-plugin,代碼行數:27,代碼來源:IbatisManagerImpl.java

示例9: createConfigurationByElement

import com.intellij.openapi.module.ModuleUtil; //導入方法依賴的package包/類
@Nullable
@Override
protected RunnerAndConfigurationSettings createConfigurationByElement(Location location, ConfigurationContext configurationContext) {
    sourceFile = location.getPsiElement().getContainingFile();
    if (sourceFile != null && sourceFile.getFileType().getName().toLowerCase().contains("javascript")) {
        Project project = sourceFile.getProject();

        VirtualFile file = sourceFile.getVirtualFile();

        RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(project, configurationContext);

        MongoRunConfiguration runConfiguration = (MongoRunConfiguration) settings.getConfiguration();
        runConfiguration.setName(file.getName());

        runConfiguration.setScriptPath(file.getPath());

        Module module = ModuleUtil.findModuleForPsiElement(location.getPsiElement());
        if (module != null) {
            runConfiguration.setModule(module);
        }

        return settings;
    }
    return null;
}
 
開發者ID:dboissier,項目名稱:nosql4idea,代碼行數:26,代碼來源:MongoScriptRunConfigurationProducer.java

示例10: visitMethodCallExpression

import com.intellij.openapi.module.ModuleUtil; //導入方法依賴的package包/類
@Override
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
  final Project project = expression.getProject();
  final Module module = ModuleUtil.findModuleForPsiElement(expression);
  if (module == null) {
    return;
  }
  final PsiClass newAssertClass = JavaPsiFacade.getInstance(project)
    .findClass("org.junit.Assert", GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module));
  if (newAssertClass == null) {
    return;
  }
  final PsiMethod psiMethod = expression.resolveMethod();
  if (psiMethod == null || !psiMethod.hasModifierProperty(PsiModifier.STATIC)) {
    return;
  }
  final PsiClass containingClass = psiMethod.getContainingClass();
  if (containingClass != null && Comparing.strEqual(containingClass.getQualifiedName(), "junit.framework.Assert")) {
    registerMethodCallError(expression);
  }
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:22,代碼來源:UseOfObsoleteAssertInspection.java

示例11: getAllTypeHandlers

import com.intellij.openapi.module.ModuleUtil; //導入方法依賴的package包/類
/**
 * get all type handler in iBATIS
 *
 * @return type handler map
 */
public Map<String, TypeHandler> getAllTypeHandlers(PsiElement psiElement) {
    Map<String, TypeHandler> typeHandlerMap = new HashMap<String, TypeHandler>();
    Module module = ModuleUtil.findModuleForPsiElement(psiElement);
    IbatisProjectComponent projectComponent = IbatisProjectComponent.getInstance(module.getProject());
    List<IbatisConfigurationModel> configurationModels = projectComponent.getConfigurationModelFactory().getAllModels(module);
    for (IbatisConfigurationModel configurationModel : configurationModels) {
        List<TypeHandler> typeHandlerList = configurationModel.getMergedModel().getTypeHandlers();
        for (TypeHandler typeHandler : typeHandlerList) {
            String javaType = typeHandler.getJavaType().getStringValue();
            if (StringUtil.isNotEmpty(javaType)) {
                typeHandlerMap.put(javaType, typeHandler);
            }
        }
    }
    return typeHandlerMap;
}
 
開發者ID:code4craft,項目名稱:ibatis-plugin,代碼行數:22,代碼來源:IbatisManagerImpl.java

示例12: suggestLastSelectedPropertiesFileUrl

import com.intellij.openapi.module.ModuleUtil; //導入方法依賴的package包/類
@Nullable
public String suggestLastSelectedPropertiesFileUrl(PsiFile context) {
  VirtualFile virtualFile = context.getVirtualFile();

  while (virtualFile != null) {
    String contextUrl = virtualFile.getUrl();
    String url = lastSelectedUrls.get(contextUrl);
    if (url != null) {
      return url;
    }
    virtualFile = virtualFile.getParent();
  }
  if (lastSelectedFileUrl != null) {
    VirtualFile lastFile = VirtualFileManager.getInstance().findFileByUrl(lastSelectedFileUrl);
    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(context.getProject()).getFileIndex();
    if (lastFile != null && ModuleUtil.findModuleForPsiElement(context) == fileIndex.getModuleForFile(lastFile)) {
      return lastSelectedFileUrl;
    }
  }
  return null;
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:22,代碼來源:LastSelectedPropertiesFileStore.java

示例13: getProximity

import com.intellij.openapi.module.ModuleUtil; //導入方法依賴的package包/類
@Nullable
public static WeighingComparable<PsiElement, ProximityLocation> getProximity(final Computable<PsiElement> elementComputable, final PsiElement context, ProcessingContext processingContext) {
  PsiElement element = elementComputable.compute();
  if (element == null) return null;
  if (element instanceof MetadataPsiElementBase) return null;
  if (context == null) return null;
  Module contextModule = processingContext.get(MODULE_BY_LOCATION);
  if (contextModule == null) {
    contextModule = ModuleUtil.findModuleForPsiElement(context);
    processingContext.put(MODULE_BY_LOCATION, contextModule);
  }

  if (contextModule == null) return null;

  return new WeighingComparable<PsiElement,ProximityLocation>(elementComputable,
                                                              new ProximityLocation(context, contextModule, processingContext),
                                                              PROXIMITY_WEIGHERS);
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:19,代碼來源:PsiProximityComparator.java

示例14: getAvailableNamespaces

import com.intellij.openapi.module.ModuleUtil; //導入方法依賴的package包/類
@Override
@NotNull
public Set<String> getAvailableNamespaces(@NotNull XmlFile file, @Nullable String tagName) {
    final Module module = ModuleUtil.findModuleForPsiElement(file);
    Map<String, XmlFile> schemas = getSchemas(module);
    Set<String> namespaces = new HashSet<>();

    try {
        for (XmlFile xsd : schemas.values()) {
            final XmlDocument document = xsd.getDocument();
            if (document != null) {
                final PsiMetaData metaData = document.getMetaData();
                if (metaData instanceof XmlNSDescriptorImpl) {
                    XmlNSDescriptorImpl descriptor = (XmlNSDescriptorImpl) metaData;
                    String defaultNamespace = descriptor.getDefaultNamespace();

                    //Stupid HTTP module XSD weirdo
                    if (xsd.getName().contains("mule-httpn"))
                        defaultNamespace = "http://www.mulesoft.org/schema/mule/http";
                    /////

                    if (StringUtils.isNotEmpty(defaultNamespace)) {
                        if (StringUtils.isNotEmpty(tagName)) {
                            XmlElementDescriptor elementDescriptor = descriptor.getElementDescriptor(tagName, defaultNamespace);
                            if (elementDescriptor != null) {
                                namespaces.add(defaultNamespace);
                            }
                        } else {
                            namespaces.add(defaultNamespace);
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        //e.printStackTrace();
    }
    return namespaces;
}
 
開發者ID:machaval,項目名稱:mule-intellij-plugins,代碼行數:40,代碼來源:MuleSchemaProvider.java

示例15: getAntObjects

import com.intellij.openapi.module.ModuleUtil; //導入方法依賴的package包/類
private static Map<String, Class> getAntObjects(final GroovyFile groovyFile) {
  final Project project = groovyFile.getProject();

  final Module module = ModuleUtil.findModuleForPsiElement(groovyFile);
  Set<VirtualFile> jars = new HashSet<VirtualFile>();
  if (module != null) {
    ContainerUtil.addAll(jars, OrderEnumerator.orderEntries(module).getAllLibrariesAndSdkClassesRoots());
  }

  if (groovyFile.isScript() && GroovyScriptUtil.getScriptType(groovyFile) instanceof GantScriptType) {
    jars.addAll(GantScriptType.additionalScopeFiles(groovyFile));
  }

  final ArrayList<URL> urls = new ArrayList<URL>();
  for (VirtualFile jar : jars) {
    VirtualFile localFile = PathUtil.getLocalFile(jar);
    if (localFile.getFileSystem() instanceof LocalFileSystem) {
      urls.add(VfsUtilCore.convertToURL(localFile.getUrl()));
    }
  }

  AntClassLoader loader;
  synchronized (ourLock) {
    final Map<List<URL>, AntClassLoader> map = CachedValuesManager.getManager(project).getParameterizedCachedValue(project, KEY,
                                                                                                                   PROVIDER, false, project);

    loader = map.get(urls);
    if (loader == null) {
      map.put(urls, loader = new AntClassLoader(urls));
    }
  }

  return loader.getAntObjects();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:35,代碼來源:AntTasksProvider.java


注:本文中的com.intellij.openapi.module.ModuleUtil.findModuleForPsiElement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。