Community
Participate
Working Groups
I am running into a problem with an ICompilationUnit from a Java file which has a comment section and several blank lines before the package declaration. The getElement method (which I expect to return an IJavaElement) is returning null. However (and this is the really strange part), if I remove the comments and blank lines to place the package delcaration on the first line of the Java file, then the getElement method of this ICompilationUnit properly returns the IJavaElement I expect. I found this problem in a view which implements ISelectionListener. The selectionChanged method checks to see if the current selection in the Navigator is an instanceof ICompilationUnit and if so gets the IJavaElement.
Could you provide the exact test case ?
Please reopen if you have a test case.