mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-88652 make FileTypeIndex aware of newly added file types
This commit is contained in:
@@ -65,7 +65,12 @@ public class FileTypeIndex extends ScalarIndexExtension<FileType>
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return 1;
|
||||
FileType[] types = myFileTypeManager.getRegisteredFileTypes();
|
||||
int version = 1;
|
||||
for (FileType type : types) {
|
||||
version += type.getName().hashCode();
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.psi.search;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileNameMatcher;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.fileTypes.ex.FakeFileType;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.PlatformTestCase;
|
||||
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
* Date: 7/24/12
|
||||
*/
|
||||
public class FileTypeIndexTest extends LightPlatformCodeInsightFixtureTestCase {
|
||||
|
||||
public FileTypeIndexTest() {
|
||||
PlatformTestCase.initPlatformLangPrefix();
|
||||
}
|
||||
|
||||
public void testAddFileType() throws Exception {
|
||||
FileType foo = new FakeFileType() {
|
||||
@Override
|
||||
public boolean isMyFileType(VirtualFile file) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "foo";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
FileTypeIndex index = new FileTypeIndex(FileTypeManager.getInstance());
|
||||
int version = index.getVersion();
|
||||
|
||||
FileTypeManager.getInstance().registerFileType(foo, Collections.<FileNameMatcher>emptyList());
|
||||
|
||||
assertNotSame(version, index.getVersion());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user