<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import org . eclipse . jdt . core . dom . CompilationUnit ; import org . eclipse . jface . text . BadLocationException ; import org . eclipse . jface . text . IDocument ; public abstract class LineInformation { public static LineInformation create ( final IDocument doc ) { return new LineInformation ( ) { public int getLineOfOffset ( int offset ) { try { return doc . getLineOfOffset ( offset ) ; } catch ( BadLocationException e ) { return - 1 ; } } public int getLineOffset ( int line ) { try { return doc . getLineOffset ( line ) ; } catch ( BadLocationException e ) { return - 1 ; } } } ; } public static LineInformation create ( final CompilationUnit astRoot ) { return new LineInformation ( ) { public int getLineOfOffset ( int offset ) { return astRoot . getLineNumber ( offset ) - 1 ; } public int getLineOffset ( int line ) { return astRoot . getPosition ( line + 1 , 0 ) ; } } ; } public abstract int getLineOfOffset ( int offset ) ; public abstract int getLineOffset ( int line ) ; } </s>