use of com.intellij.lang.javascript.psi.jsdoc.JSDocComment 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.lang.javascript.psi.jsdoc.JSDocComment in project intellij-plugins by JetBrains.
the class AngularJSDocumentationProvider method getUrlFor.
@Override
public List<String> getUrlFor(PsiElement element, PsiElement originalElement) {
if (element instanceof JSImplicitElement)
element = element.getParent();
if (element instanceof JSDocComment) {
JSDocTag ngdocTag = null;
JSDocTag nameTag = null;
for (JSDocTag tag : ((JSDocComment) element).getTags()) {
if ("ngdoc".equals(tag.getName()))
ngdocTag = tag;
else if ("name".equals(tag.getName()))
nameTag = tag;
}
if (ngdocTag != null && nameTag != null) {
final JSDocTagValue nameValue = nameTag.getValue();
String name = nameValue != null ? nameValue.getText() : null;
if (name != null)
name = name.substring(name.indexOf(':') + 1);
if (name != null && AngularIndexUtil.resolve(element.getProject(), AngularDirectivesDocIndex.KEY, DirectiveUtil.getAttributeName(name)) != null) {
final String directiveName = DirectiveUtil.attributeToDirective(null, name);
return Collections.singletonList("http://docs.angularjs.org/api/ng/directive/" + directiveName);
}
}
}
return null;
}
Aggregations