use of com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType in project intellij-community by JetBrains.
the class CommentByLineCommentHandler method getBlockSuitableCommenter.
private static Commenter getBlockSuitableCommenter(final PsiFile file, int offset, int endOffset) {
final Language languageSuitableForCompleteFragment;
if (offset >= endOffset) {
// we are on empty line
PsiElement element = file.findElementAt(offset);
if (element != null)
languageSuitableForCompleteFragment = element.getParent().getLanguage();
else
languageSuitableForCompleteFragment = null;
} else {
languageSuitableForCompleteFragment = PsiUtilBase.reallyEvaluateLanguageInRange(offset, endOffset, file);
}
Commenter blockSuitableCommenter = languageSuitableForCompleteFragment == null ? LanguageCommenters.INSTANCE.forLanguage(file.getLanguage()) : null;
if (blockSuitableCommenter == null && file.getFileType() instanceof CustomSyntaxTableFileType) {
blockSuitableCommenter = new Commenter() {
final SyntaxTable mySyntaxTable = ((CustomSyntaxTableFileType) file.getFileType()).getSyntaxTable();
@Override
@Nullable
public String getLineCommentPrefix() {
return mySyntaxTable.getLineComment();
}
@Override
@Nullable
public String getBlockCommentPrefix() {
return mySyntaxTable.getStartComment();
}
@Override
@Nullable
public String getBlockCommentSuffix() {
return mySyntaxTable.getEndComment();
}
@Override
public String getCommentedBlockCommentPrefix() {
return null;
}
@Override
public String getCommentedBlockCommentSuffix() {
return null;
}
};
}
return blockSuitableCommenter;
}
use of com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType in project intellij-community by JetBrains.
the class IdTableBuilding method getFileTypeIndexer.
@Nullable
public static FileTypeIdIndexer getFileTypeIndexer(FileType fileType) {
final FileTypeIdIndexer idIndexer = ourIdIndexers.get(fileType);
if (idIndexer != null) {
return idIndexer;
}
final FileTypeIdIndexer extIndexer = IdIndexers.INSTANCE.forFileType(fileType);
if (extIndexer != null) {
return extIndexer;
}
final WordsScanner customWordsScanner = CacheBuilderRegistry.getInstance().getCacheBuilder(fileType);
if (customWordsScanner != null) {
return new WordsScannerFileTypeIdIndexerAdapter(customWordsScanner);
}
if (fileType instanceof LanguageFileType) {
final Language lang = ((LanguageFileType) fileType).getLanguage();
final FindUsagesProvider findUsagesProvider = LanguageFindUsages.INSTANCE.forLanguage(lang);
WordsScanner scanner = findUsagesProvider == null ? null : findUsagesProvider.getWordsScanner();
if (scanner == null) {
scanner = new SimpleWordsScanner();
}
return new WordsScannerFileTypeIdIndexerAdapter(scanner);
}
if (fileType instanceof CustomSyntaxTableFileType) {
return new WordsScannerFileTypeIdIndexerAdapter(createCustomFileTypeScanner(((CustomSyntaxTableFileType) fileType).getSyntaxTable()));
}
return null;
}
Aggregations