Search in sources :

Example 56 with FileType

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;
    }
}
Also used : FileType(com.intellij.openapi.fileTypes.FileType) LanguageFileType(com.intellij.openapi.fileTypes.LanguageFileType)

Example 57 with FileType

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 + "'");
        }
    }
}
Also used : FileType(com.intellij.openapi.fileTypes.FileType)

Example 58 with FileType

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);
    }
}
Also used : PsiFileFactory(com.intellij.psi.PsiFileFactory) FileType(com.intellij.openapi.fileTypes.FileType) PsiFile(com.intellij.psi.PsiFile) Document(com.intellij.openapi.editor.Document)

Example 59 with FileType

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;
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) FileType(com.intellij.openapi.fileTypes.FileType)

Example 60 with FileType

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;
}
Also used : FileType(com.intellij.openapi.fileTypes.FileType) CustomSyntaxTableFileType(com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType) LanguageFileType(com.intellij.openapi.fileTypes.LanguageFileType)

Aggregations

FileType (com.intellij.openapi.fileTypes.FileType)198 VirtualFile (com.intellij.openapi.vfs.VirtualFile)60 NotNull (org.jetbrains.annotations.NotNull)38 Language (com.intellij.lang.Language)31 PsiFile (com.intellij.psi.PsiFile)31 LanguageFileType (com.intellij.openapi.fileTypes.LanguageFileType)30 Nullable (org.jetbrains.annotations.Nullable)28 Project (com.intellij.openapi.project.Project)27 Document (com.intellij.openapi.editor.Document)20 IncorrectOperationException (com.intellij.util.IncorrectOperationException)13 ArrayList (java.util.ArrayList)12 IOException (java.io.IOException)11 Editor (com.intellij.openapi.editor.Editor)10 HighlighterIterator (com.intellij.openapi.editor.highlighter.HighlighterIterator)10 CustomSyntaxTableFileType (com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType)10 PlainTextFileType (com.intellij.openapi.fileTypes.PlainTextFileType)9 UnknownFileType (com.intellij.openapi.fileTypes.UnknownFileType)9 BraceMatcher (com.intellij.codeInsight.highlighting.BraceMatcher)8 AbstractFileType (com.intellij.openapi.fileTypes.impl.AbstractFileType)8 PsiElement (com.intellij.psi.PsiElement)8