use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.
the class StubVersionMap method registerStamp.
private void registerStamp(FileType fileTypeByName, long stamp) {
fileTypeToVersion.put(fileTypeByName, stamp);
FileType previousType = versionToFileType.put(stamp, fileTypeByName);
if (previousType != null) {
assert false;
}
}
use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.
the class IndexConfiguration method registerIndex.
<K, V> void registerIndex(ID<K, V> name, @NotNull UpdatableIndex<K, V, FileContent> index, FileBasedIndex.InputFilter inputFilter, int version, @Nullable Collection<FileType> associatedFileTypes) {
assert !myFreezed;
synchronized (myIndices) {
myIndexIdToVersionMap.put(name, version);
if (associatedFileTypes != null && !associatedFileTypes.isEmpty()) {
for (FileType fileType : associatedFileTypes) {
List<ID<?, ?>> ids = myFileType2IndicesWithFileTypeInfoMap.get(fileType);
if (ids == null)
myFileType2IndicesWithFileTypeInfoMap.put(fileType, ids = new ArrayList<>(5));
ids.add(name);
}
} else {
myIndicesWithoutFileTypeInfo.add(name);
}
Pair<UpdatableIndex<?, ?, FileContent>, FileBasedIndex.InputFilter> old = myIndices.put(name, new Pair<>(index, inputFilter));
if (old != null) {
throw new IllegalStateException("Index " + old.first + " already registered for the name '" + name + "'");
}
}
}
use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.
the class LanguageTextField method createDocument.
public static Document createDocument(String value, @Nullable Language language, Project project, @NotNull SimpleDocumentCreator documentCreator) {
if (language != null) {
final PsiFileFactory factory = PsiFileFactory.getInstance(project);
final FileType fileType = language.getAssociatedFileType();
assert fileType != null;
final long stamp = LocalTimeCounter.currentTime();
final PsiFile psiFile = factory.createFileFromText("Dummy." + fileType.getDefaultExtension(), fileType, value, stamp, true, false);
documentCreator.customizePsiFile(psiFile);
final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
assert document != null;
return document;
} else {
return EditorFactory.getInstance().createDocument(value);
}
}
use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.
the class LanguageTextField method createEditor.
@Override
protected EditorEx createEditor() {
final EditorEx ex = super.createEditor();
if (myLanguage != null) {
final FileType fileType = myLanguage.getAssociatedFileType();
ex.setHighlighter(HighlighterFactory.createHighlighter(myProject, fileType));
}
ex.setEmbeddedIntoDialogWrapper(true);
return ex;
}
use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.
the class TodoIndex method getVersion.
@Override
public int getVersion() {
int version = 9;
FileType[] types = myFileTypeManager.getRegisteredFileTypes();
Arrays.sort(types, (o1, o2) -> Comparing.compare(o1.getName(), o2.getName()));
for (FileType fileType : types) {
DataIndexer<TodoIndexEntry, Integer, FileContent> indexer = TodoIndexers.INSTANCE.forFileType(fileType);
if (indexer == null)
continue;
int versionFromIndexer = indexer instanceof VersionedTodoIndexer ? (((VersionedTodoIndexer) indexer).getVersion()) : 0xFF;
version = version * 31 + (versionFromIndexer ^ indexer.getClass().getName().hashCode());
}
return version;
}
Aggregations