当前位置: 首页>>代码示例>>Java>>正文


Java PlainTextFileType类代码示例

本文整理汇总了Java中com.intellij.openapi.fileTypes.PlainTextFileType的典型用法代码示例。如果您正苦于以下问题:Java PlainTextFileType类的具体用法?Java PlainTextFileType怎么用?Java PlainTextFileType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PlainTextFileType类属于com.intellij.openapi.fileTypes包,在下文中一共展示了PlainTextFileType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doRun

import com.intellij.openapi.fileTypes.PlainTextFileType; //导入依赖的package包/类
@Override
    public void doRun() {
        PsiDirectory psiParent = PsiHelper.findPsiDirByPath(project, file.getParentFile().getPath());
        if(psiParent==null){
            ReportHelper.setState(ExecutionState.FAILED);
            return;
        }

        try {
            PsiFile psiResultFile = PsiFileFactory.getInstance(project).createFileFromText(file.getName(), PlainTextFileType.INSTANCE, content);
//            PsiFile psiFile = psiDirectory.createFile(psiDirectory.createFile(file.getName()).getName());
//            psiFile.getVirtualFile().
            psiParent.add(psiResultFile);
        } catch (IncorrectOperationException ex){
            Logger.log("CreateFileAction " + ex.getMessage());
            Logger.printStack(ex);
            ReportHelper.setState(ExecutionState.FAILED);
            return;
        }
    }
 
开发者ID:CeH9,项目名称:PackageTemplates,代码行数:21,代码来源:CreateFileAction.java

示例2: testTextFileClearingDoesNotCrash

import com.intellij.openapi.fileTypes.PlainTextFileType; //导入依赖的package包/类
public void testTextFileClearingDoesNotCrash() {
  configureByText(PlainTextFileType.INSTANCE, "foo bar goo\n");
  SmartPsiElementPointer pointer = createPointer(myFile.getFirstChild());

  PlatformTestUtil.tryGcSoftlyReachableObjects();
  assertEquals(myFile.getFirstChild(), pointer.getElement());

  Document document = myFile.getViewProvider().getDocument();
  document.deleteString(0, document.getTextLength());

  PlatformTestUtil.tryGcSoftlyReachableObjects();
  assertEquals(myFile.getFirstChild(), pointer.getElement());

  PsiDocumentManager.getInstance(myProject).commitAllDocuments();
  PlatformTestUtil.tryGcSoftlyReachableObjects();
  assertEquals(myFile.getFirstChild(), pointer.getElement());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:SmartPsiElementPointersTest.java

示例3: testLargeFileWithManyChangesPerformance

import com.intellij.openapi.fileTypes.PlainTextFileType; //导入依赖的package包/类
public void testLargeFileWithManyChangesPerformance() {
  configureByText(PlainTextFileType.INSTANCE, StringUtil.repeat("foo foo \n", 50000));
  final TextRange range = TextRange.from(10, 10);
  final SmartPsiFileRange pointer = getPointerManager().createSmartPsiFileRangePointer(myFile, range);

  final Document document = myFile.getViewProvider().getDocument();
  assertNotNull(document);

  PlatformTestUtil.startPerformanceTest("smart pointer range update", 25000, () -> {
    for (int i = 0; i < 10000; i++) {
      document.insertString(i * 20 + 100, "x\n");
      assertFalse(PsiDocumentManager.getInstance(myProject).isCommitted(document));
      assertEquals(range, pointer.getRange());
    }
  }).cpuBound().assertTiming();

  PsiDocumentManager.getInstance(myProject).commitAllDocuments();
  assertEquals(range, pointer.getRange());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:SmartPsiElementPointersTest.java

示例4: testConvergingRanges

import com.intellij.openapi.fileTypes.PlainTextFileType; //导入依赖的package包/类
public void testConvergingRanges() {
  configureByText(PlainTextFileType.INSTANCE, "aba");
  final Document document = myFile.getViewProvider().getDocument();
  assertNotNull(document);

  SmartPsiFileRange range1 = getPointerManager().createSmartPsiFileRangePointer(myFile, TextRange.create(0, 2));
  SmartPsiFileRange range2 = getPointerManager().createSmartPsiFileRangePointer(myFile, TextRange.create(1, 3));

  document.deleteString(0, 1);
  document.deleteString(1, 2);
  assertEquals(TextRange.create(0, 1), range1.getRange());
  assertEquals(TextRange.create(0, 1), range2.getRange());

  PsiDocumentManager.getInstance(myProject).commitAllDocuments();
  assertEquals(TextRange.create(0, 1), range1.getRange());
  assertEquals(TextRange.create(0, 1), range2.getRange());

  document.insertString(0, "a");
  assertEquals(TextRange.create(1, 2), range1.getRange());
  assertEquals(TextRange.create(1, 2), range2.getRange());

  PsiDocumentManager.getInstance(myProject).commitAllDocuments();
  assertEquals(TextRange.create(1, 2), range1.getRange());
  assertEquals(TextRange.create(1, 2), range2.getRange());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:SmartPsiElementPointersTest.java

示例5: doTest

import com.intellij.openapi.fileTypes.PlainTextFileType; //导入依赖的package包/类
private void doTest(boolean enabled, String document) {
  InspectionProfileImpl.INIT_INSPECTIONS = true;
  try {
    myFixture.configureByText(PlainTextFileType.INSTANCE, document);
    myFixture.enableInspections(new SpellCheckingInspection());

    EditorCustomization customization = SpellCheckingEditorCustomizationProvider.getInstance().getCustomization(enabled);
    assertNotNull(customization);
    customization.customize((EditorEx)myFixture.getEditor());

    myFixture.checkHighlighting();
  }
  finally {
    InspectionProfileImpl.INIT_INSPECTIONS = false;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:SpellCheckingEditorCustomizationTest.java

示例6: createNotificationPanel

import com.intellij.openapi.fileTypes.PlainTextFileType; //导入依赖的package包/类
@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
  if (file.getFileType() != PlainTextFileType.INSTANCE) return null;

  final String extension = file.getExtension();
  final String fileName = file.getName();
  if (extension != null && isIgnored("*." + extension) || isIgnored(fileName)) return null;

  final PluginsAdvertiser.KnownExtensions knownExtensions = PluginsAdvertiser.loadExtensions();
  if (knownExtensions != null) {
    final EditorNotificationPanel panel = extension != null ? createPanel("*." + extension, knownExtensions) : null;
    if (panel != null) {
      return panel;
    }
    return createPanel(fileName, knownExtensions);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PluginAdvertiserEditorNotificationProvider.java

示例7: testRestoreState

import com.intellij.openapi.fileTypes.PlainTextFileType; //导入依赖的package包/类
public void testRestoreState() throws Exception {
  String text = "some<caret> text<caret>\n" +
                "some <selection><caret>other</selection> <selection>text<caret></selection>\n" +
                "<selection>ano<caret>ther</selection> line";
  PsiFile psiFile = myFixture.configureByText(PlainTextFileType.INSTANCE, text);
  VirtualFile virtualFile = psiFile.getVirtualFile();
  assertNotNull(virtualFile);
  myManager.openFile(virtualFile, false);
  myManager.closeAllFiles();
  FileEditor[] fileEditors = myManager.openFile(virtualFile, false);
  assertNotNull(fileEditors);
  assertEquals(1, fileEditors.length);
  Editor editor = ((TextEditor)fileEditors[0]).getEditor();

  verifyEditorState(editor, text);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:EditorMultiCaretStateRestoreTest.java

示例8: testInfoTestAttributes

import com.intellij.openapi.fileTypes.PlainTextFileType; //导入依赖的package包/类
public void testInfoTestAttributes() throws Exception {
  LanguageExtensionPoint<Annotator> extension = new LanguageExtensionPoint<Annotator>();
  extension.language="TEXT";
  extension.implementationClass = TestAnnotator.class.getName();
  PlatformTestUtil.registerExtension(ExtensionPointName.create(LanguageAnnotators.EP_NAME), extension, getTestRootDisposable());
  myFixture.configureByText(PlainTextFileType.INSTANCE, "foo");
  EditorColorsScheme scheme = new EditorColorsSchemeImpl(new DefaultColorsScheme()){{initFonts();}};
  scheme.setAttributes(HighlighterColors.TEXT, new TextAttributes(Color.black, Color.white, null, null, Font.PLAIN));
  ((EditorEx)myFixture.getEditor()).setColorsScheme(scheme);
  myFixture.doHighlighting();
  MarkupModel model = DocumentMarkupModel.forDocument(myFixture.getEditor().getDocument(), getProject(), false);
  RangeHighlighter[] highlighters = model.getAllHighlighters();
  assertEquals(1, highlighters.length);
  TextAttributes attributes = highlighters[0].getTextAttributes();
  assertNotNull(attributes);
  assertNull(attributes.getBackgroundColor());
  assertNull(attributes.getForegroundColor());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:DocumentMarkupModelTest.java

示例9: getFile

import com.intellij.openapi.fileTypes.PlainTextFileType; //导入依赖的package包/类
@Nullable
@Override
protected VirtualFile getFile(@NotNull AnActionEvent e) {
  VcsFileRevision revision = getFileRevision(e);
  if (revision == null) return null;

  final FileType currentFileType = myAnnotation.getFile().getFileType();
  FilePath filePath =
    (revision instanceof VcsFileRevisionEx ? ((VcsFileRevisionEx)revision).getPath() : VcsUtil.getFilePath(myAnnotation.getFile()));
  return new VcsVirtualFile(filePath.getPath(), revision, VcsFileSystem.getInstance()) {
    @NotNull
    @Override
    public FileType getFileType() {
      FileType type = super.getFileType();
      if (!type.isBinary()) return type;
      if (!currentFileType.isBinary()) return currentFileType;
      return PlainTextFileType.INSTANCE;
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:AnnotateRevisionAction.java

示例10: showUsages

import com.intellij.openapi.fileTypes.PlainTextFileType; //导入依赖的package包/类
private static void showUsages(@NotNull JPanel panel, @Nullable TextDescriptor exampleUsage) {
  String text = "";
  FileType fileType = PlainTextFileType.INSTANCE;
  if (exampleUsage != null) {
    try {
      text = exampleUsage.getText();
      String name = exampleUsage.getFileName();
      FileTypeManagerEx fileTypeManager = FileTypeManagerEx.getInstanceEx();
      String extension = fileTypeManager.getExtension(name);
      fileType = fileTypeManager.getFileTypeByExtension(extension);
    }
    catch (IOException e) {
      LOG.error(e);
    }
  }

  ((ActionUsagePanel)panel.getComponent(0)).reset(text, fileType);
  panel.repaint();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PostfixDescriptionPanel.java

示例11: updateFileTypeForEditorComponent

import com.intellij.openapi.fileTypes.PlainTextFileType; //导入依赖的package包/类
private void updateFileTypeForEditorComponent(@NotNull ComboBox inputComboBox) {
  final Component editorComponent = inputComboBox.getEditor().getEditorComponent();

  if (editorComponent instanceof EditorTextField) {
    boolean isRegexp = myCbRegularExpressions.isSelectedWhenSelectable();
    FileType fileType = PlainTextFileType.INSTANCE;
    if (isRegexp) {
      Language regexpLanguage = Language.findLanguageByID("RegExp");
      if (regexpLanguage != null) {
        LanguageFileType regexpFileType = regexpLanguage.getAssociatedFileType();
        if (regexpFileType != null) {
          fileType = regexpFileType;
        }
      }
    }
    String fileName = isRegexp ? "a.regexp" : "a.txt";
    final PsiFile file = PsiFileFactory.getInstance(myProject).createFileFromText(fileName, fileType, ((EditorTextField)editorComponent).getText(), -1, true);

    ((EditorTextField)editorComponent).setNewDocumentAndFileType(fileType, PsiDocumentManager.getInstance(myProject).getDocument(file));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:FindDialog.java

示例12: modify

import com.intellij.openapi.fileTypes.PlainTextFileType; //导入依赖的package包/类
@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent,
                                           @NotNull Collection<AbstractTreeNode> children,
                                           ViewSettings settings) {
  ArrayList<AbstractTreeNode> nodes = new ArrayList<AbstractTreeNode>();
  for (AbstractTreeNode child : children) {
    if (child instanceof PsiFileNode) {
      VirtualFile file = ((PsiFileNode) child).getVirtualFile();
      if (file != null && !file.isDirectory() && !(file.getFileType() instanceof PlainTextFileType)) {
        continue;
      }
    }
    nodes.add(child);
  }
  return nodes;
}
 
开发者ID:JetBrains,项目名称:intellij-sdk-docs,代码行数:18,代码来源:TextOnlyTreeStructureProvider.java

示例13: buildLocation

import com.intellij.openapi.fileTypes.PlainTextFileType; //导入依赖的package包/类
@Nullable
private Location buildLocation() {
  if (mySelectedTaskProvider == null) {
    return null;
  }
  ExternalTaskExecutionInfo task = mySelectedTaskProvider.produce();
  if (task == null) {
    return null;
  }

  String projectPath = task.getSettings().getExternalProjectPath();
  String name = myExternalSystemId.getReadableName() + projectPath + StringUtil.join(task.getSettings().getTaskNames(), " ");
  // We create a dummy text file instead of re-using external system file in order to avoid clashing with other configuration producers.
  // For example gradle files are enhanced groovy scripts but we don't want to run them via regular IJ groovy script runners.
  // Gradle tooling api should be used for running gradle tasks instead. IJ execution sub-system operates on Location objects
  // which encapsulate PsiElement and groovy runners are automatically applied if that PsiElement IS-A GroovyFile.
  PsiFile file = PsiFileFactory.getInstance(myProject).createFileFromText(name, PlainTextFileType.INSTANCE, "nichts");

  return new ExternalSystemTaskLocation(myProject, file, task);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:ExternalSystemTasksPanel.java

示例14: createEditorHighlighter

import com.intellij.openapi.fileTypes.PlainTextFileType; //导入依赖的package包/类
@javax.annotation.Nullable
private static EditorHighlighter createEditorHighlighter(@Nullable Project project, @Nonnull DocumentContent content) {
  FileType type = content.getContentType();
  VirtualFile file = content.getHighlightFile();
  Language language = content.getUserData(DiffUserDataKeys.LANGUAGE);

  EditorHighlighterFactory highlighterFactory = EditorHighlighterFactory.getInstance();
  if (language != null) {
    SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(language, project, file);
    return highlighterFactory.createEditorHighlighter(syntaxHighlighter, EditorColorsManager.getInstance().getGlobalScheme());
  }
  if (file != null) {
    if ((type == null || type == PlainTextFileType.INSTANCE) || file.getFileType() == type || file instanceof LightVirtualFile) {
      return highlighterFactory.createEditorHighlighter(project, file);
    }
  }
  if (type != null) {
    return highlighterFactory.createEditorHighlighter(project, type);
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:22,代码来源:DiffUtil.java

示例15: createImpl

import com.intellij.openapi.fileTypes.PlainTextFileType; //导入依赖的package包/类
@Nonnull
private static DocumentContent createImpl(@Nullable Project project,
                                          @Nonnull String text,
                                          @Nullable FileType fileType,
                                          @javax.annotation.Nullable String fileName,
                                          @Nullable VirtualFile highlightFile,
                                          @javax.annotation.Nullable Charset charset,
                                          @javax.annotation.Nullable Boolean bom,
                                          boolean respectLineSeparators,
                                          boolean readOnly) {
  if (UnknownFileType.INSTANCE == fileType) fileType = PlainTextFileType.INSTANCE;

  // TODO: detect invalid (different across the file) separators ?
  LineSeparator separator = respectLineSeparators ? StringUtil.detectSeparators(text) : null;
  String correctedContent = StringUtil.convertLineSeparators(text);

  Document document = createDocument(project, correctedContent, fileType, fileName, readOnly);
  DocumentContent content = new DocumentContentImpl(project, document, fileType, highlightFile, separator, charset, bom);

  if (fileName != null) content.putUserData(DiffUserDataKeysEx.FILE_NAME, fileName);

  return content;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:DiffContentFactoryImpl.java


注:本文中的com.intellij.openapi.fileTypes.PlainTextFileType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。