diff --git a/src/org/jetbrains/java/decompiler/main/ClassWriter.java b/src/org/jetbrains/java/decompiler/main/ClassWriter.java index afa2473..f84e05c 100644 --- a/src/org/jetbrains/java/decompiler/main/ClassWriter.java +++ b/src/org/jetbrains/java/decompiler/main/ClassWriter.java @@ -835,9 +835,6 @@ public class ClassWriter { // We do not have line information for method start, lets have it here for now StructLineNumberTableAttribute lineNumberTable = (StructLineNumberTableAttribute)mt.getAttributes().getWithKey(StructGeneralAttribute.ATTRIBUTE_LINE_NUMBER_TABLE); - if (lineNumberTable != null && DecompilerContext.getOption(IFernflowerPreferences.USE_DEBUG_LINE_NUMBERS)) { - buffer.setCurrentLine(lineNumberTable.getFirstLine() - 1); - } buffer.append('{').appendLineSeparator(); tracer.incrementCurrentSourceLine(); @@ -851,10 +848,6 @@ public class ClassWriter { hideMethod = (clinit || dinit || hideConstructor(wrapper, init, throwsExceptions, paramCount)) && code.length() == 0; - if (!hideMethod && lineNumberTable != null && DecompilerContext.getOption(IFernflowerPreferences.USE_DEBUG_LINE_NUMBERS)) { - mapLines(code, lineNumberTable, tracer, startLine); - } - buffer.append(code); } catch (Throwable ex) { @@ -888,38 +881,6 @@ public class ClassWriter { return !hideMethod; } - private static void mapLines(TextBuffer code, StructLineNumberTableAttribute table, BytecodeMappingTracer tracer, int startLine) { - // build line start offsets map - HashMap> lineStartOffsets = new HashMap>(); - for (Map.Entry entry : tracer.getMapping().entrySet()) { - Integer lineNumber = entry.getValue() - startLine; - Set curr = lineStartOffsets.get(lineNumber); - if (curr == null) { - curr = new TreeSet(); // requires natural sorting! - } - curr.add(entry.getKey()); - lineStartOffsets.put(lineNumber, curr); - } - String lineSeparator = DecompilerContext.getNewLineSeparator(); - StringBuilder text = code.getOriginalText(); - int pos = text.indexOf(lineSeparator); - int lineNumber = 0; - while (pos != -1) { - Set startOffsets = lineStartOffsets.get(lineNumber); - if (startOffsets != null) { - for (Integer offset : startOffsets) { - int number = table.findLineNumber(offset); - if (number >= 0) { - code.setLineMapping(number, pos); - break; - } - } - } - pos = text.indexOf(lineSeparator, pos+1); - lineNumber++; - } - } - private static boolean hideConstructor(ClassWrapper wrapper, boolean init, boolean throwsExceptions, int paramCount) { if (!init || throwsExceptions || paramCount > 0 || !DecompilerContext.getOption(IFernflowerPreferences.HIDE_DEFAULT_CONSTRUCTOR)) { return false; diff --git a/src/org/jetbrains/java/decompiler/main/DecompilerContext.java b/src/org/jetbrains/java/decompiler/main/DecompilerContext.java index 15c6e40..d105959 100644 --- a/src/org/jetbrains/java/decompiler/main/DecompilerContext.java +++ b/src/org/jetbrains/java/decompiler/main/DecompilerContext.java @@ -156,6 +156,6 @@ public class DecompilerContext { public static String getNewLineSeparator() { return getOption(IFernflowerPreferences.NEW_LINE_SEPARATOR) ? - IFernflowerPreferences.LINE_SEPARATOR_LIN : IFernflowerPreferences.LINE_SEPARATOR_WIN; + IFernflowerPreferences.LINE_SEPARATOR_UNX : IFernflowerPreferences.LINE_SEPARATOR_WIN; } } diff --git a/src/org/jetbrains/java/decompiler/main/TextBuffer.java b/src/org/jetbrains/java/decompiler/main/TextBuffer.java index 95afc50..952b26f 100644 --- a/src/org/jetbrains/java/decompiler/main/TextBuffer.java +++ b/src/org/jetbrains/java/decompiler/main/TextBuffer.java @@ -42,17 +42,6 @@ public class TextBuffer { myStringBuilder = new StringBuilder(text); } - public void setCurrentLine(int line) { - setLineMapping(line, myStringBuilder.length()+1); - } - - public void setLineMapping(int line, int offset) { - if (line >= 0) { - checkMapCreated(); - myLineToOffsetMapping.put(line, offset); - } - } - public TextBuffer append(String str) { myStringBuilder.append(str); return this; @@ -301,15 +290,12 @@ public class TextBuffer { return res; } - public StringBuilder getOriginalText() { - return myStringBuilder; - } - private Map> myLineMapping = null; // new to original + public void dumpOriginalLineNumbers(int[] lineMapping) { if (lineMapping.length > 0) { myLineMapping = new HashMap>(); - for (int i = 0; i < lineMapping.length; i+=2) { + for (int i = 0; i < lineMapping.length; i += 2) { int key = lineMapping[i + 1]; Set existing = myLineMapping.get(key); if (existing == null) { diff --git a/src/org/jetbrains/java/decompiler/main/extern/IFernflowerPreferences.java b/src/org/jetbrains/java/decompiler/main/extern/IFernflowerPreferences.java index 31871c5..cd6333b 100644 --- a/src/org/jetbrains/java/decompiler/main/extern/IFernflowerPreferences.java +++ b/src/org/jetbrains/java/decompiler/main/extern/IFernflowerPreferences.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,6 @@ public interface IFernflowerPreferences { String IDEA_NOT_NULL_ANNOTATION = "inn"; String LAMBDA_TO_ANONYMOUS_CLASS = "lac"; String BYTECODE_SOURCE_MAPPING = "bsm"; - String USE_DEBUG_LINE_NUMBERS = "udl"; String LOG_LEVEL = "log"; String MAX_PROCESSING_METHOD = "mpm"; @@ -58,7 +57,7 @@ public interface IFernflowerPreferences { String UNIT_TEST_MODE = "__unit_test_mode__"; String LINE_SEPARATOR_WIN = "\r\n"; - String LINE_SEPARATOR_LIN = "\n"; + String LINE_SEPARATOR_UNX = "\n"; Map DEFAULTS = Collections.unmodifiableMap(new HashMap() {{ put(REMOVE_BRIDGE, "1"); @@ -83,7 +82,6 @@ public interface IFernflowerPreferences { put(IDEA_NOT_NULL_ANNOTATION, "1"); put(LAMBDA_TO_ANONYMOUS_CLASS, "0"); put(BYTECODE_SOURCE_MAPPING, "0"); - put(USE_DEBUG_LINE_NUMBERS, "0"); put(LOG_LEVEL, IFernflowerLogger.Severity.INFO.name()); put(MAX_PROCESSING_METHOD, "0"); diff --git a/test/org/jetbrains/java/decompiler/LineNumbersMatchTest.java b/test/org/jetbrains/java/decompiler/LineNumbersMatchTest.java deleted file mode 100644 index 758aa5f..0000000 --- a/test/org/jetbrains/java/decompiler/LineNumbersMatchTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.java.decompiler; - -import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences; -import org.junit.Test; - -import java.util.HashMap; -import java.util.Map; - -public class LineNumbersMatchTest extends SingleClassesTestBase { - @Override - protected Map getDecompilerOptions() { - return new HashMap() {{ - put(IFernflowerPreferences.USE_DEBUG_LINE_NUMBERS, "1"); - }}; - } - - @Test public void testMatch1() { doTest("pkg/TestLineNumbersMatch"); } -} diff --git a/testData/classes/pkg/TestLineNumbersMatch.class b/testData/classes/pkg/TestLineNumbersMatch.class deleted file mode 100644 index 0a96fbb..0000000 Binary files a/testData/classes/pkg/TestLineNumbersMatch.class and /dev/null differ diff --git a/testData/results/TestLineNumbersMatch.dec b/testData/results/TestLineNumbersMatch.dec deleted file mode 100644 index 9ab7626..0000000 --- a/testData/results/TestLineNumbersMatch.dec +++ /dev/null @@ -1,22 +0,0 @@ -package pkg; - -class TestLineNumbersMatch { - - - - void m1(boolean b) { - if(b) { - System.out.println("a"); - } else { - System.out.println("b"); - } } - - void m2() { - (new Runnable() { - - public void run() { - System.out.println("run with me"); - } - }).run(); - } -} diff --git a/testData/src/pkg/TestLineNumbersMatch.java b/testData/src/pkg/TestLineNumbersMatch.java deleted file mode 100644 index d9d486a..0000000 --- a/testData/src/pkg/TestLineNumbersMatch.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Weird comment here. - */ -package pkg; - -class TestLineNumbersMatch { - void m1(boolean b) { - if (b) - System.out.println("a"); - else - System.out.println("b"); - } - - void m2() { - new Runnable() { - @Override - public void run() { - System.out.println("run with me"); - } - }.run(); - } -} \ No newline at end of file