com.intellij.psi.templateLanguages.TemplateDataLanguageMappings#com.intellij.openapi.fileTypes.PlainTextLanguage源码实例Demo

下面列出了com.intellij.psi.templateLanguages.TemplateDataLanguageMappings#com.intellij.openapi.fileTypes.PlainTextLanguage 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: lsp4intellij   文件: LSPQuickDocAction.java
@Override
public void actionPerformed(AnActionEvent e) {
    Editor editor = e.getData(CommonDataKeys.EDITOR);
    VirtualFile file = FileDocumentManager.getInstance().getFile(editor.getDocument());
    Language language = PsiManager.getInstance(editor.getProject()).findFile(file).getLanguage();
    //Hack for IntelliJ 2018 TODO proper way
    if (LanguageDocumentation.INSTANCE.allForLanguage(language).isEmpty()
            || (Integer.parseInt(ApplicationInfo.getInstance().getMajorVersion()) > 2017)
            && language == PlainTextLanguage.INSTANCE) {
        EditorEventManager manager = EditorEventManagerBase.forEditor(editor);
        if (manager != null) {
            manager.quickDoc(editor);
        } else {
            super.actionPerformed(e);
        }
    } else
        super.actionPerformed(e);
}
 
public FluidFileViewProvider(PsiManager manager, VirtualFile file, boolean physical) {
    super(manager, file, physical);

    Language dataLang = TemplateDataLanguageMappings.getInstance(manager.getProject()).getMapping(file);
    if (dataLang == null) {
        dataLang = StdFileTypes.HTML.getLanguage();
    }

    if (dataLang instanceof TemplateLanguage) {
        myTemplateDataLanguage = PlainTextLanguage.INSTANCE;
    } else {
        // The substitutor signals, that a files content should be substituted
        Language mySubstitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(dataLang, file, manager.getProject());
        if (mySubstitutedLanguage == FluidLanguage.INSTANCE) {
            this.myTemplateDataLanguage = StdFileTypes.HTML.getLanguage();
        } else {
            this.myTemplateDataLanguage = mySubstitutedLanguage;
        }
    }
}
 
源代码3 项目: consulo   文件: CommitMessage.java
/**
 * Creates a text editor appropriate for creating commit messages.
 *
 * @param project project this commit message editor is intended for
 * @param forceSpellCheckOn if false, {@link com.intellij.openapi.vcs.VcsConfiguration#CHECK_COMMIT_MESSAGE_SPELLING} will control
 *                          whether or not the editor has spell check enabled
 * @return a commit message editor
 */
public static EditorTextField createCommitTextEditor(final Project project, boolean forceSpellCheckOn) {
  Set<EditorCustomization> features = new HashSet<EditorCustomization>();

  final SpellCheckerCustomization spellChecker = SpellCheckerCustomization.getInstance();
  VcsConfiguration configuration = VcsConfiguration.getInstance(project);
  if (configuration != null) {
    boolean enableSpellChecking = forceSpellCheckOn || configuration.CHECK_COMMIT_MESSAGE_SPELLING;
    if(spellChecker.isEnabled()) {
      features.add(spellChecker.getCustomization(enableSpellChecking));
    }
    features.add(new RightMarginEditorCustomization(configuration.USE_COMMIT_MESSAGE_MARGIN, configuration.COMMIT_MESSAGE_MARGIN_SIZE));
    features.add(WrapWhenTypingReachesRightMarginCustomization.getInstance(configuration.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN));
  } else {
    if(spellChecker.isEnabled()) {
      features.add(spellChecker.getCustomization(true));
    }
    features.add(new RightMarginEditorCustomization(false, -1));
  }

  features.add(SoftWrapsEditorCustomization.ENABLED);
  features.add(AdditionalPageAtBottomEditorCustomization.DISABLED);

  EditorTextFieldProvider service = ServiceManager.getService(project, EditorTextFieldProvider.class);
  return service.getEditorField(PlainTextLanguage.INSTANCE, project, features);
}
 
源代码4 项目: consulo   文件: NewEditChangelistPanel.java
private static EditorTextField createEditorField(final Project project, final int defaultLines) {
  final EditorTextFieldProvider service = ServiceManager.getService(project, EditorTextFieldProvider.class);
  final EditorTextField editorField;

  final Set<EditorCustomization> editorFeatures = ContainerUtil.newHashSet();
  final SpellCheckerCustomization spellChecker = SpellCheckerCustomization.getInstance();
  if(spellChecker.isEnabled())  {
    editorFeatures.add(spellChecker.getCustomization(true));
  }

  if (defaultLines == 1) {
    editorFeatures.add(HorizontalScrollBarEditorCustomization.DISABLED);
    editorFeatures.add(OneLineEditorCustomization.ENABLED);
  } else {
    editorFeatures.add(SoftWrapsEditorCustomization.ENABLED);
  }
  editorField = service.getEditorField(PlainTextLanguage.INSTANCE, project, editorFeatures);
  final int height = editorField.getFontMetrics(editorField.getFont()).getHeight();
  editorField.getComponent().setMinimumSize(new Dimension(100, (int)(height * 1.3)));
  return editorField;
}
 
@Override
public void handleDoubleClickOrEnter(SimpleTree tree, InputEvent inputEvent) {
    final SourceLocation location = getLocation();
    if (location != null && location.getSourceName() != null) {
        GraphQLTreeNodeNavigationUtil.openSourceLocation(myProject, location, false);
    } else if (error instanceof GraphQLInternalSchemaError) {
        String stackTrace = ExceptionUtil.getThrowableText(((GraphQLInternalSchemaError) error).getException());
        PsiFile file = PsiFileFactory.getInstance(myProject).createFileFromText("graphql-error.txt", PlainTextLanguage.INSTANCE, stackTrace);
        new OpenFileDescriptor(myProject, file.getVirtualFile()).navigate(true);
    }
}
 
源代码6 项目: editorconfig-jetbrains   文件: CodeStyleManager.java
private void applyCodeStyleSettings(final List<OutPair> outPairs, final CodeStyleSettings codeStyleSettings,
                                    final VirtualFile file) {
    // Apply indent options
    final String indentSize = Utils.configValueForKey(outPairs, indentSizeKey);
    final String tabWidth = Utils.configValueForKey(outPairs, tabWidthKey);
    final String indentStyle = Utils.configValueForKey(outPairs, indentStyleKey);
    final FileType fileType = file.getFileType();
    final Language language = fileType instanceof LanguageFileType ? ((LanguageFileType)fileType).getLanguage() :
        PlainTextLanguage.INSTANCE;
    final CommonCodeStyleSettings commonSettings = codeStyleSettings.getCommonSettings(language);
    final CommonCodeStyleSettings.IndentOptions indentOptions = commonSettings.getIndentOptions();
    applyIndentOptions(indentOptions, indentSize, tabWidth, indentStyle, file.getCanonicalPath());
}
 
源代码7 项目: Crucible4IDEA   文件: CommentForm.java
public CommentForm(@NotNull Project project, boolean isGeneral, boolean isReply, @Nullable FilePath filePath) {
  super(new BorderLayout());
  myProject = project;
  myGeneral = isGeneral;
  myReply = isReply;
  myFilePath = filePath;

  final EditorTextFieldProvider service = ServiceManager.getService(project, EditorTextFieldProvider.class);
  final Set<EditorCustomization> editorFeatures =
    ContainerUtil.newHashSet(SoftWrapsEditorCustomization.ENABLED,
                             SpellCheckingEditorCustomizationProvider.getInstance().getEnabledCustomization());
  myReviewTextField = service.getEditorField(PlainTextLanguage.INSTANCE, project, editorFeatures);

  final JScrollPane pane = ScrollPaneFactory.createScrollPane(myReviewTextField);
  pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  add(pane);

  myReviewTextField.setPreferredSize(new Dimension(ourBalloonWidth, ourBalloonHeight));

  myReviewTextField.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).
    put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK), "postComment");
  myReviewTextField.getActionMap().put("postComment", new AbstractAction() {
    @Override
    public void actionPerformed(ActionEvent e) {
      myOK = true;
      if (myBalloon != null) {
        myBalloon.dispose();
      }
    }
  });
}
 
源代码8 项目: consulo   文件: SingleRootFileViewProvider.java
private static Language calcBaseLanguage(@Nonnull VirtualFile file, @Nonnull Project project, @Nonnull final FileType fileType) {
  if (fileType.isBinary()) return Language.ANY;
  if (isTooLargeForIntelligence(file)) return PlainTextLanguage.INSTANCE;

  Language language = LanguageUtil.getLanguageForPsi(project, file);

  return language != null ? language : PlainTextLanguage.INSTANCE;
}
 
源代码9 项目: consulo   文件: TypedHandler.java
@Nonnull
static FileType getFileType(@Nonnull PsiFile file, @Nonnull Editor editor) {
  FileType fileType = file.getFileType();
  Language language = PsiUtilBase.getLanguageInEditor(editor, file.getProject());
  if (language != null && language != PlainTextLanguage.INSTANCE) {
    LanguageFileType associatedFileType = language.getAssociatedFileType();
    if (associatedFileType != null) fileType = associatedFileType;
  }
  return fileType;
}
 
源代码10 项目: consulo   文件: TextFieldWithAutoCompletion.java
public TextFieldWithAutoCompletion(final Project project,
                                   @Nonnull final TextFieldWithAutoCompletionListProvider<T> provider,
                                   final boolean showAutocompletionIsAvailableHint, @Nullable final String text) {
  super(PlainTextLanguage.INSTANCE, project, text == null ? "" : text);

  myShowAutocompletionIsAvailableHint = showAutocompletionIsAvailableHint;
  myProvider = provider;

  TextFieldWithAutoCompletionContributor.installCompletion(getDocument(), project, provider, true);
}
 
源代码11 项目: consulo   文件: TextFieldCompletionProvider.java
@Nonnull
public EditorTextField createEditor(Project project,
                                    final boolean shouldHaveBorder,
                                    @Nullable final Consumer<Editor> editorConstructionCallback)
{
  return new EditorTextField(createDocument(project, ""), project, PlainTextLanguage.INSTANCE.getAssociatedFileType()) {
    @Override
    protected boolean shouldHaveBorder() {
      return shouldHaveBorder;
    }

    @Override
    protected void updateBorder(@Nonnull EditorEx editor) {
      if (shouldHaveBorder) {
        super.updateBorder(editor);
      }
      else {
        editor.setBorder(null);
      }
    }

    @Override
    protected EditorEx createEditor() {
      EditorEx result = super.createEditor();
      if (editorConstructionCallback != null) {
        editorConstructionCallback.consume(result);
      }
      return result;
    }
  };
}
 
源代码12 项目: consulo   文件: TextFieldWithCompletion.java
public TextFieldWithCompletion(@Nullable Project project,
                               @Nonnull TextCompletionProvider provider,
                               @Nonnull String value,
                               boolean oneLineMode,
                               boolean autoPopup,
                               boolean forceAutoPopup,
                               boolean showHint) {
  super(PlainTextLanguage.INSTANCE, project, value, new TextCompletionUtil.DocumentWithCompletionCreator(provider, autoPopup),
        oneLineMode);
  myForceAutoPopup = forceAutoPopup;
  myShowHint = showHint;
}
 
源代码13 项目: consulo   文件: ScratchFileActions.java
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  Project project = e.getProject();
  if (project == null) return;
  ScratchFileCreationHelper.Context context = createContext(e, project);
  context.filePrefix = "buffer";
  context.createOption = ScratchFileService.Option.create_if_missing;
  context.fileCounter = ScratchFileActions::nextBufferIndex;
  if (context.language == null) context.language = PlainTextLanguage.INSTANCE;
  doCreateNewScratch(project, context);
}
 
源代码14 项目: Intellij-Dust   文件: DustFileViewProvider.java
public DustFileViewProvider(PsiManager manager, VirtualFile file, boolean physical) {
  super(manager, file, physical);

  // get the main language of the file
  Language dataLang = TemplateDataLanguageMappings.getInstance(manager.getProject()).getMapping(file);
  if (dataLang == null) dataLang = StdFileTypes.HTML.getLanguage();

  // some magic?
  if (dataLang instanceof TemplateLanguage) {
    myTemplateDataLanguage = PlainTextLanguage.INSTANCE;
  } else {
    myTemplateDataLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(dataLang, file, manager.getProject());
  }
}
 
源代码15 项目: lsp4intellij   文件: EditorEventManager.java
private boolean isSupportedLanguageFile(PsiFile file) {
    return file.getLanguage().isKindOf(PlainTextLanguage.INSTANCE)
            || FileUtils.isFileSupported(file.getVirtualFile());
}
 
源代码16 项目: intellij-quarkus   文件: LSPPSiElement.java
@NotNull
@Override
public Language getLanguage() {
    return PlainTextLanguage.INSTANCE;
}
 
源代码17 项目: intellij-csv-validator   文件: CsvLanguage.java
private CsvLanguage() {
    super(PlainTextLanguage.INSTANCE, "csv");
}
 
源代码18 项目: PackageTemplates   文件: ScriptDialog.java
private void createEditorField() {
    PsiFile psiFile = PsiFileFactory.getInstance(project).createFileFromText("Script", PlainTextLanguage.INSTANCE, code);

    etfCode = new EditorTextField(PsiDocumentManager.getInstance(project).getDocument(psiFile), project, PlainTextFileType.INSTANCE);
    etfCode.setOneLineMode(false);
}
 
源代码19 项目: consulo   文件: PsiPlainTextFileImpl.java
public PsiPlainTextFileImpl(FileViewProvider viewProvider) {
  super(PlainTextTokenTypes.PLAIN_TEXT_FILE, PlainTextTokenTypes.PLAIN_TEXT_FILE, viewProvider);
  myFileType = viewProvider.getBaseLanguage() != PlainTextLanguage.INSTANCE ? PlainTextFileType.INSTANCE : viewProvider.getFileType();
}
 
源代码20 项目: consulo   文件: DummyHolder.java
public DummyHolder(@Nonnull PsiManager manager, CharTable table, boolean validity) {
  this(manager, null, null, table, Boolean.valueOf(validity), PlainTextLanguage.INSTANCE);
}
 
源代码21 项目: consulo   文件: DummyHolder.java
public DummyHolder(@Nonnull PsiManager manager, @Nullable TreeElement contentElement, PsiElement context, @Nullable CharTable table) {
  this(manager, contentElement, context, table, null, language(context, PlainTextLanguage.INSTANCE));
}
 
源代码22 项目: consulo   文件: FormatConstants.java
private static boolean isPlainTextFile(@Nonnull Editor editor) {
  return editor.getProject() != null && PlainTextLanguage.INSTANCE.is(getLanguageInEditor(editor, editor.getProject()));
}
 
源代码23 项目: lsp4intellij   文件: LSPPsiElement.java
/**
 * Returns the language of the PSI element.
 *
 * @return the language instance.
 */
@NotNull
public Language getLanguage() {
    return PlainTextLanguage.INSTANCE;
}