use of com.intellij.psi.stubs.StubIndexKey in project intellij-plugins by JetBrains.
the class AngularJSIndexingHandler method addImplicitElements.
private static void addImplicitElements(@NotNull final JSImplicitElementProvider elementProvider, @Nullable final String command, @NotNull final StubIndexKey<String, JSImplicitElementProvider> index, @Nullable String defaultName, @Nullable final String value, @NotNull final JSElementIndexingData outData) {
if (defaultName == null)
return;
final List<String> keys = INDEXES.getKeysByValue(index);
assert keys != null && keys.size() == 1;
final Consumer<JSImplicitElementImpl.Builder> adder = builder -> {
builder.setType(elementProvider instanceof JSDocComment ? JSImplicitElement.Type.Tag : JSImplicitElement.Type.Class).setTypeString(value);
builder.setUserString(keys.get(0));
final JSImplicitElementImpl implicitElement = builder.toImplicitElement();
outData.addImplicitElement(implicitElement);
};
final Function<String, List<String>> variants = POLY_NAME_CONVERTERS.get(command);
final Function<String, String> converter = command != null ? NAME_CONVERTERS.get(command) : null;
final String name = converter != null ? converter.fun(defaultName) : defaultName;
if (variants != null) {
final List<String> strings = variants.fun(name);
for (String string : strings) {
adder.consume(new JSImplicitElementImpl.Builder(string, elementProvider));
}
} else {
adder.consume(new JSImplicitElementImpl.Builder(JSQualifiedNameImpl.fromQualifiedName(name), elementProvider));
}
if (!StringUtil.equals(defaultName, name)) {
JSImplicitElementImpl.Builder symbolElementBuilder = new JSImplicitElementImpl.Builder(defaultName, elementProvider).setType(elementProvider instanceof JSDocComment ? JSImplicitElement.Type.Tag : JSImplicitElement.Type.Class).setTypeString(value);
final List<String> symbolKeys = INDEXES.getKeysByValue(AngularSymbolIndex.KEY);
assert symbolKeys != null && symbolKeys.size() == 1;
symbolElementBuilder.setUserString(symbolKeys.get(0));
final JSImplicitElementImpl implicitElement2 = symbolElementBuilder.toImplicitElement();
outData.addImplicitElement(implicitElement2);
}
}
use of com.intellij.psi.stubs.StubIndexKey in project intellij-community by JetBrains.
the class IndexInfrastructure method getIndexDirectory.
@NotNull
private static File getIndexDirectory(@NotNull ID<?, ?> indexName, boolean forVersion, String relativePath) {
final String dirName = indexName.toString().toLowerCase(Locale.US);
File indexDir;
if (indexName instanceof StubIndexKey) {
// store StubIndices under StubUpdating index' root to ensure they are deleted
// when StubUpdatingIndex version is changed
indexDir = new File(getIndexDirectory(StubUpdatingIndex.INDEX_ID, false, relativePath), forVersion ? STUB_VERSIONS : dirName);
} else {
if (relativePath.length() > 0)
relativePath = File.separator + relativePath;
indexDir = new File(PathManager.getIndexRoot() + relativePath, dirName);
}
indexDir.mkdirs();
return indexDir;
}
Aggregations