本文整理汇总了Java中com.intellij.openapi.module.ModuleUtilCore类的典型用法代码示例。如果您正苦于以下问题:Java ModuleUtilCore类的具体用法?Java ModuleUtilCore怎么用?Java ModuleUtilCore使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ModuleUtilCore类属于com.intellij.openapi.module包,在下文中一共展示了ModuleUtilCore类的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: findUsages
import com.intellij.openapi.module.ModuleUtilCore; //导入依赖的package包/类
@Nullable
@Override
public List<UsageInfo> findUsages( PsiFile psiFile, PsiDirectory newParent, boolean searchInComments, boolean searchInNonJavaFiles )
{
Module mod = ModuleUtilCore.findModuleForPsiElement( psiFile );
ManModule module = ManProject.getModule( mod );
PsiClass psiClass = findPsiClass( psiFile );
if( psiClass == null )
{
return Collections.emptyList();
}
Query<PsiReference> search = ReferencesSearch.search( psiClass, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope( module.getIjModule() ) );
List<UsageInfo> usages = new ArrayList<>();
for( PsiReference ref: search.findAll() )
{
usages.add( new MoveRenameUsageInfo( ref.getElement(), ref, ref.getRangeInElement().getStartOffset(),
ref.getRangeInElement().getEndOffset(), psiClass,
ref.resolve() == null && !(ref instanceof PsiPolyVariantReference && ((PsiPolyVariantReference)ref).multiResolve( true ).length > 0) ) );
}
return usages;
}
示例3: findPsiClass
import com.intellij.openapi.module.ModuleUtilCore; //导入依赖的package包/类
@Nullable
private PsiClass findPsiClass( PsiFileSystemItem element )
{
Module mod = ModuleUtilCore.findModuleForPsiElement( element );
if( mod == null )
{
return null;
}
ManModule module = ManProject.getModule( mod );
String[] fqns = module.getTypesForFile( FileUtil.toIFile( module.getProject(), element.getVirtualFile() ) );
PsiClass psiClass = null;
for( String fqn: fqns )
{
psiClass = ManifoldPsiClassCache.instance().getPsiClass( GlobalSearchScope.moduleWithDependenciesAndLibrariesScope( module.getIjModule() ), module, fqn );
if( psiClass != null )
{
break;
}
}
return psiClass;
}
示例4: 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 );
}
示例5: findUsages
import com.intellij.openapi.module.ModuleUtilCore; //导入依赖的package包/类
private static List<UsageInfo> findUsages( PsiElement element, PsiElement ctx )
{
// Module mod = ModuleUtilCore.findModuleForPsiElement( element );
// if( mod == null )
// {
// return Collections.emptyList();
// }
Query<PsiReference> search = ReferencesSearch.search( element, GlobalSearchScope.moduleScope( ModuleUtilCore.findModuleForPsiElement( ctx ) ) );
List<UsageInfo> usages = new ArrayList<>();
for( PsiReference ref : search.findAll() )
{
MoveRenameUsageInfo usageInfo = new MoveRenameUsageInfo( ref.getElement(), ref, ref.getRangeInElement().getStartOffset(),
ref.getRangeInElement().getEndOffset(), element,
ref.resolve() == null && !(ref instanceof PsiPolyVariantReference && ((PsiPolyVariantReference)ref).multiResolve( true ).length > 0) );
usages.add( usageInfo );
}
return usages;
}
示例6: 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
示例7: getTarget
import com.intellij.openapi.module.ModuleUtilCore; //导入依赖的package包/类
/**
* Returns target proto PSI file root node.
*/
@Nullable
public ProtoPsiFileRoot getTarget() {
String filename = getFilename();
if (filename == null) {
return null;
}
Module module = ModuleUtilCore.findModuleForPsiElement(this);
if (module != null) {
return getTarget(filename, module);
}
// fallback: if we are inside of a dependency, current module is null
// in this case we try to resolve reference in all dependencies of all modules
// (might be not fully correct, but better than nothing)
ModuleManager moduleManager = ModuleManager.getInstance(getProject());
Module[] modules = moduleManager.getModules();
for (Module m : modules) {
ProtoPsiFileRoot target = getTarget(filename, m);
if (target != null) {
return target;
}
}
return null;
}
示例8: toString
import com.intellij.openapi.module.ModuleUtilCore; //导入依赖的package包/类
@Override
public String toString() {
if (myText == null) {
Module module = ModuleUtilCore.findModuleForPsiElement(myClass);
if (module != null) {
myText = module.getName();
}
else {
VirtualFile virtualFile = myClass.getContainingFile().getVirtualFile();
final ProjectFileIndex index = ProjectRootManager.getInstance(myClass.getProject()).getFileIndex();
VirtualFile root = index.getSourceRootForFile(virtualFile);
if (root == null) {
root = index.getClassRootForFile(virtualFile);
}
if (root != null) {
myText = root.getName();
}
else {
myText = virtualFile.getPath();
}
}
}
return myText;
}
示例9: getFileCache
import com.intellij.openapi.module.ModuleUtilCore; //导入依赖的package包/类
@NotNull
static CachedXmlDocumentSet getFileCache(@NotNull Module module) {
EclipseModuleManagerImpl moduleManager = EclipseModuleManagerImpl.getInstance(module);
CachedXmlDocumentSet fileCache = moduleManager != null ? moduleManager.getDocumentSet() : null;
if (fileCache == null) {
fileCache = new CachedXmlDocumentSet();
if (moduleManager != null) {
moduleManager.setDocumentSet(fileCache);
}
String storageRoot = ClasspathStorage.getStorageRootFromOptions(module);
fileCache.register(EclipseXml.CLASSPATH_FILE, storageRoot);
fileCache.register(EclipseXml.PROJECT_FILE, storageRoot);
fileCache.register(EclipseXml.PLUGIN_XML_FILE, storageRoot);
fileCache.register(module.getName() + EclipseXml.IDEA_SETTINGS_POSTFIX, ModuleUtilCore.getModuleDirPath(module));
}
return fileCache;
}
示例10: search
import com.intellij.openapi.module.ModuleUtilCore; //导入依赖的package包/类
public void search() {
myFiles.clear();
myJars.clear();
PsiManager psiManager = PsiManager.getInstance(myProject);
for (PsiFile file : search(myModule, myProject)) {
VirtualFile jar = JarFileSystem.getInstance().getVirtualFileForJar(file.getVirtualFile());
if (jar != null) {
myJars.putValue(jar, file);
}
else {
Module module = ModuleUtilCore.findModuleForPsiElement(file);
if (module != null) {
myFiles.putValue(module, file);
}
else {
VirtualFile virtualFile = file.getVirtualFile();
myVirtualFiles.putValue(virtualFile.getParent(), psiManager.findFile(virtualFile));
}
}
}
}
示例11: findModule
import com.intellij.openapi.module.ModuleUtilCore; //导入依赖的package包/类
public static Module findModule(final Module contextModule, final Set<String> patterns, final Project project, Condition<PsiClass> isTestMethod) {
final Set<Module> modules = new HashSet<Module>();
for (String className : patterns) {
final PsiClass psiClass = findMainClass(project,
className.contains(",") ? className.substring(0, className.indexOf(',')) : className,
GlobalSearchScope.allScope(project));
if (psiClass != null && isTestMethod.value(psiClass)) {
modules.add(ModuleUtilCore.findModuleForPsiElement(psiClass));
}
}
if (modules.size() == 1) {
final Module nextModule = modules.iterator().next();
if (nextModule != null) {
return nextModule;
}
}
if (contextModule != null && modules.size() > 1) {
final HashSet<Module> moduleDependencies = new HashSet<Module>();
ModuleUtilCore.getDependencies(contextModule, moduleDependencies);
if (moduleDependencies.containsAll(modules)) {
return contextModule;
}
}
return null;
}
示例12: isJarAttached
import com.intellij.openapi.module.ModuleUtilCore; //导入依赖的package包/类
public static boolean isJarAttached(@NotNull Location location,
final String fqn,
final PsiDirectory[] directories) {
final JavaPsiFacade facade = JavaPsiFacade.getInstance(location.getProject());
boolean testngJarFound = false;
final Module locationModule = location.getModule();
if (locationModule != null) {
testngJarFound = facade.findClass(fqn, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(locationModule, true)) != null;
}
else {
for (PsiDirectory directory : directories) {
final Module module = ModuleUtilCore.findModuleForFile(directory.getVirtualFile(), location.getProject());
if (module != null) {
if (facade.findClass(fqn, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, true)) != null) {
testngJarFound = true;
break;
}
}
}
}
return testngJarFound;
}
示例13: isClassInProductionSources
import com.intellij.openapi.module.ModuleUtilCore; //导入依赖的package包/类
@Nullable("null if class not found")
public static Boolean isClassInProductionSources(@NotNull String mainClassName, @NotNull Module module) {
final PsiClass psiClass = JavaExecutionUtil.findMainClass(module, mainClassName);
if (psiClass == null) {
return null;
}
final PsiFile psiFile = psiClass.getContainingFile();
if (psiFile == null) return null;
final VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile == null) return null;
Module classModule = psiClass.isValid() ? ModuleUtilCore.findModuleForPsiElement(psiClass) : null;
if (classModule == null) classModule = module;
ModuleFileIndex fileIndex = ModuleRootManager.getInstance(classModule).getFileIndex();
if (fileIndex.isInSourceContent(virtualFile)) {
return !fileIndex.isInTestSourceContent(virtualFile);
}
final List<OrderEntry> entriesForFile = fileIndex.getOrderEntriesForFile(virtualFile);
for (OrderEntry entry : entriesForFile) {
if (entry instanceof ExportableOrderEntry && ((ExportableOrderEntry)entry).getScope() == DependencyScope.TEST) {
return false;
}
}
return true;
}
示例14: generatePackageInfo
import com.intellij.openapi.module.ModuleUtilCore; //导入依赖的package包/类
private static void generatePackageInfo(StringBuilder buffer, @NotNull PsiClass aClass) {
PsiFile file = aClass.getContainingFile();
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(aClass.getProject()).getFileIndex();
VirtualFile vFile = file.getVirtualFile();
if (vFile != null && (fileIndex.isInLibrarySource(vFile) || fileIndex.isInLibraryClasses(vFile))) {
final List<OrderEntry> orderEntries = fileIndex.getOrderEntriesForFile(vFile);
if (orderEntries.size() > 0) {
final OrderEntry orderEntry = orderEntries.get(0);
buffer.append("[").append(StringUtil.escapeXml(orderEntry.getPresentableName())).append("] ");
}
}
else {
final Module module = ModuleUtilCore.findModuleForPsiElement(file);
if (module != null) {
buffer.append('[').append(module.getName()).append("] ");
}
}
if (file instanceof PsiJavaFile) {
String packageName = ((PsiJavaFile)file).getPackageName();
if (packageName.length() > 0) {
buffer.append(packageName);
newLine(buffer);
}
}
}
示例15: isAvailableForElement
import com.intellij.openapi.module.ModuleUtilCore; //导入依赖的package包/类
public static boolean isAvailableForElement(PsiElement element) {
if (Extensions.getExtensions(TestFramework.EXTENSION_NAME).length == 0) return false;
if (element == null) return false;
PsiClass psiClass = getContainingClass(element);
if (psiClass == null) return false;
Module srcModule = ModuleUtilCore.findModuleForPsiElement(psiClass);
if (srcModule == null) return false;
if (psiClass.isAnnotationType() ||
psiClass instanceof PsiAnonymousClass) {
return false;
}
return true;
}