Hi Nicolas,
I have now released a new version of the FamixGenerator
(
http://www.sharpmetrics.net/index.php/famix-generator), which handles generic Methods
similar to VerveineJ.
Cheers
Thomas
-----------
Thomas Haug
Principal Consultant
MATHEMA Software GmbH
Anschrift:
Henkestraße 91
91052 E r l a n g e n
Telefon:
09131/8903- 0
Telefax:
09131/8903-55
E-Mail:
thomas.haug(a)mathema.de
Internet:
http://www.mathema.de
Handelsregister:
HR B 8965, Fürth/Bayern
Geschäftsführer:
Michael Wiedeking
Andreas Hanke
----- Ursprüngliche Mail -----
Hi Nicolas,
thank you for your answer and explanation.
I would have hoped that generic methods would be expressed similar to
generic types/classes.
But "binding" the generic Types like TValue
to the method seem to
make sense and it is consistent to the way generic classes are
handled in InFamix, e.g:
(FAMIX.ParameterizableClass (id: 154)
(sourceAnchor (ref: 784753))
(isStub true)
(parentPackage (ref: 5))
(name 'HashMap')
)
(FAMIX.ParameterType (id: 155)
(name 'K')
(container (ref: 154))
)
But how do you handle concrete usages of the generic
method like
ClassWithGenericMethod.useTheGeneric("hi generic method"); // type
inference
ClassWithGenericMethod.useTheGeneric(1.5d); // type inference
InFamix generates the following:
(FAMIX.Invocation
(sender (ref: 19))
(candidates (ref: 25))
(signature
'useTheGeneric(_unknown_path::TValue)')
)
(FAMIX.Invocation
(sender (ref: 19))
(candidates (ref: 25))
(signature
'useTheGeneric(_unknown_path::TValue)')
)
based on the source code. It does not
"detect" the concrete types. If
you would parse compiled code this might change...
Thanks once again for your feedback!
Thomas
sorry I did
not spot this email earlier.
Here's
what I get with VerveineJ:
(FAMIX.Method
(id: 58)
(name 'getTheGeneric')
(cyclomaticComplexity 1)
(declaredType (ref: 28))
(hasClassScope true)
(modifiers 'public')
(numberOfStatements 1)
(parentType (ref: 17))
(signature 'getTheGeneric(String)')
(sourceAnchor (ref: 57)))
(FAMIX.Type (id: 28)
(name 'TResult')
(container (ref: 58))
(isStub true))
so TResult is
simply a type defined by the method getTheGeneric.
Same goes for TValue
There is nothing special marking them as
"VariableTypes"
(FAMIX.Method
(id: 34)
(name 'useTheGeneric')
(cyclomaticComplexity 1)
(declaredType (ref: 50))
(hasClassScope true)
(modifiers 'public')
(numberOfStatements 2)
(parentType (ref: 17))
(signature 'useTheGeneric(TValue)')
(sourceAnchor (ref: 37)))
(FAMIX.Parameter (id: 36)
(name 'value')
(declaredType (ref: 14))
(parentBehaviouralEntity (ref: 34)))
(FAMIX.Type (id: 14)
(name 'TValue')
(container (ref: 34))
(isStub true))
PS: I see that
verveineJ treat them as stubs.
I am not sure whether this is right. It should
probably not ...
On 18/09/2014
20:52, Thomas Haug wrote:
I hope my question is not off topic:
I am
currently trying to figure out how to describe generic
methods
in Famix 3.0 (for the .NET FamixGenerator)
For
example in Java you can write the following code.
public
class ClassWithGenericMethod {
public
static <TResult> TResult getTheGeneric(String resource) {
public static <TValue> void
useTheGeneric(TValue value) {
System.out.println("value '"+value +"' type:
"+value.getClass());
If I run InFamix on this code I get an Famix file
containing
something like:
(parentType (ref: 30)) (declaredType (ref: 33)) (name
'getTheGeneric')
(signature 'getTheGeneric(_unknown_path::String)')
But id 33 is not existing.
(signature 'useTheGeneric(_unknown_path::TValue)')
(FAMIX.Parameter (id: 35)
(parentBehaviouralEntity (ref: 25)) (declaredType (ref: 36))
(position 0)
But id 36 is not existing.
I am wondering if there should be something like
ParameterizableMethod (like ParameterizableClass?
Can anybody give me some clues?
_______________________________________________
_______________________________________________
Moose-dev mailing list
Moose-dev(a)iam.unibe.ch