Write line numbers for bridge methods (line for class header)

This commit is contained in:
Natalia Ukhorskaya
2014-10-31 15:57:13 +03:00
parent 0047655ed3
commit 4eb93c06b1
6 changed files with 69 additions and 12 deletions
@@ -16,6 +16,9 @@
package org.jetbrains.jet.backend.common;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.codegen.bridges.BridgesPackage;
@@ -202,4 +205,11 @@ public class CodegenUtil {
return DescriptorUtils.ENUM_VALUES.equals(functionDescriptor.getName())
&& methodTypeParameters.isEmpty();
}
@Nullable
public static Integer getLineNumberForElement(@NotNull PsiElement statement, boolean markEndOffset) {
Document document = statement.getContainingFile().getViewProvider().getDocument();
TextRange textRange = statement.getTextRange();
return document != null ? document.getLineNumber(markEndOffset ? textRange.getEndOffset() : textRange.getStartOffset()) + 1 : null;
}
}