Community
Participate
Working Groups
problem: class SomeSemanticHighlightingCalculator implements ISemanticHighlightingCalculator { override provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor) { if(resource == null) return; val Iterator<EObject> iter = EcoreUtil2::getAllContents(resource, true) while(iter.hasNext) { highlight(iter.next, acceptor) } } } I have to explicitly type iter as 'Iterator<EObject>' otherwise the type 'Iterator<?>' is inferred.
This works as expected. The signature of EcoreUtil.getAllContents looks like this: <T> TreeIterator<T> getAllContents(Resource, boolean) thus you'd have to use Iterator<EObject> iter = EcoreUtil.<EObject>getAllContents(..) in Java where Xtend allows to use val iter = EcoreUtil::<EObject>getAllContents(..) or val Iterator<EObject> iter = EcoreUtil::getAllContents(..)
(In reply to comment #1) > you'd have to use > > Iterator<EObject> iter = EcoreUtil.<EObject>getAllContents(..) > > in Java That was too fast. Java has inference for the type argument, too. E.g. the following is valid in Java and in Xtend: Iterator<EObject> iter = EcoreUtil.getAllContents(..)