use of com.intellij.javascript.flex.mxml.schema.CodeContext in project intellij-plugins by JetBrains.
the class NewFlexComponentAction method getPrefixAndNamespace.
public static Pair<String, String> getPrefixAndNamespace(XmlTag tag, String qName) {
Module module = ModuleUtilCore.findModuleForPsiElement(tag);
boolean isFlex4Template = ArrayUtil.contains(JavaScriptSupportLoader.MXML_URI3, tag.knownNamespaces());
CodeContextHolder holder = CodeContextHolder.getInstance(module.getProject());
// ensure namespace is loaded into code context (including all the namespaces from all the libraries)
CodeContext.getContext(MxmlJSClass.MXML_URI4, module);
Collection<String> namespaces = holder.getNamespaces(module);
String[] illegalNamespaces = isFlex4Template ? new String[] { JavaScriptSupportLoader.MXML_URI } : MxmlJSClass.FLEX_4_NAMESPACES;
for (String namespace : namespaces) {
if (ArrayUtil.contains(namespace, illegalNamespaces) || CodeContext.isPackageBackedNamespace(namespace)) {
continue;
}
CodeContext codeContext = CodeContext.isStdNamespace(namespace) ? holder.getStandardContext(namespace, module) : holder.getCodeContext(namespace, module);
if (codeContext == null) {
continue;
}
if (codeContext.getElementDescriptor(StringUtil.getShortName(qName), qName) != null) {
return Pair.create(FlexSchemaHandler.getDefaultPrefix(namespace), namespace);
}
}
String packageName = StringUtil.getPackageName(qName);
String namespace = StringUtil.isEmpty(packageName) ? "*" : packageName + ".*";
return Pair.create(FlexSchemaHandler.getDefaultPrefix(namespace), namespace);
}
use of com.intellij.javascript.flex.mxml.schema.CodeContext in project intellij-plugins by JetBrains.
the class FlexCssElementDescriptorProvider method getSimpleSelectors.
@NotNull
public String[] getSimpleSelectors(@NotNull PsiElement context) {
Module module = findModuleForPsiElement(context);
if (module == null) {
return ArrayUtil.EMPTY_STRING_ARRAY;
}
CodeContext codeContext = CodeContext.getContext(JavaScriptSupportLoader.MXML_URI, module);
XmlElementDescriptor[] descriptors = codeContext.getDescriptorsWithAllowedDeclaration();
String[] selectors = new String[descriptors.length + 1];
selectors[0] = "global";
int i = 1;
for (XmlElementDescriptor descriptor : descriptors) {
selectors[i++] = descriptor.getName();
}
return selectors;
}
Aggregations