Examples of PsiDirectory


Examples of com.intellij.psi.PsiDirectory

                                              @NotNull VirtualFile rootDir,
                                              @NotNull String templateName,
                                              @NotNull String fileName,
                                              @NotNull Properties properties) throws Exception {
    rootDir.refresh(false, false);
    PsiDirectory directory = PsiManager.getInstance(project).findDirectory(rootDir);
    if (directory != null) {
      return createFromTemplate(templateName, fileName, directory, properties);
    }
    return null;
  }
View Full Code Here

Examples of com.intellij.psi.PsiDirectory

    @NotNull
    protected PsiElement[] create(String newName, PsiDirectory directory) throws Exception {
        HaskellFileType type = HaskellFileType.INSTANCE;
        String ext = type.getDefaultExtension();
        Project project = directory.getProject();
        PsiDirectory moduleDir = directory;
        int length = newName.length() - 1;
        while (newName.charAt(length) == '.') {
            newName = newName.substring(0, length);
            length--;
        }
        String suffix = "." + ext;
        if (newName.toLowerCase().endsWith(suffix)) {
            newName = newName.substring(0, newName.length() - suffix.length());
        }
        String[] fileNames = newName.split("\\.");
        int depth = fileNames.length;
        String moduleName = fileNames[depth - 1];
        boolean needsModuleName = Character.isUpperCase(moduleName.charAt(0));
        String parentPackages = ProjectRootManager.getInstance(project).getFileIndex().getPackageNameByDirectory(directory.getVirtualFile());
        StringBuilder packages = new StringBuilder(
            "".equals(parentPackages) || !needsModuleName
                ? ""
                : parentPackages + "."
        );
        for (int i = 0; i < depth - 1; i++) {
            String fileName = fileNames[i];
            // todo: check before create
            // todo: check correct module names
            if ("".equals(fileName)) {
                throw new IncorrectOperationException("File name cannot be empty");
            }
            char oldChar = fileName.charAt(0);
            String dirName = fileName.replace(oldChar, Character.toUpperCase(oldChar));
            PsiDirectory subDir = moduleDir.findSubdirectory(dirName);
            moduleDir = subDir == null ? moduleDir.createSubdirectory(dirName) : subDir;
            if (needsModuleName) {
                packages.append(dirName).append('.');
            }
        }
View Full Code Here

Examples of com.intellij.psi.PsiDirectory

    if (psiFile != null && psiFile.getManager().isInProject(psiFile)) {
      final VirtualFile file = psiFile.getVirtualFile();
      if (file != null && file.isValid() && file.getFileType() instanceof ArchiveFileType && acceptNonProjectDirectories()) {
        final VirtualFile jarRoot = JarFileSystem.getInstance().getJarRootForLocalFile(file);
        if (jarRoot != null) {
          final PsiDirectory psiDirectory = psiFile.getManager().findDirectory(jarRoot);
          if (psiDirectory != null) {
            return new AnalysisScope(psiDirectory);
          }
        }
      }
      return new AnalysisScope(psiFile);
    }

    final VirtualFile[] virtualFiles = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
    final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
    if (virtualFiles != null && project != null) { //analyze on selection
      final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
      if (virtualFiles.length == 1) {
        final PsiDirectory psiDirectory = PsiManager.getInstance(project).findDirectory(virtualFiles[0]);
        if (psiDirectory != null && (acceptNonProjectDirectories() || psiDirectory.getManager().isInProject(psiDirectory))) {
          return new AnalysisScope(psiDirectory);
        }
      }
      final Set<VirtualFile> files = new HashSet<VirtualFile>();
      for (VirtualFile vFile : virtualFiles) {
View Full Code Here

Examples of com.intellij.psi.PsiDirectory

                if (roots.length == 0) return;

                if (roots.length == 1) {
                    result.setResult(roots[0]);
                } else {
                    PsiDirectory defaultDir = PackageUtil.findPossiblePackageDirectoryInModule(module, packageName);
                    result.setResult(MoveClassesOrPackagesUtil.chooseSourceRoot(targetPackage, new SmartList<VirtualFile>(roots), defaultDir));
                }
            }
        }.execute().getResultObject();
View Full Code Here

Examples of com.intellij.psi.PsiDirectory

        String extendsClass = extendClassEditor.getText();
        boolean createMarkup = createAssociatedMarkupFileCheckBox.isSelected();
        boolean chooseDifferentDestination = chooseDifferentDestinationFolderCheckBox.isSelected();

        if (module != null && psiPackage != null && createMarkup && chooseDifferentDestination) {
            PsiDirectory directory = WicketFileUtil.selectTargetDirectory(psiPackage.getQualifiedName(), project, module);
            if (directory == null) {
                return; // aborted
            }
            markupDirectory = directory;
        }
View Full Code Here

Examples of com.intellij.psi.PsiDirectory

    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) {
                return; // aborted
            }
            destinationDirectory = directory;
        }
View Full Code Here

Examples of com.intellij.psi.PsiDirectory

        {
            if (!project.isInitialized())
            {
                return null; // VirtualFile.getIcon() removed in v 11
            }
            PsiDirectory directory = PsiManager.getInstance(project).findDirectory(baseDir);
            return directory != null ? directory.getIcon(1) : null; // // VirtualFile.getIcon() removed in v 11
        }
        return null;
    }
View Full Code Here

Examples of com.intellij.psi.PsiDirectory

      public AbstractTreeNode createRootNode() {
        VirtualFile rootDir = findRootDir(project, suiteBundle);
        if (rootDir == null) {
          rootDir = myProject.getBaseDir();
        }
        PsiDirectory psiRootDir = PsiManager.getInstance(myProject).findDirectory(rootDir);
        return new CoverageListRootNode(myProject, psiRootDir, mySuitesBundle, myStateBean);
      }
    };
  }
View Full Code Here

Examples of com.intellij.psi.PsiDirectory

      assertNotNull("Neither class nor file " + s + " not found", child);
      files.add(myFixture.getPsiManager().findFile(child));
    }
    final VirtualFile child1 = myFixture.findFileInTempDir(getTestName(true) + "/" + targetDirName);
    assertNotNull("Target dir " + targetDirName + " not found", child1);
    final PsiDirectory targetDirectory = myFixture.getPsiManager().findDirectory(child1);
    assertNotNull(targetDirectory);

    new MoveFilesOrDirectoriesProcessor(myFixture.getProject(), PsiUtilCore.toPsiElementArray(files), targetDirectory,
                                        false, true, null, null).run();
    FileDocumentManager.getInstance().saveAllDocuments();
View Full Code Here

Examples of com.intellij.psi.PsiDirectory

  @NotNull
  @Override
  public PsiDirectory getDefaultStepDefinitionFolder(@NotNull GherkinStep step) {
    PsiFile featureFile = step.getContainingFile();
    final PsiDirectory dir = findStepDefinitionDirectory(featureFile);
    if (dir == null) {
      final PsiDirectory featureParentDir = featureFile.getParent();
      assert featureParentDir != null;

      final Ref<PsiDirectory> dirRef = new Ref<PsiDirectory>();
      new WriteCommandAction.Simple(step.getProject(),
                                    CucumberBundle.message("cucumber.quick.fix.create.step.command.name.add")) {
        @Override
        protected void run() throws Throwable {
          // create steps_definitions directory
          dirRef.set(featureParentDir.createSubdirectory(CucumberUtil.STEP_DEFINITIONS_DIR_NAME));
        }
      }.execute();

      return dirRef.get();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.