Foundry.TextDocument

g Foundry.Contextual Foundry.Contextual Foundry.TextDocument Foundry.TextDocument Foundry.Contextual->Foundry.TextDocument GObject.GInterface GObject.GInterface Json.Serializable Json.Serializable GObject.GInterface->Json.Serializable GObject.Object GObject.Object GObject.Object->Foundry.Contextual Json.Serializable->Foundry.Contextual

Subclasses:

None

Methods

Inherited:

Foundry.Contextual (4), GObject.Object (37), Json.Serializable (8)

Structs:

GObject.ObjectClass (5)

apply_edit (edit)

apply_edits (edits, n_edits)

diagnose ()

dup_buffer ()

dup_file ()

dup_icon ()

dup_title ()

dup_uri ()

find_addin (module_name)

find_symbol_at (line, line_offset)

list_addins ()

list_code_actions ()

list_symbols ()

load_settings ()

save (operation)

save_as (file, operation)

watch_diagnostics ()

when_changed ()

Virtual Methods

Inherited:

GObject.Object (7), Json.Serializable (5)

Properties

Inherited:

Foundry.Contextual (1)

Name

Type

Flags

Short Description

addins

Gio.ListModel

r

buffer

Foundry.TextBuffer

r/w/co

draft-id

str

r/w/co

file

Gio.File

r/w/co

icon

Gio.Icon

r

title

str

r

Signals

Inherited:

GObject.Object (1)

Name

Short Description

saved

This signal is emitted after the document has been saved to file.

Fields

Inherited:

GObject.Object (1)

Class Details

class Foundry.TextDocument(**kwargs)
Bases:

Foundry.Contextual

Abstract:

No

Structure:

Foundry.TextDocumentClass

Represents a text document in the development environment with editing capabilities.

Foundry.TextDocument manages the lifecycle of text documents including loading, saving, and modification tracking. It integrates with the text buffer system and provides document-level services such as diagnostics, settings, and extension management for enhanced editing functionality.

apply_edit(edit)
Parameters:

edit (Foundry.TextEdit) –

Return type:

bool

apply_edits(edits, n_edits)
Parameters:
Return type:

bool

diagnose()
Returns:

a [class`Dex`.Future] that resolves to a [iface`Gio`.ListModel] of [class`Foundry`.Diagnostic].

Return type:

Dex.Future

Queries [class`Foundry`.DiagnosticProvider] for diagnostics that are relevant to the document.

This does a single-shot run of diagnostics.

To monitor diagnostics for changes, use [method`Foundry`.TextDocument.watch_diagnostics] which will update as the document changes.

dup_buffer()
Returns:

a [iface`Foundry`.TextBuffer].

Return type:

Foundry.TextBuffer

Gets the underlying [iface`Foundry`.TextBuffer].

dup_file()
Returns:

a [iface`Gio`.File] or None

Return type:

Gio.File or None

Gets the underlying [iface`Gio`.File].

dup_icon()
Return type:

Gio.Icon or None

dup_title()
Returns:

a string or None

Return type:

str or None

Gets the title for the document.

dup_uri()
Returns:

a UTF-8 encoded string containing the URI

Return type:

str

Convenience function to get the URI of a file.

find_addin(module_name)
Parameters:

module_name (str) – the name of the plugin module

Return type:

Foundry.TextDocumentAddin or None

Gets a [class`Foundry`.TextDocumentAddin] using the name of the plugin. This is the value for “Module=” in the .plugin file.

find_symbol_at(line, line_offset)
Parameters:
  • line (int) – the line number (starting from 0)

  • line_offset (int) – the character offset (starting from 0)

Returns:

a [class`Dex`.Future] that resolves to a [class`Foundry`.Symbol] or rejects with error.

Return type:

Dex.Future

Queries [class`Foundry`.SymbolProvider] for a symbol at the specified position in the document.

New in version 1.1.

list_addins()
Return type:

Gio.ListModel or None

list_code_actions()
Returns:

a [class`Dex`.Future] that resolves to a [iface`Gio`.ListModel] of [class`Foundry`.CodeAction].

Return type:

Dex.Future

Queries [class`Foundry`.TextDocumentAddin] for actions that are relevant to the document based on the current diagnostics.

list_symbols()
Returns:

a [class`Dex`.Future] that resolves to a [iface`Gio`.ListModel] of [class`Foundry`.Symbol].

Return type:

Dex.Future

Queries [class`Foundry`.SymbolProvider] for symbols that are relevant to the document.

load_settings()
Returns:

a [class`Dex`.Future] that resolves to a [class`Foundry`.TextSettings] or rejects with error.

Return type:

Dex.Future

Loads the settings for the document.

Text editing applications should bind the properties of the resulting [class`Foundry`.TextSettings] to their document’s text editor.

save(operation)
Parameters:

operation (Foundry.Operation or None) – an operation to update with progress

Return type:

Dex.Future

save_as(file, operation)
Parameters:
  • file (Gio.File) – a [iface`Gio`.File] of where to save the document

  • operation (Foundry.Operation or None) – an operation to update with progress

Returns:

a [class`Dex`.Future] that resolves to any value or rejects with error.

Return type:

Dex.Future

watch_diagnostics()
Returns:

a [class`Foundry`.OnTypeDiagnostics]

Return type:

Foundry.OnTypeDiagnostics

Watches the document for changes and updates diagnostics in the resulting [class`Foundry`.OnTypeDiagnostics] which is a [iface`Gio`.ListModel].

when_changed()
Returns:

a [class`Dex`.Future]

Return type:

Dex.Future

This function will resolve a new [class`Dex`.Future] when the underlying [iface`Foundry`.TextBuffer] has changed.

Use this to invalidate external resources that rely on the contents of the document buffer.

This notification is done after a short delay to avoid spurious events during rapid modification to the buffer.

If the document is dispoed, this future will reject with error.

Signal Details

Foundry.TextDocument.signals.saved(text_document, file)
Signal Name:

saved

Flags:

RUN_LAST

Parameters:

This signal is emitted after the document has been saved to file.

New in version 1.1.

Property Details

Foundry.TextDocument.props.addins
Name:

addins

Type:

Gio.ListModel

Default Value:

None

Flags:

READABLE

Foundry.TextDocument.props.buffer
Name:

buffer

Type:

Foundry.TextBuffer

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Foundry.TextDocument.props.draft_id
Name:

draft-id

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Foundry.TextDocument.props.file
Name:

file

Type:

Gio.File

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Foundry.TextDocument.props.icon
Name:

icon

Type:

Gio.Icon

Default Value:

None

Flags:

READABLE

Foundry.TextDocument.props.title
Name:

title

Type:

str

Default Value:

None

Flags:

READABLE