本文整理匯總了Java中com.intellij.openapi.module.ModuleUtil類的典型用法代碼示例。如果您正苦於以下問題:Java ModuleUtil類的具體用法?Java ModuleUtil怎麽用?Java ModuleUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ModuleUtil類屬於com.intellij.openapi.module包,在下文中一共展示了ModuleUtil類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initialize
import com.intellij.openapi.module.ModuleUtil; //導入依賴的package包/類
public void initialize( PsiClass delegate, List<IFile> files, String fqn, DiagnosticCollector issues )
{
_ifiles = files;
_fqn = fqn;
_issues = issues;
PsiManager manager = PsiManagerImpl.getInstance( delegate.getProject() );
_files = new ArrayList<>( _ifiles.size() );
for( IFile ifile : _ifiles )
{
VirtualFile vfile = ((IjFile)ifile).getVirtualFile();
if( vfile != null )
{
PsiFile file = manager.findFile( vfile );
_files.add( file );
Module module = ModuleUtilCore.findModuleForFile( vfile, delegate.getProject() );
if( module != null )
{
file.putUserData( ModuleUtil.KEY_MODULE, module );
}
}
}
delegate.getContainingFile().putUserData( KEY_MANIFOLD_PSI_CLASS, this );
}
示例2: addExtensions
import com.intellij.openapi.module.ModuleUtil; //導入依賴的package包/類
private PsiClass addExtensions( GlobalSearchScope scope, ManModule module, String fqn, PsiClass psiClass )
{
if( isExtended( module, fqn ) )
{
// Find the class excluding our ManTypeFinder to avoid circularity
psiClass = psiClass != null ? psiClass : JavaPsiFacade.getInstance( module.getIjProject() ).findClass( fqn, scope );
if( psiClass != null )
{
psiClass = new ManifoldExtendedPsiClass( module.getIjModule(), psiClass );
psiClass.putUserData( ModuleUtil.KEY_MODULE, module.getIjModule() );
FqnCache<PsiClass> map = _type2Class.computeIfAbsent( module, k -> new FqnCache<>() );
map.add( fqn, psiClass );
}
}
return psiClass;
}
示例3: 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;
}
示例4: getLocations
import com.intellij.openapi.module.ModuleUtil; //導入依賴的package包/類
@Override
public Set<String> getLocations(@NotNull @NonNls final String namespace, @NotNull final XmlFile context) throws ProcessCanceledException {
Set<String> locations = new HashSet<>();
final Module module = ModuleUtil.findModuleForPsiElement(context);
if (module == null) {
return null;
}
try {
final Map<String, XmlFile> schemas = getSchemas(module);
for (Map.Entry<String, XmlFile> entry : schemas.entrySet()) {
final String s = getNamespace(entry.getValue(), context.getProject());
if (s != null && s.equals(namespace)) {
if (!entry.getKey().contains("mule-httpn.xsd"))
locations.add(entry.getKey()); //Observe the formatting rules
}
}
} catch (Exception e) {
e.printStackTrace();
}
return locations;
}
示例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;
}
}
示例6: fillCompletionVariants
import com.intellij.openapi.module.ModuleUtil; //導入依賴的package包/類
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull final CompletionResultSet resultSet) {
if (parameters.getOriginalFile().getUserData(ClassNameReferenceEditor.CLASS_NAME_REFERENCE_FRAGMENT) == null) {
return;
}
resultSet.runRemainingContributors(parameters, new Consumer<CompletionResult>() {
@Override
public void consume(CompletionResult result) {
LookupElement element = result.getLookupElement();
Object object = element.getObject();
if (object instanceof PsiClass) {
Module module = ModuleUtil.findModuleForPsiElement((PsiClass)object);
if (module != null) {
resultSet.consume(LookupElementDecorator.withRenderer(element, new AppendModuleName(module)));
return;
}
}
resultSet.passResult(result);
}
});
}
示例7: testBug
import com.intellij.openapi.module.ModuleUtil; //導入依賴的package包/類
public void testBug() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
PsiClass psiClass = myJavaFacade.findClass("p.A");
assertEquals("p.A", psiClass.getQualifiedName());
final PsiFile psiFile = myPsiManager.findFile(myPackDir.findChild("A.java"));
psiFile.getChildren();
assertEquals(psiFile, psiClass.getContainingFile());
VirtualFile file = psiFile.getVirtualFile();
assertEquals(myModule, ModuleUtil.findModuleForFile(file, myProject));
Module anotherModule = createModule("another");
myFilesToDelete.add(new File(anotherModule.getModuleFilePath()));
PsiTestUtil.addSourceRoot(anotherModule, mySrcDir1);
assertEquals(anotherModule, ModuleUtil.findModuleForFile(file, myProject));
}
});
}
示例8: findModule
import com.intellij.openapi.module.ModuleUtil; //導入依賴的package包/類
@Nullable
private Module findModule(List<OrderRoot> roots) {
for (OrderRoot root : roots) {
Module module = null;
final VirtualFile local = JarFileSystem.getInstance().getVirtualFileForJar(root.getFile());
if (local != null) {
module = ModuleUtil.findModuleForFile(local, myProject);
}
if (module == null) {
module = ModuleUtil.findModuleForFile(root.getFile(), myProject);
}
if (module != null) {
return module;
}
}
return null;
}
示例9: findLogicalRoot
import com.intellij.openapi.module.ModuleUtil; //導入依賴的package包/類
@Override
@Nullable
public LogicalRoot findLogicalRoot(@NotNull final VirtualFile file) {
final Module module = ModuleUtil.findModuleForFile(file, myProject);
if (module == null) return null;
LogicalRoot result = null;
final List<LogicalRoot> list = getLogicalRoots(module);
for (final LogicalRoot root : list) {
final VirtualFile rootFile = root.getVirtualFile();
if (rootFile != null && VfsUtil.isAncestor(rootFile, file, false)) {
result = root;
break;
}
}
return result;
}
示例10: navigate
import com.intellij.openapi.module.ModuleUtil; //導入依賴的package包/類
@Override
public void navigate(final boolean requestFocus) {
Module module = ModuleUtil.findModuleForPsiElement(getValue());
if (module != null) {
final VirtualFile file = getVirtualFile();
final Project project = getProject();
ProjectSettingsService service = ProjectSettingsService.getInstance(myProject);
if (ProjectRootsUtil.isModuleContentRoot(file, project)) {
service.openModuleSettings(module);
}
else if (ProjectRootsUtil.isLibraryRoot(file, project)) {
final OrderEntry orderEntry = LibraryUtil.findLibraryEntry(file, module.getProject());
if (orderEntry != null) {
service.openLibraryOrSdkSettings(orderEntry);
}
}
else {
service.openContentEntriesSettings(module);
}
}
}
示例11: 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;
}
示例12: value
import com.intellij.openapi.module.ModuleUtil; //導入依賴的package包/類
@Override
public boolean value(VirtualFile file) {
if (file.getFileType() != StdFileTypes.XML) {
return false;
}
if (SdkConstants.FN_ANDROID_MANIFEST_XML.equals(file.getName())) {
Module module = ModuleUtil.findModuleForFile(file, myProject);
return module != null && AndroidFacet.getInstance(module) != null;
}
VirtualFile parent = file.getParent();
if (parent == null) return false;
parent = parent.getParent();
if (parent == null) return false;
return AndroidResourceUtil.isLocalResourceDirectory(parent, myProject);
}
示例13: 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;
}
示例14: 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);
}
示例15: getModule
import com.intellij.openapi.module.ModuleUtil; //導入依賴的package包/類
/**
* Gets the {@link Module} for a given {@link VirtualFile}.
*
* @param file The file to find.
* @return The {@link Module} of the file.
*/
@Nullable
private Module getModule(final VirtualFile file) {
final Set<Module> candidates = new HashSet<>();
for (final Project project : ProjectManager.getInstance().getOpenProjects()) {
@Nullable final Module module = ModuleUtil.findModuleForFile(file, project);
if (module != null)
candidates.add(module);
}
if (candidates.size() > 1) {
this.logger.error(
"File {} found in multiple modules. Picking a random one. These modules: {}",
file,
candidates
);
}
if (!candidates.isEmpty()) {
return candidates.iterator().next();
}
return null;
}