Search in sources :

Example 1 with StylesheetFile

use of com.intellij.psi.css.StylesheetFile in project intellij-plugins by JetBrains.

the class AngularJSCssInclusionContext method getContextFiles.

@NotNull
@Override
public PsiFile[] getContextFiles(@NotNull PsiFile current) {
    final PsiElement context = current.getContext();
    final JSProperty property = PsiTreeUtil.getParentOfType(context, JSProperty.class);
    if (property != null && "template".equals(property.getName())) {
        final JSObjectLiteralExpression object = (JSObjectLiteralExpression) property.getParent();
        final JSProperty styles = object.findProperty("styles");
        if (styles != null && styles.getValue() instanceof JSArrayLiteralExpression) {
            final List<PsiFile> result = new SmartList<>();
            for (JSExpression expression : ((JSArrayLiteralExpression) styles.getValue()).getExpressions()) {
                if (expression instanceof JSLiteralExpression && ((JSLiteralExpression) expression).isQuotedLiteral()) {
                    final List<Pair<PsiElement, TextRange>> injected = InjectedLanguageManager.getInstance(context.getProject()).getInjectedPsiFiles(expression);
                    if (injected != null) {
                        for (Pair<PsiElement, TextRange> pair : injected) {
                            if (pair.first instanceof StylesheetFile) {
                                result.add((PsiFile) pair.first);
                            }
                        }
                    }
                }
            }
            return result.toArray(PsiFile.EMPTY_ARRAY);
        }
    }
    return PsiFile.EMPTY_ARRAY;
}
Also used : TextRange(com.intellij.openapi.util.TextRange) StylesheetFile(com.intellij.psi.css.StylesheetFile) PsiFile(com.intellij.psi.PsiFile) SmartList(com.intellij.util.SmartList) PsiElement(com.intellij.psi.PsiElement) Pair(com.intellij.openapi.util.Pair) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with StylesheetFile

use of com.intellij.psi.css.StylesheetFile in project intellij-plugins by JetBrains.

the class IncrementalDocumentSynchronizer method run.

@Override
public void run() {
    DesignerApplicationManager designerManager = DesignerApplicationManager.getInstance();
    if (designerManager.isInitialRendering() || designerManager.isApplicationClosed()) {
        return;
    }
    // PsiTreeChangeEvent dispatched only for root psi file, i.e not for injected
    // (so, if CSS is injected, we get psi event about mxml file, but not about injected css file)
    // WELL, IT IS NOT TRUE!!! YESTERDAY IT ALWAYS WAS XmlFile, but TODAY IT IS CssFile :)
    final XmlFile xmlFile;
    if (event.getFile() instanceof XmlFile) {
        xmlFile = (XmlFile) event.getFile();
    } else {
        assert event.getFile() instanceof StylesheetFile;
        styleChanged();
        return;
    }
    DocumentInfo info = DocumentFactoryManager.getInstance().getNullableInfo(xmlFile);
    if (info != null && !incrementalSync(info)) {
        if (isStyleDataChanged) {
            styleChanged();
        } else if (!isSkippedXml) {
            initialRender(designerManager, xmlFile);
        }
    }
}
Also used : XmlFile(com.intellij.psi.xml.XmlFile) StylesheetFile(com.intellij.psi.css.StylesheetFile) DocumentInfo(com.intellij.flex.uiDesigner.DocumentFactoryManager.DocumentInfo)

Aggregations

StylesheetFile (com.intellij.psi.css.StylesheetFile)2 DocumentInfo (com.intellij.flex.uiDesigner.DocumentFactoryManager.DocumentInfo)1 Pair (com.intellij.openapi.util.Pair)1 TextRange (com.intellij.openapi.util.TextRange)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1 XmlFile (com.intellij.psi.xml.XmlFile)1 SmartList (com.intellij.util.SmartList)1 NotNull (org.jetbrains.annotations.NotNull)1