Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2010-01-04 10:43:41 +0000
committerMarkus Schorn2010-01-04 10:43:41 +0000
commite3de98ac9e0c8d25d76f82c31d00a7faefbcf509 (patch)
tree40d11d1b79402d80dc76f6ffd888c5ee616be73f
parentb825f03bf955636b14926ce864c851bb39e733c5 (diff)
downloadorg.eclipse.cdt-e3de98ac9e0c8d25d76f82c31d00a7faefbcf509.tar.gz
org.eclipse.cdt-e3de98ac9e0c8d25d76f82c31d00a7faefbcf509.tar.xz
org.eclipse.cdt-e3de98ac9e0c8d25d76f82c31d00a7faefbcf509.zip
Bug 298069: Wrong encoding for lines in search result.
-rw-r--r--core/org.eclipse.cdt.core/META-INF/MANIFEST.MF2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java16
2 files changed, 13 insertions, 5 deletions
diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
index 43db5a9493d..be67921f66d 100644
--- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
@@ -59,7 +59,7 @@ Export-Package: org.eclipse.cdt.core,
org.eclipse.cdt.internal.core.language;x-friends:="org.eclipse.cdt.ui",
org.eclipse.cdt.internal.core.model;x-friends:="org.eclipse.cdt.ui,org.eclipse.cdt.debug.core,org.eclipse.cdt.debug.ui",
org.eclipse.cdt.internal.core.model.ext;x-friends:="org.eclipse.cdt.ui",
- org.eclipse.cdt.internal.core.parser;x-internal:=true,
+ org.eclipse.cdt.internal.core.parser;x-friends:="org.eclipse.cdt.ui",
org.eclipse.cdt.internal.core.parser.problem;x-internal:=true,
org.eclipse.cdt.internal.core.parser.scanner;x-internal:=true,
org.eclipse.cdt.internal.core.parser.token;x-friends:="org.eclipse.cdt.ui",
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java
index c3e2a9bf98e..d9b4961b89b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java
@@ -16,6 +16,7 @@ import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
@@ -24,6 +25,8 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.internal.core.parser.InternalParserUtil;
+
/**
* Element representing a line with one ore more matches.
*/
@@ -141,12 +144,13 @@ public class LineSearchElement extends PDOMSearchElement {
Arrays.sort(matches, MATCHES_COMPARATOR);
LineSearchElement[] result = {};
try {
- String path = fileLocation.getURI().getPath();
// read the content of file
- CodeReader reader = new CodeReader(path);
+ CodeReader reader = InternalParserUtil.createCodeReader(fileLocation, null);
result = collectLineElements(reader.buffer, matches, fileLocation);
} catch (IOException e) {
CUIPlugin.log(e);
+ } catch (CoreException e) {
+ CUIPlugin.log(e);
}
return result;
}
@@ -210,7 +214,9 @@ public class LineSearchElement extends PDOMSearchElement {
int lineMatchesCount = nextMatch - lineFirstMatch;
Match[] lineMatches = new Match[lineMatchesCount];
System.arraycopy(matches, lineFirstMatch, lineMatches, 0, lineMatchesCount);
- String lineContent = new String(buffer, lineOffset, lineLength);
+ char[] lineChars= new char[lineLength];
+ System.arraycopy(buffer, lineOffset, lineChars, 0, lineLength);
+ String lineContent = new String(lineChars);
result.add(new LineSearchElement(fileLocation, lineMatches, lineNumber, lineContent,
lineOffset));
lineFirstMatch = -1;
@@ -248,7 +254,9 @@ public class LineSearchElement extends PDOMSearchElement {
int lineMatchesCount = nextMatch - lineFirstMatch;
Match[] lineMatches = new Match[lineMatchesCount];
System.arraycopy(matches, lineFirstMatch, lineMatches, 0, lineMatchesCount);
- String lineContent = new String(buffer, lineOffset, lineLength);
+ char[] lineChars= new char[lineLength];
+ System.arraycopy(buffer, lineOffset, lineChars, 0, lineLength);
+ String lineContent = new String(lineChars);
result.add(new LineSearchElement(fileLocation, lineMatches, lineNumber, lineContent, lineOffset));
}
return result.toArray(new LineSearchElement[result.size()]);

Back to the top