use of com.intellij.javascript.flex.mxml.schema.ClassBackedElementDescriptor in project intellij-plugins by JetBrains.
the class CreateFlexSkinIntention method getHostComponentClass.
@Nullable
private JSClass getHostComponentClass() {
final XmlTag tag = myElement instanceof XmlTag ? ((XmlTag) myElement).getParentTag() : myElement instanceof XmlAttributeValue ? (XmlTag) myElement.getParent().getParent() : null;
final XmlElementDescriptor descriptor = tag == null ? null : tag.getDescriptor();
if (descriptor instanceof ClassBackedElementDescriptor) {
final PsiElement declaration = descriptor.getDeclaration();
if (declaration instanceof JSClass) {
return (JSClass) declaration;
}
}
return null;
}
use of com.intellij.javascript.flex.mxml.schema.ClassBackedElementDescriptor in project intellij-plugins by JetBrains.
the class MxmlWriter method processDeclarations.
void processDeclarations(XmlTag parent) {
final int lengthPosition = out.allocateShort();
int validChildrenCount = 0;
for (XmlTag tag : parent.getSubTags()) {
ClassBackedElementDescriptor descriptor = (ClassBackedElementDescriptor) tag.getDescriptor();
assert descriptor != null;
if (descriptor.isPredefined()) {
// todo IDEA-72123
if (descriptor.getName().equals(FlexPredefinedTagNames.MODEL)) {
if (propertyProcessor.processFxModel(tag)) {
validChildrenCount++;
}
}
continue;
} else if (MxmlUtil.isComponentLanguageTag(tag)) {
if (propertyProcessor.processFxComponent(tag, false)) {
validChildrenCount++;
}
continue;
}
if (processClassBackedSubTag(tag, descriptor, null, true)) {
validChildrenCount++;
}
}
out.putShort(validChildrenCount, lengthPosition);
}
use of com.intellij.javascript.flex.mxml.schema.ClassBackedElementDescriptor in project intellij-plugins by JetBrains.
the class PropertyProcessor method processClass.
// see ClassProperty test
private void processClass(XmlElementValueProvider valueProvider) throws InvalidPropertyException {
JSClass jsClass = valueProvider.getJsClass();
// IDEA-73537, cannot use only valueProvider.getJsClass()
if (jsClass == null) {
String trimmed = valueProvider.getTrimmed();
XmlElement exceptionElement = valueProvider.getElement();
if (trimmed.isEmpty() && valueProvider.getElement() instanceof XmlTag) {
// case 1, fx:Class
final XmlTag propertyTag = (XmlTag) valueProvider.getElement();
final XmlTag[] propertyTagSubTags = propertyTag.getSubTags();
if (propertyTagSubTags.length == 1) {
final XmlTag contentTag = propertyTagSubTags[0];
exceptionElement = contentTag;
final XmlElementDescriptor contentTagDescriptor = contentTag.getDescriptor();
if (contentTagDescriptor instanceof ClassBackedElementDescriptor && AsCommonTypeNames.CLASS.equals(contentTagDescriptor.getQualifiedName())) {
trimmed = contentTag.getValue().getTrimmedText();
}
}
}
if (trimmed.isEmpty()) {
throw new InvalidPropertyException(exceptionElement, "invalid.class.value");
}
final Module module = ModuleUtilCore.findModuleForPsiElement(valueProvider.getElement());
if (module != null) {
jsClass = (JSClass) ActionScriptClassResolver.findClassByQNameStatic(trimmed, module.getModuleWithDependenciesAndLibrariesScope(false));
}
if (jsClass == null) {
throw new InvalidPropertyException(exceptionElement, "unresolved.class", trimmed);
}
}
if (InjectionUtil.isProjectComponent(jsClass)) {
if (ActionScriptClassResolver.isParentClass(jsClass, "spark.components.View")) {
int projectComponentFactoryId = getProjectComponentFactoryId(jsClass);
assert projectComponentFactoryId != -1;
writer.projectClassReference(projectComponentFactoryId);
} else {
throw new InvalidPropertyException(valueProvider.getElement(), "class.reference.support.only.skin.class.or.view", jsClass.getQualifiedName());
}
} else {
writer.classReference(jsClass.getQualifiedName());
}
}
use of com.intellij.javascript.flex.mxml.schema.ClassBackedElementDescriptor in project intellij-plugins by JetBrains.
the class PropertyProcessor method writeIfFxg.
private boolean writeIfFxg(XmlTag tag, XmlElementDescriptor descriptor, Context parentContext, boolean allowIncludeInExcludeFrom, PrimitiveAmfOutputStream out) {
if (descriptor instanceof ClassBackedElementDescriptor) {
PsiElement declaration = descriptor.getDeclaration();
PsiFile psiFile = declaration.getContainingFile();
VirtualFile virtualFile = psiFile.getVirtualFile();
MxmlWriter.LOG.assertTrue(virtualFile != null);
if (JavaScriptSupportLoader.isFxgFile(virtualFile)) {
out.write(AmfExtendedTypes.REFERABLE);
mxmlWriter.processIdAttributeOfFxTag(tag, parentContext, allowIncludeInExcludeFrom);
out.write(AmfExtendedTypes.SWF);
out.writeUInt29(EmbedSwfManager.getInstance().add(virtualFile, EmbedSwfManager.FXG_MARKER, writer.getAssetCounter()));
return true;
}
}
return false;
}
use of com.intellij.javascript.flex.mxml.schema.ClassBackedElementDescriptor in project intellij-plugins by JetBrains.
the class IncrementalDocumentSynchronizer method findSupportedTarget.
@Nullable
private XmlElementValueProvider findSupportedTarget() {
PsiElement element = event.getParent();
// if we change attribute value via line marker, so, event.getParent() will be XmlAttribute instead of XmlAttributeValue
while (!(element instanceof XmlAttribute)) {
element = element.getParent();
if (element instanceof XmlTag) {
XmlTag tag = (XmlTag) element;
XmlElementDescriptor descriptor = tag.getDescriptor();
if (descriptor instanceof ClassBackedElementDescriptor) {
ClassBackedElementDescriptor classBackedElementDescriptor = (ClassBackedElementDescriptor) descriptor;
if (classBackedElementDescriptor.isPredefined()) {
isStyleDataChanged = descriptor.getQualifiedName().equals(FlexPredefinedTagNames.STYLE);
isSkippedXml = isStyleDataChanged || (!MxmlUtil.isObjectLanguageTag(tag) && !descriptor.getQualifiedName().equals(FlexPredefinedTagNames.DECLARATIONS));
}
}
return null;
} else if (element instanceof PsiFile || element == null) {
return null;
}
}
XmlAttribute attribute = (XmlAttribute) element;
if (JavaScriptSupportLoader.MXML_URI3.equals(attribute.getNamespace()) || attribute.getValueElement() == null) {
return null;
}
XmlAttributeDescriptor xmlDescriptor = attribute.getDescriptor();
if (!(xmlDescriptor instanceof AnnotationBackedDescriptor)) {
return null;
}
AnnotationBackedDescriptor descriptor = (AnnotationBackedDescriptor) xmlDescriptor;
if (descriptor.isPredefined() || MxmlUtil.isIdLanguageAttribute(attribute, descriptor)) {
return null;
}
// todo incremental sync for state-specific attributes
PsiReference[] references = attribute.getReferences();
if (references.length > 1) {
for (int i = references.length - 1; i > -1; i--) {
PsiReference psiReference = references[i];
if (psiReference instanceof FlexReferenceContributor.StateReference) {
return null;
}
}
} else {
String prefix = attribute.getName() + '.';
for (XmlAttribute anotherAttribute : attribute.getParent().getAttributes()) {
if (anotherAttribute != attribute && anotherAttribute.getName().startsWith(prefix)) {
return null;
}
}
}
XmlAttributeValueProvider valueProvider = new XmlAttributeValueProvider(attribute);
// skip binding
PsiLanguageInjectionHost injectedHost = valueProvider.getInjectedHost();
if (injectedHost != null && InjectedLanguageUtil.hasInjections(injectedHost)) {
return null;
}
return valueProvider;
}
Aggregations