Project: JDT
Bug 125504 [API] common supertype for ICompilationUnit and IClassFile
Reported: 2006-01-27 11:52:42 | Status: verified fixed

20060127 I know this is a classic, but this would help really a lot: introduce a common supertype for ICompilationUnit and IClassFile We currently often pass around IJavaElement, that can only be an IClassFile or ICompilationUnit. This can be swallowed for internal code, but is bad for API. Example: Input for the ASTParser when creating an AST Name suggestion: ITypeContainerUnit Alternative name suggestions: IJavaFile, ISourceUnit, ISourceRoot public interface ITypeContainerUnit extends IJavaElement, IParent, IOpenable, ISourceReference, ICodeAssist { IJavaElement getElementAt(int position) throws JavaModelException; IType findPrimaryType(); } -> ICompilationUnit extends ITypeContainerUnit -> IClassFile extends ITypeContainerUnit ASTParser.setSource(ITypeContainerUnit) CompilationUnit.getSourceUnit() : ITypeContainerUnit IMember.getTypeContainerUnit : ITypeContainerUnit

Files changed in fix:
org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/NodeFinder.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringExecutionStarter.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/base/JavaStatusContext.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/InlineMethodRefactoring.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ReplaceInvocationsRefactoring.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/SourceAnalyzer.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/SourceProvider.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/RefactoringASTParser.java org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/actions/InlineMethodAction.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/SelectionConverter.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/InlineAction.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/ReplaceInvocationsAction.java