5
5
import org .eclipse .jdt .core .dom .*;
6
6
import org .moosetechnology .model .famix .famixjavaentities .ContainerEntity ;
7
7
import org .moosetechnology .model .famix .famixjavaentities .Method ;
8
- import org .moosetechnology .model .famix .famixjavaentities .ParameterType ;
9
- import org .moosetechnology .model .famix .famixjavaentities .ParametricClass ;
10
8
import org .moosetechnology .model .famix .famixjavaentities .Reference ;
11
9
import org .moosetechnology .model .famix .famixtraits .TNamedEntity ;
12
10
import org .moosetechnology .model .famix .famixtraits .TType ;
@@ -70,18 +68,19 @@ public void endVisit(TypeDeclaration node) {
70
68
public boolean visit (ClassInstanceCreation node ) {
71
69
possiblyAnonymousClassDeclaration (node );
72
70
73
- //if (node.getAnonymousClassDeclaration() == null) {
74
- Expression expr = node .getExpression ();
75
- if (expr != null ) {
76
- expr .accept (this );
77
- }
78
- for (Type typeArg : (List <Type >)node .typeArguments ()) {
79
- typeArg .accept (this );
80
- }
81
- for (Expression arg : (List <Expression >)node .arguments ()) {
82
- arg .accept (this );
83
- }
84
- //}
71
+ if (node .getExpression () != null ) {
72
+ node .getExpression ().accept (this );
73
+ }
74
+ for (Type typeArg : (List <Type >)node .typeArguments ()) {
75
+ typeArg .accept (this );
76
+ }
77
+ for (Expression arg : (List <Expression >)node .arguments ()) {
78
+ arg .accept (this );
79
+ }
80
+ if (node .getAnonymousClassDeclaration () != null ) {
81
+ node .getAnonymousClassDeclaration ().accept (this );
82
+ }
83
+
85
84
return false ;
86
85
}
87
86
@@ -225,7 +224,7 @@ public boolean visit(InstanceofExpression node) {
225
224
@ Override
226
225
public boolean visit (FieldDeclaration node ) {
227
226
hasInitBlock (node ); // to recover optional EntityDictionary.INIT_BLOCK_NAME method
228
- visitVariableDeclaration ((List <VariableDeclaration >)node .fragments (), node .getType ()); // to create the TypeRefs
227
+ visitVariablesDeclaration ((List <VariableDeclaration >)node .fragments (), node .getType ()); // to create the TypeRefs
229
228
return true ;
230
229
}
231
230
@@ -242,6 +241,21 @@ public void endVisit(EnumConstantDeclaration node) {
242
241
endVisitEnumConstantDeclaration (node );
243
242
}
244
243
244
+ /**
245
+ * SingleVariableDeclaration ::=
246
+ * { ExtendedModifier } Type {Annotation} [ ... ] Identifier { Dimension } [ = Expression ]
247
+ */
248
+ @ Override
249
+ public boolean visit (SingleVariableDeclaration node ) {
250
+ setVariableDeclaredType (
251
+ node ,
252
+ referedType (
253
+ node .getType (),
254
+ (org .moosetechnology .model .famix .famixjavaentities .Type ) context .topType (),
255
+ false ));
256
+ return true ;
257
+ }
258
+
245
259
/**
246
260
* VariableDeclarationExpression ::=
247
261
* { ExtendedModifier } Type VariableDeclarationFragment
@@ -250,7 +264,7 @@ public void endVisit(EnumConstantDeclaration node) {
250
264
@ SuppressWarnings ("unchecked" )
251
265
@ Override
252
266
public boolean visit (VariableDeclarationExpression node ) {
253
- return visitVariableDeclaration ((List <VariableDeclaration >)node .fragments (), node .getType ());
267
+ return visitVariablesDeclaration ((List <VariableDeclaration >)node .fragments (), node .getType ());
254
268
}
255
269
256
270
/**
@@ -261,7 +275,7 @@ public boolean visit(VariableDeclarationExpression node) {
261
275
@ SuppressWarnings ("unchecked" )
262
276
@ Override
263
277
public boolean visit (VariableDeclarationStatement node ) {
264
- return visitVariableDeclaration ((List <VariableDeclaration >)node .fragments (), node .getType ());
278
+ return visitVariablesDeclaration ((List <VariableDeclaration >)node .fragments (), node .getType ());
265
279
}
266
280
267
281
@ SuppressWarnings ("unchecked" )
@@ -308,25 +322,20 @@ public boolean visit(SimpleName node) {
308
322
* VariableDeclaration ::=
309
323
* SingleVariableDeclaration VariableDeclarationFragment
310
324
*/
311
- private < T extends TWithTypes & TNamedEntity > boolean visitVariableDeclaration ( List < VariableDeclaration > fragments , Type declType ) {
312
- setVariablesDeclaredType ( fragments , referedType ( declType , ( T ) context . topType (), false ));
325
+ @ SuppressWarnings ( "unchecked" )
326
+ private < T extends TWithTypes & TNamedEntity > boolean visitVariablesDeclaration ( List < VariableDeclaration > fragments , Type declType ) {
313
327
for (VariableDeclaration varDecl : fragments ) {
328
+ TType declaredType = referedType (declType , (T ) context .topType (), false );
329
+ setVariableDeclaredType ( varDecl , declaredType );
314
330
varDecl .accept (this );
315
331
}
316
332
return false ;
317
333
}
318
334
319
- // public boolean visit(SimpleName node) {
320
- // IBinding bnd = node.resolveBinding();
321
- // if ( (bnd != null) && (bnd instanceof ITypeBinding) ) {
322
- // referedType((ITypeBinding) bnd, (ContainerEntity) context.top(), !((ITypeBinding) bnd).isEnum());
323
-
324
- private void setVariablesDeclaredType (List <VariableDeclaration > vars , TType varTyp ) {
325
- for (VariableDeclaration var : vars ) {
326
- TTypedEntity fmx = (TTypedEntity ) dico .getEntityByKey (var .resolveBinding ());
327
- if (fmx != null ) {
328
- fmx .setDeclaredType (varTyp );
329
- }
335
+ protected void setVariableDeclaredType (VariableDeclaration var , TType varTyp ) {
336
+ TTypedEntity fmx = (TTypedEntity ) dico .getEntityByKey (var .resolveBinding ());
337
+ if (fmx != null ) {
338
+ fmx .setDeclaredType (varTyp );
330
339
}
331
340
}
332
341
0 commit comments