Skip to content

Commit

Permalink
Code review
Browse files Browse the repository at this point in the history
  • Loading branch information
loicknuchel committed Nov 25, 2024
1 parent b32660b commit 03f7f1d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= doc_prose do %>
<p class="lead">
Azimutt explorer has several ways to import your database schema. The suggested one is the <a href="#from-database">database connection</a>
as it's more reliable and offer more features (see below) but you have many other options if you prefer.
as it's more reliable and offers more features (see below) but you have many other options if you prefer.
<img src={Routes.static_path(@conn, "/images/doc/new-project.png")} alt="New Azimutt project">
</p>

Expand Down
7 changes: 6 additions & 1 deletion extensions/vscode-aml/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
"directory": "extensions/vscode-aml"
},
"browser": "./dist/web/extension.js",
"activationEvents": [],
"activationEvents": [
"onLanguage:aml",
"onCommand:aml.new",
"onCommand:aml.fromJson",
"onCommand:aml.fromSQL"
],
"contributes": {
"languages": [
{
Expand Down
10 changes: 5 additions & 5 deletions extensions/vscode-aml/resources/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
{"name": "id", "type": "int", "extra": {"autoIncrement": null}},
{"name": "title", "type": "varchar"},
{"name": "content", "type": "text", "doc": "allow markdown"},
{"name": "status", "type": "post_status", "default": "draft"},
{"name": "status", "type": "cms.post_status", "default": "draft"},
{"name": "author", "type": "int"},
{"name": "tags", "type": "varchar[]"},
{"name": "created_at", "type": "timestamp", "default": "`now()`"},
{"name": "created_by", "type": "unknown"},
{"name": "created_by", "type": "int"},
{"name": "updated_at", "type": "timestamp", "default": "`now()`"},
{"name": "updated_by", "type": "unknown"}
{"name": "updated_by", "type": "int"}
],
"pk": {"attrs": [["id"]]},
"checks": [
Expand All @@ -50,9 +50,9 @@
{"name": "post_id", "type": "int"},
{"name": "content", "type": "text"},
{"name": "created_at", "type": "timestamp", "default": "`now()`"},
{"name": "created_by", "type": "unknown"},
{"name": "created_by", "type": "int"},
{"name": "updated_at", "type": "timestamp", "default": "`now()`"},
{"name": "updated_by", "type": "unknown"}
{"name": "updated_by", "type": "int"}
],
"pk": {"attrs": [["id"]]}
},
Expand Down
10 changes: 5 additions & 5 deletions extensions/vscode-aml/resources/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ CREATE TABLE cms.posts (
id int PRIMARY KEY,
title varchar NOT NULL CHECK (length(title) > 10),
content text NOT NULL,
status post_status NOT NULL DEFAULT 'draft',
status cms.post_status NOT NULL DEFAULT 'draft',
author int NOT NULL REFERENCES users(id),
tags varchar[] NOT NULL,
created_at timestamp NOT NULL DEFAULT now(),
created_by unknown NOT NULL REFERENCES users(id),
created_by int NOT NULL REFERENCES users(id),
updated_at timestamp NOT NULL DEFAULT now(),
updated_by unknown NOT NULL REFERENCES users(id)
updated_by int NOT NULL REFERENCES users(id)
);
COMMENT ON COLUMN cms.posts.content IS 'allow markdown';

Expand All @@ -36,9 +36,9 @@ CREATE TABLE cms.comments (
post_id int NOT NULL REFERENCES cms.posts(id),
content text NOT NULL,
created_at timestamp NOT NULL DEFAULT now(),
created_by unknown NOT NULL REFERENCES users(id),
created_by int NOT NULL REFERENCES users(id),
updated_at timestamp NOT NULL DEFAULT now(),
updated_by unknown NOT NULL REFERENCES users(id)
updated_by int NOT NULL REFERENCES users(id)
);

-- Tracking tables
Expand Down
6 changes: 3 additions & 3 deletions extensions/vscode-aml/src/web/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ function openInAzimuttUrl(aml: string): string {
class AmlDocumentSymbolProvider implements DocumentSymbolProvider {
provideDocumentSymbols(document: TextDocument, token: CancellationToken): ProviderResult<SymbolInformation[] | DocumentSymbol[]> {
const symbols: DocumentSymbol[] = []
const regex = /(^|\n)(type\s+)?((?:[a-zA-Z_][a-zA-Z0-9_]*\.)?[a-zA-Z_][a-zA-Z0-9_]*)/g
const regex = /(^|\n)(type\s+)?((?:[a-zA-Z_][a-zA-Z0-9_]*\.)?[a-zA-Z_][a-zA-Z0-9_]*)/g // TODO: use `.split('\n')` for "better" parsing
let match: RegExpExecArray | null = null
while (match = regex.exec(document.getText())) {
const [all, lr, keyword, name] = match || []
const [all = '', lr = '', keyword = '', name = ''] = match || []
if (name === 'rel') { continue }
const range = new Range(
document.positionAt(match.index + lr.length + (keyword || '').length),
document.positionAt(match.index + lr.length + keyword.length),
document.positionAt(match.index + all.length)
)
// see https://microsoft.github.io/monaco-editor/typedoc/interfaces/languages.DocumentSymbol.html
Expand Down

0 comments on commit 03f7f1d

Please sign in to comment.