Skip to content

Commit

Permalink
initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
arjanadriaanse committed Apr 22, 2020
0 parents commit a21d8e2
Show file tree
Hide file tree
Showing 10 changed files with 1,310 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/backup/
/lib/
*.lps
217 changes: 217 additions & 0 deletions basic.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
unit basic;

{$mode objfpc}{$H+}

interface

uses
Classes;

type

{ TGenericCollection }

generic TGenericCollection<T> = class(TCollection)
constructor Create;
end;

{ TDocumentUri }

TDocumentUri = string;

{ TPosition }

TPosition = class(TPersistent)
private
fLine: Integer;
fCharacter: Integer;
published
// Line position in a document (zero-based).
property line: Integer read fLine write fLine;
// Character offset on a line in a document (zero-based). Assuming
// that the line is represented as a string, the `character` value
// represents the gap between the `character` and `character + 1`.
//
// If the character value is greater than the line length it
// defaults back to the line length.
property character: Integer read fCharacter write fCharacter;
end;

{ TRange }

TRange = class(TPersistent)
private
fStart: TPosition;
fEnd: TPosition;
published
// The range's start position.
property start: TPosition read fStart write fStart;
// The range's end position.
property end_: TPosition read fEnd write fEnd;
end;

{ TLocation }

TLocation = class(TPersistent)
private
fUri: TDocumentUri;
fRange: TRange;
published
property uri: TDocumentUri read fUri write fUri;
property range: TRange read fRange write fRange;
end;

{ TLocationLink }

TLocationLink = class(TPersistent)
private
fOriginSelectionRange: TRange;
fTargetUri: TDocumentUri;
fTargetRange: TRange;
fTargetSelectionRange: TRange;
published
// Span of the origin of this link.
//
// Used as the underlined span for mouse interaction. Defaults to
// the word range at the mouse position.
property originSelectionRange: TRange read fOriginSelectionRange write fOriginSelectionRange;
// The target resource identifier of this link.
property targetUri: TDocumentUri read fTargetUri write fTargetUri;
// The full target range of this link. If the target for example
// is a symbol then target range is the range enclosing this
// symbol not including leading/trailing whitespace but everything
// else like comments. This information is typically used to
// highlight the range in the editor.
property targetRange: TRange read fTargetRange write fTargetRange;
// The range that should be selected and revealed when this link
// is being followed, e.g the name of a function. Must be
// contained by the the `targetRange`. See also
// `DocumentSymbol#range`
property targetSelectionRange: TRange read fTargetSelectionRange write fTargetSelectionRange;
end;

{ TTextDocumentIdentifier }

TTextDocumentIdentifier = class(TPersistent)
private
fUri: TDocumentUri;
published
property uri: TDocumentUri read fUri write fUri;
end;

{ TVersionedTextDocumentIdentifier }

TVersionedTextDocumentIdentifier = class(TTextDocumentIdentifier)
private
fVersion: string;
published
// The version number of this document. If a versioned text
// document identifier is sent from the server to the client and
// the file is not open in the editor (the server has not received
// an open notification before) the server can send `null` to
// indicate that the version is known and the content on disk is
// the master (as speced with document content ownership).
//
// The version number of a document will increase after each
// change, including undo/redo. The number doesn't need to be
// consecutive.
property version: string read fVersion write fVersion;
end;

{ TTextEdit }

TTextEdit = class(TCollectionItem)
private
fRange: TRange;
fNewText: string;
published
// The range of the text document to be manipulated. To insert
// text into a document create a range where start === end.
property range: TRange read fRange write fRange;
// The string to be inserted. For delete operations use an empty
// string.
property newText: string read fNewText write fNewText;
end;

TTextEdits = specialize TGenericCollection<TTextEdit>;

{ TTextDocumentEdit }

TTextDocumentEdit = class(TPersistent)
private
fTextDocument: TVersionedTextDocumentIdentifier;
fEdits: TTextEdits;
published
// The text document to change.
property textDocument: TVersionedTextDocumentIdentifier read fTextDocument write fTextDocument;
// The edits to be applied.
property edits: TTextEdits read fEdits write fEdits;
end;

{ TTextDocumentItem }

TTextDocumentItem = class(TPersistent)
private
fUri: TDocumentUri;
fLanguageId: string;
fVersion: Integer;
fText: string;
published
// The text document's URI.
property uri: TDocumentUri read fUri write fUri;
// The text document's language identifier.
property languageId: string read fLanguageId write fLanguageId;
// The version number of this document (it will increase after
// each change, including undo/redo).
property version: Integer read fVersion write fVersion;
// The content of the opened text document.
property text: string read fText write fText;
end;

{ TTextDocumentPositionParams }

TTextDocumentPositionParams = class(TPersistent)
private
fTextDocument: TTextDocumentIdentifier;
fPosition: TPosition;
published
// The text document.
property textDocument: TTextDocumentIdentifier read fTextDocument write fTextDocument;
// The position inside the text document.
property position: TPosition read fPosition write fPosition;
end;

{ TMarkupKind }

// Describes the content type that a client supports in various
// result literals like `Hover`, `ParameterInfo` or
// `CompletionItem`.
//
// Please note that `MarkupKinds` must not start with a `$`. This
// kinds are reserved for internal usage.
TMarkupKind = string;

{ TMarkupContent }

TMarkupContent = class(TPersistent)
private
fKind: TMarkupKind;
fValue: string;
published
// The type of the Markup
property kind: TMarkupKind read fKind write fKind;
// The content itself
property value: string read fValue write fValue;
end;

implementation

{ TGenericCollection }

constructor TGenericCollection.Create;
begin
inherited Create(T);
end;

end.

63 changes: 63 additions & 0 deletions capabilities.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
unit capabilities;

{$mode objfpc}{$H+}

interface

uses
Classes, options;

type

{ TWorkspaceClientCapabilities }

TWorkspaceClientCapabilities = class(TPersistent)
private
fApplyEdit: Boolean;
published
property applyEdit: Boolean read fApplyEdit write fApplyEdit;
end;

{ TTextDocumentClientCapabilities }

TTextDocumentClientCapabilities = class(TPersistent)
private
published
end;

{ TClientCapabilities }

TClientCapabilities = class(TPersistent)
private
fWorkspace: TWorkspaceClientCapabilities;
fTextDocument: TTextDocumentClientCapabilities;
published
property workspace: TWorkspaceClientCapabilities read fWorkspace write fWorkspace;
property textDocument: TTextDocumentClientCapabilities read fTextDocument write fTextDocument;
end;

{ TServerCapabilities }

TServerCapabilities = class(TPersistent)
private
fTextDocumentSync: TTextDocumentSyncOptions;
fCompletionProvider: TCompletionOptions;
public
constructor Create;
published
property textDocumentSync: TTextDocumentSyncOptions read fTextDocumentSync write fTextDocumentSync;
property completionProvider: TCompletionOptions read fCompletionProvider write fCompletionProvider;
end;

implementation

{ TServerCapabilities }

constructor TServerCapabilities.Create;
begin
textDocumentSync := TTextDocumentSyncOptions.Create;
completionProvider := TCompletionOptions.Create;
end;

end.

Loading

0 comments on commit a21d8e2

Please sign in to comment.