use of com.intellij.lang.javascript.psi.stubs.JSImplicitElement in project intellij-plugins by JetBrains.
the class AngularUiRouterDiagramBuilder method addStatesFromIndex.
private void addStatesFromIndex() {
final Collection<String> stateIds = AngularIndexUtil.getAllKeys(AngularUiRouterStatesIndex.KEY, myProject);
for (String id : stateIds) {
if (id.startsWith("."))
continue;
final CommonProcessors.CollectProcessor<JSImplicitElement> processor = new CommonProcessors.CollectProcessor<>();
AngularIndexUtil.multiResolve(myProject, AngularUiRouterStatesIndex.KEY, id, processor);
for (JSImplicitElement element : processor.getResults()) {
final UiRouterState state = new UiRouterState(id, element.getContainingFile().getVirtualFile());
if (!element.getContainingFile().getLanguage().isKindOf(JavascriptLanguage.INSTANCE) && PsiTreeUtil.getParentOfType(element, JSEmbeddedContent.class) != null) {
createRootTemplatesForEmbedded(element.getContainingFile());
}
final JSCallExpression call = findWrappingCallExpression(element);
if (call != null) {
final JSReferenceExpression methodExpression = ObjectUtils.tryCast(call.getMethodExpression(), JSReferenceExpression.class);
if (methodExpression != null && methodExpression.getQualifier() != null && "state".equals(methodExpression.getReferenceName())) {
final JSExpression[] arguments = call.getArguments();
if (arguments.length > 0 && PsiTreeUtil.isAncestor(arguments[0], element.getNavigationElement(), false)) {
state.setPointer(mySmartPointerManager.createSmartPsiElementPointer(arguments[0]));
if (arguments.length > 1 && arguments[1] instanceof JSObjectLiteralExpression) {
final JSObjectLiteralExpression object = (JSObjectLiteralExpression) arguments[1];
fillStateParameters(state, object);
} else if (arguments[0] instanceof JSObjectLiteralExpression) {
final JSObjectLiteralExpression object = (JSObjectLiteralExpression) arguments[0];
final JSProperty name = object.findProperty("name");
if (name != null && PsiTreeUtil.isAncestor(name, element.getNavigationElement(), false)) {
fillStateParameters(state, object);
}
}
}
}
}
myStates.add(state);
}
}
}
use of com.intellij.lang.javascript.psi.stubs.JSImplicitElement in project intellij-plugins by JetBrains.
the class AngularJSProcessor method scopeMatches.
private static boolean scopeMatches(PsiElement element, PsiElement declaration) {
final InjectedLanguageManager injector = InjectedLanguageManager.getInstance(element.getProject());
if (declaration instanceof JSImplicitElement) {
if ($EVENT.equals(((JSImplicitElement) declaration).getName())) {
return eventScopeMatches(injector, element, declaration.getParent());
}
declaration = declaration.getParent();
}
final PsiLanguageInjectionHost elementContainer = injector.getInjectionHost(element);
final XmlTagChild elementTag = PsiTreeUtil.getNonStrictParentOfType(elementContainer, XmlTag.class, XmlText.class);
final PsiLanguageInjectionHost declarationContainer = injector.getInjectionHost(declaration);
final XmlTagChild declarationTag = PsiTreeUtil.getNonStrictParentOfType(declarationContainer, XmlTag.class, XmlText.class);
if (declarationContainer != null && elementContainer != null && elementTag != null && declarationTag != null) {
return PsiTreeUtil.isAncestor(declarationTag, elementTag, true) || (PsiTreeUtil.isAncestor(declarationTag, elementTag, false) && declarationContainer.getTextOffset() < elementContainer.getTextOffset()) || isInRepeatStartEnd(declarationTag, declarationContainer, elementContainer);
}
return true;
}
use of com.intellij.lang.javascript.psi.stubs.JSImplicitElement in project intellij-plugins by JetBrains.
the class DirectiveUtil method getTagDirective.
private static JSImplicitElement getTagDirective(Project project, String directiveName, final StubIndexKey<String, JSImplicitElementProvider> index) {
final JSImplicitElement directive = AngularIndexUtil.resolve(project, index, directiveName);
final String restrictions = directive != null ? directive.getTypeString() : null;
if (restrictions != null) {
final String[] split = restrictions.split(";", -1);
final String restrict = AngularIndexUtil.convertRestrictions(project, split[0]);
if (!StringUtil.isEmpty(restrict) && StringUtil.containsIgnoreCase(restrict, "E")) {
return directive;
}
}
return null;
}
use of com.intellij.lang.javascript.psi.stubs.JSImplicitElement in project intellij-plugins by JetBrains.
the class DirectiveUtil method processTagDirectives.
public static boolean processTagDirectives(final Project project, Processor<JSImplicitElement> processor) {
final Collection<String> docDirectives = AngularIndexUtil.getAllKeys(AngularDirectivesDocIndex.KEY, project);
for (String directiveName : docDirectives) {
final JSImplicitElement directive = getTagDirective(project, directiveName, AngularDirectivesDocIndex.KEY);
if (directive != null) {
if (!processor.process(directive)) {
return false;
}
}
}
final Collection<String> directives = AngularIndexUtil.getAllKeys(AngularDirectivesIndex.KEY, project);
for (String directiveName : directives) {
if (!docDirectives.contains(directiveName)) {
final JSImplicitElement directive = getTagDirective(project, directiveName, AngularDirectivesIndex.KEY);
if (directive != null) {
if (!processor.process(directive)) {
return false;
}
}
}
}
return true;
}
use of com.intellij.lang.javascript.psi.stubs.JSImplicitElement in project intellij-plugins by JetBrains.
the class AngularAttributesRegistry method isAngularExpressionAttribute.
public static boolean isAngularExpressionAttribute(XmlAttribute parent) {
final String attributeName = DirectiveUtil.normalizeAttributeName(parent.getName());
final JSImplicitElement directive = AngularIndexUtil.resolve(parent.getProject(), AngularDirectivesDocIndex.KEY, attributeName);
if (directive != null) {
final String restrict = directive.getTypeString();
final String param = restrict != null ? restrict.split(";", -1)[2] : "";
return param.endsWith("expression") || param.startsWith("string");
}
return false;
}
Aggregations