mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[SourceKit/CursorInfo] Include line and column in result
Add line/column in addition to offset so clients need not map it themselves.
This commit is contained in:
@@ -2295,6 +2295,17 @@ ImmutableTextSnapshotRef SwiftEditorDocument::getLatestSnapshot() const {
|
||||
return Impl.EditableBuffer->getSnapshot();
|
||||
}
|
||||
|
||||
std::pair<unsigned, unsigned>
|
||||
SwiftEditorDocument::getLineAndColumnInBuffer(unsigned Offset) {
|
||||
llvm::sys::ScopedLock L(Impl.AccessMtx);
|
||||
|
||||
auto SyntaxInfo = Impl.getSyntaxInfo();
|
||||
auto &SM = SyntaxInfo->getSourceManager();
|
||||
|
||||
auto Loc = SM.getLocForOffset(SyntaxInfo->getBufferID(), Offset);
|
||||
return SM.getLineAndColumnInBuffer(Loc);
|
||||
}
|
||||
|
||||
void SwiftEditorDocument::reportDocumentStructure(SourceFile &SrcFile,
|
||||
EditorConsumer &Consumer) {
|
||||
ide::SyntaxModelContext ModelContext(SrcFile);
|
||||
|
||||
Reference in New Issue
Block a user