Java 类com.intellij.openapi.fileTypes.impl.AbstractFileType 实例源码

项目:intellij-ce-playground    文件:CommentByLineCommentHandler.java   
@Nullable
private static Commenter findCommenter(Editor editor, PsiFile file, final int line) {
  final FileType fileType = file.getFileType();
  if (fileType instanceof AbstractFileType) {
    return ((AbstractFileType)fileType).getCommenter();
  }

  Document document = editor.getDocument();
  int lineStartOffset = document.getLineStartOffset(line);
  int lineEndOffset = document.getLineEndOffset(line) - 1;
  final CharSequence charSequence = document.getCharsSequence();
  lineStartOffset = CharArrayUtil.shiftForward(charSequence, lineStartOffset, " \t");
  lineEndOffset = CharArrayUtil.shiftBackward(charSequence, lineEndOffset < 0 ? 0 : lineEndOffset, " \t");
  final Language lineStartLanguage = PsiUtilCore.getLanguageAtOffset(file, lineStartOffset);
  final Language lineEndLanguage = PsiUtilCore.getLanguageAtOffset(file, lineEndOffset);
  return CommentByBlockCommentHandler.getCommenter(file, editor, lineStartLanguage, lineEndLanguage);
}
项目:tools-idea    文件:CommentByLineCommentHandler.java   
@Nullable
private Commenter findCommenter(final int line) {
  final FileType fileType = myFile.getFileType();
  if (fileType instanceof AbstractFileType) {
    return ((AbstractFileType)fileType).getCommenter();
  }

  int lineStartOffset = myDocument.getLineStartOffset(line);
  int lineEndOffset = myDocument.getLineEndOffset(line) - 1;
  final CharSequence charSequence = myDocument.getCharsSequence();
  lineStartOffset = CharArrayUtil.shiftForward(charSequence, lineStartOffset, " \t");
  lineEndOffset = CharArrayUtil.shiftBackward(charSequence, lineEndOffset < 0 ? 0 : lineEndOffset, " \t");
  final Language lineStartLanguage = PsiUtilBase.getLanguageAtOffset(myFile, lineStartOffset);
  final Language lineEndLanguage = PsiUtilBase.getLanguageAtOffset(myFile, lineEndOffset);
  return CommentByBlockCommentHandler.getCommenter(myFile, myEditor, lineStartLanguage, lineEndLanguage);
}
项目:tools-idea    文件:StandardFileTypeRegistrator.java   
private static void init(final AbstractFileType abstractFileType) {
  SyntaxTable table = abstractFileType.getSyntaxTable();
  CompletionUtil.registerCompletionData(abstractFileType,new SyntaxTableCompletionData(table));

  if (!isEmpty(table.getStartComment()) && !isEmpty(table.getEndComment()) ||
      !isEmpty(table.getLineComment())) {
    abstractFileType.setCommenter(new MyCommenter(abstractFileType));
  }

  if (table.isHasBraces() || table.isHasBrackets() || table.isHasParens()) {
    BraceMatchingUtil.registerBraceMatcher(abstractFileType,new CustomFileTypeBraceMatcher());
  }

  TypedHandler.registerQuoteHandler(abstractFileType, new CustomFileTypeQuoteHandler());

}
项目:consulo    文件:PluginAdvertiserEditorNotificationProvider.java   
@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) || UnknownFeaturesCollector.getInstance(myProject).isIgnored(createFileFeatureForIgnoring(file))) return null;

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

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

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

  }
  return null;
}
项目:intellij-ce-playground    文件:CustomFileTypeEditorTest.java   
public void testInsertDeleteQuotes() throws Exception {
  configureByFile(BASE_PATH + "InsertDeleteQuote.cs");
  EditorTestUtil.performTypingAction(getEditor(), '"');
  checkResultByFile(BASE_PATH + "InsertDeleteQuote_after.cs");

  configureByFile(BASE_PATH+"InsertDeleteQuote_after.cs");
  EditorTestUtil.performTypingAction(getEditor(), BACKSPACE_FAKE_CHAR);
  checkResultByFile(BASE_PATH+"InsertDeleteQuote.cs");

  FileType extension = FileTypeManager.getInstance().getFileTypeByExtension("pl");
  assertTrue("Test is not set up correctly:"+extension, extension instanceof AbstractFileType);
  configureByFile(BASE_PATH + "InsertDeleteQuote.pl");
  EditorTestUtil.performTypingAction(getEditor(), '"');
  checkResultByFile(BASE_PATH + "InsertDeleteQuote_after.pl");

  configureByFile(BASE_PATH+"InsertDeleteQuote_after.pl");
  EditorTestUtil.performTypingAction(getEditor(), BACKSPACE_FAKE_CHAR);
  checkResultByFile(BASE_PATH+"InsertDeleteQuote.pl");

  configureByFile(BASE_PATH + "InsertDeleteQuote.aj");
  EditorTestUtil.performTypingAction(getEditor(), '"');
  checkResultByFile(BASE_PATH + "InsertDeleteQuote_after.aj");

  configureByFile(BASE_PATH+"InsertDeleteQuote_after.aj");
  EditorTestUtil.performTypingAction(getEditor(), BACKSPACE_FAKE_CHAR);
  checkResultByFile(BASE_PATH+"InsertDeleteQuote.aj");
}
项目:intellij-ce-playground    文件:CustomFileTypeEditor.java   
@Override
public void applyEditorTo(AbstractFileType type) throws ConfigurationException {
  if (myFileTypeName.getText().trim().length() == 0) {
    throw new ConfigurationException(IdeBundle.message("error.name.cannot.be.empty"),
                                     CommonBundle.getErrorTitle());
  }
  else if (myFileTypeDescr.getText().trim().length() == 0) {
    myFileTypeDescr.setText(myFileTypeName.getText());
  }
  type.setName(myFileTypeName.getText());
  type.setDescription(myFileTypeDescr.getText());
  type.setSyntaxTable(getSyntaxTable());
}
项目:intellij-ce-playground    文件:CommentByBlockCommentAction.java   
@Override
protected boolean isValidFor(@NotNull Project project, @NotNull Editor editor, @NotNull Caret caret, @NotNull final PsiFile file) {
  final FileType fileType = file.getFileType();
  if (fileType instanceof AbstractFileType) {
    return ((AbstractFileType)fileType).getCommenter() != null;
  }

  Commenter commenter = LanguageCommenters.INSTANCE.forLanguage(file.getLanguage());
  if (commenter == null) commenter = LanguageCommenters.INSTANCE.forLanguage(file.getViewProvider().getBaseLanguage());
  if (commenter == null) return false;
  return commenter.getBlockCommentPrefix() != null && commenter.getBlockCommentSuffix() != null;
}
项目:intellij-ce-playground    文件:CommentByLineCommentAction.java   
@Override
protected boolean isValidFor(@NotNull Project project, @NotNull Editor editor, @NotNull Caret caret, @NotNull final PsiFile file) {
  final FileType fileType = file.getFileType();
  if (fileType instanceof AbstractFileType) {
    return ((AbstractFileType)fileType).getCommenter() != null;
  }

  if (LanguageCommenters.INSTANCE.forLanguage(file.getLanguage()) != null ||
      LanguageCommenters.INSTANCE.forLanguage(file.getViewProvider().getBaseLanguage()) != null) return true;
  PsiElement host = InjectedLanguageManager.getInstance(project).getInjectionHost(file);
  return host != null && LanguageCommenters.INSTANCE.forLanguage(host.getLanguage()) != null;
}
项目:intellij-ce-playground    文件:CommentByBlockCommentHandler.java   
@Nullable
private static Commenter findCommenter(PsiFile file, Editor editor, Caret caret) {
  final FileType fileType = file.getFileType();
  if (fileType instanceof AbstractFileType) {
    return ((AbstractFileType)fileType).getCommenter();
  }

  Language lang = PsiUtilBase.getLanguageInEditor(caret, file.getProject());

  return getCommenter(file, editor, lang, lang);
}
项目:intellij-ce-playground    文件:StandardFileTypeRegistrator.java   
private static void init(final AbstractFileType abstractFileType) {
  SyntaxTable table = abstractFileType.getSyntaxTable();

  if (!isEmpty(table.getStartComment()) && !isEmpty(table.getEndComment()) ||
      !isEmpty(table.getLineComment())) {
    abstractFileType.setCommenter(new MyCommenter(abstractFileType));
  }

  if (table.isHasBraces() || table.isHasBrackets() || table.isHasParens()) {
    BraceMatchingUtil.registerBraceMatcher(abstractFileType, CustomFileTypeBraceMatcher.createBraceMatcher());
  }

  TypedHandler.registerQuoteHandler(abstractFileType, new CustomFileTypeQuoteHandler());

}
项目:intellij-ce-playground    文件:CustomFileTypeHighlighterProvider.java   
@Override
@Nullable
public SyntaxHighlighter create(@NotNull final FileType fileType, @Nullable final Project project, @Nullable final VirtualFile file) {
  if (fileType instanceof AbstractFileType) {
    return new CustomFileHighlighter(((CustomSyntaxTableFileType) fileType).getSyntaxTable());
  }
  return null;
}
项目:tools-idea    文件:CustomFileTypeEditorTest.java   
public void testInsertDeleteQuotes() throws Exception {
  configureByFile(BASE_PATH + "InsertDeleteQuote.cs");
  EditorTestUtil.performTypingAction(getEditor(), '"');
  checkResultByFile(BASE_PATH + "InsertDeleteQuote_after.cs");

  configureByFile(BASE_PATH+"InsertDeleteQuote_after.cs");
  EditorTestUtil.performTypingAction(getEditor(), BACKSPACE_FAKE_CHAR);
  checkResultByFile(BASE_PATH+"InsertDeleteQuote.cs");

  FileType extension = FileTypeManager.getInstance().getFileTypeByExtension("pl");
  assertTrue("Test is not set up correctly:"+extension, extension instanceof AbstractFileType);
  configureByFile(BASE_PATH + "InsertDeleteQuote.pl");
  EditorTestUtil.performTypingAction(getEditor(), '"');
  checkResultByFile(BASE_PATH + "InsertDeleteQuote_after.pl");

  configureByFile(BASE_PATH+"InsertDeleteQuote_after.pl");
  EditorTestUtil.performTypingAction(getEditor(), BACKSPACE_FAKE_CHAR);
  checkResultByFile(BASE_PATH+"InsertDeleteQuote.pl");

  configureByFile(BASE_PATH + "InsertDeleteQuote.aj");
  EditorTestUtil.performTypingAction(getEditor(), '"');
  checkResultByFile(BASE_PATH + "InsertDeleteQuote_after.aj");

  configureByFile(BASE_PATH+"InsertDeleteQuote_after.aj");
  EditorTestUtil.performTypingAction(getEditor(), BACKSPACE_FAKE_CHAR);
  checkResultByFile(BASE_PATH+"InsertDeleteQuote.aj");
}
项目:tools-idea    文件:CustomFileTypeEditor.java   
public void applyEditorTo(AbstractFileType type) throws ConfigurationException {
  if (myFileTypeName.getText().trim().length() == 0) {
    throw new ConfigurationException(IdeBundle.message("error.name.cannot.be.empty"),
                                     CommonBundle.getErrorTitle());
  }
  else if (myFileTypeDescr.getText().trim().length() == 0) {
    myFileTypeDescr.setText(myFileTypeName.getText());
  }
  type.setName(myFileTypeName.getText());
  type.setDescription(myFileTypeDescr.getText());
  type.setSyntaxTable(getSyntaxTable());
}
项目:tools-idea    文件:CommentByBlockCommentAction.java   
@Override
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull final PsiFile file) {
  final FileType fileType = file.getFileType();
  if (fileType instanceof AbstractFileType) {
    return ((AbstractFileType)fileType).getCommenter() != null;
  }

  Commenter commenter = LanguageCommenters.INSTANCE.forLanguage(file.getLanguage());
  if (commenter == null) commenter = LanguageCommenters.INSTANCE.forLanguage(file.getViewProvider().getBaseLanguage());
  if (commenter == null) return false;
  return commenter.getBlockCommentPrefix() != null && commenter.getBlockCommentSuffix() != null;
}
项目:tools-idea    文件:CommentByLineCommentAction.java   
@Override
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull final PsiFile file) {
  final FileType fileType = file.getFileType();
  if (fileType instanceof AbstractFileType) {
    return ((AbstractFileType)fileType).getCommenter() != null;
  }
  return LanguageCommenters.INSTANCE.forLanguage(file.getLanguage()) != null || LanguageCommenters.INSTANCE.forLanguage(file.getViewProvider().getBaseLanguage()) != null;
}
项目:tools-idea    文件:CommentByBlockCommentHandler.java   
@Nullable
private static Commenter findCommenter(PsiFile file, Editor editor) {
  final FileType fileType = file.getFileType();
  if (fileType instanceof AbstractFileType) {
    return ((AbstractFileType)fileType).getCommenter();
  }

  Language lang = PsiUtilBase.getLanguageInEditor(editor, file.getProject());

  return getCommenter(file, editor, lang, lang);
}
项目:tools-idea    文件:CustomFileTypeHighlighterProvider.java   
@Override
@Nullable
public SyntaxHighlighter create(final FileType fileType, @Nullable final Project project, @Nullable final VirtualFile file) {
  if (fileType instanceof AbstractFileType) {
    return new CustomFileHighlighter(((CustomSyntaxTableFileType) fileType).getSyntaxTable());
  }
  return null;
}
项目:consulo    文件:CustomFileTypeEditor.java   
public void applyEditorTo(AbstractFileType type) throws ConfigurationException {
  if (myFileTypeName.getText().trim().length() == 0) {
    throw new ConfigurationException(IdeBundle.message("error.name.cannot.be.empty"),
                                     CommonBundle.getErrorTitle());
  }
  else if (myFileTypeDescr.getText().trim().length() == 0) {
    myFileTypeDescr.setText(myFileTypeName.getText());
  }
  type.setName(myFileTypeName.getText());
  type.setDescription(myFileTypeDescr.getText());
  type.setSyntaxTable(getSyntaxTable());
}
项目:consulo    文件:CommentByLineCommentHandler.java   
@Nullable
private static Commenter findCommenter(@Nonnull Editor editor, @Nonnull PsiFile file, final int line) {
  final FileType fileType = file.getFileType();
  if (fileType instanceof AbstractFileType) {
    return ((AbstractFileType)fileType).getCommenter();
  }
  final Language lineStartLanguage = getLineStartLanguage(editor, file, line);
  final Language lineEndLanguage = getLineEndLanguage(file, editor, line);
  return CommentByBlockCommentHandler.getCommenter(file, editor, lineStartLanguage, lineEndLanguage);
}
项目:consulo    文件:CommentByBlockCommentAction.java   
@Override
protected boolean isValidFor(@Nonnull Project project, @Nonnull Editor editor, @Nonnull Caret caret, @Nonnull final PsiFile file) {
  final FileType fileType = file.getFileType();
  if (fileType instanceof AbstractFileType) {
    return ((AbstractFileType)fileType).getCommenter() != null;
  }

  Commenter commenter = LanguageCommenters.INSTANCE.forLanguage(file.getLanguage());
  if (commenter == null) commenter = LanguageCommenters.INSTANCE.forLanguage(file.getViewProvider().getBaseLanguage());
  if (commenter == null) return false;
  return commenter.getBlockCommentPrefix() != null && commenter.getBlockCommentSuffix() != null;
}
项目:consulo    文件:CommentByLineCommentAction.java   
@Override
protected boolean isValidFor(@Nonnull Project project, @Nonnull Editor editor, @Nonnull Caret caret, @Nonnull final PsiFile file) {
  final FileType fileType = file.getFileType();
  if (fileType instanceof AbstractFileType) {
    return ((AbstractFileType)fileType).getCommenter() != null;
  }

  if (LanguageCommenters.INSTANCE.forLanguage(file.getLanguage()) != null || LanguageCommenters.INSTANCE.forLanguage(file.getViewProvider().getBaseLanguage()) != null) return true;
  PsiElement host = InjectedLanguageManager.getInstance(project).getInjectionHost(file);
  return host != null && LanguageCommenters.INSTANCE.forLanguage(host.getLanguage()) != null;
}
项目:consulo    文件:CommentByBlockCommentHandler.java   
@Nullable
private static Commenter findCommenter(PsiFile file, Editor editor, Caret caret) {
  final FileType fileType = file.getFileType();
  if (fileType instanceof AbstractFileType) {
    return ((AbstractFileType)fileType).getCommenter();
  }

  Language lang = PsiUtilBase.getLanguageInEditor(caret, file.getProject());

  return getCommenter(file, editor, lang, lang);
}
项目:consulo    文件:StandardFileTypeRegistrator.java   
private static void init(final AbstractFileType abstractFileType) {
  SyntaxTable table = abstractFileType.getSyntaxTable();

  if (!isEmpty(table.getStartComment()) && !isEmpty(table.getEndComment()) ||
      !isEmpty(table.getLineComment())) {
    abstractFileType.setCommenter(new MyCommenter(abstractFileType));
  }

  if (table.isHasBraces() || table.isHasBrackets() || table.isHasParens()) {
    BraceMatchingUtil.registerBraceMatcher(abstractFileType, CustomFileTypeBraceMatcher.createBraceMatcher());
  }

  TypedHandler.registerQuoteHandler(abstractFileType, new CustomFileTypeQuoteHandler());

}
项目:consulo    文件:CustomFileTypeHighlighterProvider.java   
@Override
@Nullable
public SyntaxHighlighter create(final FileType fileType, @Nullable final Project project, @Nullable final VirtualFile file) {
  if (fileType instanceof AbstractFileType) {
    return new CustomFileHighlighter(((CustomSyntaxTableFileType) fileType).getSyntaxTable());
  }
  return null;
}
项目:consulo-java    文件:CustomFileTypeEditorTest.java   
public void testInsertDeleteQuotes() throws Exception {
  configureByFile(BASE_PATH + "InsertDeleteQuote.cs");
  EditorTestUtil.performTypingAction(getEditor(), '"');
  checkResultByFile(BASE_PATH + "InsertDeleteQuote_after.cs");

  configureByFile(BASE_PATH+"InsertDeleteQuote_after.cs");
  EditorTestUtil.performTypingAction(getEditor(), BACKSPACE_FAKE_CHAR);
  checkResultByFile(BASE_PATH+"InsertDeleteQuote.cs");

  FileType extension = FileTypeManager.getInstance().getFileTypeByExtension("pl");
  assertTrue("Test is not set up correctly:"+extension, extension instanceof AbstractFileType);
  configureByFile(BASE_PATH + "InsertDeleteQuote.pl");
  EditorTestUtil.performTypingAction(getEditor(), '"');
  checkResultByFile(BASE_PATH + "InsertDeleteQuote_after.pl");

  configureByFile(BASE_PATH+"InsertDeleteQuote_after.pl");
  EditorTestUtil.performTypingAction(getEditor(), BACKSPACE_FAKE_CHAR);
  checkResultByFile(BASE_PATH+"InsertDeleteQuote.pl");

  configureByFile(BASE_PATH + "InsertDeleteQuote.aj");
  EditorTestUtil.performTypingAction(getEditor(), '"');
  checkResultByFile(BASE_PATH + "InsertDeleteQuote_after.aj");

  configureByFile(BASE_PATH+"InsertDeleteQuote_after.aj");
  EditorTestUtil.performTypingAction(getEditor(), BACKSPACE_FAKE_CHAR);
  checkResultByFile(BASE_PATH+"InsertDeleteQuote.aj");
}
项目:intellij-ce-playground    文件:StandardFileTypeRegistrator.java   
@Override
public void initFileType(final FileType fileType) {
  if (fileType instanceof AbstractFileType) {
    init(((AbstractFileType)fileType));
  }
}
项目:tools-idea    文件:MockFileTypeManager.java   
@Override
public SchemesManager<FileType, AbstractFileType> getSchemesManager() {
  return SchemesManager.EMPTY;
}
项目:tools-idea    文件:StandardFileTypeRegistrator.java   
@Override
public void initFileType(final FileType fileType) {
  if (fileType instanceof AbstractFileType) {
    init(((AbstractFileType)fileType));
  }
}
项目:consulo    文件:StandardFileTypeRegistrator.java   
@Override
public void initFileType(final FileType fileType) {
  if (fileType instanceof AbstractFileType) {
    init(((AbstractFileType)fileType));
  }
}
项目:tools-idea    文件:FileTypeManagerEx.java   
public abstract SchemesManager<FileType, AbstractFileType> getSchemesManager();