當前位置: 首頁>>代碼示例>>Java>>正文


Java PsiDirectory.add方法代碼示例

本文整理匯總了Java中com.intellij.psi.PsiDirectory.add方法的典型用法代碼示例。如果您正苦於以下問題:Java PsiDirectory.add方法的具體用法?Java PsiDirectory.add怎麽用?Java PsiDirectory.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.psi.PsiDirectory的用法示例。


在下文中一共展示了PsiDirectory.add方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createFromTemplate

import com.intellij.psi.PsiDirectory; //導入方法依賴的package包/類
public static PsiElement createFromTemplate(PsiDirectory directory, String fileName, Template template, String text2) {
    final PsiFileFactory factory = PsiFileFactory.getInstance(directory.getProject());
    if ((new File(fileName)).exists()) {
        throw new RuntimeException("File already exists");
    }
    final PsiFile file = factory.createFileFromText(fileName, GCMLanguageType.INSTANCE, text2);
    return directory.add(file);
}
 
開發者ID:datathings,項目名稱:greycat-idea-plugin,代碼行數:9,代碼來源:GCMTemplatesFactory.java

示例2: actionPerformed

import com.intellij.psi.PsiDirectory; //導入方法依賴的package包/類
@Override
public void actionPerformed(AnActionEvent e) {
    VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE);
    try {
        Project project = e.getProject();
        SpecflowFileContents content = lexer.analyze(new String(file.contentsToByteArray()), project.getName());
        PsiFileFactory fileFactory = psiFileFactory.getInstance(project);
        PsiDirectory directory = psiDirectoryFactory.getInstance(project).createDirectory(file.getParent());
        directory.add(fileFactory.createFileFromText(file.getName()+"Feature.cs",content.feature));
        directory.add(fileFactory.createFileFromText(file.getName()+"Steps.cs",content.steps));
    } catch (IOException ioExeption) {

    }
}
 
開發者ID:kanekotic,項目名稱:Specflow.Rider,代碼行數:15,代碼來源:SpecflowGenerateCode.java

示例3: createSourceFile

import com.intellij.psi.PsiDirectory; //導入方法依賴的package包/類
/**
 * Writes a source file generated by a {@link Generator} to disk.
 *
 * @param project to write file in.
 * @param generator to generate file with.
 * @param directory to write file to.
 */
private static void createSourceFile(
    Project project, Generator generator, PsiDirectory directory) {
  PsiFile file =
      PsiFileFactory.getInstance(project)
          .createFileFromText(
              String.format("%s.java", generator.getClassName()),
              JavaLanguage.INSTANCE,
              generator.generate());
  directory.add(file);
}
 
開發者ID:uber,項目名稱:RIBs,代碼行數:18,代碼來源:GenerateAction.java

示例4: createFile

import com.intellij.psi.PsiDirectory; //導入方法依賴的package包/類
protected PsiFile createFile(Project project, @NotNull PsiDirectory psiDirectory, String fileName, String context, LanguageFileType fileType) {
    PsiFile psiFile = PsiFileFactory.getInstance(project).createFileFromText(fileName, fileType, context);
    // reformat class
    CodeStyleManager.getInstance(project).reformat(psiFile);
    if (psiFile instanceof PsiJavaFile) {
        JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(project);
        styleManager.optimizeImports(psiFile);
        styleManager.shortenClassReferences(psiFile);
    }
    psiDirectory.add(psiFile);
    return psiFile;
}
 
開發者ID:hykes,項目名稱:CodeGen,代碼行數:13,代碼來源:AbstractFileProvider.java


注:本文中的com.intellij.psi.PsiDirectory.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。