本文整理汇总了Java中com.intellij.psi.PsiDirectory类的典型用法代码示例。如果您正苦于以下问题:Java PsiDirectory类的具体用法?Java PsiDirectory怎么用?Java PsiDirectory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PsiDirectory类属于com.intellij.psi包,在下文中一共展示了PsiDirectory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: modifyChildNode
import com.intellij.psi.PsiDirectory; //导入依赖的package包/类
@Nullable
@Override
public AbstractTreeNode modifyChildNode(AbstractTreeNode childNode) {
Object value = childNode.getValue();
if (value instanceof PsiDirectory) {
PsiDirectory directory = (PsiDirectory)value;
Task task = myLesson.getTask(directory.getName());
if (task == null) {
return null;
}
VirtualFile srcDir = directory.getVirtualFile().findChild(EduNames.SRC);
if (srcDir != null) {
directory = PsiManager.getInstance(myProject).findDirectory(srcDir);
if (directory == null) {
return null;
}
}
return createChildDirectoryNode(task, directory);
}
return null;
}
示例2: canMove
import com.intellij.psi.PsiDirectory; //导入依赖的package包/类
@Override
public boolean canMove(DataContext dataContext) {
if (CommonDataKeys.PSI_FILE.getData(dataContext) != null) {
return false;
}
IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return false;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0 || directories.length > 1) {
return false;
}
final PsiDirectory sourceDirectory = directories[0];
return CCUtils.isLessonDir(sourceDirectory);
}
示例3: canMove
import com.intellij.psi.PsiDirectory; //导入依赖的package包/类
@Override
public boolean canMove(DataContext dataContext) {
if (CommonDataKeys.PSI_FILE.getData(dataContext) != null) {
return false;
}
IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return false;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0 || directories.length > 1) {
return false;
}
final PsiDirectory sourceDirectory = directories[0];
return isTaskDir(sourceDirectory);
}
示例4: isAvailable
import com.intellij.psi.PsiDirectory; //导入依赖的package包/类
@Override
protected boolean isAvailable(DataContext dataContext) {
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final Module module = LangDataKeys.MODULE.getData(dataContext);
final ModuleType moduleType = module == null ? null : ModuleType.get(module);
final boolean isGravModule = moduleType instanceof GravModuleType || moduleType instanceof WebModuleTypeBase;
final boolean pluginEnabled = GravProjectComponent.isEnabled(project);
if (!pluginEnabled) return false;
if (dataContext.getData(PlatformDataKeys.NAVIGATABLE) instanceof PsiDirectory) {
PsiDirectory psiDirectory = (PsiDirectory) dataContext.getData(PlatformDataKeys.NAVIGATABLE);
String themeFolder = psiDirectory.getParent().getVirtualFile().getName();
themeName = psiDirectory.getName();
GravFileTypes.setModuleName(themeName);
boolean isThemeFolder = themeFolder.equalsIgnoreCase("themes");
return super.isAvailable(dataContext) && isGravModule && isThemeFolder;
} else {
return false;
}
}
示例5: resolve
import com.intellij.psi.PsiDirectory; //导入依赖的package包/类
@Nullable
@Override
public PsiElement resolve() {
PsiElement possibleArrayCreation = myElement.getParent().getParent().getParent();
if (possibleArrayCreation instanceof ArrayCreationExpression) {
ArrayCreationExpression arrayCreation = (ArrayCreationExpression)possibleArrayCreation;
PsiDirectory dir = myElement.getContainingFile().getContainingDirectory();
PhpClass phpClass = ObjectFactoryUtils.findClassByArrayCreation(arrayCreation, dir);
if (phpClass != null) {
PsiElement field = ClassUtils.findWritableField(phpClass, myElement.getText());
return field;
}
}
return null;
}
示例6: actionPerformed
import com.intellij.psi.PsiDirectory; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
final Project project = e.getProject();
if (view == null || project == null) {
return;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0 || directories.length > 1) {
return;
}
final PsiDirectory directory = directories[0];
if (directory == null) return;
final Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return;
}
createItem(view, project, directory, course);
}
示例7: PhpNewClassDialog
import com.intellij.psi.PsiDirectory; //导入依赖的package包/类
public PhpNewClassDialog(@NotNull Project project, @Nullable PsiDirectory directory) {
super(project);
this.myAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
Disposer.register(this.getDisposable(), new Disposable() {
public void dispose() {
PhpNewClassDialog.this.myAlarm.cancelAllRequests();
PhpNewClassDialog.this.myDisposed = true;
}
});
this.myProperties = new Properties();
this.myProject = project;
this.myDirectory = directory;
init();
}
示例8: modify
import com.intellij.psi.PsiDirectory; //导入依赖的package包/类
@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
ArrayList<AbstractTreeNode> nodes = new ArrayList<AbstractTreeNode>();
if (isLanguageFolder(parent)) {
if (children.size() > 0 && parent.getValue() instanceof PsiDirectory) {
Collection<PsiFileNode> childrenPsi2 = new ArrayList<>();
for (AbstractTreeNode eachChild : children) {
if (!(eachChild.getValue() instanceof PsiFile)) continue;
PsiFile psiFile = (PsiFile) eachChild.getValue();
LanguageNodeFile nodeFile = new LanguageNodeFile(parent.getProject(), psiFile, settings);
childrenPsi2.add(nodeFile);
}
LanguageNestingNode languageFormNode = new LanguageNestingNode(childrenPsi2.iterator().next(), childrenPsi2);
nodes.add(languageFormNode);
}
} else {
nodes.addAll(children);
}
return nodes;
}
示例9: getExtensionDirectory
import com.intellij.psi.PsiDirectory; //导入依赖的package包/类
public static PsiDirectory getExtensionDirectory(@NotNull AnActionEvent event) {
Project project = event.getData(PlatformDataKeys.PROJECT);
if (project == null) {
return null;
}
DataContext dataContext = event.getDataContext();
IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return null;
}
PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0) {
return null;
}
return FilesystemUtil.findParentExtensionDirectory(directories[0]);
}
示例10: actionPerformed
import com.intellij.psi.PsiDirectory; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent event) {
// TODO: insert action logic here
Project project = event.getData(PlatformDataKeys.PROJECT);
Object nav = event.getData(CommonDataKeys.NAVIGATABLE);
String path;
try {
if (nav instanceof PsiDirectory) {
PsiDirectory directory = (PsiDirectory) nav;
path = directory.getVirtualFile().getPath();
} else {
PsiFile file = (PsiFile) nav;
path = file.getVirtualFile().getPath();
}
Toast.make(project, MessageType.INFO, "Open: " + path);
Runtime.getRuntime().exec("cmd /c start " + path);
} catch (Exception e) {
e.printStackTrace();
if (nav instanceof PsiClass) {
Toast.make(project, MessageType.ERROR, "Could not open the java file, double-click to open.");
return;
}
Toast.make(project, MessageType.ERROR, e.getMessage());
}
}
示例11: findResourcesDirectory
import com.intellij.psi.PsiDirectory; //导入依赖的package包/类
/**
* 根据选择的package目录,找到resources目录
* @param psiDirectory
* @return
*/
private PsiDirectory findResourcesDirectory(PsiDirectory psiDirectory) {
PsiDirectory parentDirectory = psiDirectory.getParentDirectory();
PsiDirectory iterator = psiDirectory.getParentDirectory();
while (iterator != null && !iterator.getName().equals("main")) {
iterator = iterator.getParentDirectory();
}
PsiDirectory resourcesDirectory = iterator == null ? null : iterator.findSubdirectory("resources");
if (resourcesDirectory == null) {
resourcesDirectory = parentDirectory.findSubdirectory("resources");
if (resourcesDirectory == null) {
resourcesDirectory = parentDirectory.createSubdirectory("resources");
}
}
return resourcesDirectory;
}
示例12: findUsages
import com.intellij.psi.PsiDirectory; //导入依赖的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;
}
示例13: processPackageDirectories
import com.intellij.psi.PsiDirectory; //导入依赖的package包/类
@Override
public boolean processPackageDirectories(@NotNull PsiPackage psiPackage,
@NotNull final GlobalSearchScope scope,
@NotNull final Processor<PsiDirectory> consumer,
boolean includeLibrarySources) {
//System.out.println( "processDirectories() : " + psiPackage + " : " + scope );
final PsiManager psiManager = PsiManager.getInstance( _project );
return PackageIndex.getInstance( _project )
.getDirsByPackageName(psiPackage.getQualifiedName(), includeLibrarySources)
.forEach(new ReadActionProcessor<VirtualFile>() {
@Override
public boolean processInReadAction(final VirtualFile dir) {
if (!scope.contains(dir)) return true;
PsiDirectory psiDir = psiManager.findDirectory(dir);
return psiDir == null || consumer.process(psiDir);
}
});
}
示例14: getMagentoName
import com.intellij.psi.PsiDirectory; //导入依赖的package包/类
@Override
public String getMagentoName() {
if (moduleName != null) {
return moduleName;
}
PsiDirectory configurationDir = directory.findSubdirectory(CONFIGURATION_PATH);
if (configurationDir != null) {
PsiFile configurationFile = configurationDir.findFile("module.xml");
if (configurationFile != null && configurationFile instanceof XmlFile) {
XmlTag rootTag = ((XmlFile) configurationFile).getRootTag();
if (rootTag != null) {
XmlTag module = rootTag.findFirstSubTag("module");
if (module != null && module.getAttributeValue("name") != null) {
moduleName = module.getAttributeValue("name");
return moduleName;
}
}
}
}
return DEFAULT_MODULE_NAME;
}
示例15: isAvailable
import com.intellij.psi.PsiDirectory; //导入依赖的package包/类
@CheckReturnValue
@VisibleForTesting
@SuppressWarnings("WeakerAccess")
static boolean isAvailable(@Nonnull AnActionEvent event) {
final Project project = event.getProject();
if (project == null) {
return false;
}
final IdeView view = event.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
return false;
}
final ProjectRootManager rootManager = ProjectRootManager.getInstance(project);
final ProjectFileIndex fileIndex = rootManager.getFileIndex();
final Optional<PsiDirectory> sourceDirectory = Stream.of(view.getDirectories())
.filter(directory -> {
final VirtualFile virtualFile = directory.getVirtualFile();
return fileIndex.isUnderSourceRootOfType(virtualFile, JavaModuleSourceRootTypes.SOURCES);
})
.findFirst();
return sourceDirectory.isPresent();
}