Community
Participate
Working Groups
I have no clue why this happens, but sometimes, the foreach template just doesn’t work. I type fore, then Ctrl+Space, and confirm foreach, and nothing happens: fore is still there, the template has not been filled in. Funny thing is, whenever this happens, the other for templates do work: removing the e, so typing for then Ctrl+space gives four options for for loops, of which the first three work, but foreach doesn’t. I have tried with comments before or after it, with or without compile errors, with or without whitespace surrounding, it all makes no sense. A minimal example for the problem is this: import test_test.TransitionFunction; public class Test { private Object productFunction(TransitionFunction function2) { fore } } where the fore does not work. I tried transforming this into a usable test function (where you wouldn’t need TransitionFunction), however, the problem ceases to exist then. Even creating a class TransitionFunction in the default package, or in another package, or in a package containing an underscore, or even removing the import statement, made it work again. I am stumped. I will attach the TransitionFunction class, so maybe someone could point to an error there, but that seems highly improbable to me.
Created attachment 40471 [details] A test class showing the problem This class file shows the problem. After much trimming, I found the core of the problem: an iterator over Map.Entry: If you remove 'Map.' from the Iterable statement, it works fine.
Changed the subject, as that really seems to be the problem.
The problem seems to be that the supertype hierarchy for the package visible type does not contain the implemented interface. Moving to jdt-core for comments. Given the example code in the attached Java source file, and a super type hierarchy on 'Function' will contain Iterable in its allInterfaces list, but not return Iterable as a super type of Function, nor Function as a sub type of Iterable. I get the following exception in the log: Caused by: org.eclipse.jface.text.Assert$AssertionFailedException: Assertion failed: at org.eclipse.jface.text.Assert.isTrue(Assert.java:188) at org.eclipse.jface.text.Assert.isTrue(Assert.java:173) at org.eclipse.jdt.internal.corext.template.java.CompilationUnitCompletion$TypeParameterResolver.computeTypeParameterBinding(CompilationUnitCompletion.java:454) at org.eclipse.jdt.internal.corext.template.java.CompilationUnitCompletion$TypeParameterResolver.computeBinding(CompilationUnitCompletion.java:421) at org.eclipse.jdt.internal.corext.template.java.CompilationUnitCompletion$TypeParameterResolver.computeBinding(CompilationUnitCompletion.java:399) at org.eclipse.jdt.internal.corext.template.java.CompilationUnitCompletion$LocalVariable.getMemberTypeSignatures(CompilationUnitCompletion.java:246) at org.eclipse.jdt.internal.corext.template.java.CompilationUnitCompletion$LocalVariable.getMemberTypeNames(CompilationUnitCompletion.java:272) at org.eclipse.jdt.internal.corext.template.java.JavaContextType$AbstractIterableType.resolve(JavaContextType.java:129) at org.eclipse.jface.text.templates.TemplateContextType.resolve(TemplateContextType.java:272) at org.eclipse.jface.text.templates.TemplateContextType.resolve(TemplateContextType.java:239) at org.eclipse.jdt.internal.corext.template.java.JavaContext.evaluate(JavaContext.java:164) at org.eclipse.jdt.internal.ui.text.template.contentassist.TemplateProposal.getAdditionalProposalInfo(TemplateProposal.java:391) at org.eclipse.jface.text.contentassist.AdditionalInfoController$6.run(AdditionalInfoController.java:162) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123) ... 20 more
Changed HierarchyResolver#findSuperInterfaces(...) to check for '<' before checking for '.' Added regression test TypeHierarchyTests#testGeneric10(). Released for 3.3M5 in HEAD.
Verified for 3.3M5 using I20070205-0009.