use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.
the class DetectAndAdjustIndentOptionsTask method getDefaultIndentOptions.
@NotNull
public static TimeStampedIndentOptions getDefaultIndentOptions(@NotNull PsiFile file, @NotNull Document document) {
Project project = file.getProject();
FileType fileType = file.getFileType();
CodeStyleSettings manager = CodeStyleSettingsManager.getSettings(project);
return new TimeStampedIndentOptions(manager.getIndentOptions(fileType), document.getModificationStamp());
}
use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.
the class CompletionUtil method getCompletionDataByElement.
@Nullable
public static CompletionData getCompletionDataByElement(@Nullable final PsiElement position, @NotNull PsiFile originalFile) {
if (position == null)
return null;
PsiElement parent = position.getParent();
Language language = parent == null ? position.getLanguage() : parent.getLanguage();
final FileType fileType = language.getAssociatedFileType();
if (fileType != null) {
final CompletionData mainData = getCompletionDataByFileType(fileType);
if (mainData != null) {
return mainData;
}
}
final CompletionData mainData = getCompletionDataByFileType(originalFile.getFileType());
return mainData != null ? mainData : ourGenericCompletionData;
}
use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.
the class TypedHandler method getQuoteHandler.
@Nullable
public static QuoteHandler getQuoteHandler(@NotNull PsiFile file, @NotNull Editor editor) {
FileType fileType = getFileType(file, editor);
QuoteHandler quoteHandler = getQuoteHandlerForType(fileType);
if (quoteHandler == null) {
FileType fileFileType = file.getFileType();
if (fileFileType != fileType) {
quoteHandler = getQuoteHandlerForType(fileFileType);
}
}
if (quoteHandler == null) {
return getLanguageQuoteHandler(file.getViewProvider().getBaseLanguage());
}
return quoteHandler;
}
use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.
the class CommentByLineCommentHandler method findCommenter.
@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 = Math.max(0, CharArrayUtil.shiftForward(charSequence, lineStartOffset, " \t"));
lineEndOffset = Math.max(0, 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);
}
use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.
the class CommentByBlockCommentHandler method findCommenter.
@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);
}
Aggregations