vscode-as3mxml icon indicating copy to clipboard operation
vscode-as3mxml copied to clipboard

Check SWCs for design.xml to get suggestions for MXML namespace prefixes

Open joshtynjala opened this issue 7 years ago • 0 comments

This should happen in MXMLNamespaceUtils.getMXMLNamespaceForTypeDefinition().

Some code to get started:

if (prefix == null)
{
    for (ISWC swc : currentProject.getLibraries())
    {
        if (swc.getSWCFile().getAbsolutePath().equals(definition.getContainingFilePath()))
        {
            //design.xml is an optional file that contains a suggested
            //namespace for the namespaces the SWC contains
            ISWCFileEntry fileInSWC = swc.getFile("design.xml");
            if (fileInSWC != null)
            {
                //TODO: figure out how to parse the file and extract the prefix
            }
        }
    }
}

Example design.xml:

<?xml version="1.0"?>
<design>
	<namespaces>
		<namespace prefix="mike" uri="http://morearty.com/test" />
	</namespaces>

	<categories>
		<category id="mike" label="Mike's stuff" defaultExpand="true" />
	</categories>

	<components>
		<component name="Calculator" namespace="mike" category="mike" insertStyle="control">
			<defaultAttribute name="layout" value="standard" />
			<mxmlProperties>
				<combo id="layout" name="Layout:" />
			</mxmlProperties>
		</component>
	</components>
</design>

Source of sample design.xml: http://www.morearty.com/blog/2008/11/19/extending-flex-builder-sample-code-for-designxml/

joshtynjala avatar Nov 03 '16 20:11 joshtynjala