本文整理匯總了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();
}