use of com.intellij.lang.css.CssDialect in project intellij-plugins by JetBrains.
the class AngularJSCssElementDescriptionProvider method isMyContext.
@Override
public boolean isMyContext(@Nullable PsiElement context) {
if (context == null || !context.isValid())
return false;
final PsiFile file = context.getContainingFile();
if (file == null)
return false;
final Project project = context.getProject();
if (HtmlUtil.hasHtml(file))
return AngularIndexUtil.hasAngularJS(project);
final VirtualFile virtualFile = file.getOriginalFile().getVirtualFile();
final CssDialect mapping = CssDialectMappings.getInstance(project).getMapping(virtualFile);
return (mapping == null || mapping == CssDialect.CLASSIC) && AngularIndexUtil.hasAngularJS(project);
}
use of com.intellij.lang.css.CssDialect 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;
}
use of com.intellij.lang.css.CssDialect 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;
}
use of com.intellij.lang.css.CssDialect in project intellij-plugins by JetBrains.
the class FlexCssElementDescriptorProvider method isMyContext.
public boolean isMyContext(@Nullable PsiElement context) {
if (context == null || !context.isValid())
return false;
PsiFile file = context.getContainingFile();
if (file == null)
return false;
if (HtmlUtil.hasHtml(file))
return false;
final VirtualFile vFile = file.getOriginalFile().getVirtualFile();
if (vFile != null) {
final FileType type = vFile.getFileType();
if (type instanceof LanguageFileType) {
Language lang = ((LanguageFileType) type).getLanguage();
if (lang.isKindOf(CSSLanguage.INSTANCE) && !lang.is(CSSLanguage.INSTANCE))
return false;
}
}
Module module = findModuleForPsiElement(file);
if (module == null) {
file = InjectedLanguageManager.getInstance(file.getProject()).getTopLevelFile(context);
if (file != null) {
module = findModuleForPsiElement(file);
}
}
if (module == null || ModuleType.get(module) != FlexModuleType.getInstance()) {
return false;
}
if (vFile != null) {
CssDialect dialect = CssDialectMappings.getInstance(context.getProject()).getMapping(vFile);
return dialect == null || dialect == FlexCSSDialect.getInstance();
}
return true;
}
Aggregations