This is an automated email from the ASF dual-hosted git repository. joshtynjala pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
commit f01fa8e0f2effab5a90e0c59549f954a205c53fb Author: Josh Tynjala <[email protected]> AuthorDate: Wed Mar 6 13:12:38 2024 -0800 MXMLModelNode: add problem if it has multiple root tags Flex SDK compiler compatibility --- .../compiler/internal/tree/mxml/MXMLModelNode.java | 12 ++++++- .../problems/MXMLModelOnlyOneRootTagProblem.java | 38 ++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLModelNode.java b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLModelNode.java index a41bdc361..28742fdfc 100644 --- a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLModelNode.java +++ b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLModelNode.java @@ -27,6 +27,7 @@ import org.apache.royale.compiler.mxml.IMXMLTagAttributeData; import org.apache.royale.compiler.mxml.IMXMLTagData; import org.apache.royale.compiler.problems.ICompilerProblem; import org.apache.royale.compiler.problems.MXMLDualContentProblem; +import org.apache.royale.compiler.problems.MXMLModelOnlyOneRootTagProblem; import org.apache.royale.compiler.tree.ASTNodeID; import org.apache.royale.compiler.tree.as.IASNode; import org.apache.royale.compiler.tree.mxml.IMXMLModelNode; @@ -55,6 +56,9 @@ class MXMLModelNode extends MXMLInstanceNode implements IMXMLModelNode */ private MXMLModelRootNode rootNode; + // did we see more than one child tag? + boolean multipleTags = false; + @Override public ASTNodeID getNodeID() { @@ -136,7 +140,7 @@ class MXMLModelNode extends MXMLInstanceNode implements IMXMLModelNode } else { - // TODO Report a problem if more than one root node. + multipleTags = true; } } @@ -151,5 +155,11 @@ class MXMLModelNode extends MXMLInstanceNode implements IMXMLModelNode ICompilerProblem problem = new MXMLDualContentProblem(tag, tag.getShortName()); builder.addProblem(problem); } + + if (multipleTags) + { + MXMLModelOnlyOneRootTagProblem problem = new MXMLModelOnlyOneRootTagProblem(tag); + builder.addProblem(problem); + } } } diff --git a/compiler/src/main/java/org/apache/royale/compiler/problems/MXMLModelOnlyOneRootTagProblem.java b/compiler/src/main/java/org/apache/royale/compiler/problems/MXMLModelOnlyOneRootTagProblem.java new file mode 100644 index 000000000..cbb962a40 --- /dev/null +++ b/compiler/src/main/java/org/apache/royale/compiler/problems/MXMLModelOnlyOneRootTagProblem.java @@ -0,0 +1,38 @@ +/* + * + * 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 org.apache.royale.compiler.problems; + +import org.apache.royale.compiler.common.ISourceLocation; + +/** + * Problem generated when a {@code <Model>} tag has more than one root tag. + * TODO: how is this different from MXMLMultipleRootTagsProblme + */ +public final class MXMLModelOnlyOneRootTagProblem extends MXMLSemanticProblem +{ + public static final String DESCRIPTION = + "Only one root tag is allowed"; + + + public MXMLModelOnlyOneRootTagProblem(ISourceLocation site) + { + super(site); + } +}
