use of com.intellij.lang.javascript.psi.stubs.JSImplicitElement in project intellij-plugins by JetBrains.
the class AngularJSTagDescriptor method getAttributesDescriptors.
@Override
public XmlAttributeDescriptor[] getAttributesDescriptors(@Nullable XmlTag context) {
final JSImplicitElement declaration = getDeclaration();
final String string = declaration.getTypeString();
final String attributes = string.split(";", -1)[3];
final String[] split = attributes.split(",");
final XmlAttributeDescriptor[] result;
if (context != null && AngularIndexUtil.hasAngularJS2(context.getProject())) {
result = AngularAttributeDescriptor.getFieldBasedDescriptors(declaration);
} else if (split.length == 1 && split[0].isEmpty()) {
result = XmlAttributeDescriptor.EMPTY;
} else {
result = new XmlAttributeDescriptor[split.length];
for (int i = 0; i < split.length; i++) {
result[i] = new AnyXmlAttributeDescriptor(DirectiveUtil.getAttributeName(split[i]));
}
}
final XmlAttributeDescriptor[] commonAttributes = HtmlNSDescriptorImpl.getCommonAttributeDescriptors(context);
return ArrayUtil.mergeArrays(result, commonAttributes);
}
use of com.intellij.lang.javascript.psi.stubs.JSImplicitElement in project intellij-plugins by JetBrains.
the class DirectiveUtil method getDirective.
@Nullable
private static JSImplicitElement getDirective(@NotNull PsiElement element, final String name) {
final String directiveName = getAttributeName(name);
final JSImplicitElement directive = AngularIndexUtil.resolve(element.getProject(), AngularDirectivesIndex.KEY, directiveName);
if (directive != null && directive.isEquivalentTo(element)) {
return directive;
}
return null;
}
use of com.intellij.lang.javascript.psi.stubs.JSImplicitElement in project intellij-plugins by JetBrains.
the class AngularAttributeDescriptor method getCompiledFieldBasedDescriptors.
@NotNull
private static XmlAttributeDescriptor[] getCompiledFieldBasedDescriptors(JSImplicitElement declaration, String decorator, NullableFunction<Pair<PsiElement, String>, XmlAttributeDescriptor> factory) {
Project project = declaration.getProject();
Collection<String> keys = StubIndex.getInstance().getAllKeys(AngularDecoratorsIndex.KEY, project);
GlobalSearchScope scope = GlobalSearchScope.fileScope(declaration.getContainingFile());
JSAssignmentExpression context = PsiTreeUtil.getContextOfType(declaration, JSAssignmentExpression.class);
if (context == null)
return EMPTY;
final List<XmlAttributeDescriptor> result = new ArrayList<>();
for (String key : keys) {
StubIndex.getInstance().processElements(AngularDecoratorsIndex.KEY, key, project, scope, JSImplicitElementProvider.class, (provider) -> {
JSElementIndexingData data = provider.getIndexingData();
Collection<JSImplicitElement> elements = data != null ? data.getImplicitElements() : null;
if (elements != null) {
for (JSImplicitElement element : elements) {
if (key.equals(element.getName())) {
String type = element.getTypeString();
if (type != null && type.startsWith(decorator + ";") && inContext(context, element)) {
ContainerUtil.addIfNotNull(result, factory.fun(Pair.create(element, element.getName())));
}
}
}
}
return true;
});
}
return result.toArray(new XmlAttributeDescriptor[result.size()]);
}
use of com.intellij.lang.javascript.psi.stubs.JSImplicitElement in project intellij-plugins by JetBrains.
the class AngularUiRouterDiagramBuilder method moduleDependenciesStep.
private void moduleDependenciesStep(String mainModule, NonCyclicQueue<VirtualFile> filesQueue, NonCyclicQueue<String> modulesQueue) {
addContainingFile(filesQueue, mainModule);
if (!StringUtil.isEmptyOrSpaces(mainModule)) {
final JSImplicitElement element = AngularIndexUtil.resolve(myProject, AngularModuleIndex.KEY, mainModule);
if (element != null) {
final JSCallExpression callExpression = PsiTreeUtil.getParentOfType(element, JSCallExpression.class);
if (callExpression == null)
return;
final List<String> dependenciesInModuleDeclaration = AngularModuleIndex.findDependenciesInModuleDeclaration(callExpression);
if (dependenciesInModuleDeclaration != null) {
for (String module : dependenciesInModuleDeclaration) {
modulesQueue.add(module);
addContainingFile(filesQueue, module);
}
}
}
}
}
use of com.intellij.lang.javascript.psi.stubs.JSImplicitElement in project intellij-plugins by JetBrains.
the class AngularRouterStateLoader method loadFreelyDefinedStates.
public List<JSObjectLiteralExpression> loadFreelyDefinedStates() {
final List<JSObjectLiteralExpression> states = new ArrayList<>();
final Collection<String> allKeys = AngularIndexUtil.getAllKeys(AngularUiRouterGenericStatesIndex.KEY, myProject);
for (String key : allKeys) {
final List<JSImplicitElement> list = new ArrayList<>();
AngularIndexUtil.multiResolve(myProject, AngularUiRouterGenericStatesIndex.KEY, key, list::add);
for (JSImplicitElement element : list) {
final JSCallExpression callExpression = AngularUiRouterDiagramBuilder.findWrappingCallExpression(element);
if (callExpression != null) {
findPossibleReferences(callExpression, object -> {
final JSProperty name = object.findProperty("name");
if (name != null && name.getValue() instanceof JSLiteralExpression && ((JSLiteralExpression) name.getValue()).isQuotedLiteral()) {
for (String field : STATE_FIELDS) {
if (object.findProperty(field) != null && (myStateName == null || myStateName.endsWith(StringUtil.unquoteString(name.getValue().getText())))) {
states.add(object);
return true;
}
}
}
return false;
});
if (myStateName != null && !states.isEmpty())
return states;
}
}
}
return states;
}
Aggregations