com.intellij.openapi.fileTypes.PlainTextFileType Java Examples

The following examples show how to use com.intellij.openapi.fileTypes.PlainTextFileType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RenameDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected void createNewNameComponent() {
  String[] suggestedNames = getSuggestedNames();
  myOldName = UsageViewUtil.getShortName(myPsiElement);
  myNameSuggestionsField = new NameSuggestionsField(suggestedNames, myProject, PlainTextFileType.INSTANCE, myEditor) {
    @Override
    protected boolean shouldSelectAll() {
      return myEditor == null || myEditor.getSettings().isPreselectRename();
    }
  };
  if (myPsiElement instanceof PsiFile && myEditor == null) {
    myNameSuggestionsField.selectNameWithoutExtension();
  }
  myNameChangedListener = new NameSuggestionsField.DataChanged() {
    @Override
    public void dataChanged() {
      processNewNameChanged();
    }
  };
  myNameSuggestionsField.addDataChangedListener(myNameChangedListener);

}
 
Example #2
Source File: AnnotateRevisionAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
protected VirtualFile getFile(@Nonnull 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()) {
    @Nonnull
    @Override
    public FileType getFileType() {
      FileType type = super.getFileType();
      if (!type.isBinary()) return type;
      if (!currentFileType.isBinary()) return currentFileType;
      return PlainTextFileType.INSTANCE;
    }
  };
}
 
Example #3
Source File: FileProviderFactory.java    From CodeGen with MIT License 6 votes vote down vote up
/**
 * 根据文件后缀获取文件类型
 */
public static FileType getFileType(String suffix) {
    if (StringUtils.isBlank(suffix)) {
        return PlainTextFileType.INSTANCE;
    }
    String extension = suffix.toLowerCase();
    FileType fileType = FILE_TYPES.get(extension);
    if (fileType == null) {
        for (FileType ft : FileTypeManager.getInstance().getRegisteredFileTypes()) {
            if (extension.equals(ft.getDefaultExtension())) {
                fileType = ft;
                FILE_TYPES.put(extension, ft);
                break;
            }
        }
    }
    return StringUtils.nullOr(fileType, PlainTextFileType.INSTANCE);
}
 
Example #4
Source File: ParameterNameHintsConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private static EditorTextField createEditorField(@Nonnull String text, @Nullable TextRange rangeToSelect) {
  Document document = EditorFactory.getInstance().createDocument(text);
  EditorTextField field = new EditorTextField(document, null, PlainTextFileType.INSTANCE, false, false);
  field.setPreferredSize(new Dimension(200, 350));
  field.addSettingsProvider(editor -> {
    editor.setVerticalScrollbarVisible(true);
    editor.setHorizontalScrollbarVisible(true);
    editor.getSettings().setAdditionalLinesCount(2);
    if (rangeToSelect != null) {
      editor.getCaretModel().moveToOffset(rangeToSelect.getStartOffset());
      editor.getScrollingModel().scrollVertically(document.getTextLength() - 1);
      editor.getSelectionModel().setSelection(rangeToSelect.getStartOffset(), rangeToSelect.getEndOffset());
    }
  });
  return field;
}
 
Example #5
Source File: PluginAdvertiserEditorNotificationProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@Nonnull VirtualFile file, @Nonnull FileEditor fileEditor) {
  if (file.getFileType() != PlainTextFileType.INSTANCE && !(file.getFileType() instanceof AbstractFileType)) return null;

  final String extension = file.getExtension();
  if (extension == null) {
    return null;
  }

  if (myEnabledExtensions.contains(extension) || isIgnoredFile(file)) return null;

  UnknownExtension fileFeatureForChecking = new UnknownExtension(FileTypeFactory.FILE_TYPE_FACTORY_EP.getName(), file.getName());

  List<PluginDescriptor> allPlugins = PluginsAdvertiserHolder.getLoadedPluginDescriptors();

  Set<PluginDescriptor> byFeature = PluginsAdvertiser.findByFeature(allPlugins, fileFeatureForChecking);
  if (!byFeature.isEmpty()) {
    return createPanel(file, byFeature);

  }
  return null;
}
 
Example #6
Source File: ExportToFileUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected JComponent createCenterPanel() {
  final Document document = ((EditorFactoryImpl)EditorFactory.getInstance()).createDocument(true);
  ((DocumentImpl)document).setAcceptSlashR(true);

  myTextArea = EditorFactory.getInstance().createEditor(document, myProject, PlainTextFileType.INSTANCE, true);
  final EditorSettings settings = myTextArea.getSettings();
  settings.setLineNumbersShown(false);
  settings.setLineMarkerAreaShown(false);
  settings.setFoldingOutlineShown(false);
  settings.setRightMarginShown(false);
  settings.setAdditionalLinesCount(0);
  settings.setAdditionalColumnsCount(0);
  settings.setAdditionalPageAtBottom(false);
  ((EditorEx)myTextArea).setBackgroundColor(UIUtil.getInactiveTextFieldBackgroundColor());
  return myTextArea.getComponent();
}
 
Example #7
Source File: PostfixDescriptionPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void showUsages(@Nonnull 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();
}
 
Example #8
Source File: ExternalSystemTasksPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
@javax.annotation.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);
}
 
Example #9
Source File: SyntaxHighlighterOverEditorHighlighter.java    From consulo with Apache License 2.0 6 votes vote down vote up
public SyntaxHighlighterOverEditorHighlighter(SyntaxHighlighter _highlighter, VirtualFile file, Project project) {
  if (file.getFileType() == PlainTextFileType.INSTANCE) { // optimization for large files, PlainTextSyntaxHighlighterFactory is slow
    highlighter = new PlainSyntaxHighlighter();
    lexer = highlighter.getHighlightingLexer();
  } else {
    highlighter = _highlighter;
    LayeredLexer.ourDisableLayersFlag.set(Boolean.TRUE);
    EditorHighlighter editorHighlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(project, file);

    try {
      if (editorHighlighter instanceof LayeredLexerEditorHighlighter) {
        lexer = new LexerEditorHighlighterLexer(editorHighlighter, false);
      }
      else {
        lexer = highlighter.getHighlightingLexer();
      }
    }
    finally {
      LayeredLexer.ourDisableLayersFlag.set(null);
    }
  }
}
 
Example #10
Source File: SelectionQuotingTypedHandlerTest.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void testRuby7852ErrantEditor() {
  myFixture.configureByText(PlainTextFileType.INSTANCE, "\"aaa\"\nbbb\n\n");
  myFixture.getEditor().getCaretModel().moveToOffset(0);
  myFixture.getEditor().getSelectionModel().setSelection(0, 5);
  final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction();
  performAction(myFixture.getProject(), new Runnable() {
    @Override
    public void run() {
      typedAction.actionPerformed(myFixture.getEditor(), '\'', ((EditorEx)myFixture.getEditor()).getDataContext());
    }
  });
  myFixture.getEditor().getSelectionModel().removeSelection();
  myFixture.checkResult("'aaa'\nbbb\n\n");

  myFixture.getEditor().getCaretModel().moveToOffset(myFixture.getEditor().getDocument().getLineStartOffset(3));
  performAction(myFixture.getProject(), new Runnable() {
    @Override
    public void run() {
      typedAction.actionPerformed(myFixture.getEditor(), 'A', ((EditorEx)myFixture.getEditor()).getDataContext());
      typedAction.actionPerformed(myFixture.getEditor(), 'B', ((EditorEx)myFixture.getEditor()).getDataContext());
    }
  });
  myFixture.checkResult("'aaa'\nbbb\n\nAB");
}
 
Example #11
Source File: FileIncludeManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
private PsiFileSystemItem doResolve(@Nonnull final FileIncludeInfo info, @Nonnull final PsiFile context) {
  if (info instanceof FileIncludeInfoImpl) {
    String id = ((FileIncludeInfoImpl)info).providerId;
    FileIncludeProvider provider = id == null ? null : myProviderMap.get(id);
    final PsiFileSystemItem resolvedByProvider = provider == null ? null : provider.resolveIncludedFile(info, context);
    if (resolvedByProvider != null) {
      return resolvedByProvider;
    }
  }

  PsiFileImpl psiFile = (PsiFileImpl)myPsiFileFactory.createFileFromText("dummy.txt", PlainTextFileType.INSTANCE, info.path);
  psiFile.setOriginalFile(context);
  return new FileReferenceSet(psiFile) {
    @Override
    protected boolean useIncludingFileAsContext() {
      return false;
    }
  }.resolve();
}
 
Example #12
Source File: DiffContentFactoryImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private static DocumentContent createImpl(@javax.annotation.Nullable Project project,
                                          @Nonnull String text,
                                          @Nullable FileType fileType,
                                          @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;
}
 
Example #13
Source File: CreateFileAction.java    From PackageTemplates with Apache License 2.0 6 votes vote down vote up
@Override
    public void doRun() {
        PsiDirectory psiParent = VFSHelper.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;
        }
    }
 
Example #14
Source File: SelectionQuotingTypedHandlerTest.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void doTest(@Nonnull final String cs, @Nonnull String before, @Nonnull String expected) {
  final boolean smarterSelection = Registry.is("editor.smarterSelectionQuoting");
  Registry.get("editor.smarterSelectionQuoting").setValue(true);
  try {
    myFixture.configureByText(PlainTextFileType.INSTANCE, before);
    final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction();

    performAction(myFixture.getProject(), new Runnable() {
      @Override
      public void run() {
        for (int i = 0, max = cs.length(); i < max; i++) {
          final char c = cs.charAt(i);
          typedAction.actionPerformed(myFixture.getEditor(), c, ((EditorEx)myFixture.getEditor()).getDataContext());
        }
      }
    });
    myFixture.checkResult(expected);
  } finally {
    Registry.get("editor.smarterSelectionQuoting").setValue(smarterSelection);
  }
}
 
Example #15
Source File: DiffUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #16
Source File: TextOnlyTreeStructureProvider.java    From intellij-sdk-docs with Apache License 2.0 6 votes vote down vote up
@NotNull
@Override
public Collection<AbstractTreeNode<?>> modify(@NotNull AbstractTreeNode<?> parent,
                                           @NotNull Collection<AbstractTreeNode<?>> children,
                                           ViewSettings settings) {
  ArrayList<AbstractTreeNode<?>> nodes = new ArrayList<>();
  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;
}
 
Example #17
Source File: TabbedLanguageCodeStylePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("ConstantConditions")
@Nonnull
@Override
protected FileType getFileType() {
  Language language = getDefaultLanguage();
  return language != null ? language.getAssociatedFileType() : PlainTextFileType.INSTANCE;
}
 
Example #18
Source File: ChangeListChooserPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public MyEditorComboBox(Project project) {
  super(PREF_WIDTH);
  setEditor(new StringComboboxEditor(project, PlainTextFileType.INSTANCE, this) {
    @Override
    protected void onEditorCreate(EditorEx editor) {
      super.onEditorCreate(editor);
      getDocument().putUserData(CONTINUE_RUN_COMPLETION, true);
    }
  });
}
 
Example #19
Source File: TextViewer.java    From consulo with Apache License 2.0 5 votes vote down vote up
public TextViewer(@Nonnull Document document, @Nonnull Project project, boolean embeddedIntoDialogWrapper, boolean useSoftWraps) {
  super(document, project, PlainTextFileType.INSTANCE, true, false);

  myEmbeddedIntoDialogWrapper = embeddedIntoDialogWrapper;
  myUseSoftWraps = useSoftWraps;
  setFontInheritedFromLAF(false);
}
 
Example #20
Source File: TemplateCommentPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void initEditor() {
  if (myEditor == null) {
    myPreviewEditorPanel.removeAll();
    EditorFactory editorFactory = EditorFactory.getInstance();
    myDocument = editorFactory.createDocument("");

    myEditor = editorFactory.createEditor(myDocument, myProject, ObjectUtil.notNull(myFileType, PlainTextFileType.INSTANCE), true);
    CopyrightConfigurable.setupEditor(myEditor);

    myPreviewEditorPanel.add(myEditor.getComponent(), BorderLayout.CENTER);
  }
}
 
Example #21
Source File: ProjectViewPsiTreeChangeListener.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected void childrenChanged(PsiElement parent, final boolean stopProcessingForThisModificationCount) {
  if (parent instanceof PsiDirectory && isFlattenPackages()) {
    addSubtreeToUpdateByRoot();
    return;
  }

  long newModificationCount = myModificationTracker.getModificationCount();
  if (newModificationCount == myModificationCount) return;
  if (stopProcessingForThisModificationCount) {
    myModificationCount = newModificationCount;
  }

  while (true) {
    if (parent == null) break;
    if (parent instanceof PsiFile) {
      VirtualFile virtualFile = ((PsiFile)parent).getVirtualFile();
      if (virtualFile != null && virtualFile.getFileType() != PlainTextFileType.INSTANCE) {
        // adding a class within a file causes a new node to appear in project view => entire dir should be updated
        parent = ((PsiFile)parent).getContainingDirectory();
        if (parent == null) break;
      }
    }
    else if (parent instanceof PsiDirectory && ScratchUtil.isScratch(((PsiDirectory)parent).getVirtualFile())) {
      addSubtreeToUpdateByRoot();
      break;
    }

    if (addSubtreeToUpdateByElementFile(parent)) {
      break;
    }

    if (parent instanceof PsiFile || parent instanceof PsiDirectory) break;
    parent = parent.getParent();
  }
}
 
Example #22
Source File: DocumentationManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private static String generateFileDoc(@Nonnull PsiFile psiFile, boolean withUrl) {
  VirtualFile file = PsiUtilCore.getVirtualFile(psiFile);
  File ioFile = file == null || !file.isInLocalFileSystem() ? null : VfsUtilCore.virtualToIoFile(file);
  BasicFileAttributes attr = null;
  try {
    attr = ioFile == null ? null : Files.readAttributes(Paths.get(ioFile.toURI()), BasicFileAttributes.class);
  }
  catch (Exception ignored) {
  }
  if (attr == null) return null;
  FileType type = file.getFileType();
  String typeName = type == UnknownFileType.INSTANCE ? "Unknown" : type == PlainTextFileType.INSTANCE ? "Text" : type instanceof ArchiveFileType ? "Archive" : type.getId();
  String languageName = type.isBinary() ? "" : psiFile.getLanguage().getDisplayName();
  return (withUrl ? DocumentationMarkup.DEFINITION_START + file.getPresentableUrl() + DocumentationMarkup.DEFINITION_END + DocumentationMarkup.CONTENT_START : "") +
         getVcsStatus(psiFile.getProject(), file) +
         getScope(psiFile.getProject(), file) +
         "<p><span class='grayed'>Size:</span> " +
         StringUtil.formatFileSize(attr.size()) +
         "<p><span class='grayed'>Type:</span> " +
         typeName +
         (type.isBinary() || typeName.equals(languageName) ? "" : " (" + languageName + ")") +
         "<p><span class='grayed'>Modified:</span> " +
         DateFormatUtil.formatDateTime(attr.lastModifiedTime().toMillis()) +
         "<p><span class='grayed'>Created:</span> " +
         DateFormatUtil.formatDateTime(attr.creationTime().toMillis()) +
         (withUrl ? DocumentationMarkup.CONTENT_END : "");
}
 
Example #23
Source File: RevealingSpaceComboboxEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
public RevealingSpaceComboboxEditor(final Project project, ComboBox comboBox) {
  super(project, PlainTextFileType.INSTANCE, comboBox);

  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
      Editor editor = getEditor();
      if (editor != null) {
        editor.getSettings().setWhitespacesShown(true);
      }
    }
  });
}
 
Example #24
Source File: TabbedLanguageCodeStylePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("ConstantConditions")
@Nonnull
@Override
protected FileType getFileType() {
  Language language = TabbedLanguageCodeStylePanel.this.getDefaultLanguage();
  return language != null ? language.getAssociatedFileType() : PlainTextFileType.INSTANCE;
}
 
Example #25
Source File: CustomizableLanguageCodeStylePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
protected FileType getFileType() {
  if (getDefaultLanguage() != null) {
    FileType assocType = getDefaultLanguage().getAssociatedFileType();
    if (assocType != null) {
      return assocType;
    }
  }
  return PlainTextFileType.INSTANCE;
}
 
Example #26
Source File: DiffPreviewPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public DiffContent[] getContents() {
  return new DiffContent[]{
          new SimpleContent(LEFT_TEXT, PlainTextFileType.INSTANCE),
          new SimpleContent(CENTER_TEXT, PlainTextFileType.INSTANCE),
          new SimpleContent(RIGHT_TEXT, PlainTextFileType.INSTANCE)
  };
}
 
Example #27
Source File: IdeConsoleRootType.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public Image substituteIcon(@Nonnull Project project, @Nonnull VirtualFile file) {
  if (file.isDirectory()) return null;
  FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(file.getNameSequence());
  Image icon = fileType == UnknownFileType.INSTANCE || fileType == PlainTextFileType.INSTANCE ? AllIcons.Debugger.Console : ObjectUtils.notNull(fileType.getIcon(), AllIcons.Debugger.Console);
  return ImageEffects.layered(icon, AllIcons.Nodes.RunnableMark);
}
 
Example #28
Source File: EditorComboWithBrowseButton.java    From consulo with Apache License 2.0 5 votes vote down vote up
public EditorComboWithBrowseButton(final ActionListener browseActionListener,
                                   final String text,
                                   @Nonnull final Project project,
                                   final String recentsKey) {
  super(new EditorComboBox(text, project, PlainTextFileType.INSTANCE), browseActionListener);
  final List<String> recentEntries = RecentsManager.getInstance(project).getRecentEntries(recentsKey);
  if (recentEntries != null) {
    setHistory(ArrayUtil.toStringArray(recentEntries));
  }
  if (text != null && text.length() > 0) {
    prependItem(text);
  }
}
 
Example #29
Source File: LanguageTextField.java    From consulo with Apache License 2.0 5 votes vote down vote up
public LanguageTextField(@Nullable Language language,
                         @Nonnull Project project,
                         @Nonnull String value,
                         @Nonnull DocumentCreator documentCreator,
                         boolean oneLineMode) {
  super(documentCreator.createDocument(value, language, project), project,
        language != null ? language.getAssociatedFileType() : PlainTextFileType.INSTANCE, language == null, oneLineMode);

  myLanguage = language;
  myProject = project;

  setEnabled(language != null);
}
 
Example #30
Source File: DummyHolder.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public FileType getFileType() {
  PsiElement context = getContext();
  if (context != null) {
    PsiFile containingFile = context.getContainingFile();
    if (containingFile != null) return containingFile.getFileType();
  }
  final LanguageFileType fileType = myLanguage.getAssociatedFileType();
  return fileType != null ? fileType : PlainTextFileType.INSTANCE;
}