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;
}
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);
}
}
}
Aggregations