use of com.intellij.lang.javascript.psi.stubs.JSImplicitElement 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.stubs.JSImplicitElement in project intellij-plugins by JetBrains.
the class AngularJSTagDescriptorsProvider method getDescriptor.
@Nullable
@Override
public XmlElementDescriptor getDescriptor(XmlTag xmlTag) {
final Project project = xmlTag.getProject();
if (!(xmlTag instanceof HtmlTag && AngularIndexUtil.hasAngularJS(project)))
return null;
final String tagName = xmlTag.getName();
final String directiveName = DirectiveUtil.normalizeAttributeName(tagName);
final XmlNSDescriptor nsDescriptor = xmlTag.getNSDescriptor(xmlTag.getNamespace(), false);
final XmlElementDescriptor descriptor = nsDescriptor != null ? nsDescriptor.getElementDescriptor(xmlTag) : null;
if (descriptor != null && !(descriptor instanceof AnyXmlElementDescriptor)) {
return null;
}
if ((NG_CONTAINER.equals(directiveName) || NG_CONTENT.equals(directiveName) || NG_TEMPLATE.equals(directiveName)) && AngularIndexUtil.hasAngularJS2(project)) {
return new AngularJSTagDescriptor(directiveName, createDirective(xmlTag, directiveName));
}
JSImplicitElement directive = DirectiveUtil.getTagDirective(directiveName, project);
if (DirectiveUtil.isAngular2Directive(directive) && !directive.getName().equals(tagName)) {
// we've found directive via normalized name for Angular, it should not work
directive = null;
}
if (directive == null && !tagName.equals(directiveName) && AngularIndexUtil.hasAngularJS2(project)) {
directive = DirectiveUtil.getTagDirective(tagName, project);
if (!DirectiveUtil.isAngular2Directive(directive))
directive = null;
}
return directive != null ? new AngularJSTagDescriptor(directiveName, directive) : null;
}
use of com.intellij.lang.javascript.psi.stubs.JSImplicitElement in project intellij-plugins by JetBrains.
the class AngularJSBracesUtil method getInjectionDelimiter.
private static String getInjectionDelimiter(Project project, final Key<CachedValue<String>> key, final String defaultDelimiter) {
return CachedValuesManager.getManager(project).getCachedValue(project, key, () -> {
String id = key.toString();
final JSImplicitElement delimiter = AngularIndexUtil.resolve(project, AngularInjectionDelimiterIndex.KEY, id.substring(id.lastIndexOf(".") + 1));
if (delimiter != null) {
return CachedValueProvider.Result.create(delimiter.getTypeString(), delimiter);
}
return CachedValueProvider.Result.create(defaultDelimiter, PsiModificationTracker.MODIFICATION_COUNT);
}, false);
}
use of com.intellij.lang.javascript.psi.stubs.JSImplicitElement in project intellij-plugins by JetBrains.
the class AngularIndexUtil method multiResolve.
public static void multiResolve(Project project, final StubIndexKey<String, JSImplicitElementProvider> index, final String lookupKey, final Processor<JSImplicitElement> processor) {
final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
StubIndex.getInstance().processElements(index, lookupKey, project, scope, JSImplicitElementProvider.class, provider -> {
final JSElementIndexingData indexingData = provider.getIndexingData();
if (indexingData != null) {
final Collection<JSImplicitElement> elements = indexingData.getImplicitElements();
if (elements != null) {
for (JSImplicitElement element : elements) {
if (element.getName().equals(lookupKey) && ((index != AngularDirectivesIndex.KEY && index != AngularDirectivesDocIndex.KEY) || AngularJSIndexingHandler.isAngularRestrictions(element.getTypeString()))) {
if (!processor.process(element))
return false;
}
}
}
}
return true;
});
}
use of com.intellij.lang.javascript.psi.stubs.JSImplicitElement in project intellij-plugins by JetBrains.
the class AngularUiRouterDiagramBuilder method addContainingFile.
private void addContainingFile(@NotNull final NonCyclicQueue<VirtualFile> filesQueue, @NotNull final String module) {
final CommonProcessors.CollectProcessor<JSImplicitElement> collectProcessor = new CommonProcessors.CollectProcessor<>();
AngularIndexUtil.multiResolve(myProject, AngularModuleIndex.KEY, module, collectProcessor);
if (collectProcessor.getResults().size() != 1)
return;
for (JSImplicitElement element : collectProcessor.getResults()) {
if (element != null && element.getNavigationElement() != null && element.getNavigationElement().getContainingFile() != null) {
final VirtualFile file = element.getNavigationElement().getContainingFile().getVirtualFile();
// prefer library resolves
if (NodeModuleUtil.isFromNodeModules(myProject, file))
return;
}
}
final JSImplicitElement element = collectProcessor.getResults().iterator().next();
if (element != null && element.getNavigationElement() != null && element.getNavigationElement().getContainingFile() != null) {
filesQueue.add(element.getNavigationElement().getContainingFile().getVirtualFile());
}
}
Aggregations