This is an automated email from the ASF dual-hosted git repository.
Harbs pushed a commit to branch codegraph
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
The following commit(s) were added to refs/heads/codegraph by this push:
new 8a92d8acc feat(codegraph): Enhance Code Graph functionality with
static and instance field handling, improved error reporting, and updated
configuration files
8a92d8acc is described below
commit 8a92d8acc6161c335142aaa8e77535e9f50d35cb
Author: Harbs <[email protected]>
AuthorDate: Sat Aug 1 22:06:45 2026 +0300
feat(codegraph): Enhance Code Graph functionality with static and instance
field handling, improved error reporting, and updated configuration files
---
CODEGRAPH_EXPORTER_IMPLEMENTATION_PLAN.md | 19 +++++
.../apache/royale/compiler/clients/CODEGRAPH.java | 2 +
.../internal/codegen/graph/CodeGraphExporter.java | 96 +++++++++++++++++++---
.../internal/codegen/graph/CodeGraphIdFactory.java | 5 ++
.../codegen/graph/TestCodeGraphExporter.java | 16 ++++
.../codegen/graph/TestCodeGraphIdFactory.java | 2 +
.../test/resources/codegraph/InvalidCodeGraph.as | 19 +++++
.../codegraph/conditional/ConditionalGraph.as | 19 +++++
.../codegraph/conditional/IncludedOnly.as | 19 +++++
.../test/resources/codegraph/golden/GraphBase.as | 19 +++++
.../test/resources/codegraph/golden/GraphRoot.as | 19 +++++
.../resources/codegraph/golden/IGraphContract.as | 19 +++++
.../resources/codegraph/golden/packageFunction.as | 19 +++++
.../java/org/apache/royale/maven/BaseMojo.java | 4 +
.../apache/royale/maven/CompileCodeGraphMojo.java | 45 +++++++++-
.../config/compile-codegraph-js-config.xml | 49 +++++++++++
.../config/compile-codegraph-swf-config.xml | 29 +++++++
17 files changed, 387 insertions(+), 13 deletions(-)
diff --git a/CODEGRAPH_EXPORTER_IMPLEMENTATION_PLAN.md
b/CODEGRAPH_EXPORTER_IMPLEMENTATION_PLAN.md
index ca1aa1f46..1aba1c326 100644
--- a/CODEGRAPH_EXPORTER_IMPLEMENTATION_PLAN.md
+++ b/CODEGRAPH_EXPORTER_IMPLEMENTATION_PLAN.md
@@ -1,3 +1,22 @@
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+
# Royale Code Graph Exporter Implementation Plan
## Objective
diff --git
a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/CODEGRAPH.java
b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/CODEGRAPH.java
index ace87b2c8..2d0158c2c 100644
---
a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/CODEGRAPH.java
+++
b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/CODEGRAPH.java
@@ -39,6 +39,7 @@ import
org.apache.royale.compiler.internal.driver.mxml.royale.MXMLRoyaleSWCBacke
import org.apache.royale.compiler.internal.targets.RoyaleSWCTarget;
import org.apache.royale.compiler.problems.ICompilerProblem;
import org.apache.royale.compiler.problems.InternalCompilerProblem;
+import org.apache.royale.compiler.problems.ResourceBundleNotFoundProblem;
import org.apache.royale.compiler.targets.ITarget.TargetType;
import org.apache.royale.compiler.targets.ITargetSettings;
import org.apache.royale.compiler.units.ICompilationUnit;
@@ -83,6 +84,7 @@ public class CODEGRAPH extends MXMLJSCRoyale
{
try
{
+
problems.setShowProblemByClass(ResourceBundleNotFoundProblem.class, false);
project.getSourceCompilationUnitFactory().addHandler(asFileHandler);
if (!setupTargetFile())
return false;
diff --git
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/graph/CodeGraphExporter.java
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/graph/CodeGraphExporter.java
index 74a405a84..adeed9120 100644
---
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/graph/CodeGraphExporter.java
+++
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/graph/CodeGraphExporter.java
@@ -25,10 +25,12 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.apache.royale.abc.ABCConstants;
import org.apache.royale.compiler.asdoc.IASDocComment;
import org.apache.royale.compiler.asdoc.IASDocTag;
import org.apache.royale.compiler.definitions.IClassDefinition;
@@ -81,7 +83,7 @@ public final class CodeGraphExporter
else if (definition instanceof IFunctionDefinition)
model.addSymbol(exportFunction((IFunctionDefinition)definition, null));
else if (definition instanceof IVariableDefinition)
-
model.addSymbol(exportVariable((IVariableDefinition)definition, null));
+
model.addSymbol(exportVariable((IVariableDefinition)definition, null, false));
}
for (ITypeDefinition externalDefinition : externalDefinitions.values())
{
@@ -125,22 +127,44 @@ public final class CodeGraphExporter
interfaceDefinition.getExtendedInterfacesAsDisplayStrings());
}
+ Set<String> collidingVariableNames =
getStaticVariableCollisions(definition);
for (IDefinition memberDefinition :
definition.getContainedScope().getAllLocalDefinitions())
{
- boolean isConstructor = memberDefinition instanceof
IFunctionDefinition
- && ((IFunctionDefinition)memberDefinition).isConstructor();
- boolean isPublic = memberDefinition.isPublic() || definition
instanceof IInterfaceDefinition;
- if (!isPublic || memberDefinition.isImplicit() || isConstructor
- || isExcludedFromPublicAPI(memberDefinition))
+ if (!isExportedMember(memberDefinition, definition))
continue;
if (memberDefinition instanceof IFunctionDefinition)
symbol.addMember(exportFunction((IFunctionDefinition)memberDefinition,
definition));
else if (memberDefinition instanceof IVariableDefinition)
-
symbol.addMember(exportVariable((IVariableDefinition)memberDefinition,
definition));
+
symbol.addMember(exportVariable((IVariableDefinition)memberDefinition,
definition,
+
collidingVariableNames.contains(memberDefinition.getBaseName())));
}
return symbol;
}
+ private Set<String> getStaticVariableCollisions(ITypeDefinition definition)
+ {
+ Set<String> staticNames = new HashSet<String>();
+ Set<String> instanceNames = new HashSet<String>();
+ for (IDefinition memberDefinition :
definition.getContainedScope().getAllLocalDefinitions())
+ {
+ if (!(memberDefinition instanceof IVariableDefinition)
+ || !isExportedMember(memberDefinition, definition))
+ continue;
+ (memberDefinition.isStatic() ? staticNames :
instanceNames).add(memberDefinition.getBaseName());
+ }
+ staticNames.retainAll(instanceNames);
+ return staticNames;
+ }
+
+ private boolean isExportedMember(IDefinition memberDefinition,
ITypeDefinition definition)
+ {
+ boolean isConstructor = memberDefinition instanceof IFunctionDefinition
+ && ((IFunctionDefinition)memberDefinition).isConstructor();
+ boolean isPublic = memberDefinition.isPublic() || definition
instanceof IInterfaceDefinition;
+ return isPublic && !memberDefinition.isImplicit() && !isConstructor
+ && !isExcludedFromPublicAPI(memberDefinition);
+ }
+
private void addInterfaces(CodeGraphSymbol symbol, IInterfaceDefinition[]
definitions, String[] displayNames)
{
int count = Math.max(definitions.length, displayNames.length);
@@ -191,9 +215,9 @@ public final class CodeGraphExporter
IFunctionDefinition overriddenFunction =
definition.resolveOverriddenFunction(project);
if (overriddenFunction != null)
symbol.setOverriddenMember(createFunctionReference(overriddenFunction));
- IFunctionDefinition implementedFunction =
definition.resolveImplementedFunction(project);
- if (implementedFunction != null)
-
symbol.setImplementedMember(createFunctionReference(implementedFunction));
+ CodeGraphReference implementedMember =
resolveImplementedMember(definition, declaringType);
+ if (implementedMember != null)
+ symbol.setImplementedMember(implementedMember);
if (definition instanceof IGetterDefinition || definition instanceof
ISetterDefinition)
{
ITypeDefinition typeDefinition = definition.resolveType(project);
@@ -211,12 +235,57 @@ public final class CodeGraphExporter
parameterDefinition.getTypeAsDisplayString());
Object defaultValue = parameterDefinition.hasDefaultValue()
? parameterDefinition.resolveDefaultValue(project) : null;
+ if (defaultValue == ABCConstants.UNDEFINED_VALUE)
+ defaultValue = "undefined";
+ else if (defaultValue == ABCConstants.NULL_VALUE)
+ defaultValue = null;
symbol.addParameter(new
CodeGraphParameter(parameterDefinition.getBaseName(), typeReference,
parameterDefinition.hasDefaultValue(),
parameterDefinition.isRest(), defaultValue));
}
return symbol;
}
+ private CodeGraphReference resolveImplementedMember(IFunctionDefinition
definition,
+ ITypeDefinition declaringType)
+ {
+ if (!(declaringType instanceof IClassDefinition))
+ return null;
+ String signature = getFunctionSignature(definition);
+ CodeGraphReference result = null;
+ Iterator<IInterfaceDefinition> interfaces =
((IClassDefinition)declaringType).interfaceIterator(project);
+ while (interfaces.hasNext())
+ {
+ IInterfaceDefinition interfaceDefinition = interfaces.next();
+ for (IDefinition memberDefinition :
interfaceDefinition.getContainedScope().getAllLocalDefinitions())
+ {
+ if (!(memberDefinition instanceof IFunctionDefinition))
+ continue;
+ IFunctionDefinition candidate =
(IFunctionDefinition)memberDefinition;
+ if (!signature.equals(getFunctionSignature(candidate)))
+ continue;
+ CodeGraphReference reference =
createFunctionReference(candidate);
+ if (result == null ||
reference.getId().compareTo(result.getId()) < 0)
+ result = reference;
+ }
+ }
+ return result;
+ }
+
+ private String getFunctionSignature(IFunctionDefinition definition)
+ {
+ StringBuilder result = new StringBuilder();
+ result.append(definition instanceof IGetterDefinition ? "get:" :
+ definition instanceof ISetterDefinition ? "set:" :
"function:");
+ result.append(definition.getBaseName()).append('(');
+ for (IParameterDefinition parameterDefinition :
definition.getParameters())
+ {
+ ITypeDefinition parameterType =
parameterDefinition.resolveType(project);
+ result.append(parameterType == null ?
parameterDefinition.getTypeAsDisplayString()
+ : parameterType.getQualifiedName()).append(',');
+ }
+ return result.append(')').toString();
+ }
+
private String createCallableId(IFunctionDefinition definition,
ITypeDefinition declaringType)
{
List<String> parameterTypes = new ArrayList<String>();
@@ -233,12 +302,15 @@ public final class CodeGraphExporter
return CodeGraphIdFactory.callable(declaringType.getQualifiedName(),
definition.getBaseName(), parameterTypes);
}
- private CodeGraphSymbol exportVariable(IVariableDefinition definition,
ITypeDefinition declaringType)
+ private CodeGraphSymbol exportVariable(IVariableDefinition definition,
ITypeDefinition declaringType,
+ boolean hasStaticCollision)
{
String kind = definition instanceof IConstantDefinition ? "constant"
: declaringType == null ? "variable" : "field";
String id = declaringType == null ?
CodeGraphIdFactory.definition(definition.getQualifiedName())
- : CodeGraphIdFactory.member(declaringType.getQualifiedName(),
definition.getBaseName());
+ : hasStaticCollision && definition.isStatic()
+ ?
CodeGraphIdFactory.staticMember(declaringType.getQualifiedName(),
definition.getBaseName())
+ :
CodeGraphIdFactory.member(declaringType.getQualifiedName(),
definition.getBaseName());
CodeGraphSymbol symbol = new CodeGraphSymbol(id,
definition.getQualifiedName(), definition.getBaseName(),
definition.getPackageName(), kind);
addDefinitionDetails(symbol, definition);
diff --git
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/graph/CodeGraphIdFactory.java
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/graph/CodeGraphIdFactory.java
index 05b46e1d1..4d821989a 100644
---
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/graph/CodeGraphIdFactory.java
+++
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/graph/CodeGraphIdFactory.java
@@ -42,6 +42,11 @@ public final class CodeGraphIdFactory
return definition(ownerQualifiedName) + "#" + memberName;
}
+ public static String staticMember(String ownerQualifiedName, String
memberName)
+ {
+ return member(ownerQualifiedName, memberName) + ":static";
+ }
+
public static String accessor(String ownerQualifiedName, String
propertyName, boolean getter)
{
return member(ownerQualifiedName, propertyName) + (getter ? ":get" :
":set");
diff --git
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/graph/TestCodeGraphExporter.java
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/graph/TestCodeGraphExporter.java
index fb04c3d21..1c244d253 100644
---
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/graph/TestCodeGraphExporter.java
+++
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/graph/TestCodeGraphExporter.java
@@ -68,6 +68,22 @@ public class TestCodeGraphExporter extends ASTestBase
assertTrue(model.getExternalSymbols().get(1).isExternal());
}
+ @Test
+ public void testStaticAndInstanceFieldsWithSameNameHaveUniqueIds()
+ {
+ IClassNode classNode = getClassNode("public class Widget {"
+ + "public static var label:String;"
+ + "public var label:String;"
+ + "}");
+
+ CodeGraphModel model = new CodeGraphExporter(project).export(
+
Collections.singleton(classNode.getDefinition()), "js", null);
+ List<CodeGraphSymbol> members =
model.getSymbols().get(0).getMembers();
+ assertEquals(2, members.size());
+ assertEquals("as3://Widget#label:static",
members.get(0).getId());
+ assertEquals("as3://Widget#label", members.get(1).getId());
+ }
+
@Test
public void testCallableMembersAreCollectedSemantically()
{
diff --git
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/graph/TestCodeGraphIdFactory.java
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/graph/TestCodeGraphIdFactory.java
index d5d088bb4..ba266ec95 100644
---
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/graph/TestCodeGraphIdFactory.java
+++
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/graph/TestCodeGraphIdFactory.java
@@ -40,6 +40,8 @@ public class TestCodeGraphIdFactory
{
assertEquals("as3://org/apache/royale/core/UIBase#typeNames",
CodeGraphIdFactory.member("org.apache.royale.core.UIBase",
"typeNames"));
+ assertEquals("as3://org/apache/royale/core/UIBase#typeNames:static",
+ CodeGraphIdFactory.staticMember("org.apache.royale.core.UIBase",
"typeNames"));
}
@Test
diff --git a/compiler-jx/src/test/resources/codegraph/InvalidCodeGraph.as
b/compiler-jx/src/test/resources/codegraph/InvalidCodeGraph.as
index 9d577256a..82bea7180 100644
--- a/compiler-jx/src/test/resources/codegraph/InvalidCodeGraph.as
+++ b/compiler-jx/src/test/resources/codegraph/InvalidCodeGraph.as
@@ -1,3 +1,22 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
package codegraph
{
public class InvalidCodeGraph implements MissingInterface
diff --git
a/compiler-jx/src/test/resources/codegraph/conditional/ConditionalGraph.as
b/compiler-jx/src/test/resources/codegraph/conditional/ConditionalGraph.as
index 608ca0e8e..8f38f880f 100644
--- a/compiler-jx/src/test/resources/codegraph/conditional/ConditionalGraph.as
+++ b/compiler-jx/src/test/resources/codegraph/conditional/ConditionalGraph.as
@@ -1,3 +1,22 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
package codegraph.conditional
{
public class ConditionalGraph
diff --git
a/compiler-jx/src/test/resources/codegraph/conditional/IncludedOnly.as
b/compiler-jx/src/test/resources/codegraph/conditional/IncludedOnly.as
index 3cd1e0dc6..a5ca8551e 100644
--- a/compiler-jx/src/test/resources/codegraph/conditional/IncludedOnly.as
+++ b/compiler-jx/src/test/resources/codegraph/conditional/IncludedOnly.as
@@ -1,3 +1,22 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
package codegraph.conditional
{
public class IncludedOnly
diff --git a/compiler-jx/src/test/resources/codegraph/golden/GraphBase.as
b/compiler-jx/src/test/resources/codegraph/golden/GraphBase.as
index 8dbf45f4f..d073fe61f 100644
--- a/compiler-jx/src/test/resources/codegraph/golden/GraphBase.as
+++ b/compiler-jx/src/test/resources/codegraph/golden/GraphBase.as
@@ -1,3 +1,22 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
package codegraph.golden
{
public class GraphBase
diff --git a/compiler-jx/src/test/resources/codegraph/golden/GraphRoot.as
b/compiler-jx/src/test/resources/codegraph/golden/GraphRoot.as
index 1c84a39f8..fcfb7fac1 100644
--- a/compiler-jx/src/test/resources/codegraph/golden/GraphRoot.as
+++ b/compiler-jx/src/test/resources/codegraph/golden/GraphRoot.as
@@ -1,3 +1,22 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
package codegraph.golden
{
/** Dispatched when graph work completes. */
diff --git a/compiler-jx/src/test/resources/codegraph/golden/IGraphContract.as
b/compiler-jx/src/test/resources/codegraph/golden/IGraphContract.as
index 3c49ced49..0dbf05610 100644
--- a/compiler-jx/src/test/resources/codegraph/golden/IGraphContract.as
+++ b/compiler-jx/src/test/resources/codegraph/golden/IGraphContract.as
@@ -1,3 +1,22 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
package codegraph.golden
{
public interface IGraphContract
diff --git a/compiler-jx/src/test/resources/codegraph/golden/packageFunction.as
b/compiler-jx/src/test/resources/codegraph/golden/packageFunction.as
index 45669d536..da9b1da33 100644
--- a/compiler-jx/src/test/resources/codegraph/golden/packageFunction.as
+++ b/compiler-jx/src/test/resources/codegraph/golden/packageFunction.as
@@ -1,3 +1,22 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
package codegraph.golden
{
public function packageFunction(value:String):Boolean
diff --git
a/royale-maven-plugin/src/main/java/org/apache/royale/maven/BaseMojo.java
b/royale-maven-plugin/src/main/java/org/apache/royale/maven/BaseMojo.java
index 8bb7d40a8..b002d5fd2 100644
--- a/royale-maven-plugin/src/main/java/org/apache/royale/maven/BaseMojo.java
+++ b/royale-maven-plugin/src/main/java/org/apache/royale/maven/BaseMojo.java
@@ -396,6 +396,10 @@ public abstract class BaseMojo
// Get an instance of the compiler and run the build.
FlexTool tool = toolGroup.getFlexTool(getFlexTool());
+ if(tool == null) {
+ throw new MojoExecutionException("Could not find tool " +
getFlexTool()
+ + " in tool group " + getToolGroupName());
+ }
String[] args = getCompilerArgs(configFile).toArray(new String[0]);
getLog().info("Executing " + getFlexTool() + " in tool group " +
getToolGroupName() + " with args: " + Arrays.toString(args));
int exitCode = tool.execute(args);
diff --git
a/royale-maven-plugin/src/main/java/org/apache/royale/maven/CompileCodeGraphMojo.java
b/royale-maven-plugin/src/main/java/org/apache/royale/maven/CompileCodeGraphMojo.java
index bddb112ac..43c985b10 100644
---
a/royale-maven-plugin/src/main/java/org/apache/royale/maven/CompileCodeGraphMojo.java
+++
b/royale-maven-plugin/src/main/java/org/apache/royale/maven/CompileCodeGraphMojo.java
@@ -26,6 +26,7 @@ import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import java.io.File;
+import java.util.LinkedList;
import java.util.List;
/**
@@ -83,9 +84,32 @@ public class CompileCodeGraphMojo
type.get() == Type.SWF ? "swf" : "js"), outputFileName);
}
+ @Override
+ protected List<String> getCompilerArgs(File configFile) throws
MojoExecutionException {
+ List<String> args = super.getCompilerArgs(configFile);
+ args.removeIf(arg -> arg.startsWith("-js-compiler-define="));
+ return args;
+ }
+
@Override
protected boolean skip() {
- return skipCodeGraph;
+ return skipCodeGraph || "pom".equals(project.getPackaging());
+ }
+
+ @Override
+ protected List<Namespace> getNamespaces() {
+ List<Namespace> namespaces = new LinkedList<Namespace>();
+ for(Namespace namespace : super.getNamespaces()) {
+ boolean matches = type.get() == Type.JS
+ ? namespace.getType().equals(Namespace.TYPE_DEFAULT)
+ || namespace.getType().equals(Namespace.TYPE_JS)
+ : namespace.getType().equals(Namespace.TYPE_DEFAULT)
+ || namespace.getType().equals(Namespace.TYPE_AS);
+ if(matches) {
+ namespaces.add(namespace);
+ }
+ }
+ return namespaces;
}
@Override
@@ -114,6 +138,15 @@ public class CompileCodeGraphMojo
if(type.get() == null) {
throw new MojoExecutionException("type not set");
}
+ for(Define define : defines) {
+ if("GOOG::DEBUG".equals(define.getName())) {
+ define.setValue(type.get() == Type.SWF ? "true" :
"goog.DEBUG");
+ } else if("ROYALE::DISPLAYOBJECT".equals(define.getName())) {
+ define.setValue(type.get() == Type.SWF ? "DisplayObject" :
"IUIComponent");
+ } else if("ROYALE::PROXYVISIBILITY".equals(define.getName())) {
+ define.setValue(type.get() == Type.SWF ? "flash_proxy" :
"public");
+ }
+ }
switch (type.get()) {
case SWF:
defines.add(new Define("COMPILE::JS", "false"));
@@ -148,6 +181,16 @@ public class CompileCodeGraphMojo
return false;
}
+ @Override
+ protected boolean includeLibraryJS(Artifact library) {
+ return includeLibrary(library);
+ }
+
+ @Override
+ protected boolean includeLibrarySWF(Artifact library) {
+ return includeLibrary(library);
+ }
+
private enum Type {
SWF,
JS
diff --git
a/royale-maven-plugin/src/main/resources/config/compile-codegraph-js-config.xml
b/royale-maven-plugin/src/main/resources/config/compile-codegraph-js-config.xml
index 1cd47231f..ab04341ad 100644
---
a/royale-maven-plugin/src/main/resources/config/compile-codegraph-js-config.xml
+++
b/royale-maven-plugin/src/main/resources/config/compile-codegraph-js-config.xml
@@ -21,6 +21,10 @@
<compiler>
<debug>$debug</debug>
+ <targets>
+ <target>JSRoyale</target>
+ </targets>
+
<library-path>
#foreach($artifact in $libraries)
<path-element>$artifact.file</path-element>
#end
@@ -31,6 +35,26 @@
#end
</external-library-path>
+ <js-library-path>
+ #foreach($artifact in $jsLibraries)
<path-element>$artifact.file</path-element>
+ #end
+ </js-library-path>
+
+ <swf-library-path>
+ #foreach($artifact in $jsLibraries)
<path-element>$artifact.file</path-element>
+ #end
+ </swf-library-path>
+
+ <js-external-library-path>
+ #foreach($artifact in $jsExternalLibraries)
<path-element>$artifact.file</path-element>
+ #end
+ </js-external-library-path>
+
+ <swf-external-library-path>
+ #foreach($artifact in $jsExternalLibraries)
<path-element>$artifact.file</path-element>
+ #end
+ </swf-external-library-path>
+
<source-path>
#foreach($sourcePath in $sourcePaths)
<path-element>$sourcePath</path-element>
#end
@@ -56,6 +80,29 @@
</keep-as3-metadata>
<allow-subclass-overrides>$allowSubclassOverrides</allow-subclass-overrides>
+
+ <mxml>
+ <children-as-data>true</children-as-data>
+ <imports>
+ <implicit-import>org.apache.royale.events.*</implicit-import>
+ <implicit-import>org.apache.royale.geom.*</implicit-import>
+ <implicit-import>org.apache.royale.core.ClassFactory</implicit-import>
+ <implicit-import>org.apache.royale.core.IFactory</implicit-import>
+ </imports>
+ </mxml>
+
<binding-value-change-event>org.apache.royale.events.ValueChangeEvent</binding-value-change-event>
+
<binding-value-change-event-kind>org.apache.royale.events.ValueChangeEvent</binding-value-change-event-kind>
+
<binding-value-change-event-type>valueChange</binding-value-change-event-type>
+
<binding-event-handler-event>org.apache.royale.events.Event</binding-event-handler-event>
+
<binding-event-handler-class>org.apache.royale.events.EventDispatcher</binding-event-handler-class>
+
<binding-event-handler-interface>org.apache.royale.events.IEventDispatcher</binding-event-handler-interface>
+ <states-class>org.apache.royale.states.State</states-class>
+
<states-instance-override-class>org.apache.royale.states.AddItems</states-instance-override-class>
+
<states-property-override-class>org.apache.royale.states.SetProperty</states-property-override-class>
+
<states-event-override-class>org.apache.royale.states.SetEventHandler</states-event-override-class>
+
<component-factory-class>org.apache.royale.core.ClassFactory</component-factory-class>
+
<component-factory-interface>org.apache.royale.core.IFactory</component-factory-interface>
+
<show-deprecation-warnings>false</show-deprecation-warnings>
#foreach($define in $defines) <define>
@@ -65,10 +112,12 @@
#end
</compiler>
+#if($includeSources)
<include-sources>
#foreach($sourcePath in $sourcePaths)
<path-element>$sourcePath</path-element>
#end
</include-sources>
+#end
#if($includeClasses)
<include-classes>
diff --git
a/royale-maven-plugin/src/main/resources/config/compile-codegraph-swf-config.xml
b/royale-maven-plugin/src/main/resources/config/compile-codegraph-swf-config.xml
index ad5610444..597465afd 100644
---
a/royale-maven-plugin/src/main/resources/config/compile-codegraph-swf-config.xml
+++
b/royale-maven-plugin/src/main/resources/config/compile-codegraph-swf-config.xml
@@ -21,6 +21,10 @@
<compiler>
<debug>$debug</debug>
+ <targets>
+ <target>SWF</target>
+ </targets>
+
<library-path>
#foreach($artifact in $libraries)
<path-element>$artifact.file</path-element>
#end
@@ -56,6 +60,29 @@
</keep-as3-metadata>
<allow-subclass-overrides>$allowSubclassOverrides</allow-subclass-overrides>
+
+ <mxml>
+ <children-as-data>true</children-as-data>
+ <imports>
+ <implicit-import>org.apache.royale.events.*</implicit-import>
+ <implicit-import>org.apache.royale.geom.*</implicit-import>
+ <implicit-import>org.apache.royale.core.ClassFactory</implicit-import>
+ <implicit-import>org.apache.royale.core.IFactory</implicit-import>
+ </imports>
+ </mxml>
+
<binding-value-change-event>org.apache.royale.events.ValueChangeEvent</binding-value-change-event>
+
<binding-value-change-event-kind>org.apache.royale.events.ValueChangeEvent</binding-value-change-event-kind>
+
<binding-value-change-event-type>valueChange</binding-value-change-event-type>
+
<binding-event-handler-event>org.apache.royale.events.Event</binding-event-handler-event>
+
<binding-event-handler-class>org.apache.royale.events.EventDispatcher</binding-event-handler-class>
+
<binding-event-handler-interface>org.apache.royale.events.IEventDispatcher</binding-event-handler-interface>
+ <states-class>org.apache.royale.states.State</states-class>
+
<states-instance-override-class>org.apache.royale.states.AddItems</states-instance-override-class>
+
<states-property-override-class>org.apache.royale.states.SetProperty</states-property-override-class>
+
<states-event-override-class>org.apache.royale.states.SetEventHandler</states-event-override-class>
+
<component-factory-class>org.apache.royale.core.ClassFactory</component-factory-class>
+
<component-factory-interface>org.apache.royale.core.IFactory</component-factory-interface>
+
<show-deprecation-warnings>false</show-deprecation-warnings>
#foreach($define in $defines) <define>
@@ -65,10 +92,12 @@
#end
</compiler>
+#if($includeSources)
<include-sources>
#foreach($sourcePath in $sourcePaths)
<path-element>$sourcePath</path-element>
#end
</include-sources>
+#end
#if($includeClasses)
<include-classes>