use of com.intellij.javascript.flex.css.CssPropertyValueReference in project intellij-plugins by JetBrains.
the class ActionScriptReferenceContributor method registerReferenceProviders.
@Override
public void registerReferenceProviders(@NotNull final PsiReferenceRegistrar registrar) {
registrar.registerReferenceProvider(psiElement(JSLiteralExpression.class).and(new FilterPattern(new ElementFilter() {
public boolean isAcceptable(Object element, PsiElement context) {
PsiElement parent = ((JSLiteralExpression) element).getParent();
if (parent instanceof JSArgumentList) {
JSExpression[] arguments = ((JSArgumentList) parent).getArguments();
if (arguments.length > 0 && arguments[0] == element) {
parent = parent.getParent();
if (parent instanceof JSCallExpression) {
JSExpression invokedMethod = ((JSCallExpression) parent).getMethodExpression();
if (invokedMethod instanceof JSReferenceExpression) {
String methodName = ((JSReferenceExpression) invokedMethod).getReferencedName();
if (SET_STYLE_METHOD_NAME.equals(methodName)) {
Module module = findModuleForPsiElement(parent);
return module != null && ModuleType.get(module) == FlexModuleType.getInstance();
}
}
}
}
}
return false;
}
public boolean isClassAcceptable(Class hintClass) {
return true;
}
})), new PsiReferenceProvider() {
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
String value = element.getText();
if (FlexCssUtil.inQuotes(value)) {
return new PsiReference[] { new CssPropertyValueReference(element) };
}
return PsiReference.EMPTY_ARRAY;
}
});
registrar.registerReferenceProvider(psiElement(JSLiteralExpression.class).and(new FilterPattern(new ElementFilter() {
public boolean isAcceptable(Object element, PsiElement context) {
PsiElement parent = ((JSLiteralExpression) element).getParent();
if (parent instanceof JSAssignmentExpression) {
PsiElement assignee = parent.getChildren()[0];
if (assignee instanceof JSDefinitionExpression) {
JSExpression expression = ((JSDefinitionExpression) assignee).getExpression();
if (expression instanceof JSReferenceExpression) {
String refName = ((JSReferenceExpression) expression).getReferencedName();
if (refName != null && FlexCssUtil.isStyleNameProperty(refName)) {
Module module = findModuleForPsiElement(parent);
return module != null && ModuleType.get(module) == FlexModuleType.getInstance();
}
}
}
}
return false;
}
public boolean isClassAcceptable(Class hintClass) {
return true;
}
})), new PsiReferenceProvider() {
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
String value = element.getText();
if (FlexCssUtil.inQuotes(value)) {
return new PsiReference[] { new CssClassValueReference(element) };
}
return PsiReference.EMPTY_ARRAY;
}
});
registrar.registerReferenceProvider(psiElement(JSLiteralExpression.class).and(new FilterPattern(new ElementFilter() {
public boolean isAcceptable(Object element, PsiElement context) {
PsiElement parent = ((JSLiteralExpression) element).getParent();
if (parent instanceof JSArgumentList) {
final JSExpression[] arguments = ((JSArgumentList) parent).getArguments();
if (arguments.length > 0 && arguments[0] == element) {
parent = parent.getParent();
if (parent instanceof JSCallExpression) {
final JSExpression invokedMethod = ((JSCallExpression) parent).getMethodExpression();
if (invokedMethod instanceof JSReferenceExpression) {
final String methodName = ((JSReferenceExpression) invokedMethod).getReferencedName();
if (methodName != null && FlexCssUtil.isStyleNameMethod(methodName)) {
Module module = findModuleForPsiElement(parent);
return module != null && ModuleType.get(module) == FlexModuleType.getInstance();
}
}
}
}
}
return false;
}
public boolean isClassAcceptable(Class hintClass) {
return true;
}
})), new PsiReferenceProvider() {
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
String value = element.getText();
if (FlexCssUtil.inQuotes(value)) {
return new PsiReference[] { new CssClassValueReference(element) };
}
return PsiReference.EMPTY_ARRAY;
}
});
registrar.registerReferenceProvider(psiElement(JSLiteralExpression.class), new FlexPropertyReferenceProvider());
registrar.registerReferenceProvider(psiElement(JSAttributeNameValuePair.class), new FlexAttributeReferenceProvider());
}
Aggregations