NameResolution.jrag 1.15 KB
Newer Older
1
2
aspect NameResolution {

3
  refine RefResolverStubs eq EndpointDefinition.resolveMappingByToken(String id, int position) {
4
    // return a MappingDefinition
5
    for (MappingDefinition mappingDefinition : ragconnect().getMappingDefinitionList()) {
6
7
8
9
10
11
12
      if (mappingDefinition.getID().equals(id)) {
        return mappingDefinition;
      }
    }
    System.err.println("Could not resolve MappingDefinition '" + id + "'.");
    return null;
  }
13

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  refine RefResolverStubs eq ASTNode.globallyResolveTypeComponentByToken(String id) {
    // return a TypeComponent. id is of the form 'parent_type_name + "." + child_type_name'
    int dotIndex = id.indexOf(".");
    String parentTypeName = id.substring(0, dotIndex);
    String childTypeName = id.substring(dotIndex + 1);
    TypeDecl type = program().resolveTypeDecl(parentTypeName);
    // iterate over components and find the matching typeComponent
    for (Component comp : type.getComponentList()) {
      if (comp.isTypeComponent() && comp.getName().equals(childTypeName)) {
        return comp.asTypeComponent();
      }
    }
    System.err.println("Could not resolve TypeComponent '" + id + "'.");
    return null;
  }

30
}