Java Examples for com.intellij.psi.PsiDirectory
The following java examples will help you to understand the usage of com.intellij.psi.PsiDirectory. These source code samples are taken from different open source projects.
Example 1
| Project: idea-php-symfony2-plugin-master File: YamlCompletionContributor.java View source code |
@Override
protected void addCompletions(@NotNull CompletionParameters completionParameters, final ProcessingContext processingContext, @NotNull final CompletionResultSet completionResultSet) {
PsiFile originalFile = completionParameters.getOriginalFile();
if (!Symfony2ProjectComponent.isEnabled(originalFile)) {
return;
}
final PsiDirectory containingDirectory = originalFile.getContainingDirectory();
if (containingDirectory == null) {
return;
}
final VirtualFile containingDirectoryFiles = containingDirectory.getVirtualFile();
VfsUtil.visitChildrenRecursively(containingDirectoryFiles, new VirtualFileVisitor() {
@Override
public boolean visitFile(@NotNull VirtualFile file) {
String relativePath = VfsUtil.getRelativePath(file, containingDirectoryFiles, '/');
if (relativePath == null) {
return super.visitFile(file);
}
completionResultSet.addElement(LookupElementBuilder.create(relativePath).withIcon(file.getFileType().getIcon()));
return super.visitFile(file);
}
});
}Example 2
| Project: intellij-community-master File: StudyUtils.java View source code |
public static boolean isRenameableOrMoveable(@NotNull final Project project, @NotNull final Course course, @NotNull final PsiElement element) {
if (element instanceof PsiFile) {
VirtualFile virtualFile = ((PsiFile) element).getVirtualFile();
if (project.getBaseDir().equals(virtualFile.getParent())) {
return false;
}
TaskFile file = getTaskFile(project, virtualFile);
if (file != null) {
return false;
}
String name = virtualFile.getName();
return !isTestsFile(project, name) && !isTaskDescriptionFile(name);
}
if (element instanceof PsiDirectory) {
VirtualFile virtualFile = ((PsiDirectory) element).getVirtualFile();
VirtualFile parent = virtualFile.getParent();
if (parent == null) {
return true;
}
if (project.getBaseDir().equals(parent)) {
return false;
}
Lesson lesson = course.getLesson(parent.getName());
if (lesson != null) {
Task task = lesson.getTask(virtualFile.getName());
if (task != null) {
return false;
}
}
}
return true;
}Example 3
| Project: folding-plugin-master File: ProjectStructureProvider.java View source code |
@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings viewSettings) {
List<AbstractTreeNode> resultList = new ArrayList<>();
if (parent.getValue() instanceof PsiDirectory) {
PsiDirectory directory = (PsiDirectory) parent.getValue();
String path = directory.getVirtualFile().getPath();
if (SettingsManager.isComposed(path)) {
resultList.addAll(createComposedFiles(children, viewSettings));
} else {
resultList.addAll(children);
}
} else {
resultList.addAll(children);
}
return resultList;
}Example 4
| Project: intellij-perl-plugin-master File: NewFileAction.java View source code |
@NotNull
@Override
protected PsiElement[] invokeDialog(Project project, PsiDirectory directory) {
final CreateFileAction.MyValidator validator = new CreateFileAction.MyValidator(project, directory) {
@Override
public boolean checkInput(String inputString) {
if (!inputString.endsWith(Constants.PM_EXTENSION) && !inputString.endsWith(Constants.PL_EXTENSION)) {
return false;
}
return super.checkInput(inputString);
}
};
Messages.showInputDialog(project, IdeBundle.message("prompt.enter.new.file.name", new Object[0]) + " (must end with pl/pm)", IdeBundle.message("title.new.file", new Object[0]), PerlIcons.LANGUAGE, null, validator);
return validator.getCreatedElements();
}Example 5
| Project: intellij-plugins-master File: CodeContext.java View source code |
public boolean process(VirtualFile file, String name, JSPackageIndexInfo.Kind kind, boolean isPublic) {
if (kind != JSPackageIndexInfo.Kind.CLASS)
return true;
if (JavaScriptSupportLoader.isMxmlOrFxgFile(file)) {
addFileBackedDescriptor(file, codeContext, packageName, project);
PsiDirectory psiDirectory = PsiManager.getInstance(project).findDirectory(file.getParent());
if (psiDirectory != null)
codeContext.addDependency(psiDirectory);
} else {
String qName = JSPackageIndex.buildQualifiedName(packageName, name);
codeContext.putDescriptor(name, new ClassBackedElementDescriptor(name, qName, codeContext, project), true);
final PsiFile containingFile = PsiManager.getInstance(project).findFile(file);
if (containingFile == null)
return true;
final PsiDirectory containingDirectory = containingFile.getParent();
final Object dependency = containingDirectory != null ? containingDirectory : containingFile;
codeContext.addDependency(dependency);
}
return true;
}Example 6
| Project: MonkeyC-master File: MonkeyFileTemplateProvider.java View source code |
public static PsiElement createFromTemplate(@NotNull Project project, @NotNull VirtualFile rootDir, @NotNull String templateName, @NotNull String fileName) throws Exception {
Properties properties = FileTemplateManager.getInstance(project).getDefaultProperties();
rootDir.refresh(false, false);
PsiDirectory directory = PsiManager.getInstance(project).findDirectory(rootDir);
if (directory != null) {
FileTemplateManager manager = FileTemplateManager.getInstance(directory.getProject());
FileTemplate template = manager.getInternalTemplate(templateName);
return FileTemplateUtil.createFromTemplate(template, fileName, properties, directory);
}
return null;
}Example 7
| Project: old-gosu-repo-master File: GosuDocInfoGenerator.java View source code |
@Nullable
public String generateDocInfo(@Nullable List<String> docURLs) {
StringBuilder buffer = new StringBuilder();
if (myElement instanceof PsiClass) {
generateClassJavaDoc(buffer, (PsiClass) myElement);
} else if (myElement instanceof GosuMethodImpl) {
generateMethodJavaDoc(buffer, (GosuMethodImpl) myElement);
} else if (myElement instanceof PsiParameter) {
generateMethodParameterJavaDoc(buffer, (PsiParameter) myElement);
} else if (myElement instanceof PsiField) {
generateFieldJavaDoc(buffer, (PsiField) myElement);
} else if (myElement instanceof PsiVariable) {
generateVariableJavaDoc(buffer, (PsiVariable) myElement);
} else if (myElement instanceof PsiDirectory) {
final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage((PsiDirectory) myElement);
if (aPackage == null)
return null;
generatePackageJavaDoc(buffer, aPackage);
} else if (myElement instanceof PsiPackage) {
generatePackageJavaDoc(buffer, (PsiPackage) myElement);
} else {
return null;
}
if (docURLs != null) {
final StringBuilder sb = new StringBuilder("<p id=\"error\">Following external urls were checked:<br> <i>");
sb.append(StringUtil.join(docURLs, "</i><br> <i>"));
sb.append("</i><br>The documentation for this element is not found. Please add all the needed paths to API docs in ");
sb.append("<a href=\"open://Project Settings\">Project Settings.</a></p>");
buffer.insert(buffer.indexOf("<body>"), sb.toString());
}
return fixupDoc(buffer);
}Example 8
| Project: platform_tools_adt_idea-master File: ResourceFolderRepositoryTest.java View source code |
public void testDeleteResourceDirectory() throws Exception {
final VirtualFile file1 = myFixture.copyFileToProject(LAYOUT1, "res/layout/layout1.xml");
final VirtualFile file2 = myFixture.copyFileToProject(LAYOUT1, "res/layout/layout2.xml");
final VirtualFile file3 = myFixture.copyFileToProject(LAYOUT1, "res/layout-xlarge-land/layout3.xml");
PsiFile psiFile3 = PsiManager.getInstance(getProject()).findFile(file3);
assertNotNull(psiFile3);
ResourceFolderRepository resources = createRepository();
assertNotNull(resources);
// Try deleting a whole resource directory and ensure we remove the files within
long generation = resources.getModificationCount();
Collection<String> layouts = resources.getItemsOfType(ResourceType.LAYOUT);
assertEquals(3, layouts.size());
final PsiDirectory directory = psiFile3.getContainingDirectory();
assertNotNull(directory);
WriteCommandAction.runWriteCommandAction(null, new Runnable() {
@Override
public void run() {
directory.delete();
}
});
layouts = resources.getItemsOfType(ResourceType.LAYOUT);
assertEquals(2, layouts.size());
assertTrue(resources.getModificationCount() > generation);
}Example 9
| Project: yii2support-master File: ViewsUtil.java View source code |
@Nullable
public static PsiFile getViewFile(PsiElement element) {
final MethodReference reference = PsiTreeUtil.getParentOfType(element, MethodReference.class);
if (reference == null) {
return null;
}
final PsiElement[] parameters = reference.getParameters();
if (parameters.length == 0 || !(parameters[0] instanceof StringLiteralExpression)) {
return null;
}
String view = reference.getUserData(RENDER_VIEW);
if (!((StringLiteralExpression) parameters[0]).getContents().equals(view)) {
view = ((StringLiteralExpression) parameters[0]).getContents();
reference.putUserData(RENDER_VIEW, view);
reference.putUserData(RENDER_VIEW_FILE, null);
reference.putUserData(RENDER_VIEW_PATH, null);
}
PsiFile file = reference.getUserData(RENDER_VIEW_FILE);
if (file != null && file.isValid()) {
if (!file.getVirtualFile().getPath().equals(reference.getUserData(RENDER_VIEW_PATH))) {
reference.putUserData(RENDER_VIEW_FILE, null);
reference.putUserData(RENDER_VIEW_PATH, null);
file = null;
}
}
if (file == null || !file.isValid()) {
if (reference.getParameters()[0] instanceof StringLiteralExpression) {
PsiDirectory directory;
String path = ((StringLiteralExpression) reference.getParameters()[0]).getContents();
if (path.startsWith("/")) {
directory = ViewsUtil.getRootDirectory(element);
path = path.substring(1);
} else {
directory = ViewsUtil.getContextDirectory(element);
}
String filename;
if (path.contains("/")) {
filename = path.substring(path.lastIndexOf('/') + 1);
path = path.substring(0, path.lastIndexOf('/') + 1);
} else {
filename = path;
path = "";
}
while (path.contains("/") && directory != null) {
final String dirName = path.substring(0, path.indexOf('/'));
directory = dirName.equals("..") ? directory.getParent() : directory.findSubdirectory(dirName);
path = path.substring(path.indexOf('/') + 1);
}
if (directory == null) {
return null;
}
if (filename.contains(".")) {
file = directory.findFile(filename);
} else {
file = directory.findFile(filename + ".php");
if (file == null) {
file = directory.findFile(filename + ".twig");
}
if (file == null) {
file = directory.findFile(filename + ".tpl");
}
}
if (file != null) {
reference.putUserData(RENDER_VIEW_FILE, file);
reference.putUserData(RENDER_VIEW_PATH, file.getVirtualFile().getPath());
}
}
}
return file;
}Example 10
| Project: consulo-master File: FileTreeModelBuilder.java View source code |
@Nullable public DefaultMutableTreeNode removeNode(final PsiElement element, PsiDirectory parent) { LOG.assertTrue(parent != null, element instanceof PsiFile && ((PsiFile) element).getVirtualFile() != null ? ((PsiFile) element).getVirtualFile().getPath() : element); final VirtualFile parentVirtualFile = parent.getVirtualFile(); Module module = myFileIndex.getModuleForFile(parentVirtualFile); if (element instanceof PsiDirectory && myFlattenPackages) { final PackageDependenciesNode moduleNode = getModuleNode(module); final PsiDirectory psiDirectory = (PsiDirectory) element; final VirtualFile virtualFile = psiDirectory.getVirtualFile(); final PackageDependenciesNode dirNode = getModuleDirNode(virtualFile, myFileIndex.getModuleForFile(virtualFile), null); dirNode.removeFromParent(); return moduleNode; } DefaultMutableTreeNode dirNode = myModuleDirNodes.get(parentVirtualFile); if (dirNode == null) return null; if (dirNode instanceof DirectoryNode) { DirectoryNode wrapper = ((DirectoryNode) dirNode).getWrapper(); while (wrapper != null) { dirNode = wrapper; myModuleDirNodes.put(wrapper.getDirectory(), null); wrapper = ((DirectoryNode) dirNode).getWrapper(); } } final PackageDependenciesNode[] classOrDirNodes = findNodeForPsiElement((PackageDependenciesNode) dirNode, element); if (classOrDirNodes != null) { for (PackageDependenciesNode classNode : classOrDirNodes) { classNode.removeFromParent(); } } DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) dirNode.getParent(); DefaultMutableTreeNode node = dirNode; if (element == parent) { myModuleDirNodes.put(parentVirtualFile, null); dirNode.removeFromParent(); node = parentNode; } while (node != null && node.getChildCount() == 0) { PsiDirectory directory = parent.getParentDirectory(); parentNode = (DefaultMutableTreeNode) node.getParent(); node.removeFromParent(); if (node instanceof DirectoryNode) { while (node != null) { //clear all compacted links myModuleDirNodes.put(((DirectoryNode) node).getDirectory(), null); node = ((DirectoryNode) node).getCompactedDirNode(); } } else if (node instanceof ModuleNode) { myModuleNodes.put(((ModuleNode) node).getModule(), null); } else if (node instanceof ModuleGroupNode) { myModuleGroupNodes.put(((ModuleGroupNode) node).getModuleGroupName(), null); } node = parentNode; parent = directory; } if (myCompactEmptyMiddlePackages && node instanceof DirectoryNode && node.getChildCount() == 1) { //compact final TreeNode treeNode = node.getChildAt(0); if (treeNode instanceof DirectoryNode) { node.removeAllChildren(); for (int i = treeNode.getChildCount() - 1; i >= 0; i--) { node.add((MutableTreeNode) treeNode.getChildAt(i)); } ((DirectoryNode) node).setCompactedDirNode((DirectoryNode) treeNode); } } return parentNode != null ? parentNode : myRoot; }
Example 11
| Project: css-x-fire-master File: IncomingChangesProcessor.java View source code |
/**
* Assembles a path for a given CSS declaration and block.
*
* @param declaration the declaration
* @param block the block
* @return a path for an existing CSS declaration, or <tt>null</tt> if the containing file or directory can not be determined
*/
@Nullable
private CssDeclarationPath createPath(CssDeclaration declaration, CssBlock block) {
CssDeclarationNode declarationNode = new CssDeclarationNode(declaration, changesBean.getValue(), changesBean.isDeleted(), changesBean.isImportant());
CssSelectorNode selectorNode = new CssSelectorNode(changesBean.getSelector(), block);
PsiFile file = declaration.getContainingFile().getOriginalFile();
if (!file.isValid()) {
return null;
}
CssFileNode fileNode = new CssFileNode(file);
PsiDirectory directory = file.getParent();
if (directory == null || !directory.isValid()) {
LOG.warn("Invalid directory for existing path: " + (directory == null ? directory : directory.getVirtualFile().getUrl()));
return null;
}
return new CssDeclarationPath(new CssDirectoryNode(directory), fileNode, selectorNode, declarationNode);
}Example 12
| Project: fan4idea-master File: FanFileImpl.java View source code |
public String getPodName() {
if (podName != null) {
return podName;
}
// If I'm a build.fan get it
if (PodModel.BUILD_FAN.equals(getName())) {
// Ugly Hack until we can execute Fan script (TODO: use the PodFileParser)
final FanClassDefinition[] classDef = this.findChildrenByClass(FanClassDefinition.class);
if (classDef.length > 0) {
final FanMethod[] methods = classDef[0].getFanMethods();
if (methods.length > 0) {
for (final FanMethod method : methods) {
// TODO: Even uglier hack until we have Expression parsing
if (method.getName().equals("setup")) {
final String setupBody = method.getBody().getText();
final int podNameIdx = setupBody.indexOf("podName");
if (podNameIdx != -1) {
final int firstDQ = setupBody.indexOf('"', podNameIdx + "podName".length() + 1);
final int lastDQ = setupBody.indexOf('"', firstDQ + 1);
podName = setupBody.substring(firstDQ + 1, lastDQ);
return podName;
}
}
}
}
}
logger.warn("Did not find pod name in " + (getVirtualFile() != null ? getVirtualFile().getPath() : this.toString()));
return "NotFound";
}
// If the file is inside a pod
final VirtualFile myVirtualFile = getVirtualFile();
if (myVirtualFile != null && myVirtualFile.getUrl().contains(".pod")) {
final String url = myVirtualFile.getUrl();
final String podPath = url.substring(0, url.indexOf(".pod"));
int podNameStartIndex = podPath.lastIndexOf(VirtualFileUtil.VFS_PATH_SEPARATOR);
podNameStartIndex = podNameStartIndex < 0 ? 0 : podNameStartIndex + 1;
podName = podPath.substring(podNameStartIndex);
return podName;
}
// Go up until the directory contain a build.fan file
PsiDirectory psiDirectory = getParent();
int upMax = 4;
while (psiDirectory != null && upMax > 0) {
final PsiFile[] files = psiDirectory.getFiles();
if (files != null) {
for (final PsiFile file : files) {
if (PodModel.BUILD_FAN.equals(file.getName())) {
podName = ((FanFile) file).getPodName();
return podName;
}
}
}
psiDirectory = psiDirectory.getParentDirectory();
upMax--;
}
return "NotFound";
}Example 13
| Project: go-lang-idea-plugin-master File: GoHighlightingTest.java View source code |
@SuppressWarnings("ConstantConditions")
public void testDoNotReportNonLastMultiResolvedImport() {
myFixture.addFileToProject("root1/src/to_import/unique/foo.go", "package unique; func Foo() {}");
myFixture.addFileToProject("root1/src/to_import/shared/a.go", "package shared");
myFixture.addFileToProject("root2/src/to_import/shared/a.go", "package shared");
GoModuleLibrariesService.getInstance(myFixture.getModule()).setLibraryRootUrls(myFixture.findFileInTempDir("root1").getUrl(), myFixture.findFileInTempDir("root2").getUrl());
doTest();
PsiReference reference = myFixture.getFile().findReferenceAt(myFixture.getCaretOffset());
PsiElement resolve = reference.resolve();
assertInstanceOf(resolve, PsiDirectory.class);
assertTrue(((PsiDirectory) resolve).getVirtualFile().getPath().endsWith("root1/src/to_import/shared"));
GoModuleLibrariesService.getInstance(myFixture.getModule()).setLibraryRootUrls(myFixture.findFileInTempDir("root2").getUrl(), myFixture.findFileInTempDir("root1").getUrl());
reference = myFixture.getFile().findReferenceAt(myFixture.getCaretOffset());
resolve = reference.resolve();
assertInstanceOf(resolve, PsiDirectory.class);
assertTrue(((PsiDirectory) resolve).getVirtualFile().getPath().endsWith("root2/src/to_import/shared"));
}Example 14
| Project: idea-php-typo3-plugin-master File: TYPO3ExtensionUtil.java View source code |
/**
* Traverses the given directories and returns the first valid
* extension definition that's applicable.
*
* @param directories List of directories to analyze
*/
public static TYPO3ExtensionDefinition findContainingExtension(PsiDirectory[] directories) {
for (PsiDirectory directory : directories) {
VirtualDirectoryImpl virtualFile = (VirtualDirectoryImpl) directory.getVirtualFile();
while (!isExtensionRootDirectory(virtualFile)) {
if (virtualFile.getParent() == null) {
return null;
}
virtualFile = virtualFile.getParent();
}
TYPO3ExtensionDefinition extensionDefinition = ExtensionDefinitionFactory.fromDirectory(virtualFile);
if (extensionDefinition != null) {
return extensionDefinition;
}
}
return null;
}Example 15
| Project: intellij-elixir-master File: CreateElixirModuleAction.java View source code |
/**
* @link com.intellij.ide.actions.CreateTemplateInPackageAction#checkOrCreate
*/
@Nullable
private static ElixirFile createDirectoryAndModuleFromTemplate(@NotNull String moduleName, @NotNull PsiDirectory directory, @NotNull String templateName) {
PsiDirectory currentDirectory = directory;
Pair<List<String>, String> ancestorDirectoryNamesBaseNamePair = ancestorDirectoryNamesBaseNamePair(moduleName);
List<String> ancestorDirectoryNames = ancestorDirectoryNamesBaseNamePair.first;
for (String ancestorDirectoryName : ancestorDirectoryNames) {
PsiDirectory subdirectory = currentDirectory.findSubdirectory(ancestorDirectoryName);
if (subdirectory == null) {
subdirectory = currentDirectory.createSubdirectory(ancestorDirectoryName);
}
currentDirectory = subdirectory;
}
String basename = ancestorDirectoryNamesBaseNamePair.second;
return createModuleFromTemplate(currentDirectory, basename, moduleName, templateName);
}Example 16
| Project: intellij-erlang-master File: RebarEunitRunningState.java View source code |
private void writeModifiedConfig(File oldConfig, final File newConfig) throws IOException {
Project project = myConfiguration.getProject();
final PsiFile configPsi = createModifiedConfigPsi(oldConfig);
VirtualFile outputDirectory = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(newConfig.getParentFile());
final PsiDirectory psiDirectory = outputDirectory != null ? PsiDirectoryFactory.getInstance(project).createDirectory(outputDirectory) : null;
if (psiDirectory == null) {
throw new IOException("Failed to save modified rebar.config");
}
ApplicationManager.getApplication().runWriteAction(() -> {
String name = newConfig.getName();
PsiFile prev = psiDirectory.findFile(name);
if (prev != null)
prev.delete();
configPsi.setName(name);
psiDirectory.add(configPsi);
});
}Example 17
| Project: intellij-pants-plugin-master File: VirtualFileTreeNode.java View source code |
@Override
protected void update(PresentationData presentation) {
final PsiManager psiManager = PsiManager.getInstance(myProject);
final VirtualFile virtualFile = getValue();
final PsiFile psiElement = virtualFile.isValid() ? psiManager.findFile(virtualFile) : null;
if (psiElement instanceof PsiDirectory) {
new PsiDirectoryNode(myProject, (PsiDirectory) psiElement, getSettings()).update(presentation);
} else if (psiElement != null) {
new PsiFileNode(myProject, psiElement, getSettings()).update(presentation);
} else {
presentation.setPresentableText(virtualFile.getName());
presentation.setIcon(virtualFile.isDirectory() ? AllIcons.Nodes.Folder : virtualFile.getFileType().getIcon());
}
}Example 18
| Project: IntelliVault-master File: FileUtils.java View source code |
/**
* Copy the contents of an import operation from the IDEA project directory
* to the vault temp directory.
*
* @param importBaseDir
* the file system directory, which serves as the root of the
* copy target
* @param importDir
* the PsiDirectory (IDEA virtual directory) containing the
* contents to be copied
* @param path
* the jcr path representing the root of the import
* @param filter
* A list of Filters specifying which files should be ignored
* (not imported).
*
* @throws com.razorfish.platforms.intellivault.exceptions.IntelliVaultException
* if an error occurs during copy
*/
public static void copyImportContents(File importBaseDir, PsiDirectory importDir, String path, Filter<VirtualFile> filter) throws IntelliVaultException {
File copyRootDir = new File(importBaseDir.getAbsolutePath() + File.separator + IntelliVaultConstants.JCR_ROOT + path.replace(IntelliVaultConstants.JCR_PATH_SEPERATOR, File.separator));
copyRootDir.mkdirs();
try {
copyImportContents(copyRootDir, importDir.getVirtualFile(), filter);
} catch (IOException e) {
throw new IntelliVaultException("Failed copying contents.", e);
}
}Example 19
| Project: la-clojure-master File: ClojureScriptRunConfigurationType.java View source code |
public RunnerAndConfigurationSettings createConfigurationByLocation(Location location) {
PsiFile file = location.getPsiElement().getContainingFile();
if (file instanceof ClojureFile) {
ClojureFile clojureFile = (ClojureFile) file;
RunnerAndConfigurationSettings settings = RunManager.getInstance(location.getProject()).createRunConfiguration("", myConfigurationFactory);
ClojureScriptRunConfiguration configuration = (ClojureScriptRunConfiguration) settings.getConfiguration();
PsiDirectory dir = clojureFile.getContainingDirectory();
assert dir != null;
configuration.setWorkDir(dir.getVirtualFile().getPath());
VirtualFile vFile = clojureFile.getVirtualFile();
assert vFile != null;
configuration.setScriptPath(vFile.getPath());
configuration.setName(vFile.getNameWithoutExtension());
configuration.setModule(ModuleUtil.findModuleForPsiElement(clojureFile));
return settings;
}
return null;
}Example 20
| Project: msopentech-tools-for-intellij-master File: AzureIconProvider.java View source code |
@Override
public Icon getIcon(@NotNull final PsiElement element, final int flags) {
if (element instanceof PsiDirectory) {
final PsiDirectory psiDirectory = (PsiDirectory) element;
final VirtualFile vFile = psiDirectory.getVirtualFile();
final Project project = psiDirectory.getProject();
Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(vFile);
if (module != null && AzureModuleType.AZURE_MODULE.equals(module.getOptionValue(Module.ELEMENT_TYPE)) && PluginUtil.isRoleFolder(vFile, module)) {
return WorkerRole;
}
}
return null;
}Example 21
| Project: salesforce-plugin-master File: AbstractFileAction.java View source code |
@Override
protected void buildDialog(final Project project, PsiDirectory psiDirectory, CreateFileFromTemplateDialog.Builder builder) {
this.project = project;
// Add validator - Salesforce doesn't have namespaces, so validate the filename does not contain a period
builder.setValidator(new InputValidatorEx() {
@Override
public String getErrorText(String inputString) {
if (inputString.length() > 0 && (inputString.contains(".") || inputString.contains(" "))) {
return "This is not a valid Apex file name";
}
return null;
}
@Override
public boolean checkInput(String inputString) {
return true;
}
@Override
public boolean canClose(String inputString) {
return !StringUtil.isEmptyOrSpaces(inputString) && getErrorText(inputString) == null;
}
});
}Example 22
| Project: wicketforge-master File: ExtractPropertiesDialog.java View source code |
@Override
protected void doOKAction() {
Object selectedItem = propertiesFileComboBox.getSelectedItem();
// if we dont have any properties file (we will create one) -> ask for destination
if (module != null && psiPackage != null && selectedItem instanceof NewPropertiesFileInfo && chooseDifferentDestinationFolderCheckBox.isSelected()) {
PsiDirectory directory = WicketFileUtil.selectTargetDirectory(psiPackage.getQualifiedName(), project, module);
if (directory == null) {
// aborted
return;
}
destinationDirectory = directory;
}
if (validateInput() && actionRunnable.run(selectedItem, destinationDirectory, propertyKeyTextField.getText(), propertyValueTextArea.getText())) {
super.doOKAction();
}
}Example 23
| Project: Azure-Toolkit-for-IntelliJ-master File: AzureIconProvider.java View source code |
@Override
public Icon getIcon(@NotNull final PsiElement element, final int flags) {
if (element instanceof PsiDirectory) {
final PsiDirectory psiDirectory = (PsiDirectory) element;
final VirtualFile vFile = psiDirectory.getVirtualFile();
final Project project = psiDirectory.getProject();
Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(vFile);
if (module != null && AzureModuleType.AZURE_MODULE.equals(module.getOptionValue(Module.ELEMENT_TYPE)) && PluginUtil.isRoleFolder(vFile, module)) {
return WorkerRole;
}
}
return null;
}Example 24
| Project: com.cedarsoft.serialization-master File: GenerateSerializerAction.java View source code |
@Override
protected void run() throws Throwable {
PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(getProject());
JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(getProject());
//StringBuilder builder = new StringBuilder();
//builder.append( "public void deserializeStuff(){" )
// .append( psiClass.getName() ).append( ".class.getName();" )
// .append( "}" );
//
//PsiElement method = psiClass.add( elementFactory.createMethodFromText( builder.toString(), psiClass ) );
//
//codeStyleManager.shortenClassReferences( method );
PsiReferenceList implementsList = psiClass.getImplementsList();
if (implementsList == null) {
throw new IllegalStateException("no implements list found");
}
if (isUnderTestSources(psiClass)) {
throw new IllegalStateException("Is a test source!");
}
Module srcModule = ModuleUtilCore.findModuleForPsiElement(psiClass);
if (srcModule == null) {
throw new IllegalStateException("No src module found");
}
PsiDirectory srcDir = psiClass.getContainingFile().getContainingDirectory();
PsiPackage srcPackage = JavaDirectoryService.getInstance().getPackage(srcDir);
//PsiClass serializerClass = elementFactory.createClass( psiClass.getQualifiedName() + "Serializer" );
final Set<VirtualFile> testFolders = new HashSet<VirtualFile>();
fillTestRoots(srcModule, testFolders);
if (testFolders.isEmpty()) {
throw new IllegalStateException("No test folders found");
}
VirtualFile testFolder = testFolders.iterator().next();
final String packageName = "com.cedarsoft.test.hardcoded.test";
PsiManager psiManager = PsiManager.getInstance(getProject());
final PackageWrapper targetPackage = new PackageWrapper(psiManager, packageName);
PsiDirectory targetPackageDir = RefactoringUtil.createPackageDirectoryInSourceRoot(targetPackage, testFolder);
PsiClass test = createTest(getProject(), targetPackageDir, psiClass);
Editor editor = CodeInsightUtil.positionCursor(getProject(), test.getContainingFile(), test.getLBrace());
}Example 25
| Project: consulo-cfml-master File: CfmlFileReferenceInspection.java View source code |
public void visitElement(final PsiElement element) {
PsiElement tagParent = PsiTreeUtil.getParentOfType((element), CfmlTag.class);
if ((element.getNode().getElementType() == CfmlTokenTypes.STRING_TEXT)) {
if ((tagParent == null || (!((CfmlTag) tagParent).getTagName().equalsIgnoreCase("cfinclude") && !((CfmlTag) tagParent).getTagName().equalsIgnoreCase("cfmodule")))) {
PsiElement superParent = element.getParent() != null ? element.getParent().getParent() : null;
ASTNode superParentNode = superParent != null ? superParent.getNode() : null;
if ((superParentNode == null || superParentNode.getElementType() != CfmlElementTypes.INCLUDEEXPRESSION)) {
return;
}
}
final PsiReference[] refs = element.getParent().getReferences();
for (int i = 0, refsLength = refs.length; i < refsLength; i++) {
PsiReference ref = refs[i];
if (!(ref instanceof FileReference))
continue;
if (ref.resolve() == null) {
PsiDirectory dir;
if (i > 0) {
final PsiElement target = refs[i - 1].resolve();
dir = target instanceof PsiDirectory ? (PsiDirectory) target : null;
} else {
dir = element.getContainingFile().getParent();
}
holder.registerProblem(ref.getElement(), ref.getRangeInElement(), isOnTheFly ? "Path '" + ref.getCanonicalText() + "' not found" : "Path not found", isOnTheFly && dir != null ? new LocalQuickFix[] { new CreateFileFix(i < refs.length - 1, ref.getCanonicalText(), dir) } : LocalQuickFix.EMPTY_ARRAY);
// ProblemHighlightType.ERROR);
break;
}
}
}
}Example 26
| Project: consulo-unity3d-master File: UnityNamespaceGeneratePolicy.java View source code |
@RequiredReadAction
@Nullable
@Override
public String calculateDirtyNamespace(@NotNull PsiDirectory psiDirectory) {
Project project = psiDirectory.getProject();
VirtualFile baseDir = project.getBaseDir();
if (baseDir == null) {
return myNamespacePrefix;
}
VirtualFile currentDirectory = psiDirectory.getVirtualFile();
VirtualFile assetsDirectory = baseDir.findChild(Unity3dProjectUtil.ASSETS_DIRECTORY);
if (assetsDirectory != null) {
VirtualFile targetDirectory = assetsDirectory;
VirtualFile temp = currentDirectory;
while (temp != null && !temp.equals(targetDirectory)) {
if ("Editor".equals(temp.getName())) {
targetDirectory = temp;
}
temp = temp.getParent();
}
// if path is not changed
if (targetDirectory.equals(assetsDirectory)) {
temp = currentDirectory;
while (temp != null && !temp.equals(targetDirectory)) {
if ("Scripts".equals(temp.getName())) {
targetDirectory = temp;
}
temp = temp.getParent();
}
}
// if path is not changed
if (targetDirectory.equals(assetsDirectory)) {
for (String path : Unity3dProjectUtil.FIRST_PASS_PATHS) {
VirtualFile child = baseDir.findFileByRelativePath(path);
if (child != null && VfsUtil.isAncestor(child, currentDirectory, false)) {
targetDirectory = child;
break;
}
}
}
String relativePath = VfsUtil.getRelativePath(currentDirectory, targetDirectory, '.');
if (relativePath != null) {
if (!StringUtil.isEmpty(myNamespacePrefix)) {
return myNamespacePrefix + "." + relativePath;
}
return relativePath;
}
}
return myNamespacePrefix;
}Example 27
| Project: DeftIDEA-master File: DeftTemplatesFactory.java View source code |
public static PsiFile createFromTemplate(final PsiDirectory directory, final String name, String fileName, FileType fileType, String templateName, String... parameters) throws IncorrectOperationException {
final FileTemplate template = FileTemplateManager.getInstance().getTemplate(templateName);
Properties properties = new Properties(FileTemplateManager.getInstance().getDefaultProperties());
properties.setProperty(NAME_TEMPLATE_PROPERTY, name);
JavaTemplateUtil.setPackageNameAttribute(properties, directory);
for (int i = 0; i < parameters.length; i += 2) {
properties.setProperty(parameters[i], parameters[i + 1]);
}
String text;
try {
text = template.getText(properties);
} catch (Exception e) {
throw new RuntimeException("Unable to load template " + FileTemplateManager.getInstance().internalTemplateToSubject(templateName), e);
}
final PsiFileFactory factory = PsiFileFactory.getInstance(directory.getProject());
final PsiFile file = factory.createFileFromText(fileName, fileType, text);
return (PsiFile) directory.add(file);
}Example 28
| Project: easyb-ext-master File: EasybRunConfigurationType.java View source code |
private RunnerAndConfigurationSettings createConfiguration(final PsiFile easybSpecFile) {
final Project project = easybSpecFile.getProject();
RunnerAndConfigurationSettings settings = RunManager.getInstance(project).createRunConfiguration(easybSpecFile.getName(), factory);
final EasybRunConfiguration configuration = (EasybRunConfiguration) settings.getConfiguration();
final PsiDirectory dir = easybSpecFile.getContainingDirectory();
assert dir != null;
final VirtualFile vFile = easybSpecFile.getVirtualFile();
assert vFile != null;
configuration.setSpecificationPath(vFile.getPath());
configuration.setModule(ModuleUtil.findModuleForPsiElement(easybSpecFile));
return settings;
}Example 29
| Project: easyb-master File: EasybRunConfigurationType.java View source code |
private RunnerAndConfigurationSettings createConfiguration(final PsiFile easybSpecFile) {
final Project project = easybSpecFile.getProject();
RunnerAndConfigurationSettings settings = RunManager.getInstance(project).createRunConfiguration(easybSpecFile.getName(), factory);
final EasybRunConfiguration configuration = (EasybRunConfiguration) settings.getConfiguration();
final PsiDirectory dir = easybSpecFile.getContainingDirectory();
assert dir != null;
final VirtualFile vFile = easybSpecFile.getVirtualFile();
assert vFile != null;
configuration.setSpecificationPath(vFile.getPath());
configuration.setModule(ModuleUtil.findModuleForPsiElement(easybSpecFile));
return settings;
}Example 30
| Project: getGists-master File: GithubGetGistCache.java View source code |
public static PsiDirectory getCacheDir(Project project) { File dirName = new File(project.getBasePath(), ".idea/gits"); VirtualFile directory = LocalFileSystem.getInstance().findFileByIoFile(new File(project.getBasePath(), ".idea/gits")); if (directory == null) { try { LOG.info("dir is null" + dirName.getPath()); directory = VfsUtil.createDirectories(dirName.getPath()); } catch (IOException e) { e.printStackTrace(); } } PsiDirectory psiDirectory = PsiManager.getInstance(project).findDirectory(directory); return psiDirectory; }
Example 31
| Project: IDLua-master File: GenerateLuaListingAction.java View source code |
public void actionPerformed(AnActionEvent e) {
Project project = (Project) e.getData(LangDataKeys.PROJECT);
assert project != null;
Sdk sdk = null;
Module module = null;
Module modules[] = ModuleManager.getInstance(project).getModules();
for (Module m : modules) {
module = m;
sdk = LuaSdkType.findLuaSdk(m);
if (sdk != null)
break;
}
assert module != null;
assert sdk != null;
final String homePath = sdk.getHomePath();
if (homePath == null)
return;
String path = LuaSdkType.getByteCodeCompilerExecutable(homePath).getParent();
String exePath = LuaSdkType.getTopLevelExecutable(homePath).getAbsolutePath();
PsiFile currfile = e.getData(LangDataKeys.PSI_FILE);
if (currfile == null || !(currfile instanceof LuaPsiFile))
return;
FileDocumentManager.getInstance().saveAllDocuments();
LuaSystemUtil.clearConsoleToolWindow(project);
final VirtualFile virtualFile = currfile.getVirtualFile();
if (virtualFile == null)
return;
final ProcessOutput processOutput;
try {
final VirtualFile child = StdLibrary.getListingModuleLocation().findChild("listing.lua");
if (child == null)
return;
final String listingScript = child.getPath();
processOutput = LuaSystemUtil.getProcessOutput(path, exePath, listingScript, virtualFile.getPath());
} catch (final ExecutionException ex) {
return;
}
if (processOutput.getExitCode() != 0)
return;
String errors = processOutput.getStderr();
if (StringUtil.notNullize(errors).length() > 0) {
LuaSystemUtil.printMessageToConsole(project, errors, ConsoleViewContentType.ERROR_OUTPUT);
return;
}
String listing = processOutput.getStdout();
final IdeView view = LangDataKeys.IDE_VIEW.getData(e.getDataContext());
if (view == null)
return;
final PsiDirectory dir = view.getOrChooseDirectory();
if (dir == null)
return;
final PsiFileFactory factory = PsiFileFactory.getInstance(project);
final String listingFileName = virtualFile.getNameWithoutExtension() + "-listing.lua";
final PsiFile existingFile = dir.findFile(listingFileName);
if (existingFile != null)
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
existingFile.delete();
}
});
final PsiFile file = factory.createFileFromText(listingFileName, LuaFileType.LUA_FILE_TYPE, listing);
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
created = dir.add(file);
}
});
if (created == null)
return;
final PsiFile containingFile = created.getContainingFile();
if (containingFile == null)
return;
final VirtualFile virtualFile1 = containingFile.getVirtualFile();
if (virtualFile1 == null)
return;
OpenFileDescriptor fileDesc = new OpenFileDescriptor(project, virtualFile1);
FileEditorManager.getInstance(project).openTextEditor(fileDesc, false);
view.selectElement(created);
created = null;
}Example 32
| Project: intellij-haxe-master File: HaxeFileTemplateUtil.java View source code |
public static PsiElement createClass(String className, String packageName, PsiDirectory directory, String templateName, @org.jetbrains.annotations.Nullable java.lang.ClassLoader classLoader) throws Exception {
final Properties props = new Properties(FileTemplateManager.getInstance().getDefaultProperties(directory.getProject()));
props.setProperty(FileTemplate.ATTRIBUTE_NAME, className);
props.setProperty(FileTemplate.ATTRIBUTE_PACKAGE_NAME, packageName);
final FileTemplate template = FileTemplateManager.getInstance().getInternalTemplate(templateName);
return FileTemplateUtil.createFromTemplate(template, className, props, directory, classLoader);
}Example 33
| Project: Intellij-Plugin-master File: SpecsExecutionProducer.java View source code |
@Override
public boolean isConfigurationFromContext(RunConfiguration config, ConfigurationContext context) {
if (!(config.getType() instanceof GaugeRunTaskConfigurationType))
return false;
if (!(context.getPsiLocation() instanceof PsiDirectory) && !(context.getPsiLocation() instanceof PsiFile))
return false;
VirtualFile[] selectedFiles = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(context.getDataContext());
if (selectedFiles == null)
return false;
String specs = ((GaugeRunConfiguration) config).getSpecsToExecute();
return StringUtil.join(getSpecs(selectedFiles), SPEC_FILE_DELIMITER).equals(specs);
}Example 34
| Project: JHelper-master File: TaskUtils.java View source code |
private static PsiElement generateCPP(Project project, TaskData taskData) {
VirtualFile parent = FileUtils.findOrCreateByRelativePath(project.getBaseDir(), FileUtils.getDirectory(taskData.getCppPath()));
PsiDirectory psiParent = PsiManager.getInstance(project).findDirectory(parent);
if (psiParent == null) {
throw new NotificationException("Couldn't open parent directory as PSI");
}
Language objC = Language.findLanguageByID("ObjectiveC");
if (objC == null) {
throw new NotificationException("Language not found");
}
PsiFile file = PsiFileFactory.getInstance(project).createFileFromText(FileUtils.getFilename(taskData.getCppPath()), objC, getTaskContent(project, taskData.getClassName()));
if (file == null) {
throw new NotificationException("Couldn't generate file");
}
return ApplicationManager.getApplication().runWriteAction((Computable<PsiElement>) () -> psiParent.add(file));
}Example 35
| Project: netbeans-mmd-plugin-master File: KnowledgeViewProjectNode.java View source code |
@Nonnull
@Override
public Collection<? extends AbstractTreeNode> getChildren() {
final ArrayList<AbstractTreeNode> result = new ArrayList<AbstractTreeNode>();
final PsiManager psiManager = PsiManager.getInstance(getProject());
for (final Module m : ModuleManager.getInstance(myProject).getModules()) {
final VirtualFile knowledgeFolder = IdeaUtils.findKnowledgeFolderForModule(m, false);
if (knowledgeFolder != null) {
final String moduleName = m.getName();
final PsiDirectory dir = psiManager.findDirectory(knowledgeFolder);
final PsiDirectoryNode node = new PsiDirectoryNode(myProject, dir, getSettings()) {
protected Icon patchIcon(final Icon original, final VirtualFile file) {
return AllIcons.File.FOLDER;
}
@Override
public String getTitle() {
return moduleName;
}
@Override
public String toString() {
return moduleName;
}
@Override
public boolean isFQNameShown() {
return false;
}
@Override
public VirtualFile getVirtualFile() {
return knowledgeFolder;
}
@Nullable
@Override
protected String calcTooltip() {
return "The Knowledge folder for " + m.getName();
}
@Override
protected boolean shouldShowModuleName() {
return false;
}
};
result.add(node);
}
}
return result;
}Example 36
| Project: qi4j-sdk-master File: CreateConcernOfInPackageAction.java View source code |
@NotNull
protected final PsiElement[] invokeDialog(Project project, PsiDirectory directory) {
MyInputValidator validator = new MyInputValidator(project, directory);
Messages.showInputDialog(project, message("createConcernOfInPackage.dlg.prompt"), message("createConcernOfInPackage.dlg.title"), Messages.getQuestionIcon(), "", validator);
return validator.getCreatedElements();
}Example 37
| Project: textmapper-master File: CreateTextmapperFileAction.java View source code |
@Override
protected void buildDialog(Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) {
builder.setTitle(TextmapperBundle.message("newfile.action.text"));
for (TemplatesHandler handler : TemplatesHandler.EP_NAME.getExtensions()) {
handler.addTemplates(builder);
}
builder.addKind("generates Javascript", StdFileTypes.JS.getIcon(), "GrammarForJS.tm");
builder.setValidator(new InputValidatorEx() {
@Nullable
@Override
public String getErrorText(String inputString) {
return null;
}
@Override
public boolean checkInput(String inputString) {
return StringUtil.isJavaIdentifier(inputString);
}
@Override
public boolean canClose(String inputString) {
return checkInput(inputString);
}
});
}Example 38
| Project: Wolfram-Language-Parser-master File: PsiCachedValue.java View source code |
@Override
protected long getTimeStamp(Object dependency) {
if (dependency instanceof PsiDirectory) {
return myManager.getModificationTracker().getOutOfCodeBlockModificationCount();
}
if (dependency instanceof PsiElement) {
PsiElement element = (PsiElement) dependency;
if (!element.isValid())
return -1;
PsiFile containingFile = element.getContainingFile();
if (containingFile == null)
return -1;
return containingFile.getModificationStamp();
}
if (dependency == PsiModificationTracker.MODIFICATION_COUNT) {
return myManager.getModificationTracker().getModificationCount();
}
if (dependency == PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT) {
return myManager.getModificationTracker().getOutOfCodeBlockModificationCount();
}
if (dependency == PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT) {
return myManager.getModificationTracker().getJavaStructureModificationCount();
}
return super.getTimeStamp(dependency);
}Example 39
| Project: angularjs-plugin-master File: GotoAngularAction.java View source code |
private Collection<Usage> getAngularUsages(Project project, DataContext dataContext, FindModel findModel) {
FindInProjectUtil.setDirectoryName(findModel, dataContext);
CommonProcessors.CollectProcessor<Usage> collectProcessor = new CommonProcessors.CollectProcessor<Usage>();
PsiDirectory directory = PsiManager.getInstance(project).findDirectory(project.getBaseDir());
FindInProjectUtil.findUsages(findModel, directory, project, true, new AdapterProcessor<UsageInfo, Usage>(collectProcessor, UsageInfo2UsageAdapter.CONVERTER), new FindUsagesProcessPresentation());
return collectProcessor.getResults();
}Example 40
| Project: citrus-tool-master File: SpringExtSchemaXmlFileSet.java View source code |
@NotNull
private Resource[] getResources(@NotNull String locationPattern, boolean singleResult) {
String packageName = getParentPackageName(locationPattern);
String fileName = getFileName(locationPattern);
WildcardFileNameMatcher fileNameMatcher = fileName.contains("*") ? new WildcardFileNameMatcher(fileName) : null;
PsiPackage psiPackage = JavaPsiFacade.getInstance(project).findPackage(packageName);
if (psiPackage != null) {
PsiDirectory[] psiDirectories = psiPackage.getDirectories(GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, true));
List<PsiFile> files = createLinkedList();
LOOP: for (PsiDirectory psiDirectory : psiDirectories) {
if (fileNameMatcher == null) {
PsiFile psiFile = psiDirectory.findFile(fileName);
if (psiFile != null) {
files.add(psiFile);
if (singleResult) {
break;
}
}
} else {
for (PsiFile file : psiDirectory.getFiles()) {
if (fileNameMatcher.accept(file.getName())) {
files.add(file);
if (singleResult) {
break LOOP;
}
}
}
}
}
if (!files.isEmpty()) {
List<Resource> resources = createLinkedList();
for (PsiFile psiFile : files) {
dependencies.add(psiFile);
final VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile != null) {
resources.add(new VirtualFileResource(virtualFile));
} else {
log.warn("PsiFile was ignored, because it only exists in memory: " + psiFile);
}
}
return resources.toArray(new Resource[resources.size()]);
}
}
return new Resource[0];
}Example 41
| Project: consulo-csharp-master File: CSharpCreateFileAction.java View source code |
@Override
@RequiredDispatchThread
protected boolean isAvailable(DataContext dataContext) {
Module module = findModule(dataContext);
if (module != null) {
DotNetModuleExtension extension = ModuleUtilCore.getExtension(module, DotNetModuleExtension.class);
if (extension != null && extension.isAllowSourceRoots()) {
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return false;
}
PsiDirectory orChooseDirectory = view.getOrChooseDirectory();
if (orChooseDirectory == null) {
return false;
}
PsiPackage aPackage = PsiPackageManager.getInstance(module.getProject()).findPackage(orChooseDirectory, DotNetModuleExtension.class);
if (aPackage == null) {
return false;
}
}
}
return module != null && ModuleUtilCore.getExtension(module, CSharpSimpleModuleExtension.class) != null;
}Example 42
| Project: glsl4idea-master File: GLSLCreateFromTemplateHandler.java View source code |
//Copied and modified from parent class
@NotNull
@Override
public PsiFile createFromTemplate(final Project project, final PsiDirectory directory, String fileName, FileTemplate template, String templateText, @NotNull final Map<String, Object> props) throws IncorrectOperationException {
Map<String, FileTemplate> templates = getTemplates(project);
//Make sure it has some extension
int extensionDot = fileName.lastIndexOf('.');
String extension;
if (extensionDot == -1) {
extension = template.getExtension();
fileName = fileName + "." + extension;
} else {
extension = fileName.substring(extensionDot + 1);
if (extension.isEmpty()) {
//Filename ends with a dot
extension = template.getExtension();
fileName = fileName + extension;
} else {
//Do template replacement
FileTemplate alternateTemplate = templates.get(extension.toLowerCase());
if (alternateTemplate != null) {
//There is a template defined for this
try {
templateText = alternateTemplate.getText(props);
} catch (IOException e) {
throw new IncorrectOperationException("Failed to load template file.", (Throwable) e);
}
}
}
}
//Make sure that the extension is valid
if (!templates.containsKey(extension.toLowerCase())) {
//Extension is not recognized, add recognized default one
fileName = fileName + "." + DEFAULT_EXTENSION;
}
if (FileTypeManager.getInstance().isFileIgnored(fileName)) {
throw new IncorrectOperationException("This filename is ignored (Settings | File Types | Ignore files and folders)");
}
directory.checkCreateFile(fileName);
FileType type = FileTypeRegistry.getInstance().getFileTypeByFileName(fileName);
PsiFile file = PsiFileFactory.getInstance(project).createFileFromText(fileName, type, templateText);
if (template.isReformatCode()) {
CodeStyleManager.getInstance(project).reformat(file);
}
file = (PsiFile) directory.add(file);
return file;
}Example 43
| Project: idea-gitignore-master File: Utils.java View source code |
/**
* Gets Ignore file for given {@link Project} and root {@link PsiDirectory}.
* If file is missing - creates new one.
*
* @param project current project
* @param fileType current ignore file type
* @param directory root directory
* @param createIfMissing create new file if missing
* @return Ignore file
*/
@Nullable
public static PsiFile getIgnoreFile(@NotNull Project project, @NotNull IgnoreFileType fileType, @Nullable PsiDirectory directory, boolean createIfMissing) {
if (directory == null) {
directory = PsiManager.getInstance(project).findDirectory(project.getBaseDir());
}
assert directory != null;
String filename = fileType.getIgnoreLanguage().getFilename();
PsiFile file = directory.findFile(filename);
VirtualFile virtualFile = file == null ? directory.getVirtualFile().findChild(filename) : file.getVirtualFile();
if (file == null && virtualFile == null && createIfMissing) {
file = new CreateFileCommandAction(project, directory, fileType).execute().getResultObject();
}
return file;
}Example 44
| Project: idea-latex-master File: LatexTemplatesFactory.java View source code |
public static LatexFile createFromTemplate(@NotNull final PsiDirectory directory, @NotNull final String name, @NotNull String fileName, @NotNull String templateName, boolean allowReformatting, @NonNls String... parameters) throws IncorrectOperationException {
final FileTemplate template = FileTemplateManager.getInstance(directory.getProject()).getInternalTemplate(templateName);
Project project = directory.getProject();
Properties properties = new Properties(FileTemplateManager.getInstance(project).getDefaultProperties());
// properties.setProperty(LOW_CASE_NAME_TEMPLATE_PROPERTY, name.substring(0, 1).toLowerCase() + name.substring(1));
for (int i = 0; i < parameters.length; i += 2) {
properties.setProperty(parameters[i], parameters[i + 1]);
}
String text;
try {
text = template.getText(properties);
} catch (Exception e) {
throw new RuntimeException("Unable to load template for " + FileTemplateManager.getInstance(project).internalTemplateToSubject(templateName), e);
}
final PsiFileFactory factory = PsiFileFactory.getInstance(project);
PsiFile file = factory.createFileFromText(fileName, LatexFileType.INSTANCE, text);
file = (PsiFile) directory.add(file);
if (file != null && allowReformatting && template.isReformatCode()) {
new ReformatCodeProcessor(project, file, null, false).run();
}
return (LatexFile) file;
}Example 45
| Project: idea.thermit-master File: AntDomFileReferenceSet.java View source code |
@NotNull
public Collection<PsiFileSystemItem> computeDefaultContexts() {
final AntDomElement element = myValue.getParentOfType(AntDomElement.class, false);
final AntDomProject containingProject = element != null ? element.getAntProject() : null;
if (containingProject != null) {
VirtualFile root = null;
if (isAbsolutePathReference()) {
root = LocalFileSystem.getInstance().getRoot();
} else {
if (element instanceof AntDomAnt) {
final PsiFileSystemItem dirValue = ((AntDomAnt) element).getAntFileDir().getValue();
if (dirValue instanceof PsiDirectory) {
root = dirValue.getVirtualFile();
}
}
if (root == null) {
final String basedir;
if (element instanceof AntDomIncludingDirective) {
basedir = containingProject.getContainingFileDir();
} else {
basedir = containingProject.getContextAntProject().getProjectBasedirPath();
}
if (basedir != null) {
root = LocalFileSystem.getInstance().findFileByPath(basedir);
}
}
}
if (root != null) {
final XmlElement xmlElement = containingProject.getXmlElement();
if (xmlElement != null) {
final PsiDirectory directory = xmlElement.getManager().findDirectory(root);
if (directory != null) {
return Collections.<PsiFileSystemItem>singleton(directory);
}
}
}
}
return super.computeDefaultContexts();
}Example 46
| Project: intelli-arc-master File: ArcTemplatesFactory.java View source code |
public static PsiFile createFromTemplate(final PsiDirectory directory, final String name, String fileName, String templateName, @NonNls String... parameters) throws IncorrectOperationException {
FileTemplateManager tMgr = FileTemplateManager.getInstance();
try {
FileTemplate template = tMgr.getTemplate(templateName);
String text = template.getText(defineTemplateProperties(name, parameters));
PsiFile file = PsiFileFactory.getInstance(directory.getProject()).createFileFromText(fileName, text);
return (PsiFile) directory.add(file);
} catch (Exception e) {
throw new RuntimeException("Unable to load template for " + tMgr.internalTemplateToSubject(templateName), e);
}
}Example 47
| Project: MPS-master File: MPSPsiModel.java View source code |
@Override
public boolean equals(Object obj) {
/* TODO: remove after fix in platform:
This override fixes check for equality of SmartPointerElementInfo and MPSPsiModel
in SmartPsiElementPointerImpl.createElementInfo() */
if (obj instanceof PsiDirectory && !(obj instanceof MPSPsiNodeBase)) {
return this.getVirtualFile().equals(((PsiDirectory) obj).getVirtualFile());
}
return super.equals(obj);
}Example 48
| Project: randori-plugin-intellij-master File: RandoriTemplatesFactory.java View source code |
public static PsiFile createFromTemplate(@NotNull PsiDirectory directory, @NotNull String name, @NotNull String fileName, @NotNull String templateName, @NonNls String... parameters) throws IncorrectOperationException {
FileTemplateManager templateManager = FileTemplateManager.getInstance();
FileTemplate template = templateManager.getJ2eeTemplate(templateName);
Properties properties = new Properties(templateManager.getDefaultProperties(directory.getProject()));
JavaTemplateUtil.setPackageNameAttribute(properties, directory);
properties.setProperty("NAME", name);
properties.setProperty("lowCaseName", name.substring(0, 1).toLowerCase() + name.substring(1));
for (int i = 0; i < parameters.length; i += 2) properties.setProperty(parameters[i], parameters[(i + 1)]);
String text;
try {
text = template.getText(properties);
} catch (Exception e) {
throw new RuntimeException("Unable to load template for " + templateManager.internalTemplateToSubject(templateName), e);
}
PsiFileFactory factory = PsiFileFactory.getInstance(directory.getProject());
PsiFile file = factory.createFileFromText(fileName, ActionScriptFileType.INSTANCE, text);
return (PsiFile) directory.add(file);
}Example 49
| Project: visage-compiler-master File: NewVisageClassAction.java View source code |
@NotNull
protected final PsiElement[] invokeDialog(Project project, PsiDirectory directory) {
Module module = ModuleUtil.findModuleForFile(directory.getVirtualFile(), project);
if (module == null)
return PsiElement.EMPTY_ARRAY;
MyInputValidator validator = new MyInputValidator(project, directory);
Messages.showInputDialog(project, "Enter a new class name", "New Visage Class", Messages.getQuestionIcon(), "", validator);
return validator.getCreatedElements();
}Example 50
| Project: i-pascal-master File: CreateModuleAction.java View source code |
@Override
protected void buildDialog(Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) {
builder.setTitle(PascalBundle.message("action.create.new.module"));
for (FileTemplate fileTemplate : getApplicableTemplates()) {
final String templateName = fileTemplate.getName();
final String shortName = getTemplateShortName(templateName);
final Icon icon = getTemplateIcon(templateName);
builder.addKind(shortName, icon, templateName);
}
}Example 51
| Project: idea-ofbiz-plugin-master File: OfbizFrameworkSupportProvider.java View source code |
public void run() {
final VirtualFile[] sourceRoots = ModuleRootManager.getInstance(module).getSourceRoots();
if (sourceRoots.length <= 0) {
return;
}
final PsiDirectory directory = PsiManager.getInstance(module.getProject()).findDirectory(sourceRoots[0]);
if (directory == null || directory.findFile(Constants.CONTROLLER_XML_DEFAULT_FILENAME) != null) {
return;
}
try {
final OfbizFacetConfiguration ofbizFacetConfiguration = ofbizFacet.getConfiguration();
final Set<OfbizFileSet> empty = Collections.emptySet();
final OfbizFileSet controllerFileSet = new OfbizFileSet(OfbizFileSet.getUniqueId(empty), OfbizFileSet.getUniqueName("Controller Default File Set", empty), ofbizFacetConfiguration);
final OfbizConfigsSercher searcher = new OfbizControllerConfigsSearcher(module);
searcher.search();
final MultiMap<Module, PsiFile> configFiles = searcher.getFilesByModules();
for (PsiFile psiFile : configFiles.values()) {
controllerFileSet.addFile(psiFile.getVirtualFile());
}
ofbizFacetConfiguration.getControllerFileSets().add(controllerFileSet);
//service fileset
final OfbizFileSet serviceFileSet = new OfbizFileSet(OfbizFileSet.getUniqueId(empty), OfbizFileSet.getUniqueName("Services Default File Set", empty), ofbizFacetConfiguration);
final OfbizConfigsSercher serviceSearcher = new OfbizServiceConfigsSearcher(module);
serviceSearcher.search();
final MultiMap<Module, PsiFile> serviceConfigFiles = serviceSearcher.getFilesByModules();
for (PsiFile psiFile : serviceConfigFiles.values()) {
serviceFileSet.addFile(psiFile.getVirtualFile());
}
ofbizFacetConfiguration.getServiceFileSets().add(serviceFileSet);
final NotificationListener showFacetSettingsListener = new NotificationListener() {
public void hyperlinkUpdate(@NotNull final Notification notification, @NotNull final HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
notification.expire();
ModulesConfigurator.showFacetSettingsDialog(ofbizFacet, null);
}
}
};
Notifications.Bus.notify(new Notification("Ofbiz", "Ofbiz Setup", "Ofbiz Facet has been created, please check <a href=\"more\">created fileset</a>", NotificationType.INFORMATION, showFacetSettingsListener), module.getProject());
} catch (Exception e) {
LOG.error("error creating struts.xml from template", e);
}
}Example 52
| Project: idea-php-class-templates-master File: PhpNewClassDialog.java View source code |
@Nullable protected PsiDirectory getDirectory() { VirtualFile directory = this.myDirectoryCombobox.getExistingParent(); if (directory != null) { PsiDirectory psiDirectory = PsiManager.getInstance(this.myProject).findDirectory(directory); if (psiDirectory != null) { return psiDirectory; } } return null; }
Example 53
| Project: intellij-haskell-master File: CreateHaskellFileAction.java View source code |
@Override
protected void buildDialog(Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) {
builder.setTitle(NEW_HASKELL_FILE).addKind("Empty module", HaskellIcons.FILE, "Haskell Module").setValidator(new InputValidatorEx() {
@Nullable
@Override
public String getErrorText(String inputString) {
final String error = " is not a valid Haskell module name.";
if (inputString.isEmpty()) {
return null;
}
if (VALID_MODULE_NAME_REGEX.matcher(inputString).matches()) {
return null;
}
return '\'' + inputString + '\'' + error;
}
@Override
public boolean checkInput(String inputString) {
return true;
}
@Override
public boolean canClose(String inputString) {
return getErrorText(inputString) == null;
}
});
}Example 54
| Project: intellij-haskforce-master File: CreateHaskellFileAction.java View source code |
@Override
protected void buildDialog(Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) {
builder.setTitle(NEW_HASKELL_FILE).addKind("Empty module", HaskellIcons.FILE, "Haskell Module").setValidator(new InputValidatorEx() {
@Nullable
@Override
public String getErrorText(String inputString) {
final String error = " is not a valid Haskell module name.";
if (inputString.isEmpty()) {
return null;
}
if (VALID_MODULE_NAME_REGEX.matcher(inputString).matches()) {
return null;
}
return '\'' + inputString + '\'' + error;
}
@Override
public boolean checkInput(String inputString) {
return true;
}
@Override
public boolean canClose(String inputString) {
return getErrorText(inputString) == null;
}
});
}Example 55
| Project: jstestdriver-idea-plugin-master File: StrutsFrameworkSupportProvider.java View source code |
public void run() {
final VirtualFile[] sourceRoots = ModuleRootManager.getInstance(module).getSourceRoots();
if (sourceRoots.length <= 0) {
return;
}
final PsiDirectory directory = PsiManager.getInstance(module.getProject()).findDirectory(sourceRoots[0]);
if (directory == null || directory.findFile(StrutsConstants.STRUTS_XML_DEFAULT_FILENAME) != null) {
return;
}
String template = StrutsFileTemplateGroupDescriptorFactory.STRUTS_2_0_XML;
final boolean is2_1orNewer = VersionComparatorUtil.compare(version.getVersionName(), "2.1") > 0;
final boolean is2_3orNewer = VersionComparatorUtil.compare(version.getVersionName(), "2.3") > 0;
if (is2_3orNewer) {
template = StrutsFileTemplateGroupDescriptorFactory.STRUTS_2_3_XML;
} else if (is2_1orNewer) {
final boolean is2_1_7X = VersionComparatorUtil.compare(version.getVersionName(), "2.1.7") > 0;
template = is2_1_7X ? StrutsFileTemplateGroupDescriptorFactory.STRUTS_2_1_7_XML : StrutsFileTemplateGroupDescriptorFactory.STRUTS_2_1_XML;
}
final FileTemplateManager fileTemplateManager = FileTemplateManager.getInstance();
final FileTemplate strutsXmlTemplate = fileTemplateManager.getJ2eeTemplate(template);
try {
final StrutsFacetConfiguration strutsFacetConfiguration = strutsFacet.getConfiguration();
// create empty struts.xml & fileset with all found struts-*.xml files (struts2.jar, plugins)
final PsiElement psiElement = FileTemplateUtil.createFromTemplate(strutsXmlTemplate, StrutsConstants.STRUTS_XML_DEFAULT_FILENAME, null, directory);
final Set<StrutsFileSet> empty = Collections.emptySet();
final StrutsFileSet fileSet = new StrutsFileSet(StrutsFileSet.getUniqueId(empty), StrutsFileSet.getUniqueName("Default File Set", empty), strutsFacetConfiguration);
fileSet.addFile(((XmlFile) psiElement).getVirtualFile());
final StrutsConfigsSearcher searcher = new StrutsConfigsSearcher(module);
searcher.search();
final MultiMap<VirtualFile, PsiFile> jarConfigFiles = searcher.getJars();
for (final VirtualFile virtualFile : jarConfigFiles.keySet()) {
final Collection<PsiFile> psiFiles = jarConfigFiles.get(virtualFile);
for (final PsiFile psiFile : psiFiles) {
fileSet.addFile(psiFile.getVirtualFile());
}
}
strutsFacetConfiguration.getFileSets().add(fileSet);
// create filter & mapping in web.xml
new WriteCommandAction.Simple(modifiableRootModel.getProject()) {
protected void run() throws Throwable {
final WebFacet webFacet = strutsFacet.getWebFacet();
final WebApp webApp = webFacet.getRoot();
assert webApp != null;
final Filter strutsFilter = webApp.addFilter();
strutsFilter.getFilterName().setStringValue("struts2");
@NonNls final String filterClass = is2_1orNewer ? StrutsConstants.STRUTS_2_1_FILTER_CLASS : StrutsConstants.STRUTS_2_0_FILTER_CLASS;
strutsFilter.getFilterClass().setStringValue(filterClass);
final FilterMapping filterMapping = webApp.addFilterMapping();
filterMapping.getFilterName().setValue(strutsFilter);
filterMapping.addUrlPattern().setStringValue("/*");
}
}.execute();
final NotificationListener showFacetSettingsListener = new NotificationListener() {
public void hyperlinkUpdate(@NotNull final Notification notification, @NotNull final HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
notification.expire();
ModulesConfigurator.showFacetSettingsDialog(strutsFacet, null);
}
}
};
Notifications.Bus.notify(new Notification("Struts 2", "Struts 2 Setup", "Struts 2 Facet has been created, please check <a href=\"more\">created fileset</a>", NotificationType.INFORMATION, showFacetSettingsListener), module.getProject());
} catch (Exception e) {
LOG.error("error creating struts.xml from template", e);
}
}Example 56
| Project: MVPHelper-master File: BaseDirGenerator.java View source code |
/**
* Locate the root dir of current project.<br/>
* For Android studio project, 'java' folder is always the root of any model by default.<br/>
* For IDEA java project, 'src' folder is always the root of any model by default.
*
* @param currentDir where the action happens
*/
private void locateRootDir(PsiDirectory currentDir) {
String currentDirName = currentDir.getName();
if (currentDirName.equals("java") || currentDirName.equals("src")) {
myCurrentDir = currentDir;
} else {
PsiDirectory parent = currentDir.getParent();
if (parent != null) {
//if this folder is not the root, then try its parent.
locateRootDir(parent);
} else {
//when there is no more parent, we reached the ROOT of a hard-disk...
//if we still can't locate myCurrentDir by now...
//I guess..not the plugin's fault.. =(
Messages.showErrorDialog("I can't imagine what happens to your project," + " technically, no project could reach here.\n" + " For your project match the IDEA's 'Java Project' definition," + " and it match our basic rule: 'Contract' under contract-package and 'Presenter' under presenter-package." + " Since it does happened, report us the detail please:" + " image of this dialog, image of your project structure tree, and your description\n" + ResourceBundle.getBundle("string").getString("feedBackUrl"), "Locate Root Dir Error");
throw new RuntimeException("The plugin cannot find a root dir like \"java\" or \"src\"");
}
}
}Example 57
| Project: mybatis-plugin-master File: GenerateMapperIntention.java View source code |
@Override
public void invoke(@NotNull final Project project, final Editor editor, PsiFile file) throws IncorrectOperationException {
PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
PsiClass clazz = PsiTreeUtil.getParentOfType(element, PsiClass.class);
Collection<PsiDirectory> directories = MapperUtils.findMapperDirectories(project);
if (CollectionUtils.isEmpty(directories)) {
handleChooseNewFolder(project, editor, clazz);
} else {
handleMutilDirectories(project, editor, clazz, directories);
}
}Example 58
| Project: needsmoredojo-master File: ImportResolver.java View source code |
@NotNull
public LinkedHashMap<String, PsiFile> getChoicesFromFiles(@NotNull PsiFile[] filesArray, @NotNull SourceLibrary[] libraries, @NotNull String module, @Nullable PsiFile originalModule, boolean prioritizeRelativePaths, boolean getMap) {
Map<String, PsiFile> moduleFileMap = new HashMap<String, PsiFile>();
SourcesLocator locator = new SourcesLocator();
List<String> choices = new ArrayList<String>();
for (int i = 0; i < filesArray.length; i++) {
PsiFile file = filesArray[i];
PsiDirectory directory = file.getContainingDirectory();
String result = directory.getVirtualFile().getCanonicalPath();
SourceLibrary firstLibrary = locator.getFirstLibraryThatIncludesFile(result, libraries);
if (firstLibrary != null) {
if (!firstLibrary.getPath().equals("")) {
result = firstLibrary.getName() + result.substring(result.indexOf(firstLibrary.getPath()) + firstLibrary.getPath().length());
}
result = result.substring(result.indexOf(firstLibrary.getName()));
result = result.replace('\\', '/') + '/' + file.getName().substring(0, file.getName().indexOf('.'));
String originalModulePath = null;
String relativePathOption = null;
String absolutePathOption = null;
if (originalModule != null) {
originalModulePath = originalModule.getContainingDirectory().getVirtualFile().getCanonicalPath();
SourceLibrary originalModuleLibrary = locator.getFirstLibraryThatIncludesFile(originalModulePath, libraries);
try {
originalModulePath = originalModuleLibrary.getName() + originalModulePath.substring(originalModulePath.indexOf(originalModuleLibrary.getPath()) + originalModuleLibrary.getPath().length());
String relativePath = FileUtil.convertToRelativePath(originalModulePath, result);
relativePath = NameResolver.convertRelativePathToDojoPath(relativePath);
if (relativePath != null) {
relativePathOption = relativePath;
}
} catch (IndexOutOfBoundsException exc) {
Logger.getLogger(ImportResolver.class).info(originalModulePath + " could not be used in a relative path import");
} catch (NullPointerException exc) {
Logger.getLogger(ImportResolver.class).info(originalModulePath + " could not be used in a relative path import");
}
}
absolutePathOption = result;
String pluginPostFix = NameResolver.getAMDPluginResourceIfPossible(module, true);
if (prioritizeRelativePaths && relativePathOption != null) {
choices.add(relativePathOption + pluginPostFix);
moduleFileMap.put(relativePathOption + pluginPostFix, file);
choices.add(absolutePathOption + pluginPostFix);
moduleFileMap.put(absolutePathOption + pluginPostFix, file);
} else {
choices.add(absolutePathOption + pluginPostFix);
moduleFileMap.put(absolutePathOption + pluginPostFix, file);
if (relativePathOption != null) {
choices.add(relativePathOption + pluginPostFix);
moduleFileMap.put(relativePathOption + pluginPostFix, file);
}
}
}
}
Collections.sort(choices, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
return getScore(o2, o1) - getScore(o1, o2);
}
});
LinkedHashMap<String, PsiFile> finalMapResults = new LinkedHashMap<String, PsiFile>();
for (String choice : choices) {
for (Map.Entry<String, PsiFile> entry : moduleFileMap.entrySet()) {
if (choice.equals(entry.getKey())) {
finalMapResults.put(entry.getKey(), entry.getValue());
break;
}
}
}
choices.add(module);
return finalMapResults;
}Example 59
| Project: WebStormRequireJsPlugin-master File: RequirejsProjectComponent.java View source code |
public List<String> getCompletion(PsiElement element) {
List<String> completions = new ArrayList<String>();
String value = element.getText().replace("'", "").replace("\"", "").replace("IntellijIdeaRulezzz ", "");
String valuePath = value;
boolean exclamationMark = value.contains("!");
String plugin = "";
int doubleDotCount = 0;
boolean notEndSlash = false;
String pathOnDots = "";
String dotString = "";
VirtualFile elementFile = element.getContainingFile().getOriginalFile().getVirtualFile();
if (exclamationMark) {
String[] exclamationMarkSplit = valuePath.split("!");
plugin = exclamationMarkSplit[0];
if (exclamationMarkSplit.length == 2) {
valuePath = exclamationMarkSplit[1];
} else {
valuePath = "";
}
}
if (exclamationMark) {
for (String moduleName : getModulesNames()) {
completions.add(plugin + '!' + moduleName);
}
} else {
completions.addAll(getModulesNames());
// expand current package
}
PsiDirectory fileDirectory = element.getContainingFile().getOriginalFile().getContainingDirectory();
if (null == fileDirectory) {
return completions;
}
String filePath = fileDirectory.getVirtualFile().getPath().replace(getWebDir(elementFile).getPath(), "");
if (filePath.startsWith("/")) {
filePath = filePath.substring(1);
}
boolean startSlash = valuePath.startsWith("/");
if (startSlash) {
valuePath = valuePath.substring(1);
}
boolean oneDot = valuePath.startsWith("./");
if (oneDot) {
if (filePath.isEmpty()) {
valuePath = valuePath.substring(2);
} else {
valuePath = valuePath.replaceFirst(".", filePath);
}
}
if (valuePath.startsWith("..")) {
doubleDotCount = FileUtils.getDoubleDotCount(valuePath);
String[] pathsOfPath = filePath.split("/");
if (pathsOfPath.length > 0) {
if (doubleDotCount > 0) {
if (doubleDotCount > pathsOfPath.length || filePath.isEmpty()) {
return new ArrayList<String>();
}
pathOnDots = FileUtils.getNormalizedPath(doubleDotCount, pathsOfPath);
dotString = StringUtil.repeat("../", doubleDotCount);
if (valuePath.endsWith("..")) {
notEndSlash = true;
}
if (valuePath.endsWith("..") || !StringUtil.isEmpty(pathOnDots)) {
dotString = dotString.substring(0, dotString.length() - 1);
}
valuePath = valuePath.replaceFirst(dotString, pathOnDots);
}
}
}
List<String> allFiles = FileUtils.getAllFilesInDirectory(getWebDir(elementFile), getWebDir(elementFile).getPath() + '/', "");
List<String> aliasFiles = requirePaths.getAllFilesOnPaths();
aliasFiles.addAll(packageConfig.getAllFilesOnPackages());
String requireMapModule = FileUtils.removeExt(element.getContainingFile().getOriginalFile().getVirtualFile().getPath().replace(getWebDir(elementFile).getPath() + '/', ""), ".js");
completions.addAll(requireMap.getCompletionByModule(requireMapModule));
String valuePathForAlias = valuePath;
if (!oneDot && 0 == doubleDotCount && !startSlash && !getBaseUrl().isEmpty()) {
valuePath = FileUtils.join(getBaseUrl(), valuePath);
}
for (String file : allFiles) {
if (file.startsWith(valuePath)) {
// Prepare file path
if (oneDot) {
if (filePath.isEmpty()) {
file = "./" + file;
} else {
file = file.replaceFirst(filePath, ".");
}
}
if (doubleDotCount > 0) {
if (!StringUtil.isEmpty(valuePath)) {
file = file.replace(pathOnDots, "");
}
if (notEndSlash) {
file = '/' + file;
}
file = dotString + file;
}
if (!oneDot && 0 == doubleDotCount && !startSlash && !getBaseUrl().isEmpty()) {
file = file.substring(getBaseUrl().length() + 1);
}
if (startSlash) {
file = '/' + file;
}
addToCompletion(completions, file, exclamationMark, plugin);
}
}
for (String file : aliasFiles) {
if (file.startsWith(valuePathForAlias)) {
addToCompletion(completions, file, exclamationMark, plugin);
}
}
return completions;
}Example 60
| Project: webtoper-master File: Utils.java View source code |
private static void collectFiles(Project project, String extension, List<VirtualFile> files, VirtualFile root) {
if (root.isDirectory()) {
PsiDirectory directory = PsiManager.getInstance(project).findDirectory(root);
if (directory != null) {
GlobalSearchScope scope = GlobalSearchScopes.directoryScope(directory, true);
files.addAll(FilenameIndex.getAllFilesByExt(project, extension, scope));
}
} else {
files.add(root);
}
}Example 61
| Project: android-drawable-importer-intellij-plugin-master File: RefactoringTask.java View source code |
private boolean checkFileExist(@Nullable PsiDirectory targetDirectory, int[] choice, PsiFile file, String name, String title) {
if (targetDirectory == null) {
return false;
}
final PsiFile existing = targetDirectory.findFile(name);
if (existing == null || existing.equals(file)) {
return false;
}
int selection;
if (choice == null || choice[0] == -1) {
final String message = String.format("File '%s' already exists in directory '%s'", name, targetDirectory.getVirtualFile().getPath());
String[] options = choice == null ? new String[] { "Overwrite", "Skip" } : new String[] { "Overwrite", "Skip", "Overwrite for all", "Skip for all" };
selection = Messages.showDialog(message, title, options, 0, Messages.getQuestionIcon());
if (selection == 2 || selection == 3) {
this.selection = selection;
}
} else {
selection = choice[0];
}
if (choice != null && selection > 1) {
choice[0] = selection % 2;
selection = choice[0];
}
if (selection == 0 && file != existing) {
existing.delete();
} else {
return true;
}
return false;
}Example 62
| Project: bitrixstorm-master File: BitrixSiteTemplate.java View source code |
public Hashtable<String, String> getTemplatesList() {
Hashtable<String, String> templates = new Hashtable<String, String>();
try {
PsiElement[] childrenLocal = null;
VirtualFile baseDir = null;
VirtualFile projectDir = this.project.getBaseDir();
if (BITRIX_ROOT_PATH == sep + "bitrix") {
baseDir = projectDir.findChild("bitrix").findChild("templates");
} else {
String[] dirs = BITRIX_ROOT_PATH_ESCAPED.split(sep);
if (dirs != null) {
for (int i = 0; i < dirs.length; i++) {
if (dirs[i] != null && !dirs[i].contentEquals("")) {
String dir = dirs[i];
baseDir = projectDir.findChild(dir);
}
}
baseDir = baseDir.findChild("templates");
}
}
if (baseDir == null)
return null;
PsiDirectory directory = PsiManager.getInstance(this.project).findDirectory(baseDir);
PsiElement[] children = directory.getChildren();
if (projectDir.findChild("local").exists() && projectDir.findChild("local").findChild("templates").exists()) {
PsiDirectory localDirectory = PsiManager.getInstance(this.project).findDirectory(projectDir.findChild("local").findChild("templates"));
childrenLocal = localDirectory.getChildren();
}
for (int i = 0; i < children.length; i++) {
templates.put(BitrixUtils.getFileNameByPsiElement(children[i]), BitrixUtils.getPathByPsiElement(children[i]));
}
if (childrenLocal != null) {
for (int i = 0; i < childrenLocal.length; i++) {
templates.put(BitrixUtils.getFileNameByPsiElement(childrenLocal[i]), BitrixUtils.getPathByPsiElement(childrenLocal[i]));
}
}
} catch (NullPointerException ex) {
return null;
}
return templates;
}Example 63
| Project: buck-master File: BuckCopyPasteProcessor.java View source code |
private VirtualFile referenceNameToBuckFile(Project project, String reference) {
// First test if it is a absolute path of a file.
File tryFile = new File(reference);
if (tryFile != null) {
VirtualFile file = VfsUtil.findFileByIoFile(tryFile, true);
if (file != null) {
return BuckBuildUtil.getBuckFileFromDirectory(file.getParent());
}
}
// Try class firstly.
PsiClass classElement = JavaPsiFacade.getInstance(project).findClass(reference, GlobalSearchScope.allScope(project));
if (classElement != null) {
VirtualFile file = PsiUtilCore.getVirtualFile(classElement);
return BuckBuildUtil.getBuckFileFromDirectory(file.getParent());
}
// Then try package.
PsiPackage packageElement = JavaPsiFacade.getInstance(project).findPackage(reference);
if (packageElement != null) {
PsiDirectory directory = packageElement.getDirectories()[0];
return BuckBuildUtil.getBuckFileFromDirectory(directory.getVirtualFile());
}
// Extract the package from the reference.
int index = reference.lastIndexOf(".");
if (index == -1) {
return null;
}
reference = reference.substring(0, index);
// Try to find the package again.
packageElement = JavaPsiFacade.getInstance(project).findPackage(reference);
if (packageElement != null) {
PsiDirectory directory = packageElement.getDirectories()[0];
return BuckBuildUtil.getBuckFileFromDirectory(directory.getVirtualFile());
}
return null;
}Example 64
| Project: esnippet_idea_plugin-master File: InsertSnippetFragmentAction.java View source code |
/**
* add macro support
*
* @param psiFile psi file
* @param rawCode raw code
* @return new code
*/
private static String addMacroSupport(PsiFile psiFile, String rawCode) {
String newCode = rawCode;
VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile != null) {
String fileName = virtualFile.getName();
newCode = newCode.replace("${file_name}", fileName);
if (!SnippetSearchAgentsFactory.RubyMinePlugin) {
PsiDirectory psiDirectory = psiFile.getParent();
if (psiDirectory != null) {
PsiPackage psiPackage = JavaDirectoryService.getInstance().getPackage(psiDirectory);
if (psiPackage != null && psiPackage.getName() != null) {
newCode = newCode.replace("${package}", psiPackage.getName());
}
}
}
}
return newCode;
}Example 65
| Project: intellij-copyright-plugin-master File: FileTypeUtil.java View source code |
public boolean isSupportedFile(PsiFile file) {
if (file == null || file instanceof PsiDirectory) {
return false;
}
FileType type = file.getFileType();
FileType match = types.get(type.getName());
if (match != null) {
if (type.equals(StdFileTypes.JAVA) && !(file instanceof PsiJavaFile)) {
return false;
}
if (type.equals(StdFileTypes.XML) && !(file instanceof XmlFile)) {
return false;
}
return !(type.equals(StdFileTypes.JSP) && !(file instanceof JspFile));
}
return false;
}Example 66
| Project: intellij-generator-plugin-master File: AbstractGenerator.java View source code |
private void createEmptyTargetClass() {
targetClass = psiFacade.findClass(qualifiedTargetClassName(), globalSearchScope);
if (targetClass == null) {
PsiDirectory sourceClassDirectory = sourceClassForGeneration.getContainingFile().getContainingDirectory();
targetClass = JavaDirectoryService.getInstance().createClass(sourceClassDirectory, targetClassName());
}
}Example 67
| Project: jetty-runner-master File: JettyRunnerEditor.java View source code |
/**
* Returns the most probable WebApps folder
* @param project Project
* @return String value
*/
private String getWebAppsFolder(Project project) {
// Using the api to look for the web.xml
PsiShortNamesCache namesCache = PsiShortNamesCache.getInstance(project);
PsiFile[] webXML = namesCache.getFilesByName("web.xml");
if (webXML == null || webXML.length < 1)
return "";
// Grab the first one that the api found
PsiFile file = webXML[0];
// The parent folder is the "WEB-INF" folder
PsiDirectory webInfFolder = file.getParent();
if (webInfFolder == null)
return "";
// The parent folder to "WEB-INF" is the WebApps folder
PsiDirectory webappFolder = webInfFolder.getParent();
if (webappFolder == null)
return "";
// Folder found, returns it to the user
VirtualFile virtualFile = webappFolder.getVirtualFile();
return virtualFile.getPresentableUrl();
}Example 68
| Project: json2java4idea-master File: NewClassAction.java View source code |
@Override
public void actionPerformed(@Nonnull AnActionEvent event) {
if (!isAvailable(event)) {
return;
}
project = event.getProject();
ideView = event.getData(DataKeys.IDE_VIEW);
final Injector injector = GuiceManager.getInstance(project).getInjector();
injector.injectMembers(this);
// 'selected' is null when directory selection is canceled although multiple directories are chosen.
final PsiDirectory selected = ideView.getOrChooseDirectory();
if (selected == null) {
return;
}
final NewClassDialog dialog = NewClassDialog.builder(project, bundle).nameValidator(nameValidatorProvider.get()).jsonValidator(jsonValidatorProvider.get()).actionListener(this).build();
dialog.show();
}Example 69
| Project: MetricsReloaded-master File: MetricsCommandLine.java View source code |
@Override
public void main(String[] args) {
if (outputXmlPath != null) {
final File file = new File(outputXmlPath);
final File parentFile = file.getParentFile();
if (parentFile != null && !parentFile.exists()) {
error("Could not find directory " + parentFile.getAbsolutePath());
}
}
final ApplicationEx application = (ApplicationEx) ApplicationManager.getApplication();
try {
final ApplicationInfoEx applicationInfo = (ApplicationInfoEx) ApplicationInfo.getInstance();
info("MetricsReloaded running on " + applicationInfo.getFullApplicationName());
application.doNotSave();
try {
info("Opening project...");
if (projectPath == null) {
projectPath = new File("").getAbsolutePath();
}
projectPath = projectPath.replace(File.separatorChar, '/');
final Project project = ProjectUtil.openOrImport(projectPath, null, false);
if (project == null) {
error("Unable to open project: " + projectPath);
}
application.runWriteAction(new Runnable() {
@Override
public void run() {
VirtualFileManager.getInstance().refreshWithoutFileWatcher(false);
}
});
PatchProjectUtil.patchProject(project);
info("Project " + project.getName() + " opened.");
final MetricsProfile profile = getMetricsProfile(metricsProfileName);
if (profile == null) {
error("Profile not found: " + metricsProfileName);
}
info("Calculating metrics");
final AnalysisScope analysisScope;
if (scope != null) {
final NamedScope namedScope = NamedScopesHolder.getScope(project, scope);
if (namedScope == null) {
error("Scope not found: " + scope);
}
analysisScope = new AnalysisScope(GlobalSearchScopesCore.filterScope(project, namedScope), project);
} else if (directory != null) {
directory = directory.replace(File.separatorChar, '/');
final VirtualFile vfsDir = LocalFileSystem.getInstance().findFileByPath(directory);
if (vfsDir == null) {
error("Directory not found: " + directory);
}
final PsiDirectory psiDirectory = PsiManager.getInstance(project).findDirectory(vfsDir);
if (psiDirectory == null) {
error("Directory not found: " + directory);
}
analysisScope = new AnalysisScope(psiDirectory);
} else {
analysisScope = new AnalysisScope(project);
}
ProgressManager.getInstance().runProcess(new Runnable() {
@Override
public void run() {
final MetricsRunImpl metricsRun = new MetricsRunImpl();
metricsRun.setProfileName(profile.getName());
metricsRun.setTimestamp(new TimeStamp());
metricsRun.setContext(analysisScope);
final MetricsExecutionContextImpl metricsExecutionContext = new MetricsExecutionContextImpl(project, analysisScope);
metricsExecutionContext.calculateMetrics(profile, metricsRun);
final Exporter exporter = new XMLExporter(metricsRun);
try {
if (outputXmlPath == null) {
final PrintWriter writer = new PrintWriter(System.out, true);
exporter.export(writer);
} else {
exporter.export(outputXmlPath);
}
} catch (IOException e) {
error(e.getMessage());
}
}
}, new ProgressIndicatorBase() {
private int lastPercent = 0;
@Override
public void setFraction(double fraction) {
final int percent = (int) (fraction * 100);
if (lastPercent != percent && !isIndeterminate()) {
lastPercent = percent;
trace("Calculating metrics " + lastPercent + "%");
}
}
});
info("Finished.");
} catch (Exception ex) {
error(ex);
}
application.exit(true, true);
} catch (Exception e) {
LOG.error(e);
error(e);
}
}Example 70
| Project: platform_build-master File: BuckCopyPasteProcessor.java View source code |
private VirtualFile referenceNameToBuckFile(Project project, String reference) {
// First test if it is a absolute path of a file.
File tryFile = new File(reference);
if (tryFile != null) {
VirtualFile file = VfsUtil.findFileByIoFile(tryFile, true);
if (file != null) {
return BuckBuildUtil.getBuckFileFromDirectory(file.getParent());
}
}
// Try class firstly.
PsiClass classElement = JavaPsiFacade.getInstance(project).findClass(reference, GlobalSearchScope.allScope(project));
if (classElement != null) {
VirtualFile file = PsiUtilCore.getVirtualFile(classElement);
return BuckBuildUtil.getBuckFileFromDirectory(file.getParent());
}
// Then try package.
PsiPackage packageElement = JavaPsiFacade.getInstance(project).findPackage(reference);
if (packageElement != null) {
PsiDirectory directory = packageElement.getDirectories()[0];
return BuckBuildUtil.getBuckFileFromDirectory(directory.getVirtualFile());
}
// Extract the package from the reference.
int index = reference.lastIndexOf(".");
if (index == -1) {
return null;
}
reference = reference.substring(0, index);
// Try to find the package again.
packageElement = JavaPsiFacade.getInstance(project).findPackage(reference);
if (packageElement != null) {
PsiDirectory directory = packageElement.getDirectories()[0];
return BuckBuildUtil.getBuckFileFromDirectory(directory.getVirtualFile());
}
return null;
}Example 71
| Project: pyscicomp-master File: NumpyDocString.java View source code |
/**
* Returns PyFunction object for specified fully qualified name accessible from specified reference.
*
* @param redirect A fully qualified name of function that is redirected to.
* @param reference An original reference element.
* @return Resolved function or null if it was not resolved.
*/
@Nullable
private static PyFunction resolveRedirectToFunction(@NotNull String redirect, @NotNull final PsiElement reference) {
PyQualifiedName qualifiedName = PyQualifiedName.fromDottedString(redirect);
final String functionName = qualifiedName.getLastComponent();
List<PsiElement> elements = ResolveImportUtil.resolveModule(qualifiedName.removeLastComponent(), reference.getContainingFile(), true, 0);
for (PsiElement element : elements) {
final PyFunction[] function = { null };
element.accept(new PyElementVisitor() {
@Override
public void visitDirectory(PsiDirectory dir) {
PsiElement element = PyUtil.getPackageElement(dir);
if (element != null) {
element.accept(this);
}
}
@Override
public void visitPyFile(PyFile file) {
PsiElement functionElement = file.getElementNamed(functionName);
if (functionElement instanceof PyFunction) {
function[0] = (PyFunction) functionElement;
}
}
});
if (function[0] != null) {
return function[0];
}
}
return null;
}Example 72
| Project: droidtestrec-master File: ToolsTestsRecorderAction.java View source code |
private void record(AnActionEvent event) {
project = ((Project) event.getData(PlatformDataKeys.PROJECT));
currentModule = ((ModulesComboBoxModel.ModuleWrapper) this.moduleBoxModel.getSelected()).getModule();
final String packageName;
PsiFile psiFile;
AccessToken token = WriteAction.start();
try {
final GradleBuildFile buildFile = GradleBuildFile.get(currentModule);
// save a copy of gradle build file
String buildFilePath = buildFile.getFile().getPath();
File buildF = new File(buildFilePath);
File dir = buildF.getParentFile();
File saved = new File(dir, GRADLE_BUILD_SAVED);
if (saved.exists()) {
saved.delete();
}
Files.copy(buildF.toPath(), saved.toPath());
final List<BuildFileStatement> dependencies = buildFile.getDependencies();
boolean espressoFound = false;
for (BuildFileStatement statement : dependencies) {
if ((statement instanceof Dependency)) {
Dependency dependency = (Dependency) statement;
if ((dependency.type == Dependency.Type.EXTERNAL) && (dependency.scope == com.android.tools.idea.gradle.parser.Dependency.Scope.ANDROID_TEST_COMPILE) && (dependency.data != null) && (dependency.data.toString().startsWith("com.android.support.test.espresso:espresso-core"))) {
espressoFound = true;
break;
}
}
}
if (!espressoFound) {
Messages.showErrorDialog(this.project, "<html>Failed to find dependencies for Espresso. You must set up Espresso as defined at " + "<a href='http://developer.android.com/training/testing/start/index.html#config-instrumented-tests'>http://developer.android.com/training/testing/start/index.html#config-instrumented-tests</a></html>", "Error");
this.recButton.setText(RECORD);
this.recButton.setIcon(IconLoader.getIcon("icons/rec.png"));
return;
}
Dependency dependency = findDepRecord(dependencies);
if (dependency == null) {
dependencies.add(new Dependency(com.android.tools.idea.gradle.parser.Dependency.Scope.COMPILE, Dependency.Type.FILES, ToolsTestsRecorderAction.this.jarPath));
new WriteCommandAction<Void>(project, "Test Recorder Start", buildFile.getPsiFile()) {
@Override
protected void run(@NotNull Result<Void> result) throws Throwable {
buildFile.setValue(BuildFileKey.DEPENDENCIES, dependencies);
}
}.execute();
}
uniqueId = System.currentTimeMillis();
Activity activity = ((ActivitiesComboBoxModel.ActivityWrapper) this.activitiesBoxModel.getSelected()).getActivity();
final PsiClass activityClass = (PsiClass) activity.getActivityClass().getValue();
com.intellij.psi.PsiManager manager = com.intellij.psi.PsiManager.getInstance(this.project);
psiFile = activityClass.getContainingFile();
final PsiDirectory psiDirectory = psiFile.getContainingDirectory();
packageName = ((com.intellij.psi.PsiJavaFile) activityClass.getContainingFile()).getPackageName();
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
try {
PsiFile testFile = psiDirectory.findFile(TEST_FILE_NAME);
if (testFile == null) {
testFile = psiDirectory.createFile(TEST_FILE_NAME);
}
ToolsTestsRecorderAction.this.testVirtualFile = testFile.getVirtualFile();
com.intellij.openapi.vfs.VfsUtil.saveText(ToolsTestsRecorderAction.this.testVirtualFile, ToolsTestsRecorderAction.template.replace("{ACTIVITY}", activityClass.getName()).replace("{PACKAGE}", packageName).replace("{CLASSNAME}", "AndrTestRec").replace("{ID}", String.valueOf(uniqueId)));
} catch (IOException e) {
Messages.showErrorDialog(ToolsTestsRecorderAction.this.project, e.getMessage(), "Error");
}
}
});
} catch (IOException e) {
e.printStackTrace();
Messages.showErrorDialog(this.project, "IO error : " + e.toString(), "Error");
return;
} finally {
token.finish();
}
RunManager runManager = RunManager.getInstance(this.project);
ConfigurationFactory factory;
RunConfiguration configuration;
String runConfigName = RUN_CONFIG_NAME + System.currentTimeMillis();
try {
// for Android Studio less them 1.5
org.jetbrains.android.run.testing.AndroidTestRunConfigurationType configurationType = new org.jetbrains.android.run.testing.AndroidTestRunConfigurationType();
factory = configurationType.getFactory();
org.jetbrains.android.run.testing.AndroidTestRunConfiguration runConfiguration = new org.jetbrains.android.run.testing.AndroidTestRunConfiguration(this.project, factory);
runConfiguration.setName(runConfigName);
runConfiguration.setModule(currentModule);
runConfiguration.setTargetSelectionMode(org.jetbrains.android.run.TargetSelectionMode.SHOW_DIALOG);
runConfiguration.TESTING_TYPE = 2;
runConfiguration.CLASS_NAME = (packageName + "." + ANDR_TEST_CLASSNAME);
configuration = runConfiguration;
} catch (NoClassDefFoundError e) {
com.android.tools.idea.run.testing.AndroidTestRunConfigurationType configurationType = new com.android.tools.idea.run.testing.AndroidTestRunConfigurationType();
factory = configurationType.getFactory();
com.android.tools.idea.run.testing.AndroidTestRunConfiguration runConfiguration = new com.android.tools.idea.run.testing.AndroidTestRunConfiguration(this.project, factory);
runConfiguration.setName(runConfigName);
runConfiguration.setModule(currentModule);
runConfiguration.setTargetSelectionMode(com.android.tools.idea.run.TargetSelectionMode.SHOW_DIALOG);
runConfiguration.TESTING_TYPE = 2;
runConfiguration.CLASS_NAME = (packageName + "." + ANDR_TEST_CLASSNAME);
configuration = runConfiguration;
}
com.intellij.execution.RunnerAndConfigurationSettings rcs = runManager.createConfiguration(configuration, factory);
if (PluginConfiguration.isLeaveRunConfiguration()) {
rcs.setTemporary(false);
runManager.addConfiguration(rcs, true);
} else {
rcs.setTemporary(true);
}
ExecutionManager executionManager = ExecutionManager.getInstance(this.project);
executionManager.restartRunProfile(this.project, com.intellij.execution.executors.DefaultRunExecutor.getRunExecutorInstance(), com.intellij.execution.DefaultExecutionTarget.INSTANCE, rcs, (ProcessHandler) null);
this.executionChecker = new ExecutionChecker(executionManager, runConfigName, this);
new java.util.Timer().schedule(this.executionChecker, 200L, 200L);
eventsList.clear(project, currentModule, psiFile);
}Example 73
| Project: Innovatian.Idea.PowerShell-master File: NewPsFileAction.java View source code |
protected String getActionName(PsiDirectory directory, String newName) {
return "New PowerShell Script";
}Example 74
| Project: intellij-demandware-master File: DWCreateDSFileAction.java View source code |
@Override
protected void buildDialog(Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) {
builder.setTitle("DS File").addKind("DS File", DWIcons.DW_DS_ICON, "DS File.ds").addKind("DS Script Node File", DWIcons.DW_DS_ICON, "DS Script Node File.ds");
}Example 75
| Project: pullupgen-master File: SisterClassesUtil.java View source code |
/* ------ Lookup for sub-classes / sister-classes ------ */
public static Collection<PsiClass> findDirectSubClassesInDirectory(@NotNull PsiClass superClass) {
final PsiDirectory superDir = getDirectoryOfClass(superClass);
return findDirectSubClassesInDirectory(superClass, superDir);
}Example 76
| Project: intellij-xquery-master File: CreateXQueryFileAction.java View source code |
@Override
protected void buildDialog(final Project project, PsiDirectory psiDirectory, CreateFileFromTemplateDialog.Builder builder) {
builder.setTitle(NEW_XQUERY_FILE).addKind("Library Module", XQueryIcons.FILE, LIBRARY_MODULE + DEFAULT_EXTENSION_WITH_DOT).addKind("Main Module", XQueryIcons.FILE, MAIN_MODULE + DEFAULT_EXTENSION_WITH_DOT).setValidator(getValidator());
}Example 77
| Project: kotlin-master File: MockFileManager.java View source code |
@Override
@Nullable
public PsiDirectory findDirectory(@NotNull VirtualFile vFile) {
throw new UnsupportedOperationException("Method findDirectory is not yet implemented in " + getClass().getName());
}