本文整理汇总了Java中com.intellij.openapi.module.ModuleUtilCore.findModuleForFile方法的典型用法代码示例。如果您正苦于以下问题:Java ModuleUtilCore.findModuleForFile方法的具体用法?Java ModuleUtilCore.findModuleForFile怎么用?Java ModuleUtilCore.findModuleForFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.module.ModuleUtilCore
的用法示例。
在下文中一共展示了ModuleUtilCore.findModuleForFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isCustomExtensionFile
import com.intellij.openapi.module.ModuleUtilCore; //导入方法依赖的package包/类
public static boolean isCustomExtensionFile(@NotNull final VirtualFile file, @NotNull final Project project) {
final Module module = ModuleUtilCore.findModuleForFile(file, project);
if (null == module) {
return false;
}
final String descriptorTypeName = module.getOptionValue(HybrisConstants.DESCRIPTOR_TYPE);
if (descriptorTypeName == null) {
if (shouldCheckFilesWithoutHybrisSettings(project)) {
return estimateIsCustomExtension(file);
}
return false;
}
final HybrisModuleDescriptorType descriptorType = HybrisModuleDescriptorType.valueOf(descriptorTypeName);
return descriptorType == HybrisModuleDescriptorType.CUSTOM;
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:19,代码来源:TypeSystemValidationUtils.java
示例2: initialize
import com.intellij.openapi.module.ModuleUtilCore; //导入方法依赖的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 );
}
示例3: determineModuleBySyncActionObject
import com.intellij.openapi.module.ModuleUtilCore; //导入方法依赖的package包/类
@NotNull
private List<Module> determineModuleBySyncActionObject(Object o) {
if (o instanceof Module) {
return Collections.singletonList((Module)o);
}
if (o instanceof Project) {
return Arrays.asList(ModuleManager.getInstance((Project)o).getModules());
}
if (o instanceof VirtualFile) {
final VirtualFile file = (VirtualFile)o;
if (file.isValid()) {
final Module module = ModuleUtilCore.findModuleForFile(file, myProject);
if (module == null) {
return Collections.emptyList();
}
return Collections.singletonList(module);
}
}
return Collections.emptyList();
}
示例4: isImportedGradleProjectRoot
import com.intellij.openapi.module.ModuleUtilCore; //导入方法依赖的package包/类
private static boolean isImportedGradleProjectRoot(VirtualFile file, Project myProject) {
VirtualFile parent = file.getParent();
if (parent.equals(myProject.getBaseDir())) {
return true;
}
Module module = ModuleUtilCore.findModuleForFile(file, myProject);
if (module != null) {
AndroidGradleFacet facet = AndroidGradleFacet.getInstance(module);
if (facet != null) {
IdeaGradleProject gradleProject = facet.getGradleProject();
if (gradleProject != null) {
VirtualFile buildFile = gradleProject.getBuildFile();
if (buildFile != null && file.getParent().equals(parent)) {
return true;
}
}
}
}
return false;
}
示例5: getQuickNavigateInfo
import com.intellij.openapi.module.ModuleUtilCore; //导入方法依赖的package包/类
@Override
public String getQuickNavigateInfo(PsiElement element, PsiElement originalElement) {
ExtensionPoint extensionPoint = findExtensionPoint(element);
if (extensionPoint == null) return null;
final XmlFile epDeclarationFile = (XmlFile)extensionPoint.getXmlTag().getContainingFile();
final Module epModule = ModuleUtilCore.findModuleForFile(epDeclarationFile.getVirtualFile(), element.getProject());
final String epPrefix = extensionPoint.getNamePrefix();
final PsiClass epClass = getExtensionPointClass(extensionPoint);
StringBuilder epClassText = new StringBuilder();
if (epClass != null) {
JavaDocInfoGenerator.generateType(epClassText, PsiTypesUtil.getClassType(epClass), epClass, true);
}
else {
epClassText.append("<unknown>");
}
return (epModule == null ? "" : "[" + epModule.getName() + "]") +
(epPrefix == null ? "" : " " + epPrefix) +
"<br/>" +
"<b>" + extensionPoint.getEffectiveName() + "</b>" +
" (" + epDeclarationFile.getName() + ")<br/>" +
epClassText.toString();
}
示例6: getPresentableRelativePath
import com.intellij.openapi.module.ModuleUtilCore; //导入方法依赖的package包/类
@Override
public String getPresentableRelativePath(@NotNull final ContentRevision fromRevision, @NotNull final ContentRevision toRevision) {
// need to use parent path because the old file is already not there
FilePath fromPath = fromRevision.getFile();
FilePath toPath = toRevision.getFile();
if ((fromPath.getParentPath() == null) || (toPath.getParentPath() == null)) {
return null;
}
final VirtualFile oldFile = fromPath.getParentPath().getVirtualFile();
final VirtualFile newFile = toPath.getParentPath().getVirtualFile();
if (oldFile != null && newFile != null) {
Module oldModule = ModuleUtilCore.findModuleForFile(oldFile, myProject);
Module newModule = ModuleUtilCore.findModuleForFile(newFile, myProject);
if (oldModule != newModule) {
return getPresentableRelativePathFor(oldFile);
}
}
final RelativePathCalculator calculator =
new RelativePathCalculator(toPath.getIOFile().getAbsolutePath(), fromPath.getIOFile().getAbsolutePath());
calculator.execute();
final String result = calculator.getResult();
return (result == null) ? null : result.replace("/", File.separator);
}
示例7: setupConfigurationFromContext
import com.intellij.openapi.module.ModuleUtilCore; //导入方法依赖的package包/类
@Override
protected boolean setupConfigurationFromContext(JUnitConfiguration configuration,
ConfigurationContext context,
Ref<PsiElement> sourceElement) {
final Project project = configuration.getProject();
final PsiElement element = context.getPsiLocation();
if (!(element instanceof PsiDirectory)) return false;
final PsiPackage aPackage = JavaRuntimeConfigurationProducerBase.checkPackage(element);
if (aPackage == null) return false;
final VirtualFile virtualFile = ((PsiDirectory)element).getVirtualFile();
final Module module = ModuleUtilCore.findModuleForFile(virtualFile, project);
if (module == null) return false;
if (!ModuleRootManager.getInstance(module).getFileIndex().isInTestSourceContent(virtualFile)) return false;
int testRootCount = ModuleRootManager.getInstance(module).getSourceRoots(JavaSourceRootType.TEST_SOURCE).size();
if (testRootCount < 2) return false;
if (!LocationUtil.isJarAttached(context.getLocation(), aPackage, JUnitUtil.TESTCASE_CLASS)) return false;
setupConfigurationModule(context, configuration);
final JUnitConfiguration.Data data = configuration.getPersistentData();
data.setDirName(virtualFile.getPath());
data.TEST_OBJECT = JUnitConfiguration.TEST_DIRECTORY;
configuration.setGeneratedName();
return true;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:AbstractAllInDirectoryConfigurationProducer.java
示例8: collapse2eclipseRelative2OtherModule
import com.intellij.openapi.module.ModuleUtilCore; //导入方法依赖的package包/类
@Nullable
public static String collapse2eclipseRelative2OtherModule(final @NotNull Project project, final @NotNull VirtualFile file) {
final Module module = ModuleUtilCore.findModuleForFile(file, project);
if (module != null) {
return collapse2eclipsePathRelative2Module(file, module);
} else { //should check all modules then
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
if (fileIndex.isExcluded(file) || fileIndex.isInLibraryClasses(file)) {
for (Module aModule : ModuleManager.getInstance(project).getModules()) {
final String path = collapse2eclipsePathRelative2Module(file, aModule);
if (path != null) {
return path;
}
}
}
}
return null;
}
示例9: BPMNFileEditor
import com.intellij.openapi.module.ModuleUtilCore; //导入方法依赖的package包/类
public BPMNFileEditor(@NotNull final Project project, @NotNull final VirtualFile file) {
final VirtualFile vf = file instanceof LightVirtualFile ? ((LightVirtualFile) file).getOriginalFile() : file;
final Module module = ModuleUtilCore.findModuleForFile(vf, project);
if (module == null) {
throw new IllegalArgumentException("No module for file " + file + " in project " + project);
}
this.myFile = file;
this.myDocument = FileDocumentManager.getInstance().getDocument(file);
this.myProject = project;
this.editor = new BPMNEditorDiagramTab(this, project, module, file);
}
示例10: getModel
import com.intellij.openapi.module.ModuleUtilCore; //导入方法依赖的package包/类
@Nullable
private static ModifiableRootModel getModel(@NotNull VirtualFile dir, @NotNull Project project) {
final Module module = ModuleUtilCore.findModuleForFile(dir, project);
if (module == null) {
LOG.info("Module for " + dir.getPath() + " was not found");
return null;
}
return ModuleRootManager.getInstance(module).getModifiableModel();
}
示例11: getModuleBase
import com.intellij.openapi.module.ModuleUtilCore; //导入方法依赖的package包/类
public static PsiDirectory getModuleBase(Project project, VirtualFile vf) {
Module module = ModuleUtilCore.findModuleForFile(vf, project);
ModuleFileIndex fileIndex = ModuleRootManager.getInstance(module).getFileIndex();
PsiDirectory baseDir = PsiDirectoryFactory.getInstance(project).createDirectory(project.getBaseDir());
PsiDirectory moduleDir = baseDir.findSubdirectory(module.getName());
if (moduleDir == null) {
return baseDir;
}
return moduleDir;
}
示例12: toMuleBreakpoint
import com.intellij.openapi.module.ModuleUtilCore; //导入方法依赖的package包/类
@NotNull
public static Breakpoint toMuleBreakpoint(Project project, @NotNull XSourcePosition sourcePosition, XExpression conditionExpression, @Nullable Map<String, String> modulesToAppsMap) {
VirtualFile file = sourcePosition.getFile();
Module module = ModuleUtilCore.findModuleForFile(file, project);
String deployableName = module.getName();
if (modulesToAppsMap != null && !StringUtils.isEmpty(modulesToAppsMap.get(deployableName)))
deployableName = modulesToAppsMap.get(deployableName);
final String conditionScript = conditionExpression != null ? asMelScript(conditionExpression.getExpression()) : null;
final XmlTag tag = getXmlTagAt(module.getProject(), sourcePosition);
if (tag != null) {
//TODO - Module name is an app name - but can I get it from Maven? Or override it by using the additional param?
return new Breakpoint(getMulePath(tag), conditionScript, deployableName);
} else {
final int line = sourcePosition.getLine();
final Document document = FileDocumentManager.getInstance().getDocument(sourcePosition.getFile());
final PsiElement xmlElement = WeavePsiUtils.getFirstWeaveElement(module.getProject(), document, line);
if (xmlElement != null) {
PsiLanguageInjectionHost parent = PsiTreeUtil.getParentOfType(xmlElement, PsiLanguageInjectionHost.class);
if (parent != null) {
final XmlTag weavePart = PsiTreeUtil.getParentOfType(xmlElement, XmlTag.class);
final XmlTag weaveTag = PsiTreeUtil.getParentOfType(weavePart, XmlTag.class);
int lineNumber = line + 1 - XSourcePositionImpl.createByElement(xmlElement).getLine();
final String mulePath = getMulePath(weaveTag);
//TODO - Module name is an app name - but can I get it from Maven? Or override it by using the additional param?
return new Breakpoint(mulePath, getPrefix(weavePart) + "/" + (lineNumber + 1), conditionScript, deployableName);
}
}
}
return new Breakpoint("", conditionScript, deployableName);
}
示例13: createNotificationPanel
import com.intellij.openapi.module.ModuleUtilCore; //导入方法依赖的package包/类
@Nullable
@Override
public ResourceQualifierSwitcherPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
if (!ApplicationManager.getApplication().isInternal()) {
return null;
}
if (file.getFileType() != XmlFileType.INSTANCE) {
return null;
}
VirtualFile parent = file.getParent();
if (parent == null) {
return null;
}
parent = parent.getParent();
if (parent == null || !parent.getName().equals("res")) {
return null;
}
Module module = ModuleUtilCore.findModuleForFile(file, myProject);
AndroidFacet facet = module == null ? null : AndroidFacet.getInstance(module);
if (facet == null) {
return null;
}
BidirectionalMap<String, VirtualFile> qualifiers = collectQualifiers(parent, file);
if (qualifiers.size() <= 1) {
return null;
}
return new ResourceQualifierSwitcherPanel(myProject, file, qualifiers);
}
示例14: findModuleForLintProject
import com.intellij.openapi.module.ModuleUtilCore; //导入方法依赖的package包/类
@Nullable
protected Module findModuleForLintProject(@NotNull Project project,
@NotNull com.android.tools.lint.detector.api.Project lintProject) {
if (myModuleMap != null) {
Module module = myModuleMap.get(lintProject);
if (module != null) {
return module;
}
}
final File dir = lintProject.getDir();
final VirtualFile vDir = LocalFileSystem.getInstance().findFileByIoFile(dir);
return vDir != null ? ModuleUtilCore.findModuleForFile(vDir, project) : null;
}
示例15: isAvailable
import com.intellij.openapi.module.ModuleUtilCore; //导入方法依赖的package包/类
@Override
public boolean isAvailable(@NotNull final Project project, final Editor editor, final PsiFile file) {
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) return false;
final Module module = ModuleUtilCore.findModuleForFile(virtualFile, project);
if (module == null) return false;
return JavaSdkUtil.isLanguageLevelAcceptable(project, module, myLevel);
}