Java Code Examples for com.intellij.psi.PsiDirectory#getName()
The following examples show how to use
com.intellij.psi.PsiDirectory#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExtraModulesUtil.java From weex-language-support with MIT License | 6 votes |
public static String getModuleName(PsiDirectory dir) { PsiFile pkg = dir.findFile("package.json"); String name = dir.getName(); if (pkg != null && pkg instanceof JsonFile) { if (((JsonFile) pkg).getTopLevelValue() instanceof JsonObject) { JsonObject object = (JsonObject) ((JsonFile) pkg).getTopLevelValue(); if (object != null) { JsonProperty property = object.findProperty("name"); JsonProperty property1 = object.findProperty("version"); if (property != null && property.getValue() != null && property.getValue() instanceof JsonStringLiteral) { JsonStringLiteral propValue = (JsonStringLiteral) property.getValue(); name = propValue.getValue(); if (property1 != null && property1.getValue() != null && property1.getValue() instanceof JsonStringLiteral) { JsonStringLiteral propValue1 = (JsonStringLiteral) property1.getValue(); name = name + ":" + propValue1.getValue(); } } } } } return name; }
Example 2
Source File: BlazeResourcesDomFileDescription.java From intellij with Apache License 2.0 | 6 votes |
/** Only check that the file is under res/values or res/values-*. */ private static boolean isBlazeResourcesFile(PsiFile file) { if (!Blaze.isBlazeProject(file.getProject())) { return false; } file = file.getOriginalFile(); PsiDirectory parent = file.getContainingDirectory(); if (parent == null) { return false; } String parentName = parent.getName(); if (!parentName.equals(FD_RES_VALUES) && !parentName.startsWith(FD_RES_VALUES + '-')) { return false; } PsiDirectory grandParent = parent.getParentDirectory(); return grandParent != null && grandParent.getName().equals(FD_RES); }
Example 3
Source File: EntityBase.java From CleanArchitecturePlugin with Apache License 2.0 | 5 votes |
/** * Method that return the complete package name for a component in clean architecture * * @param directory directory to find the parents * @return example: com.digio.project.entityName.view.activity */ public static String getPackageNameProject(PsiDirectory directory) { PsiDirectory directoryIterator = directory; String packageName = directory.getName(); while (!directoryIterator.getName().equals("com")) { directoryIterator = directoryIterator.getParentDirectory(); packageName = directoryIterator.getName() + "." + packageName; } return packageName; }
Example 4
Source File: BlazeGoPackage.java From intellij with Apache License 2.0 | 5 votes |
@VisibleForTesting static PsiElement[] getImportReferences(Label label, PsiElement buildElement, String importPath) { List<String> pathComponents = Splitter.on('/').splitToList(importPath); PsiElement[] importReferences = new PsiElement[pathComponents.size()]; if (pathComponents.isEmpty()) { return importReferences; } PsiElement lastElement = getLastElement(Iterables.getLast(pathComponents), label, buildElement); if (lastElement == null) { return importReferences; } importReferences[importReferences.length - 1] = lastElement; PsiDirectory currentElement = lastElement instanceof PsiDirectory ? (PsiDirectory) lastElement.getParent() : Optional.of(lastElement) .map(PsiElement::getContainingFile) .map(PsiFile::getParent) .orElse(null); for (int i = pathComponents.size() - 2; i >= 0 && currentElement != null; --i) { String name = currentElement.getName(); String pathComponent = pathComponents.get(i); if (Objects.equals(name, pathComponent)) { importReferences[i] = currentElement; currentElement = currentElement.getParent(); } else { break; } } return importReferences; }
Example 5
Source File: ModulesUtil.java From svgtoandroid with MIT License | 5 votes |
public @Nullable String getCurrentModule() { Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); String path = FileDocumentManager.getInstance().getFile(editor.getDocument()).getPath(); VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(path.substring(0,path.indexOf("/src"))); if (virtualFile!= null && virtualFile.isDirectory()) { PsiDirectory directory = PsiDirectoryFactory.getInstance(project).createDirectory(virtualFile); if (isModule(directory)) { return directory.getName(); } } return null; }
Example 6
Source File: PsiFileUtils.java From intellij-haxe with Apache License 2.0 | 5 votes |
static public String getDirectoryPath(PsiDirectory dir) { String out = ""; while (dir != null) { if (out.length() != 0) out = "/" + out; out = dir.getName() + out; dir = dir.getParent(); } return out; }
Example 7
Source File: RefDirectoryImpl.java From consulo with Apache License 2.0 | 4 votes |
protected RefDirectoryImpl(PsiDirectory psiElement, RefManager refManager) { super(psiElement.getName(), psiElement, refManager); }
Example 8
Source File: MoveDirectoryWithClassesProcessor.java From consulo with Apache License 2.0 | 4 votes |
private TargetDirectoryWrapper getResultDirectory(PsiDirectory dir) { return myTargetDirectory != null ? new TargetDirectoryWrapper(myTargetDirectory, dir.getName()) : getTargetDirectory(dir); }