129 case Some(file) => |
129 case Some(file) => |
130 Text.Info(snapshot.convert(info_range), Hyperlink(file, line, 0)) :: links |
130 Text.Info(snapshot.convert(info_range), Hyperlink(file, line, 0)) :: links |
131 case None => links |
131 case None => links |
132 } |
132 } |
133 |
133 |
134 case Position.Id_Offset(def_id, def_offset) if !snapshot.is_outdated => |
134 case Position.Id_Offset(id, offset) if !snapshot.is_outdated => |
135 snapshot.state.find_command(snapshot.version, def_id) match { |
135 snapshot.state.find_command(snapshot.version, id) match { |
136 case Some((def_node, def_cmd)) => |
136 case Some((node, command)) => |
137 val file = new JFile(def_cmd.node_name.node) |
137 val file = new JFile(command.node_name.node) |
138 |
138 |
139 // FIXME move!? |
|
140 val sources = |
139 val sources = |
141 def_node.commands.iterator.takeWhile(_ != def_cmd).map(_.source) ++ |
140 node.commands.iterator.takeWhile(_ != command).map(_.source) ++ |
142 Iterator.single(def_cmd.source(Text.Range(0, def_offset))) |
141 Iterator.single(command.source(Text.Range(0, command.decode(offset)))) |
143 var line = 1 |
142 val (line, column) = ((1, 1) /: sources)(Symbol.advance_line_column) |
144 var column = 1 |
143 |
145 for (source <- sources) { |
|
146 val newlines = (0 /: source.iterator) { // FIXME Symbol.iterator!? |
|
147 case (n, c) => if (c == '\n') n + 1 else n } |
|
148 if (newlines > 0) { |
|
149 line += newlines |
|
150 column = source.lastIndexOf('\n') + 2 |
|
151 } |
|
152 } |
|
153 Text.Info(snapshot.convert(info_range), Hyperlink(file, line, column)) :: links |
144 Text.Info(snapshot.convert(info_range), Hyperlink(file, line, column)) :: links |
154 |
145 |
155 case None => links |
146 case None => links |
156 } |
147 } |
157 |
148 |