Community
Participate
Working Groups
Build 20020129 We need a way to create a working copy ignoring existing files. This is necessary to analyze the impact when we are moving files to a different perspective. Jerome sugessted on the mailing the following: CompilationUnit.getWorkingCopy() will throw a JavaModelException if the compilation unit does not exist. I guess what you would want is that it returns an empty working copy. This sounds like you need a new API: ICompilationUnit.getWorkingCopy(boolean ignoreExistence) The new API could be used as follows: IPackageFragment pkg = ...; String compilationUnitName = ...; IWorkingCopy workingCopy = pkg.getCompilationUnit(compilationUnitName).getWorkingCopy(true); Unless you commit it, the corresponding file would not be created. This functionality is needed to convert refactorings to the new DOM/AST
Agreed
Dirk, do you still need this API?
I assume no response means that is not that critical. Deferring.
Reopening
Clearing resolution
Related to bug 21854, but I don't see the actual need for a separate API. When reading the contents, if no file pre-exists, then an empty buffer should be used for free.
*** Bug 21854 has been marked as a duplicate of this bug. ***
We need a new API because the existing APIs are not handle based (they declare throwing a JavaModelException if the original compilation unit does not exist)
I take what I said above back. The spec says that the reason a JavaModelException can be thrown include the fact that the compilation unit does not exist, but it doesn't enforce this exception to be thrown. So changing the current implementation to return an empty working copy if the cu doesn't exist is the right thing to do.
Changed implementation to accept the creation of a working copy on a non- existing cu. Also changed commit on working copies to allow to commit to a non- existing cu (this creates the cu in this case).
Verified.