Navigation.jrag 5.97 KB
Newer Older
René Schöne's avatar
René Schöne committed
1
2
3
import java.util.List;
import java.util.ArrayList;

4
aspect RagConnectNavigation {
5

6
  // --- program ---
7
8
  eq RagConnect.getChild().program() = getProgram();
  eq MRagConnect.getChild().program() = getRagConnect().program();
9

10
11
12
13
  // --- ragconnect ---
  inh RagConnect ASTNode.ragconnect();
  eq RagConnect.getChild().ragconnect() = this;
  eq MRagConnect.getChild().ragconnect() = getRagConnect();
14

15
16
17
18
19
20
21
22
  // --- containedConnectSpecification ---
  inh ConnectSpecification ASTNode.containedConnectSpecification();
  eq RagConnect.getChild().containedConnectSpecification() = null;
  eq MRagConnect.getChild().containedConnectSpecification() = null;
  eq Document.getChild().containedConnectSpecification() = null;
  eq Program.getChild().containedConnectSpecification() = null;
  eq ConnectSpecification.getChild().containedConnectSpecification() = this;

23
  // --- containedFile
24
  eq RagConnect.getChild().containedFile() = null;
René Schöne's avatar
René Schöne committed
25
  eq MRagConnect.getChild().containedFile() = null;
René Schöne's avatar
René Schöne committed
26

27
  // --- containedFileName ---
28
29
30
31
32
33
34
35
  eq ConnectSpecificationFile.containedFileName() = getFileName();
  refine Navigation eq ASTNode.containedFileName() {
    if (containedFile() == null) {
      return containedConnectSpecification().containedFileName();
    }
    return refined();
//    return containedFile().getFileName();
  }
René Schöne's avatar
René Schöne committed
36

René Schöne's avatar
René Schöne committed
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  //--- allEndpointDefinitionList ---
  syn List<EndpointDefinition> RagConnect.allEndpointDefinitionList() {
    List<EndpointDefinition> result = new ArrayList<>();
    for (var spec : getConnectSpecificationFileList()) {
      spec.getEndpointDefinitionList().forEach(result::add);
    }
    return result;
  }

  //--- allDependencyDefinitionList ---
  syn List<DependencyDefinition> RagConnect.allDependencyDefinitionList() {
    List<DependencyDefinition> result = new ArrayList<>();
    for (var spec : getConnectSpecificationFileList()) {
      spec.getDependencyDefinitionList().forEach(result::add);
    }
    return result;
  }

  //--- allMappingDefinitionList ---
  syn List<MappingDefinition> RagConnect.allMappingDefinitionList() {
    List<MappingDefinition> result = new ArrayList<>();
    for (var spec : getConnectSpecificationFileList()) {
      spec.getMappingDefinitionList().forEach(result::add);
    }
    return result;
  }

64
65
66
  // --- isTokenEndpointDefinition ---
  syn boolean EndpointDefinition.isTokenEndpointDefinition() = false;
  eq TokenEndpointDefinition.isTokenEndpointDefinition() = true;
René Schöne's avatar
René Schöne committed
67

68
69
70
  // --- asTokenEndpointDefinition ---
  syn TokenEndpointDefinition EndpointDefinition.asTokenEndpointDefinition() = null;
  eq TokenEndpointDefinition.asTokenEndpointDefinition() = this;
René Schöne's avatar
René Schöne committed
71

72
73
74
  // --- isTypeEndpointDefinition ---
  syn boolean EndpointDefinition.isTypeEndpointDefinition() = false;
  eq TypeEndpointDefinition.isTypeEndpointDefinition() = true;
René Schöne's avatar
René Schöne committed
75

76
77
78
  // --- asTypeEndpointDefinition ---
  syn TypeEndpointDefinition EndpointDefinition.asTypeEndpointDefinition() = null;
  eq TypeEndpointDefinition.asTypeEndpointDefinition() = this;
René Schöne's avatar
René Schöne committed
79

René Schöne's avatar
René Schöne committed
80
81
82
83
  // --- isReceiveTokenEndpointDefinition ---
  syn boolean EndpointDefinition.isReceiveTokenEndpointDefinition() = false;
  eq ReceiveTokenEndpointDefinition.isReceiveTokenEndpointDefinition() = true;

René Schöne's avatar
René Schöne committed
84
85
86
  // --- asReceiveTokenEndpointDefinition ---
  syn ReceiveTokenEndpointDefinition EndpointDefinition.asReceiveTokenEndpointDefinition() = null;
  eq ReceiveTokenEndpointDefinition.asReceiveTokenEndpointDefinition() = this;
René Schöne's avatar
René Schöne committed
87

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
  // --- isSendTokenEndpointDefinition ---
  syn boolean EndpointDefinition.isSendTokenEndpointDefinition() = false;
  eq SendTokenEndpointDefinition.isSendTokenEndpointDefinition() = true;

  // --- asSendTokenEndpointDefinition ---
  syn SendTokenEndpointDefinition EndpointDefinition.asSendTokenEndpointDefinition() = null;
  eq SendTokenEndpointDefinition.asSendTokenEndpointDefinition() = this;

  // --- isReceiveTypeEndpointDefinition ---
  syn boolean EndpointDefinition.isReceiveTypeEndpointDefinition() = false;
  eq ReceiveTypeEndpointDefinition.isReceiveTypeEndpointDefinition() = true;

  // --- asReceiveTypeEndpointDefinition ---
  syn ReceiveTypeEndpointDefinition EndpointDefinition.asReceiveTypeEndpointDefinition() = null;
  eq ReceiveTypeEndpointDefinition.asReceiveTypeEndpointDefinition() = this;

  // --- isSendTypeEndpointDefinition ---
  syn boolean EndpointDefinition.isSendTypeEndpointDefinition() = false;
  eq SendTypeEndpointDefinition.isSendTypeEndpointDefinition() = true;

  // --- asSendTypeEndpointDefinition ---
  syn SendTypeEndpointDefinition EndpointDefinition.asSendTypeEndpointDefinition() = null;
  eq SendTypeEndpointDefinition.asSendTypeEndpointDefinition() = this;

112
  // --- targetEndpointDefinition ---
René Schöne's avatar
René Schöne committed
113
  syn EndpointDefinition DependencyDefinition.targetEndpointDefinition() {
René Schöne's avatar
René Schöne committed
114
    // resolve definition in here, as we do not need resolveMethod in any other place (yet)
René Schöne's avatar
René Schöne committed
115
    for (EndpointDefinition endpointDefinition : ragconnect().allEndpointDefinitionList()) {
René Schöne's avatar
René Schöne committed
116
117
      if (endpointDefinition.isSendTokenEndpointDefinition() &&
          endpointDefinition.asSendTokenEndpointDefinition().getToken().equals(this.getTarget())) {
René Schöne's avatar
René Schöne committed
118
119
120
121
122
        return endpointDefinition;
      }
      if (endpointDefinition.isSendTypeEndpointDefinition() &&
          endpointDefinition.asSendTypeEndpointDefinition().getType().equals(this.getTarget())) {
        return endpointDefinition;
René Schöne's avatar
René Schöne committed
123
124
125
126
      }
    }
    return null;
  }
127

René Schöne's avatar
René Schöne committed
128
129
130
  // --- effectiveJavaTypeUse (should be in preprocessor) ---
  syn lazy JavaTypeUse TokenComponent.effectiveJavaTypeUse() = hasJavaTypeUse() ? getJavaTypeUse() : new SimpleJavaTypeUse("String");

131
132
133
  // --- isDefaultMappingDefinition ---
  syn boolean MappingDefinition.isDefaultMappingDefinition() = false;
  eq DefaultMappingDefinition.isDefaultMappingDefinition() = true;
René Schöne's avatar
René Schöne committed
134
135
136
137
138
139
140

  // --- mragconnect ---
  inh MRagConnect MHandler.mragconnect();
  eq MRagConnect.getHandler().mragconnect() = this;

  // --- rootTypeComponents ---
  syn JastAddList<MTypeComponent> MHandler.rootTypeComponents() = mragconnect().getRootTypeComponents();
René Schöne's avatar
René Schöne committed
141

142
143
  // --- isListComponent --- (defined in PP, but only on TypeComponent)
  syn boolean Component.isListComponent() = false;
144
}