Document.lineAt

Returns the text of a line starting at line 0.

Contains the line terminator, if it exists.

  1. string lineAt(Position position)
  2. string lineAt(Position position)
  3. string lineAt(uint line)
    struct Document
    const
    string
    lineAt
    (
    uint line
    )
  4. string lineAt(uint line)

Examples

Document d = Document("file:///home/projects/app.d");
d.setContent("im");

immutable d2 = cast(immutable)d.clone.setContent("import std.stdio;\nvoid main() {}");

static assert(is(typeof(d.lineAtScope(0)) == const(char)[]));
static assert(is(typeof(d2.lineAtScope(0)) == string));
static assert(is(typeof(d.lineAt(0)) == string));
static assert(is(typeof(d2.lineAt(0)) == string));

assert(d.lineAt(0) == "im");
assert(d2.lineAt(0) == "import std.stdio;\n");

assert(d.lineAtScope(0) == "im");
assert(d2.lineAtScope(0) == "import std.stdio;\n");

assert(d.lineAt(0).ptr !is d.rawText.ptr);
assert(d2.lineAt(0).ptr is d2.rawText.ptr);

Meta