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 30724 Details for
Bug 118246
Definition of getJavaLikeExtensions() leads to programming errors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
118246.txt (text/plain), 7.39 KB, created by
Jerome Lanneluc
on 2005-11-28 14:36:31 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2005-11-28 14:36:31 EST
Size:
7.39 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: search/org/eclipse/jdt/internal/core/search/matching/ClasspathSourceDirectory.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ClasspathSourceDirectory.java,v >retrieving revision 1.15 >diff -u -r1.15 ClasspathSourceDirectory.java >--- search/org/eclipse/jdt/internal/core/search/matching/ClasspathSourceDirectory.java 26 May 2005 10:18:02 -0000 1.15 >+++ search/org/eclipse/jdt/internal/core/search/matching/ClasspathSourceDirectory.java 28 Nov 2005 19:36:38 -0000 >@@ -103,7 +103,7 @@ > String sourceFolderPath = this.sourceFolder.getFullPath().toString() + IPath.SEPARATOR; > char[][] javaLikeExtensions = Util.getJavaLikeExtensions(); > for (int i = 0, length = javaLikeExtensions.length; i < length; i++) { >- String extension = new String(javaLikeExtensions[i]); >+ String extension = '.' + new String(javaLikeExtensions[i]); > String sourceFileName = sourceFileWithoutExtension + extension; > if (!doesFileExist(sourceFileName, qualifiedPackageName)) continue; // most common case > >Index: model/org/eclipse/jdt/internal/core/ClassFile.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java,v >retrieving revision 1.113 >diff -u -r1.113 ClassFile.java >--- model/org/eclipse/jdt/internal/core/ClassFile.java 11 Nov 2005 15:18:21 -0000 1.113 >+++ model/org/eclipse/jdt/internal/core/ClassFile.java 28 Nov 2005 19:36:32 -0000 >@@ -562,6 +562,7 @@ > entryName.append('/'); > } > entryName.append(sourceFileWithoutExtension); >+ entryName.append('.'); > entryName.append(javaLikeExtensions[i]); > ZipEntry zipEntry = jar.getEntry(entryName.toString()); > if (zipEntry != null) { >Index: model/org/eclipse/jdt/core/JavaCore.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java,v >retrieving revision 1.505 >diff -u -r1.505 JavaCore.java >--- model/org/eclipse/jdt/core/JavaCore.java 17 Nov 2005 14:53:11 -0000 1.505 >+++ model/org/eclipse/jdt/core/JavaCore.java 28 Nov 2005 19:36:30 -0000 >@@ -2491,7 +2491,8 @@ > * Returns the list of known Java-like extensions. > * Java like extension are defined in the {@link org.eclipse.core.runtime.Platform#getContentTypeManager() > * content type manager} for the org.eclipse.jdt.core.javaSource content type. >- * Note that the ".java" extension is always defined as a Java like extension. >+ * Note that a Java-like extension doesn't include the leading dot ('.'). >+ * Also note that the "java" extension is always defined as a Java like extension. > * > * @return the list of known Java-like extensions. > * @since 3.2 >@@ -3811,6 +3812,7 @@ > /** > * Removes the file extension from the given file name, if it has a Java-like file > * extension. Otherwise the file name itself is returned. >+ * Note this removes the dot ('.') before the extension as well. > * > * @param fileName the name of a file > * @return the fileName without the Java-like extension >Index: model/org/eclipse/jdt/internal/core/util/Util.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java,v >retrieving revision 1.78 >diff -u -r1.78 Util.java >--- model/org/eclipse/jdt/internal/core/util/Util.java 23 Nov 2005 15:41:57 -0000 1.78 >+++ model/org/eclipse/jdt/internal/core/util/Util.java 28 Nov 2005 19:36:37 -0000 >@@ -591,9 +591,11 @@ > char[][] javaLikeExtensions = getJavaLikeExtensions(); > suffixes: for (int i = 0, length = javaLikeExtensions.length; i < length; i++) { > char[] suffix = javaLikeExtensions[i]; >- if (stringLength + suffix.length != fileNameLength) continue; >- for (int j = stringLength; j < fileNameLength; j++) { >- if (fileName.charAt(j) != suffix[j-stringLength]) >+ int extensionStart = stringLength+1; >+ if (extensionStart + suffix.length != fileNameLength) continue; >+ if (fileName.charAt(stringLength) != '.') continue; >+ for (int j = extensionStart; j < fileNameLength; j++) { >+ if (fileName.charAt(j) != suffix[j-extensionStart]) > continue suffixes; > } > return true; >@@ -741,7 +743,7 @@ > if (JAVA_LIKE_EXTENSIONS == null) { > // TODO (jerome) reenable once JDT UI supports other file extensions (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=71460) > if (!ENABLE_JAVA_LIKE_EXTENSIONS) >- JAVA_LIKE_EXTENSIONS = new char[][] {SuffixConstants.SUFFIX_java}; >+ JAVA_LIKE_EXTENSIONS = new char[][] {SuffixConstants.EXTENSION_java.toCharArray()}; > else { > IContentType javaContentType = Platform.getContentTypeManager().getContentType(JavaModelManager.JAVA_SOURCE_CONTENT_TYPE); > String[] fileExtensions = javaContentType == null ? null : javaContentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC); >@@ -749,15 +751,12 @@ > int length = fileExtensions == null ? 0 : fileExtensions.length; > char[][] extensions = new char[length][]; > SimpleWordSet knownExtensions = new SimpleWordSet(length); // used to ensure no duplicate extensions >- extensions[0] = SuffixConstants.SUFFIX_java; // ensure that ".java" is first >- knownExtensions.add(SuffixConstants.SUFFIX_java); >+ extensions[0] = SuffixConstants.EXTENSION_java.toCharArray(); // ensure that ".java" is first >+ knownExtensions.add(extensions[0]); > int index = 1; > for (int i = 0; i < length; i++) { > String fileExtension = fileExtensions[i]; >- int extensionLength = fileExtension.length() + 1; >- char[] extension = new char[extensionLength]; >- extension[0] = '.'; >- fileExtension.getChars(0, extensionLength-1, extension, 1); >+ char[] extension = fileExtension.toCharArray(); > if (!knownExtensions.includes(extension)) { > extensions[index++] = extension; > knownExtensions.add(extension); >@@ -1153,6 +1152,7 @@ > /* > * Returns the index of the Java like extension of the given file name > * or -1 if it doesn't end with a known Java like extension. >+ * Note this is the index of the '.' even if it is not considered part of the extension. > */ > public static int indexOfJavaLikeExtension(String fileName) { > int fileNameLength = fileName.length(); >@@ -1161,12 +1161,14 @@ > char[] extension = javaLikeExtensions[i]; > int extensionLength = extension.length; > int extensionStart = fileNameLength - extensionLength; >- if (extensionStart < 0) continue; >+ int dotIndex = extensionStart - 1; >+ if (dotIndex < 0) continue; >+ if (fileName.charAt(dotIndex) != '.') continue; > for (int j = 0; j < extensionLength; j++) { > if (fileName.charAt(extensionStart + j) != extension[j]) > continue extensions; > } >- return extensionStart; >+ return dotIndex; > } > return -1; > } >@@ -2327,7 +2329,8 @@ > char[] extension = javaLikeExtensions[i]; > int extensionLength = extension.length; > int extensionStart = fileNameLength - extensionLength; >- if (extensionStart < 0) continue; >+ if (extensionStart-1 < 0) continue; >+ if (fileName[extensionStart-1] != '.') continue; > for (int j = 0; j < extensionLength; j++) { > if (fileName[extensionStart + j] != extension[j]) > continue extensions;
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 118246
: 30724