use of com.intellij.lang.javascript.psi.jsdoc.JSDocTag 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;
}
use of com.intellij.lang.javascript.psi.jsdoc.JSDocTag in project intellij-plugins by JetBrains.
the class AngularJSIndexingHandler method processJSDocComment.
@Override
public JSElementIndexingData processJSDocComment(@NotNull final JSDocComment comment, @Nullable JSElementIndexingData outData) {
JSDocTag ngdocTag = null;
JSDocTag nameTag = null;
for (JSDocTag tag : comment.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);
String ngdocValue = null;
PsiElement nextSibling = ngdocTag.getNextSibling();
if (nextSibling instanceof PsiWhiteSpace)
nextSibling = nextSibling.getNextSibling();
if (nextSibling != null && nextSibling.getNode().getElementType() == JSDocTokenTypes.DOC_COMMENT_DATA) {
ngdocValue = nextSibling.getText();
}
if (ngdocValue != null && name != null) {
final String[] commentLines = StringUtil.splitByLines(comment.getText());
final boolean directive = ngdocValue.contains(DIRECTIVE);
final boolean component = ngdocValue.contains(COMPONENT);
if (directive || component) {
final String restrictions = calculateRestrictions(commentLines, directive ? DEFAULT_RESTRICTIONS : "E");
if (outData == null)
outData = new JSElementIndexingDataImpl();
addImplicitElements(comment, directive ? DIRECTIVE : COMPONENT, AngularDirectivesDocIndex.KEY, name, restrictions, outData);
} else if (ngdocValue.contains(FILTER)) {
if (outData == null)
outData = new JSElementIndexingDataImpl();
addImplicitElements(comment, FILTER, AngularFilterIndex.KEY, name, null, outData);
}
}
}
return outData;
}
Aggregations