Committed by
Gerrit Code Review
[ONOS-4941][ONOS-4883][ONOS-4979]Grouping and uses interfile linking issue + defect fix
Change-Id: I5e8145f05d3ef570d4ecbbe885c93de172de0ea3
Showing
37 changed files
with
1472 additions
and
169 deletions
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.datamodel; | ||
18 | + | ||
19 | +import java.util.LinkedList; | ||
20 | +import java.util.List; | ||
21 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
22 | +import org.onosproject.yangutils.datamodel.utils.Parsable; | ||
23 | +import org.onosproject.yangutils.datamodel.utils.YangConstructType; | ||
24 | + | ||
25 | +/** | ||
26 | + * Represents data model node to maintain information defined in YANG app-data-structure. | ||
27 | + */ | ||
28 | +public class YangAppDataStructure implements Parsable { | ||
29 | + | ||
30 | + /** | ||
31 | + * Data structure information. | ||
32 | + */ | ||
33 | + private YangDataStructure dataStructure; | ||
34 | + | ||
35 | + /** | ||
36 | + * List of key names. | ||
37 | + */ | ||
38 | + private List<String> keyList; | ||
39 | + | ||
40 | + /** | ||
41 | + * Prefix of app-data-structure. | ||
42 | + */ | ||
43 | + private String prefix; | ||
44 | + | ||
45 | + /** | ||
46 | + * Returns the YANG data structure information. | ||
47 | + * | ||
48 | + * @return the YANG data structure information | ||
49 | + */ | ||
50 | + public YangDataStructure getDataStructure() { | ||
51 | + return dataStructure; | ||
52 | + } | ||
53 | + | ||
54 | + /** | ||
55 | + * Sets the YANG data structure information. | ||
56 | + * | ||
57 | + * @param dataStructure the YANG data structure to set | ||
58 | + */ | ||
59 | + public void setDataStructure(YangDataStructure dataStructure) { | ||
60 | + this.dataStructure = dataStructure; | ||
61 | + } | ||
62 | + | ||
63 | + /** | ||
64 | + * Returns the list of key field names. | ||
65 | + * | ||
66 | + * @return the list of key field names | ||
67 | + */ | ||
68 | + public List<String> getKeyList() { | ||
69 | + return keyList; | ||
70 | + } | ||
71 | + | ||
72 | + /** | ||
73 | + * Sets the list of key field names. | ||
74 | + * | ||
75 | + * @param keyList the list of key field names | ||
76 | + */ | ||
77 | + public void setKeyList(List<String> keyList) { | ||
78 | + this.keyList = keyList; | ||
79 | + } | ||
80 | + | ||
81 | + /** | ||
82 | + * Adds a key field name. | ||
83 | + * | ||
84 | + * @param key key field name | ||
85 | + */ | ||
86 | + public void addKey(String key) { | ||
87 | + if (getKeyList() == null) { | ||
88 | + setKeyList(new LinkedList<>()); | ||
89 | + } | ||
90 | + getKeyList().add(key); | ||
91 | + } | ||
92 | + | ||
93 | + /** | ||
94 | + * Returns the prefix. | ||
95 | + * | ||
96 | + * @return the prefix | ||
97 | + */ | ||
98 | + public String getPrefix() { | ||
99 | + return prefix; | ||
100 | + } | ||
101 | + | ||
102 | + /** | ||
103 | + * Sets the prefix information. | ||
104 | + * | ||
105 | + * @param prefix the prefix to set | ||
106 | + */ | ||
107 | + public void setPrefix(String prefix) { | ||
108 | + this.prefix = prefix; | ||
109 | + } | ||
110 | + | ||
111 | + @Override | ||
112 | + public YangConstructType getYangConstructType() { | ||
113 | + return YangConstructType.APP_DATA_STRUCTURE; | ||
114 | + } | ||
115 | + | ||
116 | + @Override | ||
117 | + public void validateDataOnEntry() throws DataModelException { | ||
118 | + // TODO : to be implemented | ||
119 | + } | ||
120 | + | ||
121 | + @Override | ||
122 | + public void validateDataOnExit() throws DataModelException { | ||
123 | + // TODO : to be implemented | ||
124 | + } | ||
125 | +} |
utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAppExtendedName.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.datamodel; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
20 | +import org.onosproject.yangutils.datamodel.utils.Parsable; | ||
21 | +import org.onosproject.yangutils.datamodel.utils.YangConstructType; | ||
22 | + | ||
23 | +/** | ||
24 | + * Represents data model node to maintain information defined in YANG extended name. | ||
25 | + */ | ||
26 | +public class YangAppExtendedName implements Parsable { | ||
27 | + | ||
28 | + /** | ||
29 | + * App extended name information. | ||
30 | + */ | ||
31 | + private String yangAppExtendedName; | ||
32 | + | ||
33 | + /** | ||
34 | + * Prefix of extended name. | ||
35 | + */ | ||
36 | + private String prefix; | ||
37 | + | ||
38 | + /** | ||
39 | + * Returns the YANG app extended name information. | ||
40 | + * | ||
41 | + * @return the YANG app extended name information | ||
42 | + */ | ||
43 | + public String getYangAppExtendedName() { | ||
44 | + return yangAppExtendedName; | ||
45 | + } | ||
46 | + | ||
47 | + /** | ||
48 | + * Sets the YANG app extended name information. | ||
49 | + * | ||
50 | + * @param yangAppExtendedName the YANG app extended name to set | ||
51 | + */ | ||
52 | + public void setYangAppExtendedName(String yangAppExtendedName) { | ||
53 | + this.yangAppExtendedName = yangAppExtendedName; | ||
54 | + } | ||
55 | + | ||
56 | + /** | ||
57 | + * Returns the prefix. | ||
58 | + * | ||
59 | + * @return the prefix | ||
60 | + */ | ||
61 | + public String getPrefix() { | ||
62 | + return prefix; | ||
63 | + } | ||
64 | + | ||
65 | + /** | ||
66 | + * Sets the prefix information. | ||
67 | + * | ||
68 | + * @param prefix the prefix to set | ||
69 | + */ | ||
70 | + public void setPrefix(String prefix) { | ||
71 | + this.prefix = prefix; | ||
72 | + } | ||
73 | + | ||
74 | + @Override | ||
75 | + public YangConstructType getYangConstructType() { | ||
76 | + return YangConstructType.APP_EXTENDED_NAME_DATA; | ||
77 | + } | ||
78 | + | ||
79 | + @Override | ||
80 | + public void validateDataOnEntry() throws DataModelException { | ||
81 | + // TODO : to be implemented | ||
82 | + } | ||
83 | + | ||
84 | + @Override | ||
85 | + public void validateDataOnExit() throws DataModelException { | ||
86 | + // TODO : to be implemented | ||
87 | + } | ||
88 | +} |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.datamodel; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
20 | +import org.onosproject.yangutils.datamodel.utils.Parsable; | ||
21 | +import org.onosproject.yangutils.datamodel.utils.YangConstructType; | ||
22 | + | ||
23 | +/** | ||
24 | + * Represents data model node to maintain information defined in YANG compiler-annotation. | ||
25 | + */ | ||
26 | +public class YangCompilerAnnotation implements Parsable { | ||
27 | + | ||
28 | + /** | ||
29 | + * App data structure information. | ||
30 | + */ | ||
31 | + private YangAppDataStructure yangAppDataStructure; | ||
32 | + | ||
33 | + /** | ||
34 | + * App extended name information. | ||
35 | + */ | ||
36 | + private YangAppExtendedName yangAppExtendedName; | ||
37 | + | ||
38 | + /** | ||
39 | + * Prefix of compiler-annotation. | ||
40 | + */ | ||
41 | + private String prefix; | ||
42 | + | ||
43 | + /** | ||
44 | + * Path of compiler-annotation. | ||
45 | + */ | ||
46 | + private String path; | ||
47 | + | ||
48 | + /** | ||
49 | + * Returns the YANG app data structure information. | ||
50 | + * | ||
51 | + * @return the YANG app data structure information | ||
52 | + */ | ||
53 | + public YangAppDataStructure getYangAppDataStructure() { | ||
54 | + return yangAppDataStructure; | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * Sets the YANG app data structure information. | ||
59 | + * | ||
60 | + * @param yangAppDataStructure the YANG app data structure to set | ||
61 | + */ | ||
62 | + public void setYangAppDataStructure(YangAppDataStructure yangAppDataStructure) { | ||
63 | + this.yangAppDataStructure = yangAppDataStructure; | ||
64 | + } | ||
65 | + | ||
66 | + /** | ||
67 | + * Returns the prefix. | ||
68 | + * | ||
69 | + * @return the prefix | ||
70 | + */ | ||
71 | + public String getPrefix() { | ||
72 | + return prefix; | ||
73 | + } | ||
74 | + | ||
75 | + /** | ||
76 | + * Sets the prefix information. | ||
77 | + * | ||
78 | + * @param prefix the prefix to set | ||
79 | + */ | ||
80 | + public void setPrefix(String prefix) { | ||
81 | + this.prefix = prefix; | ||
82 | + } | ||
83 | + | ||
84 | + /** | ||
85 | + * Returns the path. | ||
86 | + * | ||
87 | + * @return the path | ||
88 | + */ | ||
89 | + public String getPath() { | ||
90 | + return path; | ||
91 | + } | ||
92 | + | ||
93 | + /** | ||
94 | + * Sets the path. | ||
95 | + * | ||
96 | + * @param path the path to set | ||
97 | + */ | ||
98 | + public void setPath(String path) { | ||
99 | + this.path = path; | ||
100 | + } | ||
101 | + | ||
102 | + /** | ||
103 | + * Returns the YANG app extended name information. | ||
104 | + * | ||
105 | + * @return the YANG app extended name information | ||
106 | + */ | ||
107 | + public YangAppExtendedName getYangAppExtendedName() { | ||
108 | + return yangAppExtendedName; | ||
109 | + } | ||
110 | + | ||
111 | + /** | ||
112 | + * Sets the YANG app extended name information. | ||
113 | + * | ||
114 | + * @param yangAppExtendedName the YANG app extended name to set | ||
115 | + */ | ||
116 | + public void setYangAppExtendedName(YangAppExtendedName yangAppExtendedName) { | ||
117 | + this.yangAppExtendedName = yangAppExtendedName; | ||
118 | + } | ||
119 | + | ||
120 | + @Override | ||
121 | + public YangConstructType getYangConstructType() { | ||
122 | + return YangConstructType.COMPILER_ANNOTATION_DATA; | ||
123 | + } | ||
124 | + | ||
125 | + @Override | ||
126 | + public void validateDataOnEntry() throws DataModelException { | ||
127 | + // TODO : to be implemented | ||
128 | + } | ||
129 | + | ||
130 | + @Override | ||
131 | + public void validateDataOnExit() throws DataModelException { | ||
132 | + // TODO : to be implemented | ||
133 | + } | ||
134 | +} |
utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangDataStructure.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.datamodel; | ||
18 | + | ||
19 | +/** | ||
20 | + * Represents ENUM to identify the YANG data type. | ||
21 | + */ | ||
22 | +public enum YangDataStructure { | ||
23 | + | ||
24 | + MAP, | ||
25 | + | ||
26 | + LIST, | ||
27 | + | ||
28 | + SET; | ||
29 | + | ||
30 | + /** | ||
31 | + * Returns YANG data structure type for corresponding data structure name. | ||
32 | + * | ||
33 | + * @param name data structure name from YANG file. | ||
34 | + * @return YANG data structure for corresponding data structure name. | ||
35 | + */ | ||
36 | + public static YangDataStructure getType(String name) { | ||
37 | + name = name.replace("\"", ""); | ||
38 | + for (YangDataStructure dataStructure : values()) { | ||
39 | + if (dataStructure.name().toLowerCase().equals(name)) { | ||
40 | + return dataStructure; | ||
41 | + } | ||
42 | + } | ||
43 | + return null; | ||
44 | + } | ||
45 | +} |
... | @@ -16,15 +16,14 @@ | ... | @@ -16,15 +16,14 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.datamodel; | 17 | package org.onosproject.yangutils.datamodel; |
18 | 18 | ||
19 | +import java.util.ArrayList; | ||
20 | +import java.util.LinkedList; | ||
21 | +import java.util.List; | ||
19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 22 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
20 | import org.onosproject.yangutils.datamodel.utils.Parsable; | 23 | import org.onosproject.yangutils.datamodel.utils.Parsable; |
21 | import org.onosproject.yangutils.datamodel.utils.YangConstructType; | 24 | import org.onosproject.yangutils.datamodel.utils.YangConstructType; |
22 | import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; | 25 | import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; |
23 | 26 | ||
24 | -import java.util.ArrayList; | ||
25 | -import java.util.LinkedList; | ||
26 | -import java.util.List; | ||
27 | - | ||
28 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; | 27 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; |
29 | 28 | ||
30 | /* | 29 | /* |
... | @@ -72,7 +71,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol | ... | @@ -72,7 +71,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol |
72 | public class YangList | 71 | public class YangList |
73 | extends YangNode | 72 | extends YangNode |
74 | implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, | 73 | implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, |
75 | - YangAugmentableNode, YangMustHolder, YangIfFeatureHolder, YangDataNode { | 74 | + YangAugmentableNode, YangMustHolder, YangWhenHolder, YangIfFeatureHolder, YangDataNode { |
76 | 75 | ||
77 | private static final long serialVersionUID = 806201609L; | 76 | private static final long serialVersionUID = 806201609L; |
78 | 77 | ||
... | @@ -219,6 +218,7 @@ public class YangList | ... | @@ -219,6 +218,7 @@ public class YangList |
219 | * | 218 | * |
220 | * @return the when | 219 | * @return the when |
221 | */ | 220 | */ |
221 | + @Override | ||
222 | public YangWhen getWhen() { | 222 | public YangWhen getWhen() { |
223 | return when; | 223 | return when; |
224 | } | 224 | } |
... | @@ -228,6 +228,7 @@ public class YangList | ... | @@ -228,6 +228,7 @@ public class YangList |
228 | * | 228 | * |
229 | * @param when the when to set | 229 | * @param when the when to set |
230 | */ | 230 | */ |
231 | + @Override | ||
231 | public void setWhen(YangWhen when) { | 232 | public void setWhen(YangWhen when) { |
232 | this.when = when; | 233 | this.when = when; |
233 | } | 234 | } |
... | @@ -624,7 +625,6 @@ public class YangList | ... | @@ -624,7 +625,6 @@ public class YangList |
624 | * Validates key statement of list. | 625 | * Validates key statement of list. |
625 | * | 626 | * |
626 | * @param leaves list of leaf attributes of list | 627 | * @param leaves list of leaf attributes of list |
627 | - * @param leafLists list of leaf-list attributes of list | ||
628 | * @param keys list of key attributes of list | 628 | * @param keys list of key attributes of list |
629 | * @throws DataModelException a violation of data model rules | 629 | * @throws DataModelException a violation of data model rules |
630 | */ | 630 | */ | ... | ... |
... | @@ -231,7 +231,12 @@ public class YangModule | ... | @@ -231,7 +231,12 @@ public class YangModule |
231 | private List<YangResolutionInfo> augmentResolutionList; | 231 | private List<YangResolutionInfo> augmentResolutionList; |
232 | 232 | ||
233 | /** | 233 | /** |
234 | - * extension list. | 234 | + * Compiler annotation list. |
235 | + */ | ||
236 | + private List<YangCompilerAnnotation> compilerAnnotationList; | ||
237 | + | ||
238 | + /** | ||
239 | + * Extension list. | ||
235 | */ | 240 | */ |
236 | private List<YangExtension> extensionList; | 241 | private List<YangExtension> extensionList; |
237 | 242 | ||
... | @@ -248,6 +253,7 @@ public class YangModule | ... | @@ -248,6 +253,7 @@ public class YangModule |
248 | leafrefResolutionList = new LinkedList<>(); | 253 | leafrefResolutionList = new LinkedList<>(); |
249 | baseResolutionList = new LinkedList<>(); | 254 | baseResolutionList = new LinkedList<>(); |
250 | identityrefResolutionList = new LinkedList<>(); | 255 | identityrefResolutionList = new LinkedList<>(); |
256 | + compilerAnnotationList = new LinkedList<>(); | ||
251 | importList = new LinkedList<YangImport>(); | 257 | importList = new LinkedList<YangImport>(); |
252 | includeList = new LinkedList<YangInclude>(); | 258 | includeList = new LinkedList<YangInclude>(); |
253 | listOfLeaf = new LinkedList<YangLeaf>(); | 259 | listOfLeaf = new LinkedList<YangLeaf>(); |
... | @@ -563,6 +569,33 @@ public class YangModule | ... | @@ -563,6 +569,33 @@ public class YangModule |
563 | } | 569 | } |
564 | 570 | ||
565 | /** | 571 | /** |
572 | + * Adds compiler annotation in compiler-annotation list. | ||
573 | + * | ||
574 | + * @param compilerAnnotation the compiler-annotation to be added | ||
575 | + */ | ||
576 | + public void addCompilerAnnotation(YangCompilerAnnotation compilerAnnotation) { | ||
577 | + getCompilerAnnotationList().add(compilerAnnotation); | ||
578 | + } | ||
579 | + | ||
580 | + /** | ||
581 | + * Returns the compiler annotation list. | ||
582 | + * | ||
583 | + * @return the compiler annotation list | ||
584 | + */ | ||
585 | + public List<YangCompilerAnnotation> getCompilerAnnotationList() { | ||
586 | + return compilerAnnotationList; | ||
587 | + } | ||
588 | + | ||
589 | + /** | ||
590 | + * Sets the compiler-annotation list. | ||
591 | + * | ||
592 | + * @param compilerAnnotationList the list of compiler-annotation | ||
593 | + */ | ||
594 | + public void setCompilerAnnotationList(List<YangCompilerAnnotation> compilerAnnotationList) { | ||
595 | + this.compilerAnnotationList = compilerAnnotationList; | ||
596 | + } | ||
597 | + | ||
598 | + /** | ||
566 | * Adds extension in extension list. | 599 | * Adds extension in extension list. |
567 | * | 600 | * |
568 | * @param extension the extension to be added | 601 | * @param extension the extension to be added | ... | ... |
... | @@ -224,6 +224,11 @@ public class YangSubModule | ... | @@ -224,6 +224,11 @@ public class YangSubModule |
224 | private List<YangResolutionInfo> identityrefResolutionList; | 224 | private List<YangResolutionInfo> identityrefResolutionList; |
225 | 225 | ||
226 | /** | 226 | /** |
227 | + * Compiler annotation list. | ||
228 | + */ | ||
229 | + private List<YangCompilerAnnotation> compilerAnnotationList; | ||
230 | + | ||
231 | + /** | ||
227 | * extension list. | 232 | * extension list. |
228 | */ | 233 | */ |
229 | private List<YangExtension> extensionList; | 234 | private List<YangExtension> extensionList; |
... | @@ -245,6 +250,7 @@ public class YangSubModule | ... | @@ -245,6 +250,7 @@ public class YangSubModule |
245 | leafrefResolutionList = new LinkedList<>(); | 250 | leafrefResolutionList = new LinkedList<>(); |
246 | baseResolutionList = new LinkedList<>(); | 251 | baseResolutionList = new LinkedList<>(); |
247 | identityrefResolutionList = new LinkedList<>(); | 252 | identityrefResolutionList = new LinkedList<>(); |
253 | + compilerAnnotationList = new LinkedList<>(); | ||
248 | importList = new LinkedList<YangImport>(); | 254 | importList = new LinkedList<YangImport>(); |
249 | includeList = new LinkedList<YangInclude>(); | 255 | includeList = new LinkedList<YangInclude>(); |
250 | listOfLeaf = new LinkedList<YangLeaf>(); | 256 | listOfLeaf = new LinkedList<YangLeaf>(); |
... | @@ -692,6 +698,34 @@ public class YangSubModule | ... | @@ -692,6 +698,34 @@ public class YangSubModule |
692 | } | 698 | } |
693 | 699 | ||
694 | /** | 700 | /** |
701 | + * Adds compiler annotation in compiler annotation list. | ||
702 | + * | ||
703 | + * @param compilerAnnotation the compiler annotation to be added | ||
704 | + */ | ||
705 | + public void addCompilerAnnotation(YangCompilerAnnotation compilerAnnotation) { | ||
706 | + getCompilerAnnotationList().add(compilerAnnotation); | ||
707 | + } | ||
708 | + | ||
709 | + /** | ||
710 | + * Returns the compiler annotation list. | ||
711 | + * | ||
712 | + * @return the compiler annotation list | ||
713 | + */ | ||
714 | + public List<YangCompilerAnnotation> getCompilerAnnotationList() { | ||
715 | + return compilerAnnotationList; | ||
716 | + } | ||
717 | + | ||
718 | + /** | ||
719 | + * Sets the compiler annotation list. | ||
720 | + * | ||
721 | + * @param compilerAnnotationList the list of compiler annotation | ||
722 | + */ | ||
723 | + public void setCompilerAnnotationList(List<YangCompilerAnnotation> compilerAnnotationList) { | ||
724 | + this.compilerAnnotationList = compilerAnnotationList; | ||
725 | + } | ||
726 | + | ||
727 | + | ||
728 | + /** | ||
695 | * Adds extension in extension list. | 729 | * Adds extension in extension list. |
696 | * | 730 | * |
697 | * @param extension the extension to be added | 731 | * @param extension the extension to be added | ... | ... |
... | @@ -17,17 +17,20 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -17,17 +17,20 @@ package org.onosproject.yangutils.datamodel; |
17 | 17 | ||
18 | import java.util.LinkedList; | 18 | import java.util.LinkedList; |
19 | import java.util.List; | 19 | import java.util.List; |
20 | - | ||
21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 20 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
22 | import org.onosproject.yangutils.datamodel.utils.Parsable; | 21 | import org.onosproject.yangutils.datamodel.utils.Parsable; |
23 | import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; | 22 | import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; |
24 | import org.onosproject.yangutils.datamodel.utils.YangConstructType; | 23 | import org.onosproject.yangutils.datamodel.utils.YangConstructType; |
25 | 24 | ||
25 | +import static org.onosproject.yangutils.datamodel.TraversalType.CHILD; | ||
26 | +import static org.onosproject.yangutils.datamodel.TraversalType.PARENT; | ||
27 | +import static org.onosproject.yangutils.datamodel.TraversalType.ROOT; | ||
28 | +import static org.onosproject.yangutils.datamodel.TraversalType.SIBILING; | ||
26 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; | 29 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; |
27 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode; | 30 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode; |
28 | -import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.updateClonedLeavesUnionEnumRef; | ||
29 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLeafrefUnderGroupingForLeaf; | 31 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLeafrefUnderGroupingForLeaf; |
30 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLeafrefUnderGroupingForLeafList; | 32 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLeafrefUnderGroupingForLeafList; |
33 | +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.updateClonedLeavesUnionEnumRef; | ||
31 | 34 | ||
32 | /*- | 35 | /*- |
33 | * Reference RFC 6020. | 36 | * Reference RFC 6020. |
... | @@ -365,6 +368,14 @@ public class YangUses | ... | @@ -365,6 +368,14 @@ public class YangUses |
365 | 368 | ||
366 | if (referredGrouping == null) { | 369 | if (referredGrouping == null) { |
367 | throw new DataModelException("YANG uses linker error, cannot resolve uses"); | 370 | throw new DataModelException("YANG uses linker error, cannot resolve uses"); |
371 | + } else { | ||
372 | + /* | ||
373 | + * if referredGrouping has uses which is not resolved then set the status | ||
374 | + * as Intra file resolved and return | ||
375 | + */ | ||
376 | + if (checkIsUnresolvedRecursiveUsesInGrouping(referredGrouping)) { | ||
377 | + return null; | ||
378 | + } | ||
368 | } | 379 | } |
369 | 380 | ||
370 | YangNode usesParentNode = getParentNodeInGenCode(this); | 381 | YangNode usesParentNode = getParentNodeInGenCode(this); |
... | @@ -405,7 +416,7 @@ public class YangUses | ... | @@ -405,7 +416,7 @@ public class YangUses |
405 | clonedLeafList = leafList.clone(); | 416 | clonedLeafList = leafList.clone(); |
406 | if (getCurrentGroupingDepth() == 0) { | 417 | if (getCurrentGroupingDepth() == 0) { |
407 | YangEntityToResolveInfoImpl resolveInfo = | 418 | YangEntityToResolveInfoImpl resolveInfo = |
408 | - resolveLeafrefUnderGroupingForLeafList(clonedLeafList, usesParentLeavesHolder); | 419 | + resolveLeafrefUnderGroupingForLeafList(clonedLeafList, usesParentLeavesHolder); |
409 | if (resolveInfo != null) { | 420 | if (resolveInfo != null) { |
410 | addEntityToResolve(resolveInfo); | 421 | addEntityToResolve(resolveInfo); |
411 | } | 422 | } |
... | @@ -429,6 +440,49 @@ public class YangUses | ... | @@ -429,6 +440,49 @@ public class YangUses |
429 | } | 440 | } |
430 | 441 | ||
431 | /** | 442 | /** |
443 | + * Checks if referred grouping has uses which is not resolved then it set the | ||
444 | + * status of current uses as intra file resolved and returns true. | ||
445 | + * | ||
446 | + * @param referredGrouping referred grouping node of uses | ||
447 | + * @return true if referred grouping has unresolved uses | ||
448 | + */ | ||
449 | + private boolean checkIsUnresolvedRecursiveUsesInGrouping(YangGrouping referredGrouping) { | ||
450 | + | ||
451 | + /** | ||
452 | + * Search the grouping node's children for presence of uses node. | ||
453 | + */ | ||
454 | + TraversalType curTraversal = ROOT; | ||
455 | + YangNode curNode = referredGrouping.getChild(); | ||
456 | + while (curNode != null) { | ||
457 | + if (curNode.getName().equals(referredGrouping.getName())) { | ||
458 | + // if we have traversed all the child nodes, then exit from loop | ||
459 | + return false; | ||
460 | + } | ||
461 | + | ||
462 | + // if child nodes has uses, then add it to resolution stack | ||
463 | + if (curNode instanceof YangUses) { | ||
464 | + if (((YangUses) curNode).getResolvableStatus() != ResolvableStatus.RESOLVED) { | ||
465 | + setResolvableStatus(ResolvableStatus.INTRA_FILE_RESOLVED); | ||
466 | + return true; | ||
467 | + } | ||
468 | + } | ||
469 | + | ||
470 | + // Traversing all the child nodes of grouping | ||
471 | + if (curTraversal != PARENT && curNode.getChild() != null) { | ||
472 | + curTraversal = CHILD; | ||
473 | + curNode = curNode.getChild(); | ||
474 | + } else if (curNode.getNextSibling() != null) { | ||
475 | + curTraversal = SIBILING; | ||
476 | + curNode = curNode.getNextSibling(); | ||
477 | + } else { | ||
478 | + curTraversal = PARENT; | ||
479 | + curNode = curNode.getParent(); | ||
480 | + } | ||
481 | + } | ||
482 | + return false; | ||
483 | + } | ||
484 | + | ||
485 | + /** | ||
432 | * Clone the resolved uses contained in grouping to the uses of grouping. | 486 | * Clone the resolved uses contained in grouping to the uses of grouping. |
433 | * | 487 | * |
434 | * @param usesInGrouping resolved uses in grouping | 488 | * @param usesInGrouping resolved uses in grouping | ... | ... |
... | @@ -385,6 +385,21 @@ public enum YangConstructType { | ... | @@ -385,6 +385,21 @@ public enum YangConstructType { |
385 | ANYXML_DATA, | 385 | ANYXML_DATA, |
386 | 386 | ||
387 | /** | 387 | /** |
388 | + * Identifies the YANG compiler annotation element parsed data. | ||
389 | + */ | ||
390 | + COMPILER_ANNOTATION_DATA, | ||
391 | + | ||
392 | + /** | ||
393 | + * Identifies the YANG app data structure element parsed data. | ||
394 | + */ | ||
395 | + APP_DATA_STRUCTURE, | ||
396 | + | ||
397 | + /** | ||
398 | + * Identifies the YANG app extended element parsed data. | ||
399 | + */ | ||
400 | + APP_EXTENDED_NAME_DATA, | ||
401 | + | ||
402 | + /** | ||
388 | * Identifies the YANG argument element parsed data. | 403 | * Identifies the YANG argument element parsed data. |
389 | */ | 404 | */ |
390 | ARGUMENT_DATA; | 405 | ARGUMENT_DATA; |
... | @@ -544,6 +559,12 @@ public enum YangConstructType { | ... | @@ -544,6 +559,12 @@ public enum YangConstructType { |
544 | return "deviation"; | 559 | return "deviation"; |
545 | case ANYXML_DATA: | 560 | case ANYXML_DATA: |
546 | return "anyxml"; | 561 | return "anyxml"; |
562 | + case COMPILER_ANNOTATION_DATA: | ||
563 | + return "compiler-annotation"; | ||
564 | + case APP_DATA_STRUCTURE: | ||
565 | + return "app-data-structure"; | ||
566 | + case APP_EXTENDED_NAME_DATA: | ||
567 | + return "app-extended-name"; | ||
547 | case ARGUMENT_DATA: | 568 | case ARGUMENT_DATA: |
548 | return "argument"; | 569 | return "argument"; |
549 | default: | 570 | default: | ... | ... |
... | @@ -172,7 +172,7 @@ public class YangLinkerManager | ... | @@ -172,7 +172,7 @@ public class YangLinkerManager |
172 | ((YangReferenceResolver) yangNode) | 172 | ((YangReferenceResolver) yangNode) |
173 | .resolveInterFileLinking(ResolvableType.YANG_USES); | 173 | .resolveInterFileLinking(ResolvableType.YANG_USES); |
174 | ((YangReferenceResolver) yangNode) | 174 | ((YangReferenceResolver) yangNode) |
175 | - .resolveInterFileLinking(ResolvableType.YANG_AUGMENT); | 175 | + .resolveInterFileLinking(ResolvableType.YANG_AUGMENT); |
176 | ((YangReferenceResolver) yangNode) | 176 | ((YangReferenceResolver) yangNode) |
177 | .resolveInterFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE); | 177 | .resolveInterFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE); |
178 | ((YangReferenceResolver) yangNode) | 178 | ((YangReferenceResolver) yangNode) | ... | ... |
... | @@ -1594,11 +1594,7 @@ public class YangResolutionInfoImpl<T> | ... | @@ -1594,11 +1594,7 @@ public class YangResolutionInfoImpl<T> |
1594 | if (linkedNode != null) { | 1594 | if (linkedNode != null) { |
1595 | // Add the link to external entity. | 1595 | // Add the link to external entity. |
1596 | addReferredEntityLink(linkedNode, INTER_FILE_LINKED); | 1596 | addReferredEntityLink(linkedNode, INTER_FILE_LINKED); |
1597 | - /* | 1597 | + |
1598 | - * Update the current reference resolver to external | ||
1599 | - * module/sub-module containing the referred typedef/grouping. | ||
1600 | - */ | ||
1601 | - setCurReferenceResolver((YangReferenceResolver) yangInclude.getIncludedNode()); | ||
1602 | // Add the type/uses of referred typedef/grouping to the stack. | 1598 | // Add the type/uses of referred typedef/grouping to the stack. |
1603 | addUnresolvedRecursiveReferenceToStack(linkedNode); | 1599 | addUnresolvedRecursiveReferenceToStack(linkedNode); |
1604 | return true; | 1600 | return true; |
... | @@ -1641,12 +1637,7 @@ public class YangResolutionInfoImpl<T> | ... | @@ -1641,12 +1637,7 @@ public class YangResolutionInfoImpl<T> |
1641 | if (linkedNode != null) { | 1637 | if (linkedNode != null) { |
1642 | // Add the link to external entity. | 1638 | // Add the link to external entity. |
1643 | addReferredEntityLink(linkedNode, INTER_FILE_LINKED); | 1639 | addReferredEntityLink(linkedNode, INTER_FILE_LINKED); |
1644 | - /* | 1640 | + |
1645 | - * Update the current reference resolver to external | ||
1646 | - * module/sub-module containing the referred | ||
1647 | - * typedef/grouping. | ||
1648 | - */ | ||
1649 | - setCurReferenceResolver((YangReferenceResolver) yangImport.getImportedNode()); | ||
1650 | // Add the type/uses of referred typedef/grouping to the | 1641 | // Add the type/uses of referred typedef/grouping to the |
1651 | // stack. | 1642 | // stack. |
1652 | addUnresolvedRecursiveReferenceToStack(linkedNode); | 1643 | addUnresolvedRecursiveReferenceToStack(linkedNode); | ... | ... |
... | @@ -1835,136 +1835,94 @@ public interface GeneratedYangListener extends ParseTreeListener { | ... | @@ -1835,136 +1835,94 @@ public interface GeneratedYangListener extends ParseTreeListener { |
1835 | void exitCompilerAnnotationStatement(GeneratedYangParser.CompilerAnnotationStatementContext currentContext); | 1835 | void exitCompilerAnnotationStatement(GeneratedYangParser.CompilerAnnotationStatementContext currentContext); |
1836 | 1836 | ||
1837 | /** | 1837 | /** |
1838 | - * Enters a parse tree produced by GeneratedYangParser for grammar rule annotation statement. | 1838 | + * Enters a parse tree produced by GeneratedYangParser for grammar rule compiler annotation body statement. |
1839 | * | 1839 | * |
1840 | * @param currentContext current context in the parsed tree | 1840 | * @param currentContext current context in the parsed tree |
1841 | */ | 1841 | */ |
1842 | - void enterAnnotationStatement(GeneratedYangParser.AnnotationStatementContext currentContext); | 1842 | + void enterCompilerAnnotationBodyStatement(GeneratedYangParser.CompilerAnnotationBodyStatementContext |
1843 | + currentContext); | ||
1843 | 1844 | ||
1844 | /** | 1845 | /** |
1845 | - * Exits a parse tree produced by GeneratedYangParser for grammar rule annotation statement. | 1846 | + * Exits a parse tree produced by GeneratedYangParser for grammar rule compiler annotation body statement. |
1846 | * | 1847 | * |
1847 | * @param currentContext current context in the parsed tree | 1848 | * @param currentContext current context in the parsed tree |
1848 | */ | 1849 | */ |
1849 | - void exitAnnotationStatement(GeneratedYangParser.AnnotationStatementContext currentContext); | 1850 | + void exitCompilerAnnotationBodyStatement(GeneratedYangParser.CompilerAnnotationBodyStatementContext |
1851 | + currentContext); | ||
1850 | 1852 | ||
1851 | /** | 1853 | /** |
1852 | - * Enters a parse tree produced by GeneratedYangParser for grammar rule annotation type. | 1854 | + * Enters a parse tree produced by GeneratedYangParser for grammar rule app data structure statement. |
1853 | * | 1855 | * |
1854 | * @param currentContext current context in the parsed tree | 1856 | * @param currentContext current context in the parsed tree |
1855 | */ | 1857 | */ |
1856 | - void enterAnnotationType(GeneratedYangParser.AnnotationTypeContext currentContext); | 1858 | + void enterAppDataStructureStatement(GeneratedYangParser.AppDataStructureStatementContext |
1859 | + currentContext); | ||
1857 | 1860 | ||
1858 | /** | 1861 | /** |
1859 | - * Exits a parse tree produced by GeneratedYangParser for grammar rule annotation type. | 1862 | + * Exits a parse tree produced by GeneratedYangParser for grammar rule app data structure statement. |
1860 | * | 1863 | * |
1861 | * @param currentContext current context in the parsed tree | 1864 | * @param currentContext current context in the parsed tree |
1862 | */ | 1865 | */ |
1863 | - void exitAnnotationType(GeneratedYangParser.AnnotationTypeContext currentContext); | 1866 | + void exitAppDataStructureStatement(GeneratedYangParser.AppDataStructureStatementContext currentContext); |
1864 | 1867 | ||
1865 | /** | 1868 | /** |
1866 | - * Enters a parse tree produced by GeneratedYangParser for grammar rule | 1869 | + * Enters a parse tree produced by GeneratedYangParser for grammar rule app data structure. |
1867 | - * annotation parameter specification. | ||
1868 | * | 1870 | * |
1869 | * @param currentContext current context in the parsed tree | 1871 | * @param currentContext current context in the parsed tree |
1870 | */ | 1872 | */ |
1871 | - void enterAnnotationParameterSpecification(GeneratedYangParser.AnnotationParameterSpecificationContext | 1873 | + void enterAppDataStructure(GeneratedYangParser.AppDataStructureContext currentContext); |
1872 | - currentContext); | ||
1873 | 1874 | ||
1874 | /** | 1875 | /** |
1875 | - * Exits a parse tree produced by GeneratedYangParser for grammar rule | 1876 | + * Exits a parse tree produced by GeneratedYangParser for grammar rule app data strcuture. |
1876 | - * annotation parameter specification. | ||
1877 | * | 1877 | * |
1878 | * @param currentContext current context in the parsed tree | 1878 | * @param currentContext current context in the parsed tree |
1879 | */ | 1879 | */ |
1880 | - void exitAnnotationParameterSpecification(GeneratedYangParser.AnnotationParameterSpecificationContext | 1880 | + void exitAppDataStructure(GeneratedYangParser.AppDataStructureContext currentContext); |
1881 | - currentContext); | ||
1882 | 1881 | ||
1883 | /** | 1882 | /** |
1884 | - * Enters a parse tree produced by GeneratedYangParser for grammar rule | 1883 | + * Enters a parse tree produced by GeneratedYangParser for grammar rule app extended statement. |
1885 | - * annotation parameter specification argument. | ||
1886 | * | 1884 | * |
1887 | * @param currentContext current context in the parsed tree | 1885 | * @param currentContext current context in the parsed tree |
1888 | */ | 1886 | */ |
1889 | - void enterAnnotationParameterSpecificationArg(GeneratedYangParser.AnnotationParameterSpecificationArgContext | 1887 | + void enterAppExtendedStatement(GeneratedYangParser.AppExtendedStatementContext currentContext); |
1890 | - currentContext); | ||
1891 | 1888 | ||
1892 | /** | 1889 | /** |
1893 | - * Exits a parse tree produced by GeneratedYangParser for grammar rule | 1890 | + * Exits a parse tree produced by GeneratedYangParser for grammar rule app extended statement. |
1894 | - * annotation parameter specification argument. | ||
1895 | * | 1891 | * |
1896 | * @param currentContext current context in the parsed tree | 1892 | * @param currentContext current context in the parsed tree |
1897 | */ | 1893 | */ |
1898 | - void exitAnnotationParameterSpecificationArg(GeneratedYangParser.AnnotationParameterSpecificationArgContext | 1894 | + void exitAppExtendedStatement(GeneratedYangParser.AppExtendedStatementContext currentContext); |
1899 | - currentContext); | ||
1900 | 1895 | ||
1901 | /** | 1896 | /** |
1902 | - * Enters a parse tree produced by GeneratedYangParser for grammar rule annotation parameter instance. | 1897 | + * Enters a parse tree produced by GeneratedYangParser for grammar rule extended name. |
1903 | * | 1898 | * |
1904 | * @param currentContext current context in the parsed tree | 1899 | * @param currentContext current context in the parsed tree |
1905 | */ | 1900 | */ |
1906 | - void enterAnnotationParaInstance(GeneratedYangParser.AnnotationParaInstanceContext | 1901 | + void enterExtendedName(GeneratedYangParser.ExtendedNameContext currentContext); |
1907 | - currentContext); | ||
1908 | 1902 | ||
1909 | /** | 1903 | /** |
1910 | - * Exits a parse tree produced by GeneratedYangParser for grammar rule annotation parameter instance. | 1904 | + * Exits a parse tree produced by GeneratedYangParser for grammar rule extended name. |
1911 | * | 1905 | * |
1912 | * @param currentContext current context in the parsed tree | 1906 | * @param currentContext current context in the parsed tree |
1913 | */ | 1907 | */ |
1914 | - void exitAnnotationParaInstance(GeneratedYangParser.AnnotationParaInstanceContext | 1908 | + void exitExtendedName(GeneratedYangParser.ExtendedNameContext currentContext); |
1915 | - currentContext); | ||
1916 | 1909 | ||
1917 | - /** | ||
1918 | - * Enters a parse tree produced by GeneratedYangParser for grammar rule | ||
1919 | - * annotation parameter type identifier. | ||
1920 | - * | ||
1921 | - * @param currentContext current context in the parsed tree | ||
1922 | - */ | ||
1923 | - void enterAnnotationParaTypeIdentifier(GeneratedYangParser.AnnotationParaTypeIdentifierContext | ||
1924 | - currentContext); | ||
1925 | - | ||
1926 | - /** | ||
1927 | - * Exits a parse tree produced by GeneratedYangParser for grammar rule | ||
1928 | - * annotation parameter type identifier. | ||
1929 | - * | ||
1930 | - * @param currentContext current context in the parsed tree | ||
1931 | - */ | ||
1932 | - void exitAnnotationParaTypeIdentifier(GeneratedYangParser.AnnotationParaTypeIdentifierContext | ||
1933 | - currentContext); | ||
1934 | 1910 | ||
1935 | /** | 1911 | /** |
1936 | * Enters a parse tree produced by GeneratedYangParser for grammar rule | 1912 | * Enters a parse tree produced by GeneratedYangParser for grammar rule |
1937 | - * annotation parameter type value. | 1913 | + * data structure key statement. |
1938 | * | 1914 | * |
1939 | * @param currentContext current context in the parsed tree | 1915 | * @param currentContext current context in the parsed tree |
1940 | */ | 1916 | */ |
1941 | - void enterAnnotationParaTypeValue(GeneratedYangParser.AnnotationParaTypeValueContext | 1917 | + void enterDataStructureKeyStatement(GeneratedYangParser.DataStructureKeyStatementContext currentContext); |
1942 | - currentContext); | ||
1943 | 1918 | ||
1944 | /** | 1919 | /** |
1945 | * Exits a parse tree produced by GeneratedYangParser for grammar rule | 1920 | * Exits a parse tree produced by GeneratedYangParser for grammar rule |
1946 | - * annotation parameter type value. | 1921 | + * data structure key statement. |
1947 | - * | ||
1948 | - * @param currentContext current context in the parsed tree | ||
1949 | - */ | ||
1950 | - void exitAnnotationParaTypeValue(GeneratedYangParser.AnnotationParaTypeValueContext | ||
1951 | - currentContext); | ||
1952 | - | ||
1953 | - /** | ||
1954 | - * Enters a parse tree produced by GeneratedYangParser for grammar rule annotation identifier. | ||
1955 | - * | ||
1956 | - * @param currentContext current context in the parsed tree | ||
1957 | - */ | ||
1958 | - void enterAnnotationIdentifier(GeneratedYangParser.AnnotationIdentifierContext | ||
1959 | - currentContext); | ||
1960 | - | ||
1961 | - /** | ||
1962 | - * Exits a parse tree produced by GeneratedYangParser for grammar rule annotation identifier. | ||
1963 | * | 1922 | * |
1964 | * @param currentContext current context in the parsed tree | 1923 | * @param currentContext current context in the parsed tree |
1965 | */ | 1924 | */ |
1966 | - void exitAnnotationIdentifier(GeneratedYangParser.AnnotationIdentifierContext | 1925 | + void exitDataStructureKeyStatement(GeneratedYangParser.DataStructureKeyStatementContext currentContext); |
1967 | - currentContext); | ||
1968 | 1926 | ||
1969 | /** | 1927 | /** |
1970 | * Enters a parse tree produced by GeneratedYangParser for grammar rule require instance. | 1928 | * Enters a parse tree produced by GeneratedYangParser for grammar rule require instance. | ... | ... |
... | @@ -24,6 +24,8 @@ import org.onosproject.yangutils.datamodel.utils.Parsable; | ... | @@ -24,6 +24,8 @@ import org.onosproject.yangutils.datamodel.utils.Parsable; |
24 | import org.onosproject.yangutils.datamodel.utils.YangConstructType; | 24 | import org.onosproject.yangutils.datamodel.utils.YangConstructType; |
25 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangListener; | 25 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangListener; |
26 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 26 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
27 | +import org.onosproject.yangutils.parser.impl.listeners.AppDataStructureListener; | ||
28 | +import org.onosproject.yangutils.parser.impl.listeners.AppExtendedNameListener; | ||
27 | import org.onosproject.yangutils.parser.impl.listeners.ArgumentListener; | 29 | import org.onosproject.yangutils.parser.impl.listeners.ArgumentListener; |
28 | import org.onosproject.yangutils.parser.impl.listeners.AugmentListener; | 30 | import org.onosproject.yangutils.parser.impl.listeners.AugmentListener; |
29 | import org.onosproject.yangutils.parser.impl.listeners.BaseFileListener; | 31 | import org.onosproject.yangutils.parser.impl.listeners.BaseFileListener; |
... | @@ -33,9 +35,11 @@ import org.onosproject.yangutils.parser.impl.listeners.BitListener; | ... | @@ -33,9 +35,11 @@ import org.onosproject.yangutils.parser.impl.listeners.BitListener; |
33 | import org.onosproject.yangutils.parser.impl.listeners.BitsListener; | 35 | import org.onosproject.yangutils.parser.impl.listeners.BitsListener; |
34 | import org.onosproject.yangutils.parser.impl.listeners.CaseListener; | 36 | import org.onosproject.yangutils.parser.impl.listeners.CaseListener; |
35 | import org.onosproject.yangutils.parser.impl.listeners.ChoiceListener; | 37 | import org.onosproject.yangutils.parser.impl.listeners.ChoiceListener; |
38 | +import org.onosproject.yangutils.parser.impl.listeners.CompilerAnnotationListener; | ||
36 | import org.onosproject.yangutils.parser.impl.listeners.ConfigListener; | 39 | import org.onosproject.yangutils.parser.impl.listeners.ConfigListener; |
37 | import org.onosproject.yangutils.parser.impl.listeners.ContactListener; | 40 | import org.onosproject.yangutils.parser.impl.listeners.ContactListener; |
38 | import org.onosproject.yangutils.parser.impl.listeners.ContainerListener; | 41 | import org.onosproject.yangutils.parser.impl.listeners.ContainerListener; |
42 | +import org.onosproject.yangutils.parser.impl.listeners.DataStructureKeyListener; | ||
39 | import org.onosproject.yangutils.parser.impl.listeners.Decimal64Listener; | 43 | import org.onosproject.yangutils.parser.impl.listeners.Decimal64Listener; |
40 | import org.onosproject.yangutils.parser.impl.listeners.DefaultListener; | 44 | import org.onosproject.yangutils.parser.impl.listeners.DefaultListener; |
41 | import org.onosproject.yangutils.parser.impl.listeners.DescriptionListener; | 45 | import org.onosproject.yangutils.parser.impl.listeners.DescriptionListener; |
... | @@ -1428,95 +1432,72 @@ public class TreeWalkListener implements GeneratedYangListener { | ... | @@ -1428,95 +1432,72 @@ public class TreeWalkListener implements GeneratedYangListener { |
1428 | 1432 | ||
1429 | @Override | 1433 | @Override |
1430 | public void enterCompilerAnnotationStatement(GeneratedYangParser.CompilerAnnotationStatementContext ctx) { | 1434 | public void enterCompilerAnnotationStatement(GeneratedYangParser.CompilerAnnotationStatementContext ctx) { |
1431 | - // TODO: implement the method. | 1435 | + CompilerAnnotationListener.processCompilerAnnotationEntry(this, ctx); |
1432 | } | 1436 | } |
1433 | 1437 | ||
1434 | @Override | 1438 | @Override |
1435 | public void exitCompilerAnnotationStatement(GeneratedYangParser.CompilerAnnotationStatementContext ctx) { | 1439 | public void exitCompilerAnnotationStatement(GeneratedYangParser.CompilerAnnotationStatementContext ctx) { |
1436 | - // TODO: implement the method. | 1440 | + CompilerAnnotationListener.processCompilerAnnotationExit(this, ctx); |
1437 | - } | ||
1438 | - | ||
1439 | - @Override | ||
1440 | - public void enterAnnotationStatement(GeneratedYangParser.AnnotationStatementContext ctx) { | ||
1441 | - // TODO: implement the method. | ||
1442 | - } | ||
1443 | - | ||
1444 | - @Override | ||
1445 | - public void exitAnnotationStatement(GeneratedYangParser.AnnotationStatementContext ctx) { | ||
1446 | - // TODO: implement the method. | ||
1447 | } | 1441 | } |
1448 | 1442 | ||
1449 | @Override | 1443 | @Override |
1450 | - public void enterAnnotationType(GeneratedYangParser.AnnotationTypeContext ctx) { | 1444 | + public void enterCompilerAnnotationBodyStatement(GeneratedYangParser.CompilerAnnotationBodyStatementContext ctx) { |
1451 | - // TODO: implement the method. | 1445 | + // do nothing |
1452 | - } | ||
1453 | - | ||
1454 | - @Override | ||
1455 | - public void exitAnnotationType(GeneratedYangParser.AnnotationTypeContext ctx) { | ||
1456 | - // TODO: implement the method. | ||
1457 | - } | ||
1458 | - | ||
1459 | - @Override | ||
1460 | - public void enterAnnotationParameterSpecification(GeneratedYangParser.AnnotationParameterSpecificationContext | ||
1461 | - ctx) { | ||
1462 | - // TODO: implement the method. | ||
1463 | } | 1446 | } |
1464 | 1447 | ||
1465 | @Override | 1448 | @Override |
1466 | - public void exitAnnotationParameterSpecification(GeneratedYangParser.AnnotationParameterSpecificationContext ctx) { | 1449 | + public void exitCompilerAnnotationBodyStatement(GeneratedYangParser.CompilerAnnotationBodyStatementContext ctx) { |
1467 | - // TODO: implement the method. | 1450 | + // do nothing |
1468 | } | 1451 | } |
1469 | 1452 | ||
1470 | @Override | 1453 | @Override |
1471 | - public void enterAnnotationParameterSpecificationArg(GeneratedYangParser.AnnotationParameterSpecificationArgContext | 1454 | + public void enterAppDataStructureStatement(GeneratedYangParser.AppDataStructureStatementContext ctx) { |
1472 | - ctx) { | 1455 | + AppDataStructureListener.processAppDataStructureEntry(this, ctx); |
1473 | - // TODO: implement the method. | ||
1474 | } | 1456 | } |
1475 | 1457 | ||
1476 | @Override | 1458 | @Override |
1477 | - public void exitAnnotationParameterSpecificationArg(GeneratedYangParser.AnnotationParameterSpecificationArgContext | 1459 | + public void exitAppDataStructureStatement(GeneratedYangParser.AppDataStructureStatementContext ctx) { |
1478 | - ctx) { | 1460 | + AppDataStructureListener.processAppDataStructureExit(this, ctx); |
1479 | - // TODO: implement the method. | ||
1480 | } | 1461 | } |
1481 | 1462 | ||
1482 | @Override | 1463 | @Override |
1483 | - public void enterAnnotationParaInstance(GeneratedYangParser.AnnotationParaInstanceContext ctx) { | 1464 | + public void enterAppDataStructure(GeneratedYangParser.AppDataStructureContext currentContext) { |
1484 | - // TODO: implement the method. | 1465 | + // do nothing |
1485 | } | 1466 | } |
1486 | 1467 | ||
1487 | @Override | 1468 | @Override |
1488 | - public void exitAnnotationParaInstance(GeneratedYangParser.AnnotationParaInstanceContext ctx) { | 1469 | + public void exitAppDataStructure(GeneratedYangParser.AppDataStructureContext currentContext) { |
1489 | - // TODO: implement the method. | 1470 | + // do nothing |
1490 | } | 1471 | } |
1491 | 1472 | ||
1492 | @Override | 1473 | @Override |
1493 | - public void enterAnnotationParaTypeIdentifier(GeneratedYangParser.AnnotationParaTypeIdentifierContext ctx) { | 1474 | + public void enterAppExtendedStatement(GeneratedYangParser.AppExtendedStatementContext currentContext) { |
1494 | - // TODO: implement the method. | 1475 | + AppExtendedNameListener.processAppExtendedNameEntry(this, currentContext); |
1495 | } | 1476 | } |
1496 | 1477 | ||
1497 | @Override | 1478 | @Override |
1498 | - public void exitAnnotationParaTypeIdentifier(GeneratedYangParser.AnnotationParaTypeIdentifierContext ctx) { | 1479 | + public void exitAppExtendedStatement(GeneratedYangParser.AppExtendedStatementContext currentContext) { |
1499 | - // TODO: implement the method. | 1480 | + // TODO : to be implemented |
1500 | } | 1481 | } |
1501 | 1482 | ||
1502 | @Override | 1483 | @Override |
1503 | - public void enterAnnotationParaTypeValue(GeneratedYangParser.AnnotationParaTypeValueContext ctx) { | 1484 | + public void enterExtendedName(GeneratedYangParser.ExtendedNameContext currentContext) { |
1504 | - // TODO: implement the method. | 1485 | + // do nothing |
1505 | } | 1486 | } |
1506 | 1487 | ||
1507 | @Override | 1488 | @Override |
1508 | - public void exitAnnotationParaTypeValue(GeneratedYangParser.AnnotationParaTypeValueContext ctx) { | 1489 | + public void exitExtendedName(GeneratedYangParser.ExtendedNameContext currentContext) { |
1509 | - // TODO: implement the method. | 1490 | + // do nothing |
1510 | } | 1491 | } |
1511 | 1492 | ||
1512 | @Override | 1493 | @Override |
1513 | - public void enterAnnotationIdentifier(GeneratedYangParser.AnnotationIdentifierContext ctx) { | 1494 | + public void enterDataStructureKeyStatement(GeneratedYangParser.DataStructureKeyStatementContext ctx) { |
1514 | - // TODO: implement the method. | 1495 | + DataStructureKeyListener.processDataStructureKeyEntry(this, ctx); |
1515 | } | 1496 | } |
1516 | 1497 | ||
1517 | @Override | 1498 | @Override |
1518 | - public void exitAnnotationIdentifier(GeneratedYangParser.AnnotationIdentifierContext ctx) { | 1499 | + public void exitDataStructureKeyStatement(GeneratedYangParser.DataStructureKeyStatementContext ctx) { |
1519 | - // TODO: implement the method. | 1500 | + // do nothing |
1520 | } | 1501 | } |
1521 | 1502 | ||
1522 | @Override | 1503 | @Override | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.datamodel.YangAppDataStructure; | ||
20 | +import org.onosproject.yangutils.datamodel.YangCompilerAnnotation; | ||
21 | +import org.onosproject.yangutils.datamodel.YangDataStructure; | ||
22 | +import org.onosproject.yangutils.datamodel.utils.Parsable; | ||
23 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
24 | +import org.onosproject.yangutils.parser.exceptions.ParserException; | ||
25 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
26 | + | ||
27 | +import static org.onosproject.yangutils.datamodel.YangDataStructure.getType; | ||
28 | +import static org.onosproject.yangutils.datamodel.utils.YangConstructType.APP_DATA_STRUCTURE; | ||
29 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | ||
30 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | ||
31 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | ||
32 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | ||
33 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | ||
34 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | ||
35 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidPrefix; | ||
36 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | ||
37 | + | ||
38 | +/* | ||
39 | + * Reference: RFC6020 and YANG ANTLR Grammar | ||
40 | + * | ||
41 | + * ABNF grammar as per RFC6020 | ||
42 | + * app-data-structure-stmt = prefix:app-data-structure-keyword string | ||
43 | + * (";" / | ||
44 | + * "{" | ||
45 | + * [data-structure-key-stmt stmtsep] | ||
46 | + * "}") | ||
47 | + * | ||
48 | + * ANTLR grammar rule | ||
49 | + * appDataStructureStatement : APP_DATA_STRUCTURE appDataStructure (STMTEND | (LEFT_CURLY_BRACE | ||
50 | + * dataStructureKeyStatement? RIGHT_CURLY_BRACE)); | ||
51 | + */ | ||
52 | + | ||
53 | +/** | ||
54 | + * Represents listener based call back function corresponding to the "app-data-structure" | ||
55 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
56 | + */ | ||
57 | +public final class AppDataStructureListener { | ||
58 | + | ||
59 | + /** | ||
60 | + * Creates a new app-data-structure listener. | ||
61 | + */ | ||
62 | + private AppDataStructureListener() { | ||
63 | + } | ||
64 | + | ||
65 | + /** | ||
66 | + * Performs validation and updates the data model tree. It is called when parser receives an | ||
67 | + * input matching the grammar rule(app-data-structure). | ||
68 | + * | ||
69 | + * @param listener listener's object | ||
70 | + * @param ctx context object of the grammar rule | ||
71 | + */ | ||
72 | + public static void processAppDataStructureEntry(TreeWalkListener listener, | ||
73 | + GeneratedYangParser.AppDataStructureStatementContext ctx) { | ||
74 | + | ||
75 | + checkStackIsNotEmpty(listener, MISSING_HOLDER, APP_DATA_STRUCTURE, "", ENTRY); | ||
76 | + | ||
77 | + String prefix = getValidPrefix(ctx.APP_DATA_STRUCTURE().getText(), APP_DATA_STRUCTURE, ctx); | ||
78 | + YangDataStructure dataStructure = getType(ctx.appDataStructure().getText()); | ||
79 | + | ||
80 | + YangAppDataStructure appDataStructure = new YangAppDataStructure(); | ||
81 | + appDataStructure.setPrefix(prefix); | ||
82 | + appDataStructure.setDataStructure(dataStructure); | ||
83 | + | ||
84 | + Parsable curData = listener.getParsedDataStack().peek(); | ||
85 | + if (curData instanceof YangCompilerAnnotation) { | ||
86 | + YangCompilerAnnotation compilerAnnotation = ((YangCompilerAnnotation) curData); | ||
87 | + compilerAnnotation.setYangAppDataStructure(appDataStructure); | ||
88 | + listener.getParsedDataStack().push(appDataStructure); | ||
89 | + } else { | ||
90 | + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, APP_DATA_STRUCTURE, | ||
91 | + "", ENTRY)); | ||
92 | + } | ||
93 | + } | ||
94 | + | ||
95 | + /** | ||
96 | + * Performs validation and updates the data model tree. It is called when parser | ||
97 | + * exits from grammar rule (app-data-structure). | ||
98 | + * | ||
99 | + * @param listener listener's object | ||
100 | + * @param ctx context object of the grammar rule | ||
101 | + */ | ||
102 | + public static void processAppDataStructureExit(TreeWalkListener listener, | ||
103 | + GeneratedYangParser.AppDataStructureStatementContext ctx) { | ||
104 | + | ||
105 | + checkStackIsNotEmpty(listener, MISSING_HOLDER, APP_DATA_STRUCTURE, "", EXIT); | ||
106 | + if (!(listener.getParsedDataStack().peek() instanceof YangAppDataStructure)) { | ||
107 | + throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, APP_DATA_STRUCTURE, | ||
108 | + "", EXIT)); | ||
109 | + } | ||
110 | + listener.getParsedDataStack().pop(); | ||
111 | + } | ||
112 | +} |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.datamodel.YangAppExtendedName; | ||
20 | +import org.onosproject.yangutils.datamodel.YangCompilerAnnotation; | ||
21 | +import org.onosproject.yangutils.datamodel.utils.Parsable; | ||
22 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
23 | +import org.onosproject.yangutils.parser.exceptions.ParserException; | ||
24 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
25 | + | ||
26 | +import static org.onosproject.yangutils.datamodel.utils.YangConstructType.APP_EXTENDED_NAME_DATA; | ||
27 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | ||
28 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | ||
29 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | ||
30 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | ||
31 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidPrefix; | ||
32 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat; | ||
33 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | ||
34 | + | ||
35 | +/* | ||
36 | + * Reference: RFC6020 and YANG ANTLR Grammar | ||
37 | + * | ||
38 | + * ABNF grammar as per RFC6020 | ||
39 | + * app-extended-stmt = prefix:app-extended-name-keyword string ";" | ||
40 | + * | ||
41 | + * ANTLR grammar rule | ||
42 | + * appExtendedStatement : APP_EXTENDED extendedName STMTEND; | ||
43 | + */ | ||
44 | + | ||
45 | +/** | ||
46 | + * Represents listener based call back function corresponding to the "app-extended-name" | ||
47 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
48 | + */ | ||
49 | +public final class AppExtendedNameListener { | ||
50 | + | ||
51 | + /** | ||
52 | + * Creates a new app-extended-name listener. | ||
53 | + */ | ||
54 | + private AppExtendedNameListener() { | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * Performs validation and updates the data model tree. It is called when parser receives an | ||
59 | + * input matching the grammar rule(app-extended-name). | ||
60 | + * | ||
61 | + * @param listener listener's object | ||
62 | + * @param ctx context object of the grammar rule | ||
63 | + */ | ||
64 | + public static void processAppExtendedNameEntry(TreeWalkListener listener, | ||
65 | + GeneratedYangParser.AppExtendedStatementContext ctx) { | ||
66 | + | ||
67 | + checkStackIsNotEmpty(listener, MISSING_HOLDER, APP_EXTENDED_NAME_DATA, ctx.extendedName().getText(), ENTRY); | ||
68 | + | ||
69 | + String prefix = getValidPrefix(ctx.APP_EXTENDED().getText(), APP_EXTENDED_NAME_DATA, ctx); | ||
70 | + YangAppExtendedName extendedName = new YangAppExtendedName(); | ||
71 | + extendedName.setPrefix(prefix); | ||
72 | + extendedName.setYangAppExtendedName(removeQuotesAndHandleConcat(ctx.extendedName().getText())); | ||
73 | + | ||
74 | + Parsable curData = listener.getParsedDataStack().peek(); | ||
75 | + if (curData instanceof YangCompilerAnnotation) { | ||
76 | + YangCompilerAnnotation compilerAnnotation = ((YangCompilerAnnotation) curData); | ||
77 | + compilerAnnotation.setYangAppExtendedName(extendedName); | ||
78 | + } else { | ||
79 | + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, APP_EXTENDED_NAME_DATA, | ||
80 | + ctx.extendedName().getText(), ENTRY)); | ||
81 | + } | ||
82 | + } | ||
83 | +} |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.datamodel.YangCompilerAnnotation; | ||
20 | +import org.onosproject.yangutils.datamodel.YangModule; | ||
21 | +import org.onosproject.yangutils.datamodel.YangSubModule; | ||
22 | +import org.onosproject.yangutils.datamodel.utils.Parsable; | ||
23 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
24 | +import org.onosproject.yangutils.parser.exceptions.ParserException; | ||
25 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
26 | + | ||
27 | +import static org.onosproject.yangutils.datamodel.utils.YangConstructType.COMPILER_ANNOTATION_DATA; | ||
28 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | ||
29 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | ||
30 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | ||
31 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | ||
32 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | ||
33 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | ||
34 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidPrefix; | ||
35 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat; | ||
36 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | ||
37 | + | ||
38 | +/* | ||
39 | + * Reference: RFC6020 and YANG ANTLR Grammar | ||
40 | + * | ||
41 | + * ABNF grammar as per RFC6020 | ||
42 | + * compiler-annotation-stmt = prefix:compiler-annotation-keyword string | ||
43 | + * "{" | ||
44 | + * [app-data-structure-stmt stmtsep] | ||
45 | + * [app-extended-stmt stmtsep] | ||
46 | + * "}" | ||
47 | + * | ||
48 | + * ANTLR grammar rule | ||
49 | + * compilerAnnotationStatement : COMPILER_ANNOTATION string LEFT_CURLY_BRACE | ||
50 | + * compilerAnnotationBodyStatement RIGHT_CURLY_BRACE; | ||
51 | + * | ||
52 | + * compilerAnnotationBodyStatement : appDataStructureStatement? appExtendedStatement? ; | ||
53 | + */ | ||
54 | + | ||
55 | +/** | ||
56 | + * Represents listener based call back function corresponding to the "compiler-annotation" | ||
57 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
58 | + */ | ||
59 | +public final class CompilerAnnotationListener { | ||
60 | + | ||
61 | + /** | ||
62 | + * Creates a new compiler-annotation listener. | ||
63 | + */ | ||
64 | + private CompilerAnnotationListener() { | ||
65 | + } | ||
66 | + | ||
67 | + /** | ||
68 | + * Performs validation and updates the data model tree. It is called when parser receives an | ||
69 | + * input matching the grammar rule(compiler-annotation). | ||
70 | + * | ||
71 | + * @param listener listener's object | ||
72 | + * @param ctx context object of the grammar rule | ||
73 | + */ | ||
74 | + public static void processCompilerAnnotationEntry(TreeWalkListener listener, | ||
75 | + GeneratedYangParser.CompilerAnnotationStatementContext ctx) { | ||
76 | + // Check for stack to be non empty. | ||
77 | + checkStackIsNotEmpty(listener, MISSING_HOLDER, COMPILER_ANNOTATION_DATA, ctx.string().getText(), ENTRY); | ||
78 | + String prefix = getValidPrefix(ctx.COMPILER_ANNOTATION().getText(), COMPILER_ANNOTATION_DATA, ctx); | ||
79 | + | ||
80 | + YangCompilerAnnotation compilerAnnotation = new YangCompilerAnnotation(); | ||
81 | + compilerAnnotation.setPrefix(prefix); | ||
82 | + compilerAnnotation.setPath(removeQuotesAndHandleConcat(ctx.string().getText())); | ||
83 | + | ||
84 | + Parsable curData = listener.getParsedDataStack().peek(); | ||
85 | + switch (curData.getYangConstructType()) { | ||
86 | + case MODULE_DATA: | ||
87 | + YangModule module = ((YangModule) curData); | ||
88 | + module.addCompilerAnnotation(compilerAnnotation); | ||
89 | + break; | ||
90 | + case SUB_MODULE_DATA: | ||
91 | + YangSubModule subModule = ((YangSubModule) curData); | ||
92 | + subModule.addCompilerAnnotation(compilerAnnotation); | ||
93 | + break; | ||
94 | + default: | ||
95 | + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, COMPILER_ANNOTATION_DATA, | ||
96 | + ctx.string().getText(), ENTRY)); | ||
97 | + } | ||
98 | + listener.getParsedDataStack().push(compilerAnnotation); | ||
99 | + } | ||
100 | + | ||
101 | + /** | ||
102 | + * Performs validation and updates the data model tree. It is called when parser | ||
103 | + * exits from grammar rule (compiler-annotation). | ||
104 | + * | ||
105 | + * @param listener listener's object | ||
106 | + * @param ctx context object of the grammar rule | ||
107 | + */ | ||
108 | + public static void processCompilerAnnotationExit(TreeWalkListener listener, | ||
109 | + GeneratedYangParser.CompilerAnnotationStatementContext ctx) { | ||
110 | + | ||
111 | + checkStackIsNotEmpty(listener, MISSING_HOLDER, COMPILER_ANNOTATION_DATA, ctx.string().getText(), EXIT); | ||
112 | + if (!(listener.getParsedDataStack().peek() instanceof YangCompilerAnnotation)) { | ||
113 | + throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, COMPILER_ANNOTATION_DATA, | ||
114 | + ctx.string().getText(), EXIT)); | ||
115 | + } | ||
116 | + listener.getParsedDataStack().pop(); | ||
117 | + } | ||
118 | +} |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.datamodel.YangAppDataStructure; | ||
20 | +import org.onosproject.yangutils.datamodel.utils.Parsable; | ||
21 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
22 | +import org.onosproject.yangutils.parser.exceptions.ParserException; | ||
23 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
24 | + | ||
25 | +import static org.onosproject.yangutils.datamodel.utils.YangConstructType.KEY_DATA; | ||
26 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | ||
27 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | ||
28 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | ||
29 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | ||
30 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat; | ||
31 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | ||
32 | +import static org.onosproject.yangutils.utils.UtilConstants.SPACE; | ||
33 | + | ||
34 | +/* | ||
35 | + * Reference: RFC6020 and YANG ANTLR Grammar | ||
36 | + * | ||
37 | + * ABNF grammar as per RFC6020 | ||
38 | + * data-structure-key-stmt = prefix:key-keyword string ";" | ||
39 | + * | ||
40 | + * ANTLR grammar rule | ||
41 | + * dataStructureKeyStatement : DATA_STRUCTURE_KEY string STMTEND; | ||
42 | + */ | ||
43 | + | ||
44 | +/** | ||
45 | + * Represents listener based call back function corresponding to the "key" | ||
46 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
47 | + */ | ||
48 | +public final class DataStructureKeyListener { | ||
49 | + | ||
50 | + /** | ||
51 | + * Creates a new data-structure-key listener. | ||
52 | + */ | ||
53 | + private DataStructureKeyListener() { | ||
54 | + } | ||
55 | + | ||
56 | + /** | ||
57 | + * Performs validation and updates the data model tree. It is called when parser receives an | ||
58 | + * input matching the grammar rule(key). | ||
59 | + * | ||
60 | + * @param listener listener's object | ||
61 | + * @param ctx context object of the grammar rule | ||
62 | + */ | ||
63 | + public static void processDataStructureKeyEntry(TreeWalkListener listener, | ||
64 | + GeneratedYangParser.DataStructureKeyStatementContext ctx) { | ||
65 | + | ||
66 | + // Check for stack to be non empty. | ||
67 | + checkStackIsNotEmpty(listener, MISSING_HOLDER, KEY_DATA, ctx.string().getText(), ENTRY); | ||
68 | + | ||
69 | + Parsable tmpData = listener.getParsedDataStack().peek(); | ||
70 | + if (listener.getParsedDataStack().peek() instanceof YangAppDataStructure) { | ||
71 | + YangAppDataStructure dataStructure = (YangAppDataStructure) tmpData; | ||
72 | + String tmpKeyValue = removeQuotesAndHandleConcat(ctx.string().getText()); | ||
73 | + if (tmpKeyValue.contains(SPACE)) { | ||
74 | + String[] keyValues = tmpKeyValue.split(SPACE); | ||
75 | + for (String keyValue : keyValues) { | ||
76 | + dataStructure.addKey(keyValue); | ||
77 | + } | ||
78 | + } else { | ||
79 | + dataStructure.addKey(tmpKeyValue); | ||
80 | + } | ||
81 | + } else { | ||
82 | + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, KEY_DATA, ctx.string().getText(), | ||
83 | + ENTRY)); | ||
84 | + } | ||
85 | + } | ||
86 | +} | ||
87 | + |
... | @@ -1026,4 +1026,28 @@ public final class ListenerUtil { | ... | @@ -1026,4 +1026,28 @@ public final class ListenerUtil { |
1026 | throw parserException; | 1026 | throw parserException; |
1027 | } | 1027 | } |
1028 | } | 1028 | } |
1029 | + | ||
1030 | + /** | ||
1031 | + * Checks and return valid prefix. | ||
1032 | + * | ||
1033 | + * @param inputString string from yang file | ||
1034 | + * @param yangConstruct yang construct for creating error message | ||
1035 | + * @param ctx yang construct's context to get the line number and character position | ||
1036 | + * @return valid prefix | ||
1037 | + */ | ||
1038 | + public static String getValidPrefix(String inputString, | ||
1039 | + YangConstructType yangConstruct, ParserRuleContext ctx) { | ||
1040 | + String tmpPrefixString = removeQuotesAndHandleConcat(inputString); | ||
1041 | + String[] tmpData = tmpPrefixString.split(Pattern.quote(COLON)); | ||
1042 | + if (tmpData.length == 2) { | ||
1043 | + return tmpData[0]; | ||
1044 | + } else { | ||
1045 | + ParserException parserException = new ParserException("YANG file error : " + | ||
1046 | + YangConstructType.getYangConstructType(yangConstruct) + " name " + inputString + | ||
1047 | + " is not valid."); | ||
1048 | + parserException.setLine(ctx.getStart().getLine()); | ||
1049 | + parserException.setCharPosition(ctx.getStart().getCharPositionInLine()); | ||
1050 | + throw parserException; | ||
1051 | + } | ||
1052 | + } | ||
1029 | } | 1053 | } | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -101,6 +101,14 @@ lexer grammar YangLexer; | ... | @@ -101,6 +101,14 @@ lexer grammar YangLexer; |
101 | UNBOUNDED_KEYWORD : 'unbounded'; | 101 | UNBOUNDED_KEYWORD : 'unbounded'; |
102 | USER_KEYWORD : 'user'; | 102 | USER_KEYWORD : 'user'; |
103 | COMPILER_ANNOTATION_KEYWORD : 'compiler-annotation'; | 103 | COMPILER_ANNOTATION_KEYWORD : 'compiler-annotation'; |
104 | + COMPILER_ANNOTATION : IDENTIFIER COLON COMPILER_ANNOTATION_KEYWORD; | ||
105 | + APP_DATA_STRUCTURE_KEYWORD : 'app-data-structure'; | ||
106 | + APP_DATA_STRUCTURE : IDENTIFIER COLON APP_DATA_STRUCTURE_KEYWORD; | ||
107 | + DATA_STRUCTURE_KEYWORD : 'data-structure'; | ||
108 | + DATA_STRUCTURE : IDENTIFIER COLON DATA_STRUCTURE_KEYWORD; | ||
109 | + DATA_STRUCTURE_KEY : IDENTIFIER COLON KEY_KEYWORD; | ||
110 | + APP_EXTENDED_KEYWORD : 'app-extended-name'; | ||
111 | + APP_EXTENDED : IDENTIFIER COLON APP_EXTENDED_KEYWORD; | ||
104 | 112 | ||
105 | // Lexer tokens to be skipped | 113 | // Lexer tokens to be skipped |
106 | COMMENT | 114 | COMMENT |
... | @@ -117,18 +125,11 @@ lexer grammar YangLexer; | ... | @@ -117,18 +125,11 @@ lexer grammar YangLexer; |
117 | DATE_ARG : DIGIT DIGIT DIGIT DIGIT '-' DIGIT DIGIT '-' DIGIT DIGIT; | 125 | DATE_ARG : DIGIT DIGIT DIGIT DIGIT '-' DIGIT DIGIT '-' DIGIT DIGIT; |
118 | LEFT_CURLY_BRACE : '{'; | 126 | LEFT_CURLY_BRACE : '{'; |
119 | RIGHT_CURLY_BRACE : '}'; | 127 | RIGHT_CURLY_BRACE : '}'; |
120 | - LEFT_ROUND_BRACE : '('; | ||
121 | - RIGHT_ROUND_BRACE : ')'; | ||
122 | - ANNOTATION_START : '@'; | ||
123 | - ANNOTATION_IDENTIFIER : ('@')(ALPHA | '_') | ||
124 | - (ALPHA | DIGIT | '_' | '-' | '.')*; | ||
125 | IDENTIFIER : (ALPHA | '_') | 128 | IDENTIFIER : (ALPHA | '_') |
126 | (ALPHA | DIGIT | '_' | '-' | '.')*; | 129 | (ALPHA | DIGIT | '_' | '-' | '.')*; |
127 | STMTEND : ';'; | 130 | STMTEND : ';'; |
128 | DQUOTE : '"'; | 131 | DQUOTE : '"'; |
129 | COLON : ':'; | 132 | COLON : ':'; |
130 | - COMMA : ','; | ||
131 | - EQUAL : '='; | ||
132 | PLUS : '+'; | 133 | PLUS : '+'; |
133 | MINUS: '-'; | 134 | MINUS: '-'; |
134 | 135 | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
18 | + | ||
19 | +import java.io.IOException; | ||
20 | +import org.junit.Test; | ||
21 | +import org.onosproject.yangutils.datamodel.YangAppDataStructure; | ||
22 | +import org.onosproject.yangutils.datamodel.YangCompilerAnnotation; | ||
23 | +import org.onosproject.yangutils.datamodel.YangDataStructure; | ||
24 | +import org.onosproject.yangutils.datamodel.YangModule; | ||
25 | +import org.onosproject.yangutils.datamodel.YangNode; | ||
26 | +import org.onosproject.yangutils.datamodel.YangNodeType; | ||
27 | +import org.onosproject.yangutils.parser.exceptions.ParserException; | ||
28 | +import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | ||
29 | + | ||
30 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
31 | +import static org.hamcrest.core.Is.is; | ||
32 | + | ||
33 | +/** | ||
34 | + * Test cases for compiler annotation listener. | ||
35 | + */ | ||
36 | +public class CompilerAnnotationListenerTest { | ||
37 | + | ||
38 | + private final YangUtilsParserManager manager = new YangUtilsParserManager(); | ||
39 | + | ||
40 | + /** | ||
41 | + * Checks valid compiler annotation statements. | ||
42 | + */ | ||
43 | + @Test | ||
44 | + public void processValidCompilerAnnotation() throws IOException, ParserException { | ||
45 | + | ||
46 | + YangNode node = manager.getDataModel("src/test/resources/ValidCompilerAnnotation.yang"); | ||
47 | + | ||
48 | + // Check whether the data model tree returned is of type module. | ||
49 | + assertThat((node instanceof YangModule), is(true)); | ||
50 | + | ||
51 | + // Check whether the node type is set properly to module. | ||
52 | + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE)); | ||
53 | + | ||
54 | + // Check whether the module name is set correctly. | ||
55 | + YangModule yangNode = (YangModule) node; | ||
56 | + assertThat(yangNode.getName(), is("event")); | ||
57 | + | ||
58 | + YangCompilerAnnotation compilerAnnotation = yangNode.getCompilerAnnotationList() | ||
59 | + .iterator().next(); | ||
60 | + assertThat(compilerAnnotation.getPrefix(), is("ca")); | ||
61 | + assertThat(compilerAnnotation.getPath(), is("/candidate-servers/server")); | ||
62 | + | ||
63 | + YangAppDataStructure appDataStructure = compilerAnnotation.getYangAppDataStructure(); | ||
64 | + assertThat(appDataStructure.getPrefix(), is("abc")); | ||
65 | + assertThat(appDataStructure.getDataStructure(), is(YangDataStructure.MAP)); | ||
66 | + | ||
67 | + assertThat(appDataStructure.getKeyList().iterator().next(), is("name")); | ||
68 | + } | ||
69 | +} |
... | @@ -23,13 +23,13 @@ import org.junit.Rule; | ... | @@ -23,13 +23,13 @@ import org.junit.Rule; |
23 | import org.junit.Test; | 23 | import org.junit.Test; |
24 | import org.junit.rules.ExpectedException; | 24 | import org.junit.rules.ExpectedException; |
25 | import org.onosproject.yangutils.datamodel.YangContainer; | 25 | import org.onosproject.yangutils.datamodel.YangContainer; |
26 | -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; | ||
27 | import org.onosproject.yangutils.datamodel.YangLeaf; | 26 | import org.onosproject.yangutils.datamodel.YangLeaf; |
28 | import org.onosproject.yangutils.datamodel.YangList; | 27 | import org.onosproject.yangutils.datamodel.YangList; |
29 | import org.onosproject.yangutils.datamodel.YangModule; | 28 | import org.onosproject.yangutils.datamodel.YangModule; |
30 | import org.onosproject.yangutils.datamodel.YangNode; | 29 | import org.onosproject.yangutils.datamodel.YangNode; |
31 | import org.onosproject.yangutils.datamodel.YangNodeType; | 30 | import org.onosproject.yangutils.datamodel.YangNodeType; |
32 | import org.onosproject.yangutils.datamodel.YangStatusType; | 31 | import org.onosproject.yangutils.datamodel.YangStatusType; |
32 | +import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; | ||
33 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 33 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
34 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 34 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; |
35 | 35 | ||
... | @@ -208,4 +208,30 @@ public class ListListenerTest { | ... | @@ -208,4 +208,30 @@ public class ListListenerTest { |
208 | thrown.expectMessage("YANG file error : list name 1valid is not valid."); | 208 | thrown.expectMessage("YANG file error : list name 1valid is not valid."); |
209 | YangNode node = manager.getDataModel("src/test/resources/ListInvalidIdentifier.yang"); | 209 | YangNode node = manager.getDataModel("src/test/resources/ListInvalidIdentifier.yang"); |
210 | } | 210 | } |
211 | + | ||
212 | + /** | ||
213 | + * Checks list with identifier name as enum. | ||
214 | + */ | ||
215 | + @Test | ||
216 | + public void processListWithIdentifierNameEnum() throws IOException, ParserException { | ||
217 | + | ||
218 | + YangNode node = manager.getDataModel("src/test/resources/ListWithIdentifierNameEnum.yang"); | ||
219 | + | ||
220 | + assertThat((node instanceof YangModule), is(true)); | ||
221 | + | ||
222 | + // Check whether the node type is set properly to module. | ||
223 | + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE)); | ||
224 | + | ||
225 | + // Check whether the module name is set correctly. | ||
226 | + YangModule yangNode = (YangModule) node; | ||
227 | + assertThat(yangNode.getName(), is("Test")); | ||
228 | + | ||
229 | + // Check whether the list is child of module | ||
230 | + YangList yangList = (YangList) yangNode.getChild(); | ||
231 | + assertThat(yangList.getName(), is("enumList")); | ||
232 | + assertThat(yangList.getKeyList().contains("enum"), is(true)); | ||
233 | + YangLeaf leaf = yangList.getListOfLeaf().iterator().next(); | ||
234 | + assertThat(leaf.getName(), is("enum")); | ||
235 | + assertThat(leaf.getDataType().getDataType(), is(YangDataTypes.ENUMERATION)); | ||
236 | + } | ||
211 | } | 237 | } | ... | ... |
... | @@ -16,6 +16,8 @@ | ... | @@ -16,6 +16,8 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.parser.impl.listeners; | 17 | package org.onosproject.yangutils.parser.impl.listeners; |
18 | 18 | ||
19 | +import java.io.IOException; | ||
20 | +import java.util.ListIterator; | ||
19 | import org.junit.Test; | 21 | import org.junit.Test; |
20 | import org.onosproject.yangutils.datamodel.YangContainer; | 22 | import org.onosproject.yangutils.datamodel.YangContainer; |
21 | import org.onosproject.yangutils.datamodel.YangLeaf; | 23 | import org.onosproject.yangutils.datamodel.YangLeaf; |
... | @@ -25,9 +27,6 @@ import org.onosproject.yangutils.datamodel.YangNode; | ... | @@ -25,9 +27,6 @@ import org.onosproject.yangutils.datamodel.YangNode; |
25 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 27 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
26 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 28 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; |
27 | 29 | ||
28 | -import java.io.IOException; | ||
29 | -import java.util.ListIterator; | ||
30 | - | ||
31 | import static org.hamcrest.core.Is.is; | 30 | import static org.hamcrest.core.Is.is; |
32 | import static org.junit.Assert.assertThat; | 31 | import static org.junit.Assert.assertThat; |
33 | 32 | ||
... | @@ -49,12 +48,12 @@ public class WhenListenerTest { | ... | @@ -49,12 +48,12 @@ public class WhenListenerTest { |
49 | assertThat(yangNode.getName(), is("Test")); | 48 | assertThat(yangNode.getName(), is("Test")); |
50 | 49 | ||
51 | YangList yangList = (YangList) yangNode.getChild(); | 50 | YangList yangList = (YangList) yangNode.getChild(); |
51 | + String expectedConstraint = "../switching-capability = 'TDM'"; | ||
52 | assertThat(yangList.getName(), is("interface-switching-capability")); | 52 | assertThat(yangList.getName(), is("interface-switching-capability")); |
53 | + assertThat(yangList.getWhen().getCondition(), is(expectedConstraint)); | ||
53 | 54 | ||
54 | YangContainer container = (YangContainer) yangList.getNextSibling(); | 55 | YangContainer container = (YangContainer) yangList.getNextSibling(); |
55 | assertThat(container.getName(), is("time-division-multiplex-capable")); | 56 | assertThat(container.getName(), is("time-division-multiplex-capable")); |
56 | - | ||
57 | - String expectedConstraint = "../switching-capability = 'TDM'"; | ||
58 | assertThat(container.getWhen().getCondition(), is(expectedConstraint)); | 57 | assertThat(container.getWhen().getCondition(), is(expectedConstraint)); |
59 | } | 58 | } |
60 | 59 | ... | ... |
... | @@ -15,6 +15,8 @@ | ... | @@ -15,6 +15,8 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.yangutils.plugin.manager; | 16 | package org.onosproject.yangutils.plugin.manager; |
17 | 17 | ||
18 | +import java.io.IOException; | ||
19 | +import java.util.ListIterator; | ||
18 | import org.apache.maven.plugin.MojoExecutionException; | 20 | import org.apache.maven.plugin.MojoExecutionException; |
19 | import org.junit.Rule; | 21 | import org.junit.Rule; |
20 | import org.junit.Test; | 22 | import org.junit.Test; |
... | @@ -34,12 +36,10 @@ import org.onosproject.yangutils.linker.impl.YangLinkerManager; | ... | @@ -34,12 +36,10 @@ import org.onosproject.yangutils.linker.impl.YangLinkerManager; |
34 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 36 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
35 | import org.onosproject.yangutils.utils.io.impl.YangFileScanner; | 37 | import org.onosproject.yangutils.utils.io.impl.YangFileScanner; |
36 | 38 | ||
37 | -import java.io.IOException; | ||
38 | -import java.util.ListIterator; | ||
39 | - | ||
40 | import static org.hamcrest.MatcherAssert.assertThat; | 39 | import static org.hamcrest.MatcherAssert.assertThat; |
41 | import static org.hamcrest.core.Is.is; | 40 | import static org.hamcrest.core.Is.is; |
42 | import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE; | 41 | import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE; |
42 | +import static org.onosproject.yangutils.linker.impl.YangLinkerUtils.updateFilePriority; | ||
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Test cases for testing inter file linking for identity. | 45 | * Test cases for testing inter file linking for identity. |
... | @@ -73,6 +73,8 @@ public class InterFileIdentityLinkingTest { | ... | @@ -73,6 +73,8 @@ public class InterFileIdentityLinkingTest { |
73 | // Add references to import list. | 73 | // Add references to import list. |
74 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 74 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
75 | 75 | ||
76 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
77 | + | ||
76 | // Carry out inter-file linking. | 78 | // Carry out inter-file linking. |
77 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 79 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
78 | 80 | ||
... | @@ -162,6 +164,8 @@ public class InterFileIdentityLinkingTest { | ... | @@ -162,6 +164,8 @@ public class InterFileIdentityLinkingTest { |
162 | // Add references to include list. | 164 | // Add references to include list. |
163 | yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); | 165 | yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
164 | 166 | ||
167 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
168 | + | ||
165 | // Carry out inter-file linking. | 169 | // Carry out inter-file linking. |
166 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 170 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
167 | 171 | ||
... | @@ -244,6 +248,8 @@ public class InterFileIdentityLinkingTest { | ... | @@ -244,6 +248,8 @@ public class InterFileIdentityLinkingTest { |
244 | // Add references to import list. | 248 | // Add references to import list. |
245 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 249 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
246 | 250 | ||
251 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
252 | + | ||
247 | // Carry out inter-file linking. | 253 | // Carry out inter-file linking. |
248 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 254 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
249 | 255 | ||
... | @@ -302,7 +308,7 @@ public class InterFileIdentityLinkingTest { | ... | @@ -302,7 +308,7 @@ public class InterFileIdentityLinkingTest { |
302 | assertThat(yangIdentityRef.getBaseIdentity().getName(), is("ref-address-family")); | 308 | assertThat(yangIdentityRef.getBaseIdentity().getName(), is("ref-address-family")); |
303 | assertThat(yangIdentityRef.getReferredIdentity().getName(), is("ref-address-family")); | 309 | assertThat(yangIdentityRef.getReferredIdentity().getName(), is("ref-address-family")); |
304 | assertThat(yangIdentityRef.getResolvableStatus(), is(ResolvableStatus.RESOLVED)); | 310 | assertThat(yangIdentityRef.getResolvableStatus(), is(ResolvableStatus.RESOLVED)); |
305 | - } | 311 | + } |
306 | 312 | ||
307 | /** | 313 | /** |
308 | * Checks inter file feature linking with included file with dependency. | 314 | * Checks inter file feature linking with included file with dependency. |
... | @@ -332,6 +338,8 @@ public class InterFileIdentityLinkingTest { | ... | @@ -332,6 +338,8 @@ public class InterFileIdentityLinkingTest { |
332 | // Add references to import list. | 338 | // Add references to import list. |
333 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 339 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
334 | 340 | ||
341 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
342 | + | ||
335 | // Carry out inter-file linking. | 343 | // Carry out inter-file linking. |
336 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 344 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
337 | 345 | ||
... | @@ -417,6 +425,8 @@ public class InterFileIdentityLinkingTest { | ... | @@ -417,6 +425,8 @@ public class InterFileIdentityLinkingTest { |
417 | // Add references to import list. | 425 | // Add references to import list. |
418 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 426 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
419 | 427 | ||
428 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
429 | + | ||
420 | // Carry out inter-file linking. | 430 | // Carry out inter-file linking. |
421 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 431 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
422 | } | 432 | } |
... | @@ -436,10 +446,6 @@ public class InterFileIdentityLinkingTest { | ... | @@ -436,10 +446,6 @@ public class InterFileIdentityLinkingTest { |
436 | utilManager.parseYangFileInfoSet(); | 446 | utilManager.parseYangFileInfoSet(); |
437 | utilManager.createYangNodeSet(); | 447 | utilManager.createYangNodeSet(); |
438 | 448 | ||
439 | - YangNode selfNode = null; | ||
440 | - YangNode refNode1 = null; | ||
441 | - YangNode refNode2 = null; | ||
442 | - | ||
443 | // Create YANG node set | 449 | // Create YANG node set |
444 | yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet()); | 450 | yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
445 | 451 | ||
... | @@ -452,6 +458,9 @@ public class InterFileIdentityLinkingTest { | ... | @@ -452,6 +458,9 @@ public class InterFileIdentityLinkingTest { |
452 | // Add references to include list. | 458 | // Add references to include list. |
453 | yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); | 459 | yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
454 | 460 | ||
461 | + // Update the priority for all the files. | ||
462 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
463 | + | ||
455 | // Carry out inter-file linking. | 464 | // Carry out inter-file linking. |
456 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 465 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
457 | } | 466 | } |
... | @@ -478,6 +487,8 @@ public class InterFileIdentityLinkingTest { | ... | @@ -478,6 +487,8 @@ public class InterFileIdentityLinkingTest { |
478 | // Add references to import list. | 487 | // Add references to import list. |
479 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 488 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
480 | 489 | ||
490 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
491 | + | ||
481 | // Carry out inter-file linking. | 492 | // Carry out inter-file linking. |
482 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 493 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
483 | 494 | ||
... | @@ -570,6 +581,8 @@ public class InterFileIdentityLinkingTest { | ... | @@ -570,6 +581,8 @@ public class InterFileIdentityLinkingTest { |
570 | // Add references to import list. | 581 | // Add references to import list. |
571 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 582 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
572 | 583 | ||
584 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
585 | + | ||
573 | // Carry out inter-file linking. | 586 | // Carry out inter-file linking. |
574 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 587 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
575 | 588 | ... | ... |
... | @@ -36,6 +36,7 @@ import static org.hamcrest.core.Is.is; | ... | @@ -36,6 +36,7 @@ import static org.hamcrest.core.Is.is; |
36 | import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE; | 36 | import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE; |
37 | import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.INTRA_FILE_RESOLVED; | 37 | import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.INTRA_FILE_RESOLVED; |
38 | import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED; | 38 | import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED; |
39 | +import static org.onosproject.yangutils.linker.impl.YangLinkerUtils.updateFilePriority; | ||
39 | 40 | ||
40 | /** | 41 | /** |
41 | * Test cases for testing inter file linking. | 42 | * Test cases for testing inter file linking. |
... | @@ -67,6 +68,8 @@ public class InterFileIfFeatureLinkingTest { | ... | @@ -67,6 +68,8 @@ public class InterFileIfFeatureLinkingTest { |
67 | // Add references to import list. | 68 | // Add references to import list. |
68 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 69 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
69 | 70 | ||
71 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
72 | + | ||
70 | // Carry out inter-file linking. | 73 | // Carry out inter-file linking. |
71 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 74 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
72 | 75 | ||
... | @@ -137,6 +140,8 @@ public class InterFileIfFeatureLinkingTest { | ... | @@ -137,6 +140,8 @@ public class InterFileIfFeatureLinkingTest { |
137 | // Add references to include list. | 140 | // Add references to include list. |
138 | yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); | 141 | yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
139 | 142 | ||
143 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
144 | + | ||
140 | // Carry out inter-file linking. | 145 | // Carry out inter-file linking. |
141 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 146 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
142 | 147 | ||
... | @@ -201,6 +206,9 @@ public class InterFileIfFeatureLinkingTest { | ... | @@ -201,6 +206,9 @@ public class InterFileIfFeatureLinkingTest { |
201 | // Add references to import list. | 206 | // Add references to import list. |
202 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 207 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
203 | 208 | ||
209 | + // Update the priority for all the files. | ||
210 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
211 | + | ||
204 | // Carry out inter-file linking. | 212 | // Carry out inter-file linking. |
205 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 213 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
206 | 214 | ||
... | @@ -272,6 +280,8 @@ public class InterFileIfFeatureLinkingTest { | ... | @@ -272,6 +280,8 @@ public class InterFileIfFeatureLinkingTest { |
272 | // Add references to import list. | 280 | // Add references to import list. |
273 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 281 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
274 | 282 | ||
283 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
284 | + | ||
275 | // Carry out inter-file linking. | 285 | // Carry out inter-file linking. |
276 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 286 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
277 | 287 | ||
... | @@ -337,6 +347,8 @@ public class InterFileIfFeatureLinkingTest { | ... | @@ -337,6 +347,8 @@ public class InterFileIfFeatureLinkingTest { |
337 | // Add references to import list. | 347 | // Add references to import list. |
338 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 348 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
339 | 349 | ||
350 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
351 | + | ||
340 | // Carry out inter-file linking. | 352 | // Carry out inter-file linking. |
341 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 353 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
342 | 354 | ||
... | @@ -409,6 +421,8 @@ public class InterFileIfFeatureLinkingTest { | ... | @@ -409,6 +421,8 @@ public class InterFileIfFeatureLinkingTest { |
409 | // Add references to include list. | 421 | // Add references to include list. |
410 | yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); | 422 | yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
411 | 423 | ||
424 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
425 | + | ||
412 | // Carry out inter-file linking. | 426 | // Carry out inter-file linking. |
413 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 427 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
414 | 428 | ... | ... |
... | @@ -16,6 +16,9 @@ | ... | @@ -16,6 +16,9 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.plugin.manager; | 17 | package org.onosproject.yangutils.plugin.manager; |
18 | 18 | ||
19 | +import java.io.IOException; | ||
20 | +import java.util.Iterator; | ||
21 | +import java.util.ListIterator; | ||
19 | import org.apache.maven.plugin.MojoExecutionException; | 22 | import org.apache.maven.plugin.MojoExecutionException; |
20 | import org.junit.Rule; | 23 | import org.junit.Rule; |
21 | import org.junit.Test; | 24 | import org.junit.Test; |
... | @@ -32,15 +35,12 @@ import org.onosproject.yangutils.parser.exceptions.ParserException; | ... | @@ -32,15 +35,12 @@ import org.onosproject.yangutils.parser.exceptions.ParserException; |
32 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 35 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; |
33 | import org.onosproject.yangutils.utils.io.impl.YangFileScanner; | 36 | import org.onosproject.yangutils.utils.io.impl.YangFileScanner; |
34 | 37 | ||
35 | -import java.io.IOException; | ||
36 | -import java.util.Iterator; | ||
37 | -import java.util.ListIterator; | ||
38 | - | ||
39 | import static org.hamcrest.MatcherAssert.assertThat; | 38 | import static org.hamcrest.MatcherAssert.assertThat; |
40 | import static org.hamcrest.core.Is.is; | 39 | import static org.hamcrest.core.Is.is; |
41 | import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE; | 40 | import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE; |
42 | import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED; | 41 | import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED; |
43 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.LEAFREF; | 42 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.LEAFREF; |
43 | +import static org.onosproject.yangutils.linker.impl.YangLinkerUtils.updateFilePriority; | ||
44 | 44 | ||
45 | /** | 45 | /** |
46 | * Test cases for testing leafref inter file linking. | 46 | * Test cases for testing leafref inter file linking. |
... | @@ -74,6 +74,8 @@ public class InterFileLeafrefLinkingTest { | ... | @@ -74,6 +74,8 @@ public class InterFileLeafrefLinkingTest { |
74 | // Add references to import list. | 74 | // Add references to import list. |
75 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 75 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
76 | 76 | ||
77 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
78 | + | ||
77 | // Carry out inter-file linking. | 79 | // Carry out inter-file linking. |
78 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 80 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
79 | 81 | ||
... | @@ -146,6 +148,8 @@ public class InterFileLeafrefLinkingTest { | ... | @@ -146,6 +148,8 @@ public class InterFileLeafrefLinkingTest { |
146 | // Add references to import list. | 148 | // Add references to import list. |
147 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 149 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
148 | 150 | ||
151 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
152 | + | ||
149 | // Carry out inter-file linking. | 153 | // Carry out inter-file linking. |
150 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 154 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
151 | 155 | ||
... | @@ -209,6 +213,8 @@ public class InterFileLeafrefLinkingTest { | ... | @@ -209,6 +213,8 @@ public class InterFileLeafrefLinkingTest { |
209 | // Add references to import list. | 213 | // Add references to import list. |
210 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 214 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
211 | 215 | ||
216 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
217 | + | ||
212 | // Carry out inter-file linking. | 218 | // Carry out inter-file linking. |
213 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 219 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
214 | 220 | ||
... | @@ -278,6 +284,8 @@ public class InterFileLeafrefLinkingTest { | ... | @@ -278,6 +284,8 @@ public class InterFileLeafrefLinkingTest { |
278 | // Add references to import list. | 284 | // Add references to import list. |
279 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 285 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
280 | 286 | ||
287 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
288 | + | ||
281 | // Carry out inter-file linking. | 289 | // Carry out inter-file linking. |
282 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 290 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
283 | 291 | ... | ... |
... | @@ -24,6 +24,7 @@ import org.junit.Rule; | ... | @@ -24,6 +24,7 @@ import org.junit.Rule; |
24 | import org.junit.Test; | 24 | import org.junit.Test; |
25 | import org.junit.rules.ExpectedException; | 25 | import org.junit.rules.ExpectedException; |
26 | import org.onosproject.yangutils.datamodel.YangAugment; | 26 | import org.onosproject.yangutils.datamodel.YangAugment; |
27 | +import org.onosproject.yangutils.datamodel.YangChoice; | ||
27 | import org.onosproject.yangutils.datamodel.YangContainer; | 28 | import org.onosproject.yangutils.datamodel.YangContainer; |
28 | import org.onosproject.yangutils.datamodel.YangDerivedInfo; | 29 | import org.onosproject.yangutils.datamodel.YangDerivedInfo; |
29 | import org.onosproject.yangutils.datamodel.YangGrouping; | 30 | import org.onosproject.yangutils.datamodel.YangGrouping; |
... | @@ -49,6 +50,7 @@ import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE; | ... | @@ -49,6 +50,7 @@ import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE; |
49 | import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED; | 50 | import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED; |
50 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.DERIVED; | 51 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.DERIVED; |
51 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.STRING; | 52 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.STRING; |
53 | +import static org.onosproject.yangutils.linker.impl.YangLinkerUtils.updateFilePriority; | ||
52 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; | 54 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; |
53 | 55 | ||
54 | /** | 56 | /** |
... | @@ -84,6 +86,8 @@ public class InterFileLinkingTest { | ... | @@ -84,6 +86,8 @@ public class InterFileLinkingTest { |
84 | // Add references to import list. | 86 | // Add references to import list. |
85 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 87 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
86 | 88 | ||
89 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
90 | + | ||
87 | // Carry out inter-file linking. | 91 | // Carry out inter-file linking. |
88 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 92 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
89 | 93 | ||
... | @@ -154,6 +158,8 @@ public class InterFileLinkingTest { | ... | @@ -154,6 +158,8 @@ public class InterFileLinkingTest { |
154 | // Add references to import list. | 158 | // Add references to import list. |
155 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 159 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
156 | 160 | ||
161 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
162 | + | ||
157 | // Carry out inter-file linking. | 163 | // Carry out inter-file linking. |
158 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 164 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
159 | 165 | ||
... | @@ -227,6 +233,8 @@ public class InterFileLinkingTest { | ... | @@ -227,6 +233,8 @@ public class InterFileLinkingTest { |
227 | // Add reference to include list. | 233 | // Add reference to include list. |
228 | yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); | 234 | yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
229 | 235 | ||
236 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
237 | + | ||
230 | // Carry out inter-file linking. | 238 | // Carry out inter-file linking. |
231 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 239 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
232 | 240 | ||
... | @@ -300,6 +308,8 @@ public class InterFileLinkingTest { | ... | @@ -300,6 +308,8 @@ public class InterFileLinkingTest { |
300 | // Add reference to include list. | 308 | // Add reference to include list. |
301 | yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); | 309 | yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
302 | 310 | ||
311 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
312 | + | ||
303 | // Carry out inter-file linking. | 313 | // Carry out inter-file linking. |
304 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 314 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
305 | 315 | ||
... | @@ -370,6 +380,8 @@ public class InterFileLinkingTest { | ... | @@ -370,6 +380,8 @@ public class InterFileLinkingTest { |
370 | // Add references to import list. | 380 | // Add references to import list. |
371 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 381 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
372 | 382 | ||
383 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
384 | + | ||
373 | // Carry out inter-file linking. | 385 | // Carry out inter-file linking. |
374 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 386 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
375 | 387 | ||
... | @@ -440,6 +452,8 @@ public class InterFileLinkingTest { | ... | @@ -440,6 +452,8 @@ public class InterFileLinkingTest { |
440 | // Add references to import list. | 452 | // Add references to import list. |
441 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 453 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
442 | 454 | ||
455 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
456 | + | ||
443 | // Carry out inter-file linking. | 457 | // Carry out inter-file linking. |
444 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 458 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
445 | 459 | ||
... | @@ -511,6 +525,8 @@ public class InterFileLinkingTest { | ... | @@ -511,6 +525,8 @@ public class InterFileLinkingTest { |
511 | // Add references to import list. | 525 | // Add references to import list. |
512 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 526 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
513 | 527 | ||
528 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
529 | + | ||
514 | // Carry out inter-file linking. | 530 | // Carry out inter-file linking. |
515 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 531 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
516 | 532 | ||
... | @@ -579,6 +595,8 @@ public class InterFileLinkingTest { | ... | @@ -579,6 +595,8 @@ public class InterFileLinkingTest { |
579 | // Add references to import list. | 595 | // Add references to import list. |
580 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 596 | yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
581 | 597 | ||
598 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
599 | + | ||
582 | // Carry out inter-file linking. | 600 | // Carry out inter-file linking. |
583 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 601 | yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
584 | 602 | ||
... | @@ -837,4 +855,80 @@ public class InterFileLinkingTest { | ... | @@ -837,4 +855,80 @@ public class InterFileLinkingTest { |
837 | YangList list = ((YangList) uses.getNextSibling()); | 855 | YangList list = ((YangList) uses.getNextSibling()); |
838 | assertThat(list.getName(), is("connectivity-matrix")); | 856 | assertThat(list.getName(), is("connectivity-matrix")); |
839 | } | 857 | } |
858 | + | ||
859 | + /** | ||
860 | + * Checks contents of uses are copied as child of grouping. | ||
861 | + */ | ||
862 | + @Test | ||
863 | + public void interFileUsesInsideChildOfGrouping() | ||
864 | + throws IOException, ParserException, MojoExecutionException { | ||
865 | + | ||
866 | + String searchDir = "src/test/resources/interFileUsesInsideChildOfGrouping"; | ||
867 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); | ||
868 | + utilManager.parseYangFileInfoSet(); | ||
869 | + utilManager.resolveDependenciesUsingLinker(); | ||
870 | + | ||
871 | + YangNode selfNode = null; | ||
872 | + YangNode refNode1 = null; | ||
873 | + | ||
874 | + for (YangNode rootNode : utilManager.getYangNodeSet()) { | ||
875 | + if (rootNode.getName().equals("ietf-network")) { | ||
876 | + selfNode = rootNode; | ||
877 | + } else if (rootNode.getName().equals("ietf-te-topology")) { | ||
878 | + refNode1 = rootNode; | ||
879 | + } | ||
880 | + } | ||
881 | + | ||
882 | + // Check whether the data model tree returned is of type module. | ||
883 | + assertThat(selfNode instanceof YangModule, is(true)); | ||
884 | + assertThat(selfNode.getNodeType(), is(MODULE_NODE)); | ||
885 | + YangModule yangNode = (YangModule) selfNode; | ||
886 | + assertThat(yangNode.getName(), is("ietf-network")); | ||
887 | + | ||
888 | + YangModule refNode = (YangModule) refNode1; | ||
889 | + assertThat(refNode.getName(), is("ietf-te-topology")); | ||
890 | + | ||
891 | + YangAugment augment = ((YangAugment) refNode.getChild().getNextSibling(). | ||
892 | + getNextSibling().getNextSibling().getNextSibling().getNextSibling()); | ||
893 | + assertThat(augment.getName(), is("/nw:networks/nw:network/nt:link")); | ||
894 | + | ||
895 | + YangUses uses = ((YangUses) augment.getChild()); | ||
896 | + assertThat(uses.getResolvableStatus(), is(RESOLVED)); | ||
897 | + YangContainer container = ((YangContainer) uses.getNextSibling()); | ||
898 | + assertThat(container.getName(), is("te")); | ||
899 | + | ||
900 | + container = ((YangContainer) container.getChild()); | ||
901 | + assertThat(container.getName(), is("config")); | ||
902 | + | ||
903 | + uses = ((YangUses) container.getChild().getNextSibling()); | ||
904 | + assertThat(uses.getName(), is("te-link-config-attributes")); | ||
905 | + assertThat(uses.getResolvableStatus(), is(RESOLVED)); | ||
906 | + | ||
907 | + YangContainer container1 = ((YangContainer) uses.getNextSibling()); | ||
908 | + assertThat(container1.getName(), is("te-link-attributes")); | ||
909 | + | ||
910 | + container = ((YangContainer) container1.getChild()); | ||
911 | + assertThat(container.getName(), is("underlay")); | ||
912 | + | ||
913 | + uses = ((YangUses) container.getChild()); | ||
914 | + assertThat(uses.getName(), is("te-link-underlay-attributes")); | ||
915 | + assertThat(uses.getResolvableStatus(), is(RESOLVED)); | ||
916 | + | ||
917 | + container = ((YangContainer) uses.getNextSibling()); | ||
918 | + assertThat(container.getName(), is("underlay-primary-path")); | ||
919 | + | ||
920 | + YangList yangList = ((YangList) container.getChild()); | ||
921 | + assertThat(yangList.getName(), is("path-element")); | ||
922 | + | ||
923 | + uses = ((YangUses) yangList.getChild()); | ||
924 | + assertThat(uses.getName(), is("te-path-element")); | ||
925 | + assertThat(uses.getResolvableStatus(), is(RESOLVED)); | ||
926 | + | ||
927 | + uses = ((YangUses) uses.getNextSibling()); | ||
928 | + assertThat(uses.getName(), is("explicit-route-subobject")); | ||
929 | + assertThat(uses.getResolvableStatus(), is(RESOLVED)); | ||
930 | + | ||
931 | + YangChoice choice = ((YangChoice) uses.getNextSibling()); | ||
932 | + assertThat(choice.getName(), is("type")); | ||
933 | + } | ||
840 | } | 934 | } | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -486,7 +486,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -486,7 +486,7 @@ public class IntraFileUsesLinkingTest { |
486 | 486 | ||
487 | // Check whether uses is getting resolved. | 487 | // Check whether uses is getting resolved. |
488 | assertThat(uses.getResolvableStatus(), | 488 | assertThat(uses.getResolvableStatus(), |
489 | - is(ResolvableStatus.RESOLVED)); | 489 | + is(ResolvableStatus.INTRA_FILE_RESOLVED)); |
490 | 490 | ||
491 | // Check whether grouping is the child of module. | 491 | // Check whether grouping is the child of module. |
492 | assertThat((yangNode.getChild() instanceof YangGrouping), is(true)); | 492 | assertThat((yangNode.getChild() instanceof YangGrouping), is(true)); |
... | @@ -610,7 +610,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -610,7 +610,7 @@ public class IntraFileUsesLinkingTest { |
610 | 610 | ||
611 | // Check whether uses is getting resolved. | 611 | // Check whether uses is getting resolved. |
612 | assertThat(yangUses1.getResolvableStatus(), | 612 | assertThat(yangUses1.getResolvableStatus(), |
613 | - is(ResolvableStatus.RESOLVED)); | 613 | + is(ResolvableStatus.INTRA_FILE_RESOLVED)); |
614 | 614 | ||
615 | // Check whether grouping is the sibling of uses. | 615 | // Check whether grouping is the sibling of uses. |
616 | YangGrouping yangGrouping1 = (YangGrouping) yangUses1.getNextSibling(); | 616 | YangGrouping yangGrouping1 = (YangGrouping) yangUses1.getNextSibling(); | ... | ... |
... | @@ -18,7 +18,6 @@ package org.onosproject.yangutils.plugin.manager; | ... | @@ -18,7 +18,6 @@ package org.onosproject.yangutils.plugin.manager; |
18 | 18 | ||
19 | import java.io.IOException; | 19 | import java.io.IOException; |
20 | import java.util.List; | 20 | import java.util.List; |
21 | - | ||
22 | import org.apache.maven.plugin.MojoExecutionException; | 21 | import org.apache.maven.plugin.MojoExecutionException; |
23 | import org.junit.Test; | 22 | import org.junit.Test; |
24 | import org.onosproject.yangutils.datamodel.ResolvableType; | 23 | import org.onosproject.yangutils.datamodel.ResolvableType; |
... | @@ -32,6 +31,7 @@ import org.onosproject.yangutils.utils.io.impl.YangFileScanner; | ... | @@ -32,6 +31,7 @@ import org.onosproject.yangutils.utils.io.impl.YangFileScanner; |
32 | 31 | ||
33 | import static org.hamcrest.MatcherAssert.assertThat; | 32 | import static org.hamcrest.MatcherAssert.assertThat; |
34 | import static org.hamcrest.core.Is.is; | 33 | import static org.hamcrest.core.Is.is; |
34 | +import static org.onosproject.yangutils.linker.impl.YangLinkerUtils.updateFilePriority; | ||
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Unit test cases for x-path linker. | 37 | * Unit test cases for x-path linker. |
... | @@ -237,6 +237,7 @@ public class YangXpathLinkerTest { | ... | @@ -237,6 +237,7 @@ public class YangXpathLinkerTest { |
237 | utilManager.parseYangFileInfoSet(); | 237 | utilManager.parseYangFileInfoSet(); |
238 | utilManager.createYangNodeSet(); | 238 | utilManager.createYangNodeSet(); |
239 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); | 239 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
240 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
240 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 241 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
241 | 242 | ||
242 | YangNode targetNode = null; | 243 | YangNode targetNode = null; |
... | @@ -267,6 +268,7 @@ public class YangXpathLinkerTest { | ... | @@ -267,6 +268,7 @@ public class YangXpathLinkerTest { |
267 | utilManager.parseYangFileInfoSet(); | 268 | utilManager.parseYangFileInfoSet(); |
268 | utilManager.createYangNodeSet(); | 269 | utilManager.createYangNodeSet(); |
269 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); | 270 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
271 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
270 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 272 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
271 | 273 | ||
272 | YangNode targetNode = null; | 274 | YangNode targetNode = null; |
... | @@ -451,6 +453,7 @@ public class YangXpathLinkerTest { | ... | @@ -451,6 +453,7 @@ public class YangXpathLinkerTest { |
451 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 453 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
452 | linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); | 454 | linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); |
453 | linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); | 455 | linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
456 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
454 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 457 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
455 | 458 | ||
456 | YangNode targetNode = null; | 459 | YangNode targetNode = null; |
... | @@ -484,6 +487,7 @@ public class YangXpathLinkerTest { | ... | @@ -484,6 +487,7 @@ public class YangXpathLinkerTest { |
484 | linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); | 487 | linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); |
485 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 488 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
486 | linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); | 489 | linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
490 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
487 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 491 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
488 | YangNode targetNode = null; | 492 | YangNode targetNode = null; |
489 | String targetNodeName = null; | 493 | String targetNodeName = null; |
... | @@ -516,6 +520,7 @@ public class YangXpathLinkerTest { | ... | @@ -516,6 +520,7 @@ public class YangXpathLinkerTest { |
516 | linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); | 520 | linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); |
517 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 521 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
518 | linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); | 522 | linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
523 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
519 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 524 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
520 | YangNode targetNode = null; | 525 | YangNode targetNode = null; |
521 | String targetNodeName = null; | 526 | String targetNodeName = null; |
... | @@ -548,6 +553,7 @@ public class YangXpathLinkerTest { | ... | @@ -548,6 +553,7 @@ public class YangXpathLinkerTest { |
548 | linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); | 553 | linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); |
549 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 554 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
550 | linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); | 555 | linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
556 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
551 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 557 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
552 | 558 | ||
553 | YangNode targetNode = null; | 559 | YangNode targetNode = null; |
... | @@ -581,6 +587,7 @@ public class YangXpathLinkerTest { | ... | @@ -581,6 +587,7 @@ public class YangXpathLinkerTest { |
581 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); | 587 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
582 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 588 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
583 | linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); | 589 | linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
590 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
584 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 591 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
585 | 592 | ||
586 | YangNode targetNode = null; | 593 | YangNode targetNode = null; |
... | @@ -614,6 +621,7 @@ public class YangXpathLinkerTest { | ... | @@ -614,6 +621,7 @@ public class YangXpathLinkerTest { |
614 | linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); | 621 | linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); |
615 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | 622 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
616 | linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); | 623 | linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
624 | + updateFilePriority(utilManager.getYangNodeSet()); | ||
617 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | 625 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
618 | 626 | ||
619 | YangNode targetNode = null; | 627 | YangNode targetNode = null; | ... | ... |
1 | module Test { | 1 | module Test { |
2 | yang-version 1; | 2 | yang-version 1; |
3 | - namespace http://huawei.com; | 3 | + namespace "http://huawei.com"; |
4 | prefix Ant; | 4 | prefix Ant; |
5 | list interface-switching-capability { | 5 | list interface-switching-capability { |
6 | + when "../switching-capability = 'TDM'" { | ||
7 | + description "Valid only for TDM"; | ||
8 | + } | ||
6 | key "switching-capability"; | 9 | key "switching-capability"; |
7 | description | 10 | description |
8 | "List of Interface Switching Capabilities Descriptors (ISCD) | 11 | "List of Interface Switching Capabilities Descriptors (ISCD) | ... | ... |
1 | +module ietf-network-topology { | ||
2 | + yang-version 1; | ||
3 | + namespace "ietf-vidya-topology"; | ||
4 | + prefix lnk; | ||
5 | + | ||
6 | + import ietf-network { | ||
7 | + prefix nd; | ||
8 | + } | ||
9 | + | ||
10 | + revision 2015-12-08 { | ||
11 | + description | ||
12 | + "Initial revision. | ||
13 | + NOTE TO RFC EDITOR: Please replace the following reference | ||
14 | + to draft-ietf-i2rs-yang-network-topo-02 with | ||
15 | + RFC number when published (i.e. RFC xxxx)."; | ||
16 | + reference | ||
17 | + "draft-ietf-i2rs-yang-network-topo-02."; | ||
18 | + } | ||
19 | + | ||
20 | + augment "/nd:networks/nd:network" { | ||
21 | + list link { | ||
22 | + key "link-id"; | ||
23 | + container source { | ||
24 | + leaf source-node { | ||
25 | + type string; | ||
26 | + mandatory true; | ||
27 | + } | ||
28 | + leaf source-tp { | ||
29 | + type string; | ||
30 | + } | ||
31 | + } | ||
32 | + leaf link-id { | ||
33 | + type string; | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | +} |
utils/yangutils/plugin/src/test/resources/interFileUsesInsideChildOfGrouping/ietf-network.yang
0 → 100644
1 | +module ietf-network { | ||
2 | + yang-version 1; | ||
3 | + namespace "ietf-network"; | ||
4 | + prefix nd; | ||
5 | + | ||
6 | + revision 2015-12-08 { | ||
7 | + description | ||
8 | + "Initial revision. | ||
9 | + NOTE TO RFC EDITOR: Please replace the following reference | ||
10 | + to draft-ietf-i2rs-yang-network-topo-02 with | ||
11 | + RFC number when published (i.e. RFC xxxx)."; | ||
12 | + reference | ||
13 | + "draft-ietf-i2rs-yang-network-topo-02"; | ||
14 | + } | ||
15 | + | ||
16 | + container networks { | ||
17 | + list network { | ||
18 | + key "network-id"; | ||
19 | + leaf network-id { | ||
20 | + type string; | ||
21 | + } | ||
22 | + list node { | ||
23 | + key "node-id"; | ||
24 | + leaf node-id { | ||
25 | + type string; | ||
26 | + } | ||
27 | + } | ||
28 | + } | ||
29 | + } | ||
30 | +} |
utils/yangutils/plugin/src/test/resources/interFileUsesInsideChildOfGrouping/ietf-te-topology.yang
0 → 100644
1 | +module ietf-te-topology { | ||
2 | + yang-version 1; | ||
3 | + namespace "ietf-te-topology"; | ||
4 | + prefix "tet"; | ||
5 | + | ||
6 | + import ietf-te-types { | ||
7 | + prefix "te-types"; | ||
8 | + } | ||
9 | + | ||
10 | + import ietf-network { | ||
11 | + prefix "nw"; | ||
12 | + } | ||
13 | + | ||
14 | + import ietf-network-topology { | ||
15 | + prefix "nt"; | ||
16 | + } | ||
17 | + | ||
18 | + revision "2016-03-17" { | ||
19 | + description "Initial revision"; | ||
20 | + reference "TBD"; | ||
21 | + } | ||
22 | + | ||
23 | + grouping te-link-augment { | ||
24 | + container te { | ||
25 | + container config { | ||
26 | + uses te-link-config; | ||
27 | + } // config | ||
28 | + } // te | ||
29 | + } // te-link-augment | ||
30 | + | ||
31 | + grouping te-link-config { | ||
32 | + uses te-link-config-attributes; | ||
33 | + } // te-link-config | ||
34 | + | ||
35 | + grouping te-link-config-attributes { | ||
36 | + container te-link-attributes { | ||
37 | + container underlay { | ||
38 | + uses te-link-underlay-attributes; | ||
39 | + } // underlay | ||
40 | + } // te-link-attributes | ||
41 | + } // te-link-config-attributes | ||
42 | + | ||
43 | + grouping te-link-underlay-attributes { | ||
44 | + container underlay-primary-path { | ||
45 | + list path-element { | ||
46 | + key "path-element-id"; | ||
47 | + description | ||
48 | + "A list of path elements describing the service path."; | ||
49 | + leaf path-element-id { | ||
50 | + type uint32; | ||
51 | + description "To identify the element in a path."; | ||
52 | + } | ||
53 | + uses te-path-element; | ||
54 | + } | ||
55 | + } // underlay-primary-path | ||
56 | + } // te-link-underlay-attributes | ||
57 | + | ||
58 | + grouping te-path-element { | ||
59 | + uses te-types:explicit-route-subobject; | ||
60 | + } // te-path-element | ||
61 | + | ||
62 | + augment "/nw:networks/nw:network/nt:link" { | ||
63 | + uses te-link-augment; | ||
64 | + } | ||
65 | +} |
utils/yangutils/plugin/src/test/resources/interFileUsesInsideChildOfGrouping/ietf-te-types.yang
0 → 100644
1 | +module ietf-te-types { | ||
2 | + | ||
3 | + namespace "ietf-te-types"; | ||
4 | + prefix "te-types"; | ||
5 | + | ||
6 | + revision 2016-03-20 { | ||
7 | + description "Latest revision of TE generic types"; | ||
8 | + reference "RFC3209"; | ||
9 | + } | ||
10 | + grouping explicit-route-subobject { | ||
11 | + choice type { | ||
12 | + case ipv4-address { | ||
13 | + leaf v4-address { | ||
14 | + type string; | ||
15 | + } | ||
16 | + } | ||
17 | + } | ||
18 | + } | ||
19 | +} |
-
Please register or login to post a comment