forked from apache/royale-compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
implicit_imports.patch
147 lines (137 loc) · 6.3 KB
/
implicit_imports.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
From d2ad23813032ef6a1fb6ce1d18aadaae880763e1 Mon Sep 17 00:00:00 2001
From: dloverin <dloverin@adobe.com>
Date: Tue, 3 Sep 2013 17:17:44 -0400
Subject: [PATCH] add implicit imports dependending on the MXML version.
---
.../compiler/internal/projects/FlexProject.java | 59 +++++++++++++++++++---
.../internal/projects/FlexProjectConfigurator.java | 1 -
.../compiler/internal/scopes/MXMLFileScope.java | 2 +-
.../compiler/internal/tree/mxml/MXMLFileNode.java | 2 +-
4 files changed, 55 insertions(+), 9 deletions(-)
diff --git a/compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java b/compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java
index 0b827a0..c187ed3 100644
--- a/compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java
+++ b/compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java
@@ -821,10 +821,10 @@ public class FlexProject extends ASProject implements IFlexProject
}
public void setXMLUtilClass(String xmlUtilClass)
- {
+ {
this.xmlUtilClass = xmlUtilClass;
xmlUtilClassName = getMNameForQName(xmlUtilClass);
- }
+ }
/**
* Get the fully-qualified name of the runtime class
@@ -1033,25 +1033,72 @@ public class FlexProject extends ASProject implements IFlexProject
{
this.namedColors = namedColors;
}
+
+ /**
+ * Get a list of additional imports based on the MXML dialect being used.
+ *
+ * @param dialect - the dialect of the MXML language being compiled.
+ * @return An array of Strings such as <code>flash.display.*"</code>.
+ */
+ private List<String>getMXMLVersionDependentImports(MXMLDialect dialect) {
+
+ List<String> imports = new ArrayList<String>();
+ if (dialect.isEqualToOrAfter(MXMLDialect.MXML_2009))
+ {
+ // add "mx.filters.*" and "spark.filters.*"
+ imports.add("mx.filters.*");
+ imports.add("spark.filters.*");
+ }
+ else
+ {
+ // add "flash.filters.*"
+ imports.add("flash.filters.*");
+ }
+
+ return imports;
+ }
+
/**
* Gets the imports that are automatically imported into every MXML file.
*
+ * @param dialect - the dialect of the MXML language being compiled.
* @return An array of Strings such as <code>flash.display.*"</code>.
*/
- public String[] getImplicitImportsForMXML()
+ public String[] getImplicitImportsForMXML(MXMLDialect dialect)
{
- return implicitImportsForMXML;
+ String[] additionalImports = getMXMLVersionDependentImports(dialect).toArray(new String[0]);
+ String[] imports = new String[implicitImportsForMXML.length +
+ additionalImports.length];
+
+ // append MXML version dependent imports to the standard imports.
+ System.arraycopy(implicitImportsForMXML, 0, imports, 0, implicitImportsForMXML.length);
+ System.arraycopy(additionalImports, 0, imports, implicitImportsForMXML.length, additionalImports.length);
+
+ return imports;
}
/**
* Gets a list of nodes representing the implicit imports, for CodeModel.
*
+ * @param dialect - the dialect of the MXML language being compiled.
* @return A list of {@code MXMLImplicitImportNode} objects.
*/
- public List<IImportNode> getImplicitImportNodesForMXML()
+ public List<IImportNode> getImplicitImportNodesForMXML(MXMLDialect dialect)
{
- return implicitImportNodesForMXML;
+ List<String> additionalImports = getMXMLVersionDependentImports(dialect);
+ List<IImportNode> importNodes = new ArrayList<IImportNode>(implicitImportNodesForMXML.size() +
+ additionalImports.size());
+
+ // append MXML version dependent imports to the standard imports.
+ importNodes.addAll(implicitImportNodesForMXML);
+
+ for (String additionalImport : additionalImports)
+ {
+ importNodes.add(new MXMLImplicitImportNode(this, additionalImport));
+ }
+
+ return importNodes;
}
/**
diff --git a/compiler/src/org/apache/flex/compiler/internal/projects/FlexProjectConfigurator.java b/compiler/src/org/apache/flex/compiler/internal/projects/FlexProjectConfigurator.java
index 00987d8..14b98cf 100644
--- a/compiler/src/org/apache/flex/compiler/internal/projects/FlexProjectConfigurator.java
+++ b/compiler/src/org/apache/flex/compiler/internal/projects/FlexProjectConfigurator.java
@@ -83,7 +83,6 @@ public class FlexProjectConfigurator
"mx.core.IFlexModuleFactory",
"mx.core.IPropertyChangeNotifier",
"mx.core.mx_internal",
- "mx.filters.*",
"mx.styles.*"
};
diff --git a/compiler/src/org/apache/flex/compiler/internal/scopes/MXMLFileScope.java b/compiler/src/org/apache/flex/compiler/internal/scopes/MXMLFileScope.java
index facb8ac..272f3bb 100644
--- a/compiler/src/org/apache/flex/compiler/internal/scopes/MXMLFileScope.java
+++ b/compiler/src/org/apache/flex/compiler/internal/scopes/MXMLFileScope.java
@@ -136,7 +136,7 @@ public class MXMLFileScope extends ASFileScope implements IXMLNameResolver
private void addImplicitImportsForMXML()
{
// Add the implicit imports for MXML.
- for (String implicitImport : project.getImplicitImportsForMXML())
+ for (String implicitImport : project.getImplicitImportsForMXML(mxmlDialect))
{
addImport(implicitImport);
}
diff --git a/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLFileNode.java b/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLFileNode.java
index 814f3f7..7bf0aaa 100644
--- a/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLFileNode.java
+++ b/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLFileNode.java
@@ -145,7 +145,7 @@ public class MXMLFileNode extends MXMLNodeBase implements IMXMLFileNode, IScoped
}
// Add implicit import nodes for MXML.
- for (IImportNode implicitImportNode : project.getImplicitImportNodesForMXML())
+ for (IImportNode implicitImportNode : project.getImplicitImportNodesForMXML(builder.getMXMLDialect()))
{
addImportNode(implicitImportNode);
}
--
1.7.12.4 (Apple Git-37)