Bug 423125 - fix regression with 'special' encoding character.
diff --git a/plugins/org.eclipse.koneki.ldt/src/org/eclipse/koneki/ldt/core/internal/ast/parser/LuaSourceParser.java b/plugins/org.eclipse.koneki.ldt/src/org/eclipse/koneki/ldt/core/internal/ast/parser/LuaSourceParser.java
index 83490ba..ae6cfbe 100644
--- a/plugins/org.eclipse.koneki.ldt/src/org/eclipse/koneki/ldt/core/internal/ast/parser/LuaSourceParser.java
+++ b/plugins/org.eclipse.koneki.ldt/src/org/eclipse/koneki/ldt/core/internal/ast/parser/LuaSourceParser.java
@@ -104,18 +104,16 @@
final String source = input.getSourceContents();
final String moduleName = LuaUtils.getModuleFullName(input);
LuaSourceRoot module = new LuaSourceRoot(source.length());
+ final OffsetFixer fixer = new OffsetFixer(source);
synchronized (LuaSourceParser.class) {
try {
-
// Build AST
module = astBuilder.buildAST(source, moduleName);
// Fix AST
- final OffsetFixer fixer = new OffsetFixer(source);
if (module != null)
module.traverse(new EncodingVisitor(fixer));
-
}
// CHECKSTYLE:OFF
catch (final Exception e) {
@@ -143,17 +141,17 @@
final int line = problem.getSourceLineNumber();
final Document document = new Document(source);
int endLineOffset = document.getLineOffset(line) + document.getLineLength(line) - 1;
+ problem.setSourceStart(fixer.getCharacterPosition(problem.getSourceStart()));
problem.setSourceEnd(endLineOffset);
} catch (BadLocationException e) {
Activator.logWarning("Unable to retrive error offset", e); //$NON-NLS-1$
}
+ } else {
+ // Handle encoding shifts
+ problem.setSourceStart(fixer.getCharacterPosition(problem.getSourceStart()));
+ problem.setSourceEnd(fixer.getCharacterPosition(problem.getSourceEnd()));
}
- // Handle encoding shifts
- final OffsetFixer fixer = new OffsetFixer(source);
- problem.setSourceStart(fixer.getCharacterPosition(problem.getSourceStart()));
- problem.setSourceEnd(fixer.getCharacterPosition(problem.getSourceEnd()));
-
// use AST in cache
if (input.getModelElement() != null) {
final LuaSourceRoot cached = (LuaSourceRoot) cache.get(input.getModelElement());