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 181323 Details for
Bug 303511
Allow to specify encoding for source attachments
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
bug_303511.txt (text/plain), 4.93 KB, created by
Jay Arthanareeswaran
on 2010-10-20 14:09:55 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Jay Arthanareeswaran
Created:
2010-10-20 14:09:55 EDT
Size:
4.93 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.150 >diff -u -r1.150 SourceMapper.java >--- model/org/eclipse/jdt/internal/core/SourceMapper.java 28 Jul 2010 16:17:01 -0000 1.150 >+++ model/org/eclipse/jdt/internal/core/SourceMapper.java 20 Oct 2010 18:07:36 -0000 >@@ -27,6 +27,7 @@ > import org.eclipse.core.resources.IContainer; > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IFolder; >+import org.eclipse.core.resources.IProject; > import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.CoreException; >@@ -868,12 +869,13 @@ > > char[] source = null; > >+ IProject project = pkgFrag.getPackageFragmentRoot().getJavaProject().getProject(); > JavaModelManager javaModelManager = JavaModelManager.getJavaModelManager(); > try { > javaModelManager.cacheZipFiles(this); // Cache any zip files we open during this operation > > if (this.rootPath != null) { >- source = getSourceForRootPath(this.rootPath, name); >+ source = getSourceForRootPath(this.rootPath, name, project); > } > > if (source == null) { >@@ -882,7 +884,7 @@ > loop: for (Iterator iterator = this.rootPaths.iterator(); iterator.hasNext(); ) { > String currentRootPath = (String) iterator.next(); > if (!currentRootPath.equals(this.rootPath)) { >- source = getSourceForRootPath(currentRootPath, name); >+ source = getSourceForRootPath(currentRootPath, name, project); > if (source != null) { > // remember right root path > this.rootPath = currentRootPath; >@@ -901,7 +903,7 @@ > return source; > } > >- private char[] getSourceForRootPath(String currentRootPath, String name) { >+ private char[] getSourceForRootPath(String currentRootPath, String name, IProject project) { > String newFullName; > if (!currentRootPath.equals(IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH)) { > if (currentRootPath.endsWith("/")) { //$NON-NLS-1$ >@@ -912,22 +914,47 @@ > } else { > newFullName = name; > } >- return this.findSource(newFullName); >+ return this.findSource(newFullName, project); > } > >- public char[] findSource(String fullName) { >+ public char[] findSource(String fullName, IProject project) { > char[] source = null; > Object target = JavaModel.getTarget(this.sourcePath, true); >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=303511 >+ // Use the character encoding set by the user than the default one >+ String charSet = null; > if (target instanceof IContainer) { >+ // For external folders, get use the project's encoding >+ if (project != null && ExternalFoldersManager.isInternalPathForExternalFolder(((IContainer)target).getFullPath())) { >+ try { >+ charSet = project.getDefaultCharset(); >+ } catch (CoreException e) { >+ // Proceed with null encoding >+ } >+ } > IResource res = ((IContainer)target).findMember(fullName); > if (res instanceof IFile) { > try { >- source = org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsCharArray((IFile)res); >+ if (charSet == null) >+ source = org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsCharArray((IFile)res); >+ else >+ source = org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsCharArray((IFile)res, charSet); > } catch (JavaModelException e) { > // ignore > } > } > } else { >+ try { >+ // If the archive (IResource) is available from the workspace, use it's encoding >+ // Else take it from the project >+ if (target instanceof IFile) >+ charSet = ((IFile)target).getCharset(); >+ else if (project != null) >+ charSet = project.getDefaultCharset(); >+ } catch (CoreException e) { >+ // Ignore >+ } >+ > // try to get the entry > ZipEntry entry = null; > ZipFile zip = null; >@@ -937,7 +964,7 @@ > entry = zip.getEntry(fullName); > if (entry != null) { > // now read the source code >- source = readSource(entry, zip); >+ source = readSource(entry, zip, charSet); > } > } catch (CoreException e) { > return null; >@@ -948,6 +975,9 @@ > return source; > } > >+ public char[] findSource(String fullName) { >+ return findSource(fullName, null); >+ } > > > /** >@@ -1275,11 +1305,11 @@ > this.typeDepth = -1; > } > } >- private char[] readSource(ZipEntry entry, ZipFile zip) { >+ private char[] readSource(ZipEntry entry, ZipFile zip, String charSet) { > try { > byte[] bytes = Util.getZipEntryByteContent(entry, zip); > if (bytes != null) { >- return Util.bytesToChar(bytes, this.encoding); >+ return Util.bytesToChar(bytes, charSet == null ? this.encoding : charSet); > } > } catch (IOException e) { > // ignore
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 303511
:
181323
|
181364
|
181365
|
181399
|
181484
|
181601