Search in sources :

Example 1 with CssElementDescriptorProviderImpl

use of com.intellij.psi.css.impl.util.scheme.CssElementDescriptorProviderImpl in project intellij-plugins by JetBrains.

the class FlexCssElementDescriptorProvider method getQuickFixesForUnknownProperty.

@NotNull
@Override
public LocalQuickFix[] getQuickFixesForUnknownProperty(@NotNull String propertyName, @NotNull PsiElement context, boolean isOnTheFly) {
    if (!isOnTheFly) {
        return LocalQuickFix.EMPTY_ARRAY;
    }
    final VirtualFile vFile = checkForQuickFixAndGetVFile(context);
    if (vFile == null) {
        return LocalQuickFix.EMPTY_ARRAY;
    }
    final CssDialect dialect = CssDialectMappings.getInstance(context.getProject()).getMapping(vFile);
    if (dialect == CssDialect.CLASSIC) {
        final Collection<? extends CssPropertyDescriptor> flexDescriptor = findPropertyDescriptors(propertyName, context);
        if (!flexDescriptor.isEmpty()) {
            return new LocalQuickFix[] { new SwitchToCssDialectQuickFix(FlexCSSDialect.getInstance()) };
        }
    } else {
        final CssElementDescriptorProviderImpl classicCssDescriptorProvider = CssElementDescriptorProvider.EP_NAME.findExtension(CssElementDescriptorProviderImpl.class);
        if (classicCssDescriptorProvider != null) {
            Collection<? extends CssPropertyDescriptor> classicDescriptors = classicCssDescriptorProvider.findPropertyDescriptors(propertyName, context);
            if (!classicDescriptors.isEmpty()) {
                return new LocalQuickFix[] { new SwitchToCssDialectQuickFix(CssDialect.CLASSIC) };
            }
        }
    }
    return LocalQuickFix.EMPTY_ARRAY;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CssDialect(com.intellij.lang.css.CssDialect) LocalQuickFix(com.intellij.codeInspection.LocalQuickFix) CssElementDescriptorProviderImpl(com.intellij.psi.css.impl.util.scheme.CssElementDescriptorProviderImpl) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with CssElementDescriptorProviderImpl

use of com.intellij.psi.css.impl.util.scheme.CssElementDescriptorProviderImpl in project intellij-plugins by JetBrains.

the class FlexCssElementDescriptorProvider method getQuickFixesForUnknownSimpleSelector.

@NotNull
@Override
public LocalQuickFix[] getQuickFixesForUnknownSimpleSelector(@NotNull String selectorName, @NotNull PsiElement context, boolean isOnTheFly) {
    if (!isOnTheFly) {
        return LocalQuickFix.EMPTY_ARRAY;
    }
    final VirtualFile vFile = checkForQuickFixAndGetVFile(context);
    if (vFile == null) {
        return LocalQuickFix.EMPTY_ARRAY;
    }
    final CssDialect dialect = CssDialectMappings.getInstance(context.getProject()).getMapping(vFile);
    if (dialect == CssDialect.CLASSIC) {
        if (isPossibleSelector(selectorName, context)) {
            return new LocalQuickFix[] { new SwitchToCssDialectQuickFix(FlexCSSDialect.getInstance()) };
        }
    } else {
        final CssElementDescriptorProviderImpl classicCssDescriptorProvider = CssElementDescriptorProvider.EP_NAME.findExtension(CssElementDescriptorProviderImpl.class);
        if (classicCssDescriptorProvider != null && classicCssDescriptorProvider.isPossibleSelector(selectorName, context)) {
            return new LocalQuickFix[] { new SwitchToCssDialectQuickFix(CssDialect.CLASSIC) };
        }
    }
    return LocalQuickFix.EMPTY_ARRAY;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CssDialect(com.intellij.lang.css.CssDialect) LocalQuickFix(com.intellij.codeInspection.LocalQuickFix) CssElementDescriptorProviderImpl(com.intellij.psi.css.impl.util.scheme.CssElementDescriptorProviderImpl) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

LocalQuickFix (com.intellij.codeInspection.LocalQuickFix)2 CssDialect (com.intellij.lang.css.CssDialect)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 CssElementDescriptorProviderImpl (com.intellij.psi.css.impl.util.scheme.CssElementDescriptorProviderImpl)2 NotNull (org.jetbrains.annotations.NotNull)2