当前位置: 首页>>代码示例>>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;未经允许,请勿转载。