Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 66397 Details for
Bug 185950
[performance] opening class file without source attachement is too slow
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
patch_185950.txt (text/plain), 6.57 KB, created by
Olivier Thomann
on 2007-05-08 23:12:12 EDT
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2007-05-08 23:12:12 EDT
Size:
6.57 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/SourceMapper.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java,v >retrieving revision 1.128 >diff -u -r1.128 SourceMapper.java >--- model/org/eclipse/jdt/internal/core/SourceMapper.java 6 Nov 2006 14:13:45 -0000 1.128 >+++ model/org/eclipse/jdt/internal/core/SourceMapper.java 9 May 2007 03:05:40 -0000 >@@ -649,7 +649,7 @@ > if (this.anonymousCounter == this.anonymousClassName) { > this.types[typeDepth] = this.getType(this.binaryType.getElementName()); > } else { >- this.types[typeDepth] = this.getType(new String(typeInfo.name)); >+ this.types[typeDepth] = this.getType(new String(typeInfo.name)); > } > } else { > this.types[typeDepth] = this.getType(new String(typeInfo.name)); >@@ -881,7 +881,7 @@ > } > return findSource(type, simpleSourceFileName); > } >- >+ > /** > * Locates and returns source code for the given (binary) type, in this > * SourceMapper's ZIP file, or returns <code>null</code> if source >@@ -900,45 +900,134 @@ > char[] source = null; > > if (this.rootPath != null) { >- source = getSourceForRootPath(this.rootPath, name); >+ String newFullName; >+ if (!this.rootPath.equals(IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH)) { >+ if (this.rootPath.endsWith("/")) { //$NON-NLS-1$ >+ newFullName = this.rootPath + name; >+ } else { >+ newFullName = this.rootPath + '/' + name; >+ } >+ } else { >+ newFullName = name; >+ } >+ source = this.findSource(newFullName); > } > > if (source == null) { > computeAllRootPaths(type); > if (this.rootPaths != null) { >- loop: for (Iterator iterator = this.rootPaths.iterator(); iterator.hasNext(); ) { >- String currentRootPath = (String) iterator.next(); >- if (!currentRootPath.equals(this.rootPath)) { >- source = getSourceForRootPath(currentRootPath, name); >- if (source != null) { >- // remember right root path >- this.rootPath = currentRootPath; >- break loop; >- } >- } >- } >+ source = getSourceForRootPaths(name); > } > } > if (VERBOSE) { > System.out.println("spent " + (System.currentTimeMillis() - time) + "ms for " + type.getElementName()); //$NON-NLS-1$ //$NON-NLS-2$ > } >+ if (source == null) { >+ this.rootPath = null; >+ } > return source; > } > >- private char[] getSourceForRootPath(String currentRootPath, String name) { >- String newFullName; >- if (!currentRootPath.equals(IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH)) { >- if (currentRootPath.endsWith("/")) { //$NON-NLS-1$ >- newFullName = currentRootPath + name; >- } else { >- newFullName = currentRootPath + '/' + name; >+ private char[] getSourceForRootPaths(String name) { >+ char[] source = null; >+ if (Util.isArchiveFileName(this.sourcePath.lastSegment())) { >+ // try to get the entry >+ ZipEntry entry = null; >+ ZipFile zip = null; >+ JavaModelManager manager = JavaModelManager.getJavaModelManager(); >+ try { >+ zip = manager.getZipFile(this.sourcePath); >+ for (Iterator iterator = this.rootPaths.iterator(); iterator.hasNext(); ) { >+ String currentRootPath = (String) iterator.next(); >+ String newFullName = null; >+ if (!currentRootPath.equals(IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH)) { >+ if (currentRootPath.endsWith("/")) { //$NON-NLS-1$ >+ newFullName = currentRootPath + name; >+ } else { >+ newFullName = currentRootPath + '/' + name; >+ } >+ } else { >+ newFullName = name; >+ } >+ entry = zip.getEntry(newFullName); >+ if (entry != null) { >+ // now read the source code >+ source = readSource(entry, zip); >+ if (source != null) { >+ this.rootPath = currentRootPath; >+ return source; >+ } >+ } >+ } >+ } catch (CoreException e) { >+ return null; >+ } finally { >+ manager.closeZipFile(zip); // handle null case > } > } else { >- newFullName = name; >+ Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), this.sourcePath, true); >+ if (target instanceof IResource) { >+ if (target instanceof IContainer) { >+ for (Iterator iterator = this.rootPaths.iterator(); iterator.hasNext(); ) { >+ String currentRootPath = (String) iterator.next(); >+ String newFullName = null; >+ if (!currentRootPath.equals(IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH)) { >+ if (currentRootPath.endsWith("/")) { //$NON-NLS-1$ >+ newFullName = currentRootPath + name; >+ } else { >+ newFullName = currentRootPath + '/' + name; >+ } >+ } else { >+ newFullName = name; >+ } >+ IResource res = ((IContainer)target).findMember(newFullName); >+ if (res instanceof IFile) { >+ try { >+ source = org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsCharArray((IFile)res); >+ if (source != null) { >+ this.rootPath = currentRootPath; >+ return source; >+ } >+ } catch (JavaModelException e) { >+ // ignore >+ } >+ } >+ } >+ } >+ } else if (target instanceof File) { >+ File file = (File)target; >+ if (file.isDirectory()) { >+ for (Iterator iterator = this.rootPaths.iterator(); iterator.hasNext(); ) { >+ String currentRootPath = (String) iterator.next(); >+ String newFullName = null; >+ if (!currentRootPath.equals(IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH)) { >+ if (currentRootPath.endsWith("/")) { //$NON-NLS-1$ >+ newFullName = currentRootPath + name; >+ } else { >+ newFullName = currentRootPath + '/' + name; >+ } >+ } else { >+ newFullName = name; >+ } >+ File sourceFile = new File(file, newFullName); >+ if (sourceFile.isFile()) { >+ try { >+ source = Util.getFileCharContent(sourceFile, this.encoding); >+ if (source != null) { >+ this.rootPath = currentRootPath; >+ return source; >+ } >+ } catch (IOException e) { >+ // ignore >+ } >+ } >+ } >+ } >+ } > } >- return this.findSource(newFullName); >+ return null; > } >- >+ > public char[] findSource(String fullName) { > char[] source = null; > if (Util.isArchiveFileName(this.sourcePath.lastSegment())) { >@@ -988,8 +1077,6 @@ > return source; > } > >- >- > /** > * Returns the SourceRange for the name of the given element, or > * {-1, -1} if no source range is known for the name of the element.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 185950
:
66295
| 66397 |
66497