|
22 | 22 | import org.eclipse.tracecompass.ctf.core.event.metadata.DeclarationScope; |
23 | 23 | import org.eclipse.tracecompass.ctf.core.event.types.EnumDeclaration; |
24 | 24 | import org.eclipse.tracecompass.ctf.core.event.types.IDeclaration; |
| 25 | +import org.eclipse.tracecompass.ctf.core.event.types.IntegerDeclaration; |
25 | 26 | import org.eclipse.tracecompass.ctf.core.event.types.VariantDeclaration; |
26 | 27 | import org.eclipse.tracecompass.ctf.core.trace.CTFTrace; |
27 | 28 | import org.eclipse.tracecompass.ctf.parser.CTFParser; |
@@ -266,7 +267,7 @@ public VariantDeclaration parse(ICTFMetadataNode variant, ICommonTreeParserParam |
266 | 267 | if (variant instanceof JsonStructureFieldMemberMetadataNode) { |
267 | 268 | JsonObject fieldClass = ((JsonStructureFieldMemberMetadataNode) variant).getFieldClass().getAsJsonObject(); |
268 | 269 | if (fieldClass.has(SELECTOR_FIELD_LOCATION)) { |
269 | | - JsonArray location = fieldClass.get(SELECTOR_FIELD_LOCATION).getAsJsonArray(); |
| 270 | + JsonArray location = (fieldClass.get(SELECTOR_FIELD_LOCATION).getAsJsonObject().get(JsonMetadataStrings.PATH)).getAsJsonArray(); |
270 | 271 | variantTag = location.get(location.size() - 1).getAsString(); |
271 | 272 | hasTag = true; |
272 | 273 | } |
@@ -361,13 +362,17 @@ public VariantDeclaration parse(ICTFMetadataNode variant, ICommonTreeParserParam |
361 | 362 | if (decl == null) { |
362 | 363 | throw new ParseException("Variant tag not found: " + variantTag); //$NON-NLS-1$ |
363 | 364 | } |
364 | | - if (!(decl instanceof EnumDeclaration)) { |
365 | | - throw new ParseException("Variant tag must be an enum: " + variantTag); //$NON-NLS-1$ |
366 | | - } |
367 | | - EnumDeclaration tagDecl = (EnumDeclaration) decl; |
368 | | - if (!intersects(tagDecl.getLabels(), variantDeclaration.getFields().keySet())) { |
369 | | - throw new ParseException("Variant contains no values of the tag, impossible to use: " + variantName); //$NON-NLS-1$ |
| 365 | + if (decl instanceof EnumDeclaration) { |
| 366 | + EnumDeclaration tagDecl = (EnumDeclaration) decl; |
| 367 | + if (!intersects(tagDecl.getLabels(), variantDeclaration.getFields().keySet())) { |
| 368 | + throw new ParseException("Variant contains no values of the tag, impossible to use: " + variantName); //$NON-NLS-1$ |
| 369 | + } |
| 370 | + } else if (decl instanceof IntegerDeclaration) { |
| 371 | + // do nothing |
| 372 | + } else { |
| 373 | + throw new ParseException("Variant tag must be an enum: " + variantTag);//$NON-NLS-1$ |
370 | 374 | } |
| 375 | + |
371 | 376 | } |
372 | 377 |
|
373 | 378 | return variantDeclaration; |
|
0 commit comments