From 8f6d88a5ebe6236e479d293b08ad86729f4a54ed Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 24 Sep 2025 08:05:13 +0200 Subject: [PATCH 1/8] chore: rename to pgls --- CLAUDE.md | 4 +- Cargo.lock | 354 +++++++++--------- Cargo.toml | 66 ++-- README.md | 4 +- agentic/rename_to_pgls.md | 60 +++ .../{pgt_analyse => pgls_analyse}/Cargo.toml | 14 +- .../src/analysed_file_context.rs | 6 +- .../src/categories.rs | 4 +- .../src/context.rs | 8 +- .../src/filter.rs | 4 +- .../{pgt_analyse => pgls_analyse}/src/lib.rs | 2 +- .../src/macros.rs | 4 +- .../src/options.rs | 2 +- .../src/registry.rs | 4 +- .../{pgt_analyse => pgls_analyse}/src/rule.rs | 10 +- .../CONTRIBUTING.md | 6 +- crates/pgls_analyser/Cargo.toml | 29 ++ .../src/lib.rs | 21 +- crates/pgls_analyser/src/lint.rs | 4 + .../src/lint/safety.rs | 2 +- .../lint/safety/adding_field_with_default.rs | 42 ++- .../safety/adding_foreign_key_constraint.rs | 24 +- .../src/lint/safety/adding_not_null_field.rs | 12 +- .../safety/adding_primary_key_constraint.rs | 24 +- .../src/lint/safety/adding_required_field.rs | 13 +- .../src/lint/safety/ban_char_field.rs | 22 +- ...oncurrent_index_creation_in_transaction.rs | 8 +- .../src/lint/safety/ban_drop_column.rs | 12 +- .../src/lint/safety/ban_drop_database.rs | 8 +- .../src/lint/safety/ban_drop_not_null.rs | 12 +- .../src/lint/safety/ban_drop_table.rs | 10 +- .../src/lint/safety/ban_truncate_cascade.rs | 10 +- .../src/lint/safety/changing_column_type.rs | 12 +- .../safety/constraint_missing_not_valid.rs | 18 +- .../lint/safety/disallow_unique_constraint.rs | 26 +- .../src/lint/safety/prefer_big_int.rs | 24 +- .../src/lint/safety/prefer_bigint_over_int.rs | 24 +- .../safety/prefer_bigint_over_smallint.rs | 24 +- .../src/lint/safety/prefer_identity.rs | 24 +- .../src/lint/safety/prefer_jsonb.rs | 24 +- .../src/lint/safety/prefer_robust_stmts.rs | 10 +- .../src/lint/safety/prefer_text_field.rs | 24 +- .../src/lint/safety/prefer_timestamptz.rs | 24 +- .../src/lint/safety/renaming_column.rs | 10 +- .../src/lint/safety/renaming_table.rs | 10 +- .../require_concurrent_index_creation.rs | 12 +- .../require_concurrent_index_deletion.rs | 10 +- .../src/lint/safety/transaction_nesting.rs | 26 +- .../src/options.rs | 56 +-- .../src/registry.rs | 2 +- .../tests/rules_tests.rs | 14 +- .../safety/addingFieldWithDefault/basic.sql | 0 .../addingFieldWithDefault/basic.sql.snap | 0 .../generated_column.sql | 0 .../generated_column.sql.snap | 0 .../addingFieldWithDefault/no_default.sql | 0 .../no_default.sql.snap | 0 .../non_volatile_default.sql | 0 .../non_volatile_default.sql.snap | 0 .../volatile_default.sql | 0 .../volatile_default.sql.snap | 0 .../addingForeignKeyConstraint/basic.sql | 0 .../addingForeignKeyConstraint/basic.sql.snap | 0 .../specs/safety/addingNotNullField/basic.sql | 0 .../safety/addingNotNullField/basic.sql.snap | 0 .../addingPrimaryKeyConstraint/basic.sql | 0 .../addingPrimaryKeyConstraint/basic.sql.snap | 0 .../serial_column.sql | 0 .../serial_column.sql.snap | 0 .../using_index.sql | 0 .../using_index.sql.snap | 0 .../safety/addingRequiredField/basic.sql | 0 .../safety/addingRequiredField/basic.sql.snap | 0 .../addingRequiredField/with_default.sql | 0 .../addingRequiredField/with_default.sql.snap | 0 .../addingRequiredField/without_required.sql | 0 .../without_required.sql.snap | 0 .../specs/safety/banCharField/alter_table.sql | 0 .../safety/banCharField/alter_table.sql.snap | 0 .../tests/specs/safety/banCharField/basic.sql | 0 .../specs/safety/banCharField/basic.sql.snap | 0 .../specs/safety/banCharField/bpchar.sql | 0 .../specs/safety/banCharField/bpchar.sql.snap | 0 .../safety/banCharField/varchar_valid.sql | 0 .../banCharField/varchar_valid.sql.snap | 0 .../basic.sql | 0 .../basic.sql.snap | 0 .../specs/safety/banDropColumn/basic.sql | 0 .../specs/safety/banDropColumn/basic.sql.snap | 0 .../specs/safety/banDropDatabase/basic.sql | 0 .../safety/banDropDatabase/basic.sql.snap | 0 .../specs/safety/banDropNotNull/basic.sql | 0 .../safety/banDropNotNull/basic.sql.snap | 0 .../tests/specs/safety/banDropTable/basic.sql | 0 .../specs/safety/banDropTable/basic.sql.snap | 0 .../specs/safety/banTruncateCascade/basic.sql | 0 .../safety/banTruncateCascade/basic.sql.snap | 0 .../specs/safety/changingColumnType/basic.sql | 0 .../safety/changingColumnType/basic.sql.snap | 0 .../constraintMissingNotValid/basic.sql | 0 .../constraintMissingNotValid/basic.sql.snap | 0 .../check_constraint.sql | 0 .../check_constraint.sql.snap | 0 .../with_not_valid.sql | 0 .../with_not_valid.sql.snap | 0 .../tests/specs/safety/preferBigInt/basic.sql | 0 .../specs/safety/preferBigInt/basic.sql.snap | 0 .../safety/preferBigintOverInt/basic.sql | 0 .../safety/preferBigintOverInt/basic.sql.snap | 0 .../safety/preferBigintOverSmallint/basic.sql | 0 .../preferBigintOverSmallint/basic.sql.snap | 0 .../safety/preferIdentity/alter_table.sql | 0 .../preferIdentity/alter_table.sql.snap | 0 .../specs/safety/preferIdentity/basic.sql | 0 .../safety/preferIdentity/basic.sql.snap | 0 .../specs/safety/preferIdentity/bigserial.sql | 0 .../safety/preferIdentity/bigserial.sql.snap | 0 .../specs/safety/preferIdentity/valid.sql | 0 .../safety/preferIdentity/valid.sql.snap | 0 .../tests/specs/safety/preferJsonb/basic.sql | 0 .../specs/safety/preferJsonb/basic.sql.snap | 0 .../specs/safety/preferRobustStmts/basic.sql | 0 .../safety/preferRobustStmts/basic.sql.snap | 0 .../drop_without_if_exists.sql | 0 .../drop_without_if_exists.sql.snap | 0 .../preferRobustStmts/robust_statements.sql | 0 .../robust_statements.sql.snap | 0 .../specs/safety/renamingColumn/basic.sql | 0 .../safety/renamingColumn/basic.sql.snap | 0 .../specs/safety/renamingTable/basic.sql | 0 .../specs/safety/renamingTable/basic.sql.snap | 0 .../requireConcurrentIndexCreation/basic.sql | 0 .../basic.sql.snap | 0 .../concurrent_valid.sql | 0 .../concurrent_valid.sql.snap | 0 .../new_table_valid.sql | 0 .../new_table_valid.sql.snap | 0 .../requireConcurrentIndexDeletion/basic.sql | 0 .../basic.sql.snap | 0 .../concurrent_valid.sql | 0 .../concurrent_valid.sql.snap | 0 .../specs/safety/transactionNesting/basic.sql | 0 .../safety/transactionNesting/basic.sql.snap | 0 .../begin_commit_combined.sql | 0 .../begin_commit_combined.sql.snap | 0 .../safety/transactionNesting/commit.sql | 0 .../safety/transactionNesting/commit.sql.snap | 0 .../safety/transactionNesting/rollback.sql | 0 .../transactionNesting/rollback.sql.snap | 0 crates/{pgt_cli => pgls_cli}/Cargo.toml | 22 +- crates/{pgt_cli => pgls_cli}/src/changed.rs | 6 +- .../{pgt_cli => pgls_cli}/src/cli_options.rs | 10 +- .../src/commands/check.rs | 8 +- .../src/commands/clean.rs | 2 +- .../src/commands/daemon.rs | 10 +- .../src/commands/init.rs | 8 +- .../{pgt_cli => pgls_cli}/src/commands/mod.rs | 34 +- .../src/commands/version.rs | 6 +- .../{pgt_cli => pgls_cli}/src/diagnostics.rs | 16 +- .../src/execute/diagnostics.rs | 4 +- .../{pgt_cli => pgls_cli}/src/execute/mod.rs | 2 +- .../src/execute/process_file.rs | 6 +- .../src/execute/process_file/check.rs | 4 +- .../execute/process_file/workspace_file.rs | 10 +- .../src/execute/std_in.rs | 2 +- .../src/execute/traverse.rs | 34 +- crates/{pgt_cli => pgls_cli}/src/lib.rs | 6 +- crates/{pgt_cli => pgls_cli}/src/logging.rs | 0 crates/{pgt_cli => pgls_cli}/src/main.rs | 8 +- crates/{pgt_cli => pgls_cli}/src/metrics.rs | 0 crates/{pgt_cli => pgls_cli}/src/panic.rs | 0 .../src/reporter/github.rs | 4 +- .../src/reporter/gitlab.rs | 8 +- .../src/reporter/junit.rs | 8 +- .../{pgt_cli => pgls_cli}/src/reporter/mod.rs | 6 +- .../src/reporter/terminal.rs | 14 +- .../{pgt_cli => pgls_cli}/src/service/mod.rs | 2 +- .../{pgt_cli => pgls_cli}/src/service/unix.rs | 6 +- .../src/service/windows.rs | 4 +- .../{pgt_cli => pgls_cli}/tests/assert_cmd.rs | 2 +- .../tests/commands/check.rs | 6 +- .../tests/commands/mod.rs | 0 .../tests/fixtures/test.sql | 0 crates/{pgt_cli => pgls_cli}/tests/main.rs | 14 +- crates/pgls_completions/Cargo.toml | 45 +++ .../README.md | 0 .../benches/sanitization.rs | 8 +- .../src/builder.rs | 2 +- .../src/complete.rs | 6 +- .../src/item.rs | 2 +- .../src/lib.rs | 0 .../src/providers/columns.rs | 38 +- .../src/providers/functions.rs | 20 +- .../src/providers/helper.rs | 4 +- .../src/providers/mod.rs | 0 .../src/providers/policies.rs | 8 +- .../src/providers/roles.rs | 18 +- .../src/providers/schemas.rs | 10 +- .../src/providers/tables.rs | 34 +- crates/pgls_completions/src/relevance.rs | 12 + .../src/relevance/filtering.rs | 12 +- .../src/relevance/scoring.rs | 2 +- .../src/sanitization.rs | 14 +- .../src/test_helper.rs | 16 +- .../Cargo.toml | 12 +- .../src/analyser/linter/mod.rs | 0 .../src/analyser/linter/rules.rs | 67 ++-- .../src/analyser/mod.rs | 6 +- .../src/database.rs | 0 .../src/diagnostics.rs | 8 +- .../src/files.rs | 0 .../src/generated.rs | 0 .../src/generated/linter.rs | 2 +- .../src/lib.rs | 6 +- .../src/migrations.rs | 0 .../src/plpgsql_check.rs | 0 .../src/typecheck.rs | 0 .../src/vcs.rs | 2 +- .../{pgt_console => pgls_console}/Cargo.toml | 8 +- .../{pgt_console => pgls_console}/README.md | 0 .../{pgt_console => pgls_console}/src/fmt.rs | 8 +- .../{pgt_console => pgls_console}/src/lib.rs | 4 +- .../src/markup.rs | 2 +- .../src/utils.rs | 4 +- .../src/write.rs | 0 .../src/write/html.rs | 4 +- .../src/write/termcolor.rs | 0 .../tests/macro.rs | 6 +- .../markup/closing_element_standalone.rs | 2 +- .../markup/closing_element_standalone.stderr | 0 .../tests/markup/element_non_ident_name.rs | 2 +- .../markup/element_non_ident_name.stderr | 0 .../tests/markup/invalid_group.rs | 2 +- .../tests/markup/invalid_group.stderr | 0 .../tests/markup/invalid_punct.rs | 2 +- .../tests/markup/invalid_punct.stderr | 0 .../markup/open_element_improper_close_1.rs | 2 +- .../open_element_improper_close_1.stderr | 0 .../markup/open_element_improper_close_2.rs | 2 +- .../open_element_improper_close_2.stderr | 0 .../open_element_improper_prop_value.rs | 2 +- .../open_element_improper_prop_value.stderr | 0 .../markup/open_element_missing_prop_value.rs | 2 +- .../open_element_missing_prop_value.stderr | 0 .../tests/markup/open_element_unfinished_1.rs | 2 +- .../markup/open_element_unfinished_1.stderr | 0 .../tests/markup/open_element_unfinished_2.rs | 2 +- .../markup/open_element_unfinished_2.stderr | 0 .../tests/markup/open_element_unfinished_3.rs | 2 +- .../markup/open_element_unfinished_3.stderr | 0 .../tests/markup/open_element_unfinished_4.rs | 2 +- .../markup/open_element_unfinished_4.stderr | 0 .../tests/markup/open_element_unfinished_5.rs | 2 +- .../markup/open_element_unfinished_5.stderr | 0 .../tests/markup/open_element_unfinished_6.rs | 2 +- .../markup/open_element_unfinished_6.stderr | 0 .../tests/markup/open_element_unfinished_7.rs | 2 +- .../markup/open_element_unfinished_7.stderr | 0 .../tests/markup/unclosed_element.rs | 2 +- .../tests/markup/unclosed_element.stderr | 0 crates/pgls_diagnostics/Cargo.toml | 36 ++ .../src/adapters.rs | 2 +- .../src/advice.rs | 6 +- .../src/context.rs | 10 +- .../src/diagnostic.rs | 6 +- .../src/display.rs | 20 +- .../src/display/backtrace.rs | 6 +- .../src/display/diff.rs | 8 +- .../src/display/frame.rs | 4 +- .../src/display/message.rs | 8 +- .../src/display_github.rs | 6 +- .../src/error.rs | 2 +- .../src/lib.rs | 12 +- .../src/location.rs | 4 +- .../src/panic.rs | 0 .../src/serde.rs | 12 +- .../src/suggestion.rs | 6 +- .../Cargo.toml | 2 +- .../build.rs | 6 +- .../src/categories.rs | 67 ++++ .../src/lib.rs | 2 +- .../Cargo.toml | 2 +- .../src/generate.rs | 82 ++-- .../src/lib.rs | 0 .../src/parse.rs | 0 crates/{pgt_flags => pgls_flags}/Cargo.toml | 4 +- crates/{pgt_flags => pgls_flags}/src/lib.rs | 4 +- crates/pgls_fs/Cargo.toml | 33 ++ crates/{pgt_fs => pgls_fs}/src/dir.rs | 0 crates/{pgt_fs => pgls_fs}/src/fs.rs | 16 +- crates/{pgt_fs => pgls_fs}/src/fs/memory.rs | 28 +- crates/{pgt_fs => pgls_fs}/src/fs/os.rs | 14 +- crates/{pgt_fs => pgls_fs}/src/interner.rs | 0 crates/{pgt_fs => pgls_fs}/src/lib.rs | 4 +- crates/{pgt_fs => pgls_fs}/src/path.rs | 20 +- crates/pgls_hover/Cargo.toml | 37 ++ .../src/contextual_priority.rs | 2 +- .../src/hoverables/column.rs | 10 +- .../src/hoverables/function.rs | 26 +- .../src/hoverables/mod.rs | 32 +- .../src/hoverables/role.rs | 6 +- .../src/hoverables/schema.rs | 4 +- .../src/hoverables/table.rs | 12 +- .../src/hoverables/test_helper.rs | 12 +- .../src/hovered_node.rs | 2 +- crates/{pgt_hover => pgls_hover}/src/lib.rs | 10 +- .../src/to_markdown.rs | 0 .../tests/hover_integration_tests.rs | 56 +-- .../tests/snapshots/builtin_count.snap | 0 .../tests/snapshots/builtin_max.snap | 0 .../tests/snapshots/builtin_now.snap | 0 .../tests/snapshots/column_hover.snap | 0 .../tests/snapshots/column_hover_join.snap | 0 .../column_hover_quoted_column_name.snap | 0 ...n_hover_quoted_column_name_with_table.snap | 0 .../column_hover_quoted_schema_table.snap | 0 .../tests/snapshots/create_policy.snap | 0 .../tests/snapshots/custom_function.snap | 0 .../function_hover_quoted_schema.snap | 0 .../tests/snapshots/function_with_schema.snap | 0 .../tests/snapshots/grant_select.snap | 0 .../tests/snapshots/hover_on_schemas.snap | 0 .../tests/snapshots/lenghty_function.snap | 0 .../tests/snapshots/no_hover_keyword.snap | 0 .../tests/snapshots/revoke_select.snap | 0 .../tests/snapshots/role_alter.snap | 0 .../tests/snapshots/role_create.snap | 0 .../tests/snapshots/table_hover.snap | 0 .../snapshots/table_hover_quoted_schema.snap | 0 .../table_hover_quoted_table_name.snap | 0 crates/{pgt_lexer => pgls_lexer}/Cargo.toml | 10 +- crates/{pgt_lexer => pgls_lexer}/README.md | 0 .../src/codegen/mod.rs | 0 crates/pgls_lexer/src/codegen/syntax_kind.rs | 1 + crates/{pgt_lexer => pgls_lexer}/src/lexed.rs | 4 +- crates/{pgt_lexer => pgls_lexer}/src/lexer.rs | 110 +++--- crates/{pgt_lexer => pgls_lexer}/src/lib.rs | 0 .../Cargo.toml | 2 +- .../README.md | 0 .../build.rs | 0 .../src/keywords.rs | 0 .../src/lib.rs | 0 .../src/syntax_kind.rs | 0 .../vendor/17-latest/kwlist.h | 0 crates/pgls_lsp/Cargo.toml | 43 +++ .../src/adapters/from_lsp.rs | 2 +- .../src/adapters/line_index.rs | 2 +- .../{pgt_lsp => pgls_lsp}/src/adapters/mod.rs | 4 +- .../src/adapters/to_lsp.rs | 2 +- .../{pgt_lsp => pgls_lsp}/src/capabilities.rs | 2 +- .../{pgt_lsp => pgls_lsp}/src/diagnostics.rs | 8 +- crates/{pgt_lsp => pgls_lsp}/src/documents.rs | 0 crates/{pgt_lsp => pgls_lsp}/src/handlers.rs | 0 .../src/handlers/code_actions.rs | 4 +- .../src/handlers/completions.rs | 16 +- .../src/handlers/hover.rs | 2 +- .../src/handlers/text_document.rs | 2 +- crates/{pgt_lsp => pgls_lsp}/src/lib.rs | 0 crates/{pgt_lsp => pgls_lsp}/src/server.rs | 8 +- crates/{pgt_lsp => pgls_lsp}/src/session.rs | 34 +- crates/{pgt_lsp => pgls_lsp}/src/utils.rs | 18 +- crates/{pgt_lsp => pgls_lsp}/tests/server.rs | 88 +++-- crates/{pgt_markup => pgls_markup}/Cargo.toml | 2 +- crates/{pgt_markup => pgls_markup}/README.md | 0 crates/{pgt_markup => pgls_markup}/src/lib.rs | 10 +- crates/pgls_plpgsql_check/Cargo.toml | 30 ++ .../src/diagnostics.rs | 6 +- .../src/lib.rs | 83 ++-- crates/{pgt_query => pgls_query}/Cargo.toml | 4 +- crates/{pgt_query => pgls_query}/build.rs | 0 .../examples/api_example.rs | 4 +- .../{pgt_query => pgls_query}/src/deparse.rs | 2 +- crates/{pgt_query => pgls_query}/src/error.rs | 0 .../src/fingerprint.rs | 2 +- crates/pgls_query/src/iter_mut.rs | 1 + crates/pgls_query/src/iter_ref.rs | 1 + crates/{pgt_query => pgls_query}/src/lib.rs | 0 .../src/node_enum.rs | 2 +- .../{pgt_query => pgls_query}/src/node_mut.rs | 2 +- .../{pgt_query => pgls_query}/src/node_ref.rs | 2 +- .../src/node_structs.rs | 2 +- .../src/normalize.rs | 2 +- crates/{pgt_query => pgls_query}/src/parse.rs | 2 +- .../{pgt_query => pgls_query}/src/plpgsql.rs | 2 +- .../{pgt_query => pgls_query}/src/protobuf.rs | 0 crates/{pgt_query => pgls_query}/src/scan.rs | 2 +- crates/{pgt_query => pgls_query}/src/split.rs | 8 +- .../vendor/libpg_query | 0 .../Cargo.toml | 8 +- .../src/diagnostics.rs | 8 +- .../src/lib.rs | 0 .../src/utils.rs | 18 +- .../Cargo.toml | 2 +- .../build.rs | 0 .../src/iter_mut.rs | 0 .../src/iter_ref.rs | 0 .../src/lib.rs | 0 .../src/node_enum.rs | 0 .../src/node_mut.rs | 0 .../src/node_ref.rs | 0 .../src/node_structs.rs | 0 .../src/proto_analyser.rs | 0 .../vendor/17-latest/pg_query.proto | 0 crates/pgls_schema_cache/Cargo.toml | 30 ++ .../src/columns.rs | 2 +- .../src/extensions.rs | 0 .../src/functions.rs | 2 +- .../src/lib.rs | 0 .../src/policies.rs | 2 +- .../src/queries/columns.sql | 0 .../src/queries/extensions.sql | 0 .../src/queries/functions.sql | 0 .../src/queries/policies.sql | 0 .../src/queries/roles.sql | 0 .../src/queries/schemas.sql | 0 .../src/queries/tables.sql | 0 .../src/queries/triggers.sql | 0 .../src/queries/types.sql | 0 .../src/queries/versions.sql | 0 .../src/roles.rs | 4 +- .../src/schema_cache.rs | 2 +- .../src/schemas.rs | 0 .../src/tables.rs | 4 +- .../src/triggers.rs | 4 +- .../src/types.rs | 0 .../src/versions.rs | 0 .../Cargo.toml | 12 +- .../benches/splitter.rs | 2 +- .../src/diagnostics.rs | 6 +- .../src/lib.rs | 8 +- .../src/splitter.rs | 4 +- .../src/splitter/common.rs | 2 +- .../src/splitter/data.rs | 2 +- .../src/splitter/ddl.rs | 2 +- .../src/splitter/dml.rs | 2 +- .../tests/data/grant_statements__4.sql | 0 .../tests/data/on_conflict_do_update__1.sql | 0 .../tests/data/simple_select__4.sql | 0 .../tests/data/simple_union__4.sql | 0 .../tests/data/with_comments__4.sql | 0 .../tests/statement_splitter_tests.rs | 2 +- .../Cargo.toml | 10 +- .../src/lib.rs | 10 +- .../src/line_index.rs | 6 +- .../src/parser.rs | 4 +- .../src/suppression.rs | 14 +- .../Cargo.toml | 2 +- .../README.md | 0 .../src/lib.rs | 0 .../Cargo.toml | 8 +- .../src/bin/tree_print.rs | 2 +- .../src/lib.rs | 0 .../testdb_migrations/0001_setup-roles.sql | 0 crates/pgls_text_edit/Cargo.toml | 27 ++ .../src/lib.rs | 2 +- .../Cargo.toml | 2 +- .../src/lib.rs | 0 .../src/range.rs | 26 +- .../src/schemars_impls.rs | 0 .../src/serde_impls.rs | 0 .../src/size.rs | 2 +- .../src/traits.rs | 0 .../tests/auto_traits.rs | 2 +- .../tests/constructors.rs | 2 +- .../tests/indexing.rs | 2 +- .../tests/main.rs | 2 +- .../tests/serde.rs | 2 +- .../Cargo.toml | 2 +- .../README.md | 0 .../src/cursor.rs | 0 .../src/lib.rs | 0 .../pgt_tokenizer__tests__bitstring.snap | 0 .../pgt_tokenizer__tests__block_comment.snap | 0 ...er__tests__block_comment_unterminated.snap | 0 ...s__dollar_quote_mismatch_tags_complex.snap | 0 ...ts__dollar_quote_mismatch_tags_simple.snap | 0 .../pgt_tokenizer__tests__dollar_quoting.snap | 0 ...okenizer__tests__dollar_strings_part2.snap | 0 ...okenizer__tests__graphile_named_param.snap | 0 .../pgt_tokenizer__tests__lex_statement.snap | 0 .../pgt_tokenizer__tests__line_comment.snap | 0 ...nizer__tests__line_comment_whitespace.snap | 0 .../pgt_tokenizer__tests__named_param_at.snap | 0 ...__tests__named_param_colon_identifier.snap | 0 ...kenizer__tests__named_param_colon_raw.snap | 0 ..._tests__named_param_colon_raw_vs_cast.snap | 0 ...izer__tests__named_param_colon_string.snap | 0 ...enizer__tests__named_param_dollar_raw.snap | 0 .../pgt_tokenizer__tests__numeric.snap | 0 ...tokenizer__tests__numeric_non_decimal.snap | 0 ...nizer__tests__numeric_with_seperators.snap | 0 .../pgt_tokenizer__tests__params.snap | 0 .../pgt_tokenizer__tests__quoted_ident.snap | 0 ...tests__quoted_ident_with_escape_quote.snap | 0 ..._tokenizer__tests__select_with_period.snap | 0 .../pgt_tokenizer__tests__string.snap | 0 ...kenizer__tests__string_unicode_escape.snap | 0 ...tokenizer__tests__string_with_escapes.snap | 0 .../src/token.rs | 0 .../Cargo.toml | 14 +- .../src/context/base_parser.rs | 2 +- .../src/context/grant_parser.rs | 6 +- .../src/context/mod.rs | 8 +- .../src/context/policy_parser.rs | 6 +- .../src/context/revoke_parser.rs | 6 +- .../src/lib.rs | 0 .../src/queries/insert_columns.rs | 8 +- .../src/queries/mod.rs | 8 +- .../src/queries/parameters.rs | 2 +- .../src/queries/relations.rs | 16 +- .../src/queries/select_columns.rs | 6 +- .../src/queries/table_aliases.rs | 2 +- .../src/queries/where_columns.rs | 2 +- .../.editorconfig | 0 .../.gitattributes | 0 .../.gitignore | 0 .../Cargo.toml | 2 +- .../NOTICE | 0 .../build.rs | 0 .../grammar.js | 0 .../package-lock.json | 0 .../package.json | 0 .../src/grammar.json | 0 .../src/lib.rs | 2 +- .../src/node-types.json | 0 .../src/parser.c | 0 .../src/scanner.c | 0 .../src/tree_sitter/alloc.h | 0 .../src/tree_sitter/array.h | 0 .../src/tree_sitter/parser.h | 0 .../tree-sitter.json | 0 .../Cargo.toml | 6 +- .../src/functions.rs | 6 +- .../src/lib.rs | 0 .../src/types.rs | 16 +- crates/pgls_type_resolver/src/util.rs | 6 + crates/pgls_typecheck/Cargo.toml | 33 ++ .../src/diagnostics.rs | 6 +- .../src/lib.rs | 16 +- .../src/typed_identifier.rs | 14 +- .../tests/diagnostics.rs | 14 +- .../tests/snapshots/invalid_column.snap | 0 crates/pgls_workspace/Cargo.toml | 76 ++++ .../src/configuration.rs | 32 +- .../src/diagnostics.rs | 16 +- .../src/dome.rs | 18 +- .../src/features/code_actions.rs | 10 +- .../src/features/completions.rs | 12 +- .../src/features/diagnostics.rs | 10 +- .../src/features/mod.rs | 0 .../src/features/on_hover.rs | 6 +- .../src/lib.rs | 4 +- .../src/matcher/LICENCE-APACHE | 0 .../src/matcher/LICENSE-MIT | 0 .../src/matcher/mod.rs | 6 +- .../src/matcher/pattern.rs | 0 .../src/settings.rs | 26 +- .../src/workspace.rs | 20 +- .../src/workspace/client.rs | 2 +- .../src/workspace/server.rs | 32 +- .../src/workspace/server.tests.rs | 54 +-- .../src/workspace/server/analyser.rs | 12 +- .../src/workspace/server/annotation.rs | 4 +- .../src/workspace/server/async_helper.rs | 0 .../src/workspace/server/connection_key.rs | 0 .../workspace/server/connection_manager.rs | 0 .../src/workspace/server/document.rs | 18 +- .../src/workspace/server/migration.rs | 0 .../src/workspace/server/pg_query.rs | 58 +-- .../workspace/server/schema_cache_manager.rs | 2 +- .../src/workspace/server/sql_function.rs | 26 +- .../workspace/server/statement_identifier.rs | 0 .../src/workspace/server/tree_sitter.rs | 2 +- .../src/workspace_types.rs | 0 .../Cargo.toml | 2 +- .../src/lib.rs | 2 +- crates/pgt_analyser/Cargo.toml | 29 -- crates/pgt_analyser/src/lint.rs | 4 - crates/pgt_completions/Cargo.toml | 45 --- crates/pgt_completions/src/relevance.rs | 12 - crates/pgt_diagnostics/Cargo.toml | 36 -- .../src/categories.rs | 67 ---- crates/pgt_fs/Cargo.toml | 33 -- crates/pgt_hover/Cargo.toml | 37 -- crates/pgt_lexer/src/codegen/syntax_kind.rs | 1 - crates/pgt_lsp/Cargo.toml | 43 --- crates/pgt_plpgsql_check/Cargo.toml | 30 -- crates/pgt_query/src/iter_mut.rs | 1 - crates/pgt_query/src/iter_ref.rs | 1 - crates/pgt_schema_cache/Cargo.toml | 30 -- crates/pgt_text_edit/Cargo.toml | 27 -- crates/pgt_type_resolver/src/util.rs | 6 - crates/pgt_typecheck/Cargo.toml | 33 -- crates/pgt_workspace/Cargo.toml | 76 ---- docs/codegen/Cargo.toml | 22 +- docs/codegen/src/cli_doc.rs | 9 +- docs/codegen/src/default_configuration.rs | 2 +- docs/codegen/src/env_variables.rs | 2 +- docs/codegen/src/rules_docs.rs | 24 +- docs/codegen/src/rules_index.rs | 8 +- docs/codegen/src/rules_sources.rs | 4 +- docs/codegen/src/schema.rs | 2 +- docs/codegen/src/utils.rs | 2 +- docs/configuration.md | 8 +- docs/features/linting.md | 8 +- docs/getting_started.md | 18 +- docs/guides/checking_migrations.md | 8 +- docs/guides/configure_database.md | 4 +- docs/guides/continuous_integration.md | 4 +- docs/guides/ide_setup.md | 2 +- docs/guides/vcs_integration.md | 6 +- docs/reference/cli.md | 56 +-- docs/schema.json | 4 +- mkdocs.yml | 2 +- .../backend-jsonrpc/package.json | 16 +- .../backend-jsonrpc/src/command.ts | 0 .../backend-jsonrpc/src/index.ts | 0 .../backend-jsonrpc/src/socket.ts | 0 .../backend-jsonrpc/src/transport.ts | 0 .../backend-jsonrpc/src/workspace.ts | 22 +- .../backend-jsonrpc/tests/transport.test.mjs | 0 .../backend-jsonrpc/tests/workspace.test.mjs | 0 .../bin/postgrestools => @pgls/cli/bin/pgls} | 0 .../postgrestools => @pgls/cli}/package.json | 22 +- .../cli}/scripts/generate-packages.mjs | 0 pyproject.toml | 2 +- xtask/codegen/Cargo.toml | 8 +- xtask/codegen/src/generate_analyser.rs | 12 +- xtask/codegen/src/generate_bindings.rs | 2 +- xtask/codegen/src/generate_configuration.rs | 36 +- .../codegen/src/generate_new_analyser_rule.rs | 16 +- xtask/codegen/src/lib.rs | 2 +- xtask/rules_check/Cargo.toml | 20 +- xtask/rules_check/src/lib.rs | 36 +- xtask/src/install.rs | 2 +- 635 files changed, 2478 insertions(+), 2381 deletions(-) create mode 100644 agentic/rename_to_pgls.md rename crates/{pgt_analyse => pgls_analyse}/Cargo.toml (73%) rename crates/{pgt_analyse => pgls_analyse}/src/analysed_file_context.rs (63%) rename crates/{pgt_analyse => pgls_analyse}/src/categories.rs (98%) rename crates/{pgt_analyse => pgls_analyse}/src/context.rs (93%) rename crates/{pgt_analyse => pgls_analyse}/src/filter.rs (97%) rename crates/{pgt_analyse => pgls_analyse}/src/lib.rs (94%) rename crates/{pgt_analyse => pgls_analyse}/src/macros.rs (98%) rename crates/{pgt_analyse => pgls_analyse}/src/options.rs (95%) rename crates/{pgt_analyse => pgls_analyse}/src/registry.rs (97%) rename crates/{pgt_analyse => pgls_analyse}/src/rule.rs (98%) rename crates/{pgt_analyser => pgls_analyser}/CONTRIBUTING.md (97%) create mode 100644 crates/pgls_analyser/Cargo.toml rename crates/{pgt_analyser => pgls_analyser}/src/lib.rs (88%) create mode 100644 crates/pgls_analyser/src/lint.rs rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety.rs (98%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/adding_field_with_default.rs (82%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/adding_foreign_key_constraint.rs (83%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/adding_not_null_field.rs (86%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/adding_primary_key_constraint.rs (79%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/adding_required_field.rs (86%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/ban_char_field.rs (78%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/ban_concurrent_index_creation_in_transaction.rs (89%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/ban_drop_column.rs (77%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/ban_drop_database.rs (81%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/ban_drop_not_null.rs (81%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/ban_drop_table.rs (83%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/ban_truncate_cascade.rs (84%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/changing_column_type.rs (80%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/constraint_missing_not_valid.rs (81%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/disallow_unique_constraint.rs (82%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/prefer_big_int.rs (80%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/prefer_bigint_over_int.rs (78%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/prefer_bigint_over_smallint.rs (78%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/prefer_identity.rs (79%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/prefer_jsonb.rs (80%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/prefer_robust_stmts.rs (93%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/prefer_text_field.rs (78%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/prefer_timestamptz.rs (79%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/renaming_column.rs (81%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/renaming_table.rs (81%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/require_concurrent_index_creation.rs (87%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/require_concurrent_index_deletion.rs (83%) rename crates/{pgt_analyser => pgls_analyser}/src/lint/safety/transaction_nesting.rs (79%) rename crates/{pgt_analyser => pgls_analyser}/src/options.rs (55%) rename crates/{pgt_analyser => pgls_analyser}/src/registry.rs (83%) rename crates/{pgt_analyser => pgls_analyser}/tests/rules_tests.rs (92%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingFieldWithDefault/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingFieldWithDefault/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingFieldWithDefault/generated_column.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingFieldWithDefault/generated_column.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingFieldWithDefault/no_default.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingFieldWithDefault/no_default.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingFieldWithDefault/non_volatile_default.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingFieldWithDefault/non_volatile_default.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingFieldWithDefault/volatile_default.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingFieldWithDefault/volatile_default.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingForeignKeyConstraint/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingForeignKeyConstraint/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingNotNullField/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingNotNullField/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingPrimaryKeyConstraint/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingPrimaryKeyConstraint/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingPrimaryKeyConstraint/serial_column.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingPrimaryKeyConstraint/serial_column.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingPrimaryKeyConstraint/using_index.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingPrimaryKeyConstraint/using_index.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingRequiredField/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingRequiredField/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingRequiredField/with_default.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingRequiredField/with_default.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingRequiredField/without_required.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/addingRequiredField/without_required.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banCharField/alter_table.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banCharField/alter_table.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banCharField/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banCharField/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banCharField/bpchar.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banCharField/bpchar.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banCharField/varchar_valid.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banCharField/varchar_valid.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banConcurrentIndexCreationInTransaction/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banConcurrentIndexCreationInTransaction/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banDropColumn/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banDropColumn/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banDropDatabase/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banDropDatabase/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banDropNotNull/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banDropNotNull/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banDropTable/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banDropTable/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banTruncateCascade/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/banTruncateCascade/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/changingColumnType/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/changingColumnType/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/constraintMissingNotValid/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/constraintMissingNotValid/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/constraintMissingNotValid/check_constraint.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/constraintMissingNotValid/check_constraint.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/constraintMissingNotValid/with_not_valid.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/constraintMissingNotValid/with_not_valid.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferBigInt/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferBigInt/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferBigintOverInt/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferBigintOverInt/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferBigintOverSmallint/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferBigintOverSmallint/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferIdentity/alter_table.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferIdentity/alter_table.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferIdentity/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferIdentity/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferIdentity/bigserial.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferIdentity/bigserial.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferIdentity/valid.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferIdentity/valid.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferJsonb/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferJsonb/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferRobustStmts/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferRobustStmts/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferRobustStmts/drop_without_if_exists.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferRobustStmts/drop_without_if_exists.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferRobustStmts/robust_statements.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/preferRobustStmts/robust_statements.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/renamingColumn/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/renamingColumn/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/renamingTable/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/renamingTable/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/requireConcurrentIndexCreation/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/requireConcurrentIndexCreation/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/requireConcurrentIndexCreation/concurrent_valid.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/requireConcurrentIndexCreation/concurrent_valid.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/requireConcurrentIndexCreation/new_table_valid.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/requireConcurrentIndexCreation/new_table_valid.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/requireConcurrentIndexDeletion/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/requireConcurrentIndexDeletion/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/requireConcurrentIndexDeletion/concurrent_valid.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/requireConcurrentIndexDeletion/concurrent_valid.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/transactionNesting/basic.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/transactionNesting/basic.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/transactionNesting/begin_commit_combined.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/transactionNesting/begin_commit_combined.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/transactionNesting/commit.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/transactionNesting/commit.sql.snap (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/transactionNesting/rollback.sql (100%) rename crates/{pgt_analyser => pgls_analyser}/tests/specs/safety/transactionNesting/rollback.sql.snap (100%) rename crates/{pgt_cli => pgls_cli}/Cargo.toml (79%) rename crates/{pgt_cli => pgls_cli}/src/changed.rs (92%) rename crates/{pgt_cli => pgls_cli}/src/cli_options.rs (95%) rename crates/{pgt_cli => pgls_cli}/src/commands/check.rs (91%) rename crates/{pgt_cli => pgls_cli}/src/commands/clean.rs (94%) rename crates/{pgt_cli => pgls_cli}/src/commands/daemon.rs (96%) rename crates/{pgt_cli => pgls_cli}/src/commands/init.rs (77%) rename crates/{pgt_cli => pgls_cli}/src/commands/mod.rs (92%) rename crates/{pgt_cli => pgls_cli}/src/commands/version.rs (89%) rename crates/{pgt_cli => pgls_cli}/src/diagnostics.rs (96%) rename crates/{pgt_cli => pgls_cli}/src/execute/diagnostics.rs (93%) rename crates/{pgt_cli => pgls_cli}/src/execute/mod.rs (99%) rename crates/{pgt_cli => pgls_cli}/src/execute/process_file.rs (97%) rename crates/{pgt_cli => pgls_cli}/src/execute/process_file/check.rs (96%) rename crates/{pgt_cli => pgls_cli}/src/execute/process_file/workspace_file.rs (88%) rename crates/{pgt_cli => pgls_cli}/src/execute/std_in.rs (88%) rename crates/{pgt_cli => pgls_cli}/src/execute/traverse.rs (95%) rename crates/{pgt_cli => pgls_cli}/src/lib.rs (97%) rename crates/{pgt_cli => pgls_cli}/src/logging.rs (100%) rename crates/{pgt_cli => pgls_cli}/src/main.rs (92%) rename crates/{pgt_cli => pgls_cli}/src/metrics.rs (100%) rename crates/{pgt_cli => pgls_cli}/src/panic.rs (100%) rename crates/{pgt_cli => pgls_cli}/src/reporter/github.rs (93%) rename crates/{pgt_cli => pgls_cli}/src/reporter/gitlab.rs (97%) rename crates/{pgt_cli => pgls_cli}/src/reporter/junit.rs (95%) rename crates/{pgt_cli => pgls_cli}/src/reporter/mod.rs (94%) rename crates/{pgt_cli => pgls_cli}/src/reporter/terminal.rs (94%) rename crates/{pgt_cli => pgls_cli}/src/service/mod.rs (99%) rename crates/{pgt_cli => pgls_cli}/src/service/unix.rs (97%) rename crates/{pgt_cli => pgls_cli}/src/service/windows.rs (98%) rename crates/{pgt_cli => pgls_cli}/tests/assert_cmd.rs (84%) rename crates/{pgt_cli => pgls_cli}/tests/commands/check.rs (84%) rename crates/{pgt_cli => pgls_cli}/tests/commands/mod.rs (100%) rename crates/{pgt_cli => pgls_cli}/tests/fixtures/test.sql (100%) rename crates/{pgt_cli => pgls_cli}/tests/main.rs (83%) create mode 100644 crates/pgls_completions/Cargo.toml rename crates/{pgt_completions => pgls_completions}/README.md (100%) rename crates/{pgt_completions => pgls_completions}/benches/sanitization.rs (97%) rename crates/{pgt_completions => pgls_completions}/src/builder.rs (98%) rename crates/{pgt_completions => pgls_completions}/src/complete.rs (89%) rename crates/{pgt_completions => pgls_completions}/src/item.rs (98%) rename crates/{pgt_completions => pgls_completions}/src/lib.rs (100%) rename crates/{pgt_completions => pgls_completions}/src/providers/columns.rs (97%) rename crates/{pgt_completions => pgls_completions}/src/providers/functions.rs (95%) rename crates/{pgt_completions => pgls_completions}/src/providers/helper.rs (96%) rename crates/{pgt_completions => pgls_completions}/src/providers/mod.rs (100%) rename crates/{pgt_completions => pgls_completions}/src/providers/policies.rs (94%) rename crates/{pgt_completions => pgls_completions}/src/providers/roles.rs (95%) rename crates/{pgt_completions => pgls_completions}/src/providers/schemas.rs (93%) rename crates/{pgt_completions => pgls_completions}/src/providers/tables.rs (95%) create mode 100644 crates/pgls_completions/src/relevance.rs rename crates/{pgt_completions => pgls_completions}/src/relevance/filtering.rs (97%) rename crates/{pgt_completions => pgls_completions}/src/relevance/scoring.rs (99%) rename crates/{pgt_completions => pgls_completions}/src/sanitization.rs (98%) rename crates/{pgt_completions => pgls_completions}/src/test_helper.rs (93%) rename crates/{pgt_configuration => pgls_configuration}/Cargo.toml (76%) rename crates/{pgt_configuration => pgls_configuration}/src/analyser/linter/mod.rs (100%) rename crates/{pgt_configuration => pgls_configuration}/src/analyser/linter/rules.rs (91%) rename crates/{pgt_configuration => pgls_configuration}/src/analyser/mod.rs (99%) rename crates/{pgt_configuration => pgls_configuration}/src/database.rs (100%) rename crates/{pgt_configuration => pgls_configuration}/src/diagnostics.rs (96%) rename crates/{pgt_configuration => pgls_configuration}/src/files.rs (100%) rename crates/{pgt_configuration => pgls_configuration}/src/generated.rs (100%) rename crates/{pgt_configuration => pgls_configuration}/src/generated/linter.rs (92%) rename crates/{pgt_configuration => pgls_configuration}/src/lib.rs (97%) rename crates/{pgt_configuration => pgls_configuration}/src/migrations.rs (100%) rename crates/{pgt_configuration => pgls_configuration}/src/plpgsql_check.rs (100%) rename crates/{pgt_configuration => pgls_configuration}/src/typecheck.rs (100%) rename crates/{pgt_configuration => pgls_configuration}/src/vcs.rs (98%) rename crates/{pgt_console => pgls_console}/Cargo.toml (79%) rename crates/{pgt_console => pgls_console}/README.md (100%) rename crates/{pgt_console => pgls_console}/src/fmt.rs (98%) rename crates/{pgt_console => pgls_console}/src/lib.rs (99%) rename crates/{pgt_console => pgls_console}/src/markup.rs (99%) rename crates/{pgt_console => pgls_console}/src/utils.rs (97%) rename crates/{pgt_console => pgls_console}/src/write.rs (100%) rename crates/{pgt_console => pgls_console}/src/write/html.rs (99%) rename crates/{pgt_console => pgls_console}/src/write/termcolor.rs (100%) rename crates/{pgt_console => pgls_console}/tests/macro.rs (90%) rename crates/{pgt_console => pgls_console}/tests/markup/closing_element_standalone.rs (58%) rename crates/{pgt_console => pgls_console}/tests/markup/closing_element_standalone.stderr (100%) rename crates/{pgt_console => pgls_console}/tests/markup/element_non_ident_name.rs (60%) rename crates/{pgt_console => pgls_console}/tests/markup/element_non_ident_name.stderr (100%) rename crates/{pgt_console => pgls_console}/tests/markup/invalid_group.rs (52%) rename crates/{pgt_console => pgls_console}/tests/markup/invalid_group.stderr (100%) rename crates/{pgt_console => pgls_console}/tests/markup/invalid_punct.rs (51%) rename crates/{pgt_console => pgls_console}/tests/markup/invalid_punct.stderr (100%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_improper_close_1.rs (59%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_improper_close_1.stderr (100%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_improper_close_2.rs (63%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_improper_close_2.stderr (100%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_improper_prop_value.rs (66%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_improper_prop_value.stderr (100%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_missing_prop_value.rs (64%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_missing_prop_value.stderr (100%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_unfinished_1.rs (51%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_unfinished_1.stderr (100%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_unfinished_2.rs (57%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_unfinished_2.stderr (100%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_unfinished_3.rs (58%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_unfinished_3.stderr (100%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_unfinished_4.rs (60%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_unfinished_4.stderr (100%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_unfinished_5.rs (61%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_unfinished_5.stderr (100%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_unfinished_6.rs (62%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_unfinished_6.stderr (100%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_unfinished_7.rs (62%) rename crates/{pgt_console => pgls_console}/tests/markup/open_element_unfinished_7.stderr (100%) rename crates/{pgt_console => pgls_console}/tests/markup/unclosed_element.rs (58%) rename crates/{pgt_console => pgls_console}/tests/markup/unclosed_element.stderr (100%) create mode 100644 crates/pgls_diagnostics/Cargo.toml rename crates/{pgt_diagnostics => pgls_diagnostics}/src/adapters.rs (99%) rename crates/{pgt_diagnostics => pgls_diagnostics}/src/advice.rs (98%) rename crates/{pgt_diagnostics => pgls_diagnostics}/src/context.rs (99%) rename crates/{pgt_diagnostics => pgls_diagnostics}/src/diagnostic.rs (98%) rename crates/{pgt_diagnostics => pgls_diagnostics}/src/display.rs (98%) rename crates/{pgt_diagnostics => pgls_diagnostics}/src/display/backtrace.rs (99%) rename crates/{pgt_diagnostics => pgls_diagnostics}/src/display/diff.rs (99%) rename crates/{pgt_diagnostics => pgls_diagnostics}/src/display/frame.rs (99%) rename crates/{pgt_diagnostics => pgls_diagnostics}/src/display/message.rs (92%) rename crates/{pgt_diagnostics => pgls_diagnostics}/src/display_github.rs (97%) rename crates/{pgt_diagnostics => pgls_diagnostics}/src/error.rs (99%) rename crates/{pgt_diagnostics => pgls_diagnostics}/src/lib.rs (88%) rename crates/{pgt_diagnostics => pgls_diagnostics}/src/location.rs (99%) rename crates/{pgt_diagnostics => pgls_diagnostics}/src/panic.rs (100%) rename crates/{pgt_diagnostics => pgls_diagnostics}/src/serde.rs (98%) rename crates/{pgt_diagnostics => pgls_diagnostics}/src/suggestion.rs (91%) rename crates/{pgt_diagnostics_categories => pgls_diagnostics_categories}/Cargo.toml (90%) rename crates/{pgt_diagnostics_categories => pgls_diagnostics_categories}/build.rs (93%) create mode 100644 crates/pgls_diagnostics_categories/src/categories.rs rename crates/{pgt_diagnostics_categories => pgls_diagnostics_categories}/src/lib.rs (96%) rename crates/{pgt_diagnostics_macros => pgls_diagnostics_macros}/Cargo.toml (91%) rename crates/{pgt_diagnostics_macros => pgls_diagnostics_macros}/src/generate.rs (69%) rename crates/{pgt_diagnostics_macros => pgls_diagnostics_macros}/src/lib.rs (100%) rename crates/{pgt_diagnostics_macros => pgls_diagnostics_macros}/src/parse.rs (100%) rename crates/{pgt_flags => pgls_flags}/Cargo.toml (81%) rename crates/{pgt_flags => pgls_flags}/src/lib.rs (96%) create mode 100644 crates/pgls_fs/Cargo.toml rename crates/{pgt_fs => pgls_fs}/src/dir.rs (100%) rename crates/{pgt_fs => pgls_fs}/src/fs.rs (97%) rename crates/{pgt_fs => pgls_fs}/src/fs/memory.rs (95%) rename crates/{pgt_fs => pgls_fs}/src/fs/os.rs (97%) rename crates/{pgt_fs => pgls_fs}/src/interner.rs (100%) rename crates/{pgt_fs => pgls_fs}/src/lib.rs (89%) rename crates/{pgt_fs => pgls_fs}/src/path.rs (90%) create mode 100644 crates/pgls_hover/Cargo.toml rename crates/{pgt_hover => pgls_hover}/src/contextual_priority.rs (96%) rename crates/{pgt_hover => pgls_hover}/src/hoverables/column.rs (95%) rename crates/{pgt_hover => pgls_hover}/src/hoverables/function.rs (80%) rename crates/{pgt_hover => pgls_hover}/src/hoverables/mod.rs (79%) rename crates/{pgt_hover => pgls_hover}/src/hoverables/role.rs (95%) rename crates/{pgt_hover => pgls_hover}/src/hoverables/schema.rs (96%) rename crates/{pgt_hover => pgls_hover}/src/hoverables/table.rs (85%) rename crates/{pgt_hover => pgls_hover}/src/hoverables/test_helper.rs (67%) rename crates/{pgt_hover => pgls_hover}/src/hovered_node.rs (97%) rename crates/{pgt_hover => pgls_hover}/src/lib.rs (94%) rename crates/{pgt_hover => pgls_hover}/src/to_markdown.rs (100%) rename crates/{pgt_hover => pgls_hover}/tests/hover_integration_tests.rs (89%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/builtin_count.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/builtin_max.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/builtin_now.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/column_hover.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/column_hover_join.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/column_hover_quoted_column_name.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/column_hover_quoted_column_name_with_table.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/column_hover_quoted_schema_table.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/create_policy.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/custom_function.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/function_hover_quoted_schema.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/function_with_schema.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/grant_select.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/hover_on_schemas.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/lenghty_function.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/no_hover_keyword.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/revoke_select.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/role_alter.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/role_create.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/table_hover.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/table_hover_quoted_schema.snap (100%) rename crates/{pgt_hover => pgls_hover}/tests/snapshots/table_hover_quoted_table_name.snap (100%) rename crates/{pgt_lexer => pgls_lexer}/Cargo.toml (65%) rename crates/{pgt_lexer => pgls_lexer}/README.md (100%) rename crates/{pgt_lexer => pgls_lexer}/src/codegen/mod.rs (100%) create mode 100644 crates/pgls_lexer/src/codegen/syntax_kind.rs rename crates/{pgt_lexer => pgls_lexer}/src/lexed.rs (96%) rename crates/{pgt_lexer => pgls_lexer}/src/lexer.rs (57%) rename crates/{pgt_lexer => pgls_lexer}/src/lib.rs (100%) rename crates/{pgt_lexer_codegen => pgls_lexer_codegen}/Cargo.toml (93%) rename crates/{pgt_lexer_codegen => pgls_lexer_codegen}/README.md (100%) rename crates/{pgt_lexer_codegen => pgls_lexer_codegen}/build.rs (100%) rename crates/{pgt_lexer_codegen => pgls_lexer_codegen}/src/keywords.rs (100%) rename crates/{pgt_lexer_codegen => pgls_lexer_codegen}/src/lib.rs (100%) rename crates/{pgt_lexer_codegen => pgls_lexer_codegen}/src/syntax_kind.rs (100%) rename crates/{pgt_lexer_codegen => pgls_lexer_codegen}/vendor/17-latest/kwlist.h (100%) create mode 100644 crates/pgls_lsp/Cargo.toml rename crates/{pgt_lsp => pgls_lsp}/src/adapters/from_lsp.rs (96%) rename crates/{pgt_lsp => pgls_lsp}/src/adapters/line_index.rs (99%) rename crates/{pgt_lsp => pgls_lsp}/src/adapters/mod.rs (99%) rename crates/{pgt_lsp => pgls_lsp}/src/adapters/to_lsp.rs (96%) rename crates/{pgt_lsp => pgls_lsp}/src/capabilities.rs (97%) rename crates/{pgt_lsp => pgls_lsp}/src/diagnostics.rs (82%) rename crates/{pgt_lsp => pgls_lsp}/src/documents.rs (100%) rename crates/{pgt_lsp => pgls_lsp}/src/handlers.rs (100%) rename crates/{pgt_lsp => pgls_lsp}/src/handlers/code_actions.rs (96%) rename crates/{pgt_lsp => pgls_lsp}/src/handlers/completions.rs (78%) rename crates/{pgt_lsp => pgls_lsp}/src/handlers/hover.rs (95%) rename crates/{pgt_lsp => pgls_lsp}/src/handlers/text_document.rs (98%) rename crates/{pgt_lsp => pgls_lsp}/src/lib.rs (100%) rename crates/{pgt_lsp => pgls_lsp}/src/server.rs (98%) rename crates/{pgt_lsp => pgls_lsp}/src/session.rs (95%) rename crates/{pgt_lsp => pgls_lsp}/src/utils.rs (96%) rename crates/{pgt_lsp => pgls_lsp}/tests/server.rs (96%) rename crates/{pgt_markup => pgls_markup}/Cargo.toml (92%) rename crates/{pgt_markup => pgls_markup}/README.md (100%) rename crates/{pgt_markup => pgls_markup}/src/lib.rs (95%) create mode 100644 crates/pgls_plpgsql_check/Cargo.toml rename crates/{pgt_plpgsql_check => pgls_plpgsql_check}/src/diagnostics.rs (98%) rename crates/{pgt_plpgsql_check => pgls_plpgsql_check}/src/lib.rs (91%) rename crates/{pgt_query => pgls_query}/Cargo.toml (89%) rename crates/{pgt_query => pgls_query}/build.rs (100%) rename crates/{pgt_query => pgls_query}/examples/api_example.rs (91%) rename crates/{pgt_query => pgls_query}/src/deparse.rs (98%) rename crates/{pgt_query => pgls_query}/src/error.rs (100%) rename crates/{pgt_query => pgls_query}/src/fingerprint.rs (99%) create mode 100644 crates/pgls_query/src/iter_mut.rs create mode 100644 crates/pgls_query/src/iter_ref.rs rename crates/{pgt_query => pgls_query}/src/lib.rs (100%) rename crates/{pgt_query => pgls_query}/src/node_enum.rs (95%) rename crates/{pgt_query => pgls_query}/src/node_mut.rs (94%) rename crates/{pgt_query => pgls_query}/src/node_ref.rs (94%) rename crates/{pgt_query => pgls_query}/src/node_structs.rs (90%) rename crates/{pgt_query => pgls_query}/src/normalize.rs (98%) rename crates/{pgt_query => pgls_query}/src/parse.rs (99%) rename crates/{pgt_query => pgls_query}/src/plpgsql.rs (96%) rename crates/{pgt_query => pgls_query}/src/protobuf.rs (100%) rename crates/{pgt_query => pgls_query}/src/scan.rs (93%) rename crates/{pgt_query => pgls_query}/src/split.rs (92%) rename crates/{pgt_query => pgls_query}/vendor/libpg_query (100%) rename crates/{pgt_query_ext => pgls_query_ext}/Cargo.toml (68%) rename crates/{pgt_query_ext => pgls_query_ext}/src/diagnostics.rs (83%) rename crates/{pgt_query_ext => pgls_query_ext}/src/lib.rs (100%) rename crates/{pgt_query_ext => pgls_query_ext}/src/utils.rs (79%) rename crates/{pgt_query_macros => pgls_query_macros}/Cargo.toml (92%) rename crates/{pgt_query_macros => pgls_query_macros}/build.rs (100%) rename crates/{pgt_query_macros => pgls_query_macros}/src/iter_mut.rs (100%) rename crates/{pgt_query_macros => pgls_query_macros}/src/iter_ref.rs (100%) rename crates/{pgt_query_macros => pgls_query_macros}/src/lib.rs (100%) rename crates/{pgt_query_macros => pgls_query_macros}/src/node_enum.rs (100%) rename crates/{pgt_query_macros => pgls_query_macros}/src/node_mut.rs (100%) rename crates/{pgt_query_macros => pgls_query_macros}/src/node_ref.rs (100%) rename crates/{pgt_query_macros => pgls_query_macros}/src/node_structs.rs (100%) rename crates/{pgt_query_macros => pgls_query_macros}/src/proto_analyser.rs (100%) rename crates/{pgt_query_macros => pgls_query_macros}/vendor/17-latest/pg_query.proto (100%) create mode 100644 crates/pgls_schema_cache/Cargo.toml rename crates/{pgt_schema_cache => pgls_schema_cache}/src/columns.rs (99%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/extensions.rs (100%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/functions.rs (99%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/lib.rs (100%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/policies.rs (99%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/queries/columns.sql (100%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/queries/extensions.sql (100%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/queries/functions.sql (100%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/queries/policies.sql (100%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/queries/roles.sql (100%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/queries/schemas.sql (100%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/queries/tables.sql (100%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/queries/triggers.sql (100%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/queries/types.sql (100%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/queries/versions.sql (100%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/roles.rs (94%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/schema_cache.rs (98%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/schemas.rs (100%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/tables.rs (96%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/triggers.rs (98%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/types.rs (100%) rename crates/{pgt_schema_cache => pgls_schema_cache}/src/versions.rs (100%) rename crates/{pgt_statement_splitter => pgls_statement_splitter}/Cargo.toml (63%) rename crates/{pgt_statement_splitter => pgls_statement_splitter}/benches/splitter.rs (98%) rename crates/{pgt_statement_splitter => pgls_statement_splitter}/src/diagnostics.rs (90%) rename crates/{pgt_statement_splitter => pgls_statement_splitter}/src/lib.rs (99%) rename crates/{pgt_statement_splitter => pgls_statement_splitter}/src/splitter.rs (98%) rename crates/{pgt_statement_splitter => pgls_statement_splitter}/src/splitter/common.rs (99%) rename crates/{pgt_statement_splitter => pgls_statement_splitter}/src/splitter/data.rs (96%) rename crates/{pgt_statement_splitter => pgls_statement_splitter}/src/splitter/ddl.rs (91%) rename crates/{pgt_statement_splitter => pgls_statement_splitter}/src/splitter/dml.rs (97%) rename crates/{pgt_statement_splitter => pgls_statement_splitter}/tests/data/grant_statements__4.sql (100%) rename crates/{pgt_statement_splitter => pgls_statement_splitter}/tests/data/on_conflict_do_update__1.sql (100%) rename crates/{pgt_statement_splitter => pgls_statement_splitter}/tests/data/simple_select__4.sql (100%) rename crates/{pgt_statement_splitter => pgls_statement_splitter}/tests/data/simple_union__4.sql (100%) rename crates/{pgt_statement_splitter => pgls_statement_splitter}/tests/data/with_comments__4.sql (100%) rename crates/{pgt_statement_splitter => pgls_statement_splitter}/tests/statement_splitter_tests.rs (93%) rename crates/{pgt_suppressions => pgls_suppressions}/Cargo.toml (66%) rename crates/{pgt_suppressions => pgls_suppressions}/src/lib.rs (97%) rename crates/{pgt_suppressions => pgls_suppressions}/src/line_index.rs (87%) rename crates/{pgt_suppressions => pgls_suppressions}/src/parser.rs (99%) rename crates/{pgt_suppressions => pgls_suppressions}/src/suppression.rs (97%) rename crates/{pgt_test_macros => pgls_test_macros}/Cargo.toml (92%) rename crates/{pgt_test_macros => pgls_test_macros}/README.md (100%) rename crates/{pgt_test_macros => pgls_test_macros}/src/lib.rs (100%) rename crates/{pgt_test_utils => pgls_test_utils}/Cargo.toml (75%) rename crates/{pgt_test_utils => pgls_test_utils}/src/bin/tree_print.rs (94%) rename crates/{pgt_test_utils => pgls_test_utils}/src/lib.rs (100%) rename crates/{pgt_test_utils => pgls_test_utils}/testdb_migrations/0001_setup-roles.sql (100%) create mode 100644 crates/pgls_text_edit/Cargo.toml rename crates/{pgt_text_edit => pgls_text_edit}/src/lib.rs (99%) rename crates/{pgt_text_size => pgls_text_size}/Cargo.toml (94%) rename crates/{pgt_text_size => pgls_text_size}/src/lib.rs (100%) rename crates/{pgt_text_size => pgls_text_size}/src/range.rs (96%) rename crates/{pgt_text_size => pgls_text_size}/src/schemars_impls.rs (100%) rename crates/{pgt_text_size => pgls_text_size}/src/serde_impls.rs (100%) rename crates/{pgt_text_size => pgls_text_size}/src/size.rs (99%) rename crates/{pgt_text_size => pgls_text_size}/src/traits.rs (100%) rename crates/{pgt_text_size => pgls_text_size}/tests/auto_traits.rs (95%) rename crates/{pgt_text_size => pgls_text_size}/tests/constructors.rs (93%) rename crates/{pgt_text_size => pgls_text_size}/tests/indexing.rs (82%) rename crates/{pgt_text_size => pgls_text_size}/tests/main.rs (98%) rename crates/{pgt_text_size => pgls_text_size}/tests/serde.rs (97%) rename crates/{pgt_tokenizer => pgls_tokenizer}/Cargo.toml (89%) rename crates/{pgt_tokenizer => pgls_tokenizer}/README.md (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/cursor.rs (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/lib.rs (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__bitstring.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__block_comment.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__block_comment_unterminated.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__dollar_quote_mismatch_tags_complex.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__dollar_quote_mismatch_tags_simple.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__dollar_quoting.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__dollar_strings_part2.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__graphile_named_param.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__lex_statement.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__line_comment.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__line_comment_whitespace.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__named_param_at.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__named_param_colon_identifier.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__named_param_colon_raw.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__named_param_colon_raw_vs_cast.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__named_param_colon_string.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__named_param_dollar_raw.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__numeric.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__numeric_non_decimal.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__numeric_with_seperators.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__params.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__quoted_ident.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__quoted_ident_with_escape_quote.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__select_with_period.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__string.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__string_unicode_escape.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/snapshots/pgt_tokenizer__tests__string_with_escapes.snap (100%) rename crates/{pgt_tokenizer => pgls_tokenizer}/src/token.rs (100%) rename crates/{pgt_treesitter => pgls_treesitter}/Cargo.toml (51%) rename crates/{pgt_treesitter => pgls_treesitter}/src/context/base_parser.rs (99%) rename crates/{pgt_treesitter => pgls_treesitter}/src/context/grant_parser.rs (98%) rename crates/{pgt_treesitter => pgls_treesitter}/src/context/mod.rs (99%) rename crates/{pgt_treesitter => pgls_treesitter}/src/context/policy_parser.rs (99%) rename crates/{pgt_treesitter => pgls_treesitter}/src/context/revoke_parser.rs (98%) rename crates/{pgt_treesitter => pgls_treesitter}/src/lib.rs (100%) rename crates/{pgt_treesitter => pgls_treesitter}/src/queries/insert_columns.rs (93%) rename crates/{pgt_treesitter => pgls_treesitter}/src/queries/mod.rs (97%) rename crates/{pgt_treesitter => pgls_treesitter}/src/queries/parameters.rs (96%) rename crates/{pgt_treesitter => pgls_treesitter}/src/queries/relations.rs (93%) rename crates/{pgt_treesitter => pgls_treesitter}/src/queries/select_columns.rs (95%) rename crates/{pgt_treesitter => pgls_treesitter}/src/queries/table_aliases.rs (97%) rename crates/{pgt_treesitter => pgls_treesitter}/src/queries/where_columns.rs (96%) rename crates/{pgt_treesitter_grammar => pgls_treesitter_grammar}/.editorconfig (100%) rename crates/{pgt_treesitter_grammar => pgls_treesitter_grammar}/.gitattributes (100%) rename crates/{pgt_treesitter_grammar => pgls_treesitter_grammar}/.gitignore (100%) rename crates/{pgt_treesitter_grammar => pgls_treesitter_grammar}/Cargo.toml (93%) rename crates/{pgt_treesitter_grammar => pgls_treesitter_grammar}/NOTICE (100%) rename crates/{pgt_treesitter_grammar => pgls_treesitter_grammar}/build.rs (100%) rename crates/{pgt_treesitter_grammar => pgls_treesitter_grammar}/grammar.js (100%) rename crates/{pgt_treesitter_grammar => pgls_treesitter_grammar}/package-lock.json (100%) rename crates/{pgt_treesitter_grammar => pgls_treesitter_grammar}/package.json (100%) rename crates/{pgt_treesitter_grammar => pgls_treesitter_grammar}/src/grammar.json (100%) rename crates/{pgt_treesitter_grammar => pgls_treesitter_grammar}/src/lib.rs (97%) rename crates/{pgt_treesitter_grammar => pgls_treesitter_grammar}/src/node-types.json (100%) rename crates/{pgt_treesitter_grammar => pgls_treesitter_grammar}/src/parser.c (100%) rename crates/{pgt_treesitter_grammar => pgls_treesitter_grammar}/src/scanner.c (100%) rename crates/{pgt_treesitter_grammar => pgls_treesitter_grammar}/src/tree_sitter/alloc.h (100%) rename crates/{pgt_treesitter_grammar => pgls_treesitter_grammar}/src/tree_sitter/array.h (100%) rename crates/{pgt_treesitter_grammar => pgls_treesitter_grammar}/src/tree_sitter/parser.h (100%) rename crates/{pgt_treesitter_grammar => pgls_treesitter_grammar}/tree-sitter.json (100%) rename crates/{pgt_type_resolver => pgls_type_resolver}/Cargo.toml (74%) rename crates/{pgt_type_resolver => pgls_type_resolver}/src/functions.rs (92%) rename crates/{pgt_type_resolver => pgls_type_resolver}/src/lib.rs (100%) rename crates/{pgt_type_resolver => pgls_type_resolver}/src/types.rs (82%) create mode 100644 crates/pgls_type_resolver/src/util.rs create mode 100644 crates/pgls_typecheck/Cargo.toml rename crates/{pgt_typecheck => pgls_typecheck}/src/diagnostics.rs (97%) rename crates/{pgt_typecheck => pgls_typecheck}/src/lib.rs (89%) rename crates/{pgt_typecheck => pgls_typecheck}/src/typed_identifier.rs (96%) rename crates/{pgt_typecheck => pgls_typecheck}/tests/diagnostics.rs (83%) rename crates/{pgt_typecheck => pgls_typecheck}/tests/snapshots/invalid_column.snap (100%) create mode 100644 crates/pgls_workspace/Cargo.toml rename crates/{pgt_workspace => pgls_workspace}/src/configuration.rs (95%) rename crates/{pgt_workspace => pgls_workspace}/src/diagnostics.rs (96%) rename crates/{pgt_workspace => pgls_workspace}/src/dome.rs (74%) rename crates/{pgt_workspace => pgls_workspace}/src/features/code_actions.rs (93%) rename crates/{pgt_workspace => pgls_workspace}/src/features/completions.rs (96%) rename crates/{pgt_workspace => pgls_workspace}/src/features/diagnostics.rs (73%) rename crates/{pgt_workspace => pgls_workspace}/src/features/mod.rs (100%) rename crates/{pgt_workspace => pgls_workspace}/src/features/on_hover.rs (89%) rename crates/{pgt_workspace => pgls_workspace}/src/lib.rs (97%) rename crates/{pgt_workspace => pgls_workspace}/src/matcher/LICENCE-APACHE (100%) rename crates/{pgt_workspace => pgls_workspace}/src/matcher/LICENSE-MIT (100%) rename crates/{pgt_workspace => pgls_workspace}/src/matcher/mod.rs (97%) rename crates/{pgt_workspace => pgls_workspace}/src/matcher/pattern.rs (100%) rename crates/{pgt_workspace => pgls_workspace}/src/settings.rs (96%) rename crates/{pgt_workspace => pgls_workspace}/src/workspace.rs (97%) rename crates/{pgt_workspace => pgls_workspace}/src/workspace/client.rs (98%) rename crates/{pgt_workspace => pgls_workspace}/src/workspace/server.rs (96%) rename crates/{pgt_workspace => pgls_workspace}/src/workspace/server.tests.rs (94%) rename crates/{pgt_workspace => pgls_workspace}/src/workspace/server/analyser.rs (92%) rename crates/{pgt_workspace => pgls_workspace}/src/workspace/server/annotation.rs (97%) rename crates/{pgt_workspace => pgls_workspace}/src/workspace/server/async_helper.rs (100%) rename crates/{pgt_workspace => pgls_workspace}/src/workspace/server/connection_key.rs (100%) rename crates/{pgt_workspace => pgls_workspace}/src/workspace/server/connection_manager.rs (100%) rename crates/{pgt_workspace => pgls_workspace}/src/workspace/server/document.rs (97%) rename crates/{pgt_workspace => pgls_workspace}/src/workspace/server/migration.rs (100%) rename crates/{pgt_workspace => pgls_workspace}/src/workspace/server/pg_query.rs (87%) rename crates/{pgt_workspace => pgls_workspace}/src/workspace/server/schema_cache_manager.rs (97%) rename crates/{pgt_workspace => pgls_workspace}/src/workspace/server/sql_function.rs (78%) rename crates/{pgt_workspace => pgls_workspace}/src/workspace/server/statement_identifier.rs (100%) rename crates/{pgt_workspace => pgls_workspace}/src/workspace/server/tree_sitter.rs (95%) rename crates/{pgt_workspace => pgls_workspace}/src/workspace_types.rs (100%) rename crates/{pgt_workspace_macros => pgls_workspace_macros}/Cargo.toml (90%) rename crates/{pgt_workspace_macros => pgls_workspace_macros}/src/lib.rs (98%) delete mode 100644 crates/pgt_analyser/Cargo.toml delete mode 100644 crates/pgt_analyser/src/lint.rs delete mode 100644 crates/pgt_completions/Cargo.toml delete mode 100644 crates/pgt_completions/src/relevance.rs delete mode 100644 crates/pgt_diagnostics/Cargo.toml delete mode 100644 crates/pgt_diagnostics_categories/src/categories.rs delete mode 100644 crates/pgt_fs/Cargo.toml delete mode 100644 crates/pgt_hover/Cargo.toml delete mode 100644 crates/pgt_lexer/src/codegen/syntax_kind.rs delete mode 100644 crates/pgt_lsp/Cargo.toml delete mode 100644 crates/pgt_plpgsql_check/Cargo.toml delete mode 100644 crates/pgt_query/src/iter_mut.rs delete mode 100644 crates/pgt_query/src/iter_ref.rs delete mode 100644 crates/pgt_schema_cache/Cargo.toml delete mode 100644 crates/pgt_text_edit/Cargo.toml delete mode 100644 crates/pgt_type_resolver/src/util.rs delete mode 100644 crates/pgt_typecheck/Cargo.toml delete mode 100644 crates/pgt_workspace/Cargo.toml rename packages/{@postgrestools => @pgls}/backend-jsonrpc/package.json (63%) rename packages/{@postgrestools => @pgls}/backend-jsonrpc/src/command.ts (100%) rename packages/{@postgrestools => @pgls}/backend-jsonrpc/src/index.ts (100%) rename packages/{@postgrestools => @pgls}/backend-jsonrpc/src/socket.ts (100%) rename packages/{@postgrestools => @pgls}/backend-jsonrpc/src/transport.ts (100%) rename packages/{@postgrestools => @pgls}/backend-jsonrpc/src/workspace.ts (97%) rename packages/{@postgrestools => @pgls}/backend-jsonrpc/tests/transport.test.mjs (100%) rename packages/{@postgrestools => @pgls}/backend-jsonrpc/tests/workspace.test.mjs (100%) rename packages/{@postgrestools/postgrestools/bin/postgrestools => @pgls/cli/bin/pgls} (100%) rename packages/{@postgrestools/postgrestools => @pgls/cli}/package.json (56%) rename packages/{@postgrestools/postgrestools => @pgls/cli}/scripts/generate-packages.mjs (100%) diff --git a/CLAUDE.md b/CLAUDE.md index 057163a94..cb1b956ee 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -62,11 +62,11 @@ just new-crate ``` ### CLI Usage -The main CLI binary is `postgrestools`: +The main CLI binary is `pgls`: ```bash cargo run -p pgt_cli -- check file.sql # or after building: -./target/release/postgrestools check file.sql +./target/release/pgls check file.sql ``` ## Architecture diff --git a/Cargo.lock b/Cargo.lock index 48efd88ff..b92af98b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1292,17 +1292,17 @@ dependencies = [ "anyhow", "biome_string_case", "bpaf", - "pgt_analyse", - "pgt_analyser", - "pgt_cli", - "pgt_configuration", - "pgt_console", - "pgt_diagnostics", - "pgt_flags", - "pgt_query", - "pgt_query_ext", - "pgt_statement_splitter", - "pgt_workspace", + "pgls_analyse", + "pgls_analyser", + "pgls_cli", + "pgls_configuration", + "pgls_console", + "pgls_diagnostics", + "pgls_flags", + "pgls_query", + "pgls_query_ext", + "pgls_statement_splitter", + "pgls_workspace", "pulldown-cmark", "regex", "schemars", @@ -2733,42 +2733,42 @@ dependencies = [ ] [[package]] -name = "pgt_analyse" +name = "pgls_analyse" version = "0.0.0" dependencies = [ "biome_deserialize 0.6.0", "biome_deserialize_macros 0.6.0", "enumflags2", - "pgt_console", - "pgt_diagnostics", - "pgt_query", - "pgt_schema_cache", - "pgt_text_size", + "pgls_console", + "pgls_diagnostics", + "pgls_query", + "pgls_schema_cache", + "pgls_text_size", "rustc-hash 2.1.0", "schemars", "serde", ] [[package]] -name = "pgt_analyser" +name = "pgls_analyser" version = "0.0.0" dependencies = [ "insta", - "pgt_analyse", - "pgt_console", - "pgt_diagnostics", - "pgt_query", - "pgt_query_ext", - "pgt_schema_cache", - "pgt_statement_splitter", - "pgt_test_macros", - "pgt_text_size", + "pgls_analyse", + "pgls_console", + "pgls_diagnostics", + "pgls_query", + "pgls_query_ext", + "pgls_schema_cache", + "pgls_statement_splitter", + "pgls_test_macros", + "pgls_text_size", "serde", "termcolor", ] [[package]] -name = "pgt_cli" +name = "pgls_cli" version = "0.0.0" dependencies = [ "anyhow", @@ -2782,15 +2782,15 @@ dependencies = [ "libc", "mimalloc", "path-absolutize", - "pgt_analyse", - "pgt_configuration", - "pgt_console", - "pgt_diagnostics", - "pgt_flags", - "pgt_fs", - "pgt_lsp", - "pgt_text_edit", - "pgt_workspace", + "pgls_analyse", + "pgls_configuration", + "pgls_console", + "pgls_diagnostics", + "pgls_flags", + "pgls_fs", + "pgls_lsp", + "pgls_text_edit", + "pgls_workspace", "predicates", "quick-junit", "rayon", @@ -2807,17 +2807,17 @@ dependencies = [ ] [[package]] -name = "pgt_completions" +name = "pgls_completions" version = "0.0.0" dependencies = [ "async-std", "criterion 0.5.1", "fuzzy-matcher", - "pgt_schema_cache", - "pgt_test_utils", - "pgt_text_size", - "pgt_treesitter", - "pgt_treesitter_grammar", + "pgls_schema_cache", + "pgls_test_utils", + "pgls_text_size", + "pgls_treesitter", + "pgls_treesitter_grammar", "schemars", "serde", "serde_json", @@ -2828,7 +2828,7 @@ dependencies = [ ] [[package]] -name = "pgt_configuration" +name = "pgls_configuration" version = "0.0.0" dependencies = [ "biome_deserialize 0.6.0", @@ -2836,11 +2836,11 @@ dependencies = [ "bpaf", "indexmap 2.7.0", "oxc_resolver", - "pgt_analyse", - "pgt_analyser", - "pgt_console", - "pgt_diagnostics", - "pgt_text_size", + "pgls_analyse", + "pgls_analyser", + "pgls_console", + "pgls_diagnostics", + "pgls_text_size", "rustc-hash 2.1.0", "schemars", "serde", @@ -2848,11 +2848,11 @@ dependencies = [ ] [[package]] -name = "pgt_console" +name = "pgls_console" version = "0.0.0" dependencies = [ - "pgt_markup", - "pgt_text_size", + "pgls_markup", + "pgls_text_size", "schemars", "serde", "termcolor", @@ -2862,18 +2862,18 @@ dependencies = [ ] [[package]] -name = "pgt_diagnostics" +name = "pgls_diagnostics" version = "0.0.0" dependencies = [ "backtrace", "bpaf", "enumflags2", "oxc_resolver", - "pgt_console", - "pgt_diagnostics_categories", - "pgt_diagnostics_macros", - "pgt_text_edit", - "pgt_text_size", + "pgls_console", + "pgls_diagnostics_categories", + "pgls_diagnostics_macros", + "pgls_text_edit", + "pgls_text_size", "schemars", "serde", "serde_json", @@ -2882,7 +2882,7 @@ dependencies = [ ] [[package]] -name = "pgt_diagnostics_categories" +name = "pgls_diagnostics_categories" version = "0.0.0" dependencies = [ "quote", @@ -2891,7 +2891,7 @@ dependencies = [ ] [[package]] -name = "pgt_diagnostics_macros" +name = "pgls_diagnostics_macros" version = "0.0.0" dependencies = [ "proc-macro-error", @@ -2901,14 +2901,14 @@ dependencies = [ ] [[package]] -name = "pgt_flags" +name = "pgls_flags" version = "0.0.0" dependencies = [ - "pgt_console", + "pgls_console", ] [[package]] -name = "pgt_fs" +name = "pgls_fs" version = "0.0.0" dependencies = [ "crossbeam", @@ -2916,7 +2916,7 @@ dependencies = [ "enumflags2", "oxc_resolver", "parking_lot", - "pgt_diagnostics", + "pgls_diagnostics", "rayon", "rustc-hash 2.1.0", "schemars", @@ -2926,17 +2926,17 @@ dependencies = [ ] [[package]] -name = "pgt_hover" +name = "pgls_hover" version = "0.0.0" dependencies = [ "humansize", "insta", - "pgt_query", - "pgt_schema_cache", - "pgt_test_utils", - "pgt_text_size", - "pgt_treesitter", - "pgt_treesitter_grammar", + "pgls_query", + "pgls_schema_cache", + "pgls_test_utils", + "pgls_text_size", + "pgls_treesitter", + "pgls_treesitter_grammar", "schemars", "serde", "serde_json", @@ -2947,18 +2947,18 @@ dependencies = [ ] [[package]] -name = "pgt_lexer" +name = "pgls_lexer" version = "0.0.0" dependencies = [ "insta", - "pgt_diagnostics", - "pgt_lexer_codegen", - "pgt_text_size", - "pgt_tokenizer", + "pgls_diagnostics", + "pgls_lexer_codegen", + "pgls_text_size", + "pgls_tokenizer", ] [[package]] -name = "pgt_lexer_codegen" +name = "pgls_lexer_codegen" version = "0.0.0" dependencies = [ "anyhow", @@ -2971,22 +2971,22 @@ dependencies = [ ] [[package]] -name = "pgt_lsp" +name = "pgls_lsp" version = "0.0.0" dependencies = [ "anyhow", "biome_deserialize 0.6.0", "futures", - "pgt_analyse", - "pgt_completions", - "pgt_configuration", - "pgt_console", - "pgt_diagnostics", - "pgt_fs", - "pgt_test_utils", - "pgt_text_edit", - "pgt_text_size", - "pgt_workspace", + "pgls_analyse", + "pgls_completions", + "pgls_configuration", + "pgls_console", + "pgls_diagnostics", + "pgls_fs", + "pgls_test_utils", + "pgls_text_edit", + "pgls_text_size", + "pgls_workspace", "rustc-hash 2.1.0", "serde", "serde_json", @@ -3000,7 +3000,7 @@ dependencies = [ ] [[package]] -name = "pgt_markup" +name = "pgls_markup" version = "0.0.0" dependencies = [ "proc-macro-error", @@ -3009,16 +3009,16 @@ dependencies = [ ] [[package]] -name = "pgt_plpgsql_check" +name = "pgls_plpgsql_check" version = "0.0.0" dependencies = [ - "pgt_console", - "pgt_diagnostics", - "pgt_query", - "pgt_query_ext", - "pgt_schema_cache", - "pgt_test_utils", - "pgt_text_size", + "pgls_console", + "pgls_diagnostics", + "pgls_query", + "pgls_query_ext", + "pgls_schema_cache", + "pgls_test_utils", + "pgls_text_size", "regex", "serde", "serde_json", @@ -3027,7 +3027,7 @@ dependencies = [ ] [[package]] -name = "pgt_query" +name = "pgls_query" version = "0.0.0" dependencies = [ "bindgen", @@ -3036,7 +3036,7 @@ dependencies = [ "easy-parallel", "fs_extra", "glob", - "pgt_query_macros", + "pgls_query_macros", "prost", "prost-build", "thiserror 1.0.69", @@ -3044,16 +3044,16 @@ dependencies = [ ] [[package]] -name = "pgt_query_ext" +name = "pgls_query_ext" version = "0.0.0" dependencies = [ - "pgt_diagnostics", - "pgt_query", - "pgt_text_size", + "pgls_diagnostics", + "pgls_query", + "pgls_text_size", ] [[package]] -name = "pgt_query_macros" +name = "pgls_query_macros" version = "0.0.0" dependencies = [ "convert_case", @@ -3065,15 +3065,15 @@ dependencies = [ ] [[package]] -name = "pgt_schema_cache" +name = "pgls_schema_cache" version = "0.0.0" dependencies = [ "anyhow", "async-std", "futures-util", - "pgt_console", - "pgt_diagnostics", - "pgt_test_utils", + "pgls_console", + "pgls_diagnostics", + "pgls_test_utils", "serde", "serde_json", "sqlx", @@ -3082,30 +3082,30 @@ dependencies = [ ] [[package]] -name = "pgt_statement_splitter" +name = "pgls_statement_splitter" version = "0.0.0" dependencies = [ "criterion 0.3.6", "ntest", - "pgt_diagnostics", - "pgt_lexer", - "pgt_query", - "pgt_text_size", + "pgls_diagnostics", + "pgls_lexer", + "pgls_query", + "pgls_text_size", "regex", ] [[package]] -name = "pgt_suppressions" +name = "pgls_suppressions" version = "0.0.0" dependencies = [ - "pgt_analyse", - "pgt_diagnostics", - "pgt_text_size", + "pgls_analyse", + "pgls_diagnostics", + "pgls_text_size", "tracing", ] [[package]] -name = "pgt_test_macros" +name = "pgls_test_macros" version = "0.0.0" dependencies = [ "globwalk", @@ -3116,30 +3116,30 @@ dependencies = [ ] [[package]] -name = "pgt_test_utils" +name = "pgls_test_utils" version = "0.0.0" dependencies = [ "anyhow", "clap 4.5.23", "dotenv", - "pgt_treesitter_grammar", + "pgls_treesitter_grammar", "sqlx", "tree-sitter", "uuid", ] [[package]] -name = "pgt_text_edit" +name = "pgls_text_edit" version = "0.0.0" dependencies = [ - "pgt_text_size", + "pgls_text_size", "schemars", "serde", "similar", ] [[package]] -name = "pgt_text_size" +name = "pgls_text_size" version = "0.0.0" dependencies = [ "schemars", @@ -3149,26 +3149,26 @@ dependencies = [ ] [[package]] -name = "pgt_tokenizer" +name = "pgls_tokenizer" version = "0.0.0" dependencies = [ "insta", ] [[package]] -name = "pgt_treesitter" +name = "pgls_treesitter" version = "0.0.0" dependencies = [ "clap 4.5.23", - "pgt_schema_cache", - "pgt_test_utils", - "pgt_text_size", - "pgt_treesitter_grammar", + "pgls_schema_cache", + "pgls_test_utils", + "pgls_text_size", + "pgls_treesitter_grammar", "tree-sitter", ] [[package]] -name = "pgt_treesitter_grammar" +name = "pgls_treesitter_grammar" version = "0.0.0" dependencies = [ "cc", @@ -3177,35 +3177,35 @@ dependencies = [ ] [[package]] -name = "pgt_type_resolver" +name = "pgls_type_resolver" version = "0.0.0" dependencies = [ - "pgt_query", - "pgt_schema_cache", + "pgls_query", + "pgls_schema_cache", ] [[package]] -name = "pgt_typecheck" +name = "pgls_typecheck" version = "0.0.0" dependencies = [ "globset", "insta", "itertools 0.14.0", - "pgt_console", - "pgt_diagnostics", - "pgt_query", - "pgt_schema_cache", - "pgt_test_utils", - "pgt_text_size", - "pgt_treesitter", - "pgt_treesitter_grammar", + "pgls_console", + "pgls_diagnostics", + "pgls_query", + "pgls_schema_cache", + "pgls_test_utils", + "pgls_text_size", + "pgls_treesitter", + "pgls_treesitter_grammar", "sqlx", "tokio", "tree-sitter", ] [[package]] -name = "pgt_workspace" +name = "pgls_workspace" version = "0.0.0" dependencies = [ "biome_deserialize 0.6.0", @@ -3216,27 +3216,27 @@ dependencies = [ "globset", "ignore", "lru", - "pgt_analyse", - "pgt_analyser", - "pgt_completions", - "pgt_configuration", - "pgt_console", - "pgt_diagnostics", - "pgt_fs", - "pgt_hover", - "pgt_lexer", - "pgt_plpgsql_check", - "pgt_query", - "pgt_query_ext", - "pgt_schema_cache", - "pgt_statement_splitter", - "pgt_suppressions", - "pgt_test_utils", - "pgt_text_size", - "pgt_tokenizer", - "pgt_treesitter_grammar", - "pgt_typecheck", - "pgt_workspace_macros", + "pgls_analyse", + "pgls_analyser", + "pgls_completions", + "pgls_configuration", + "pgls_console", + "pgls_diagnostics", + "pgls_fs", + "pgls_hover", + "pgls_lexer", + "pgls_plpgsql_check", + "pgls_query", + "pgls_query_ext", + "pgls_schema_cache", + "pgls_statement_splitter", + "pgls_suppressions", + "pgls_test_utils", + "pgls_text_size", + "pgls_tokenizer", + "pgls_treesitter_grammar", + "pgls_typecheck", + "pgls_workspace_macros", "regex", "rustc-hash 2.1.0", "schemars", @@ -3252,7 +3252,7 @@ dependencies = [ ] [[package]] -name = "pgt_workspace_macros" +name = "pgls_workspace_macros" version = "0.0.0" dependencies = [ "proc-macro2", @@ -3799,14 +3799,14 @@ name = "rules_check" version = "0.0.0" dependencies = [ "anyhow", - "pgt_analyse", - "pgt_analyser", - "pgt_console", - "pgt_diagnostics", - "pgt_query", - "pgt_query_ext", - "pgt_statement_splitter", - "pgt_workspace", + "pgls_analyse", + "pgls_analyser", + "pgls_console", + "pgls_diagnostics", + "pgls_query", + "pgls_query_ext", + "pgls_statement_splitter", + "pgls_workspace", "pulldown-cmark", ] @@ -5659,10 +5659,10 @@ dependencies = [ "biome_rowan", "biome_string_case", "bpaf", - "pgt_analyse", - "pgt_analyser", - "pgt_diagnostics", - "pgt_workspace", + "pgls_analyse", + "pgls_analyser", + "pgls_diagnostics", + "pgls_workspace", "proc-macro2", "pulldown-cmark", "quote", diff --git a/Cargo.toml b/Cargo.toml index b7963b865..4a66bd2bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,40 +60,40 @@ tree-sitter = "0.25.9" unicode-width = "0.1.12" # postgres specific crates -pgt_analyse = { path = "./crates/pgt_analyse", version = "0.0.0" } -pgt_analyser = { path = "./crates/pgt_analyser", version = "0.0.0" } -pgt_cli = { path = "./crates/pgt_cli", version = "0.0.0" } -pgt_completions = { path = "./crates/pgt_completions", version = "0.0.0" } -pgt_configuration = { path = "./crates/pgt_configuration", version = "0.0.0" } -pgt_console = { path = "./crates/pgt_console", version = "0.0.0" } -pgt_diagnostics = { path = "./crates/pgt_diagnostics", version = "0.0.0" } -pgt_diagnostics_categories = { path = "./crates/pgt_diagnostics_categories", version = "0.0.0" } -pgt_diagnostics_macros = { path = "./crates/pgt_diagnostics_macros", version = "0.0.0" } -pgt_flags = { path = "./crates/pgt_flags", version = "0.0.0" } -pgt_fs = { path = "./crates/pgt_fs", version = "0.0.0" } -pgt_hover = { path = "./crates/pgt_hover", version = "0.0.0" } -pgt_lexer = { path = "./crates/pgt_lexer", version = "0.0.0" } -pgt_lexer_codegen = { path = "./crates/pgt_lexer_codegen", version = "0.0.0" } -pgt_lsp = { path = "./crates/pgt_lsp", version = "0.0.0" } -pgt_markup = { path = "./crates/pgt_markup", version = "0.0.0" } -pgt_plpgsql_check = { path = "./crates/pgt_plpgsql_check", version = "0.0.0" } -pgt_query = { path = "./crates/pgt_query", version = "0.0.0" } -pgt_query_ext = { path = "./crates/pgt_query_ext", version = "0.0.0" } -pgt_query_macros = { path = "./crates/pgt_query_macros", version = "0.0.0" } -pgt_schema_cache = { path = "./crates/pgt_schema_cache", version = "0.0.0" } -pgt_statement_splitter = { path = "./crates/pgt_statement_splitter", version = "0.0.0" } -pgt_suppressions = { path = "./crates/pgt_suppressions", version = "0.0.0" } -pgt_text_edit = { path = "./crates/pgt_text_edit", version = "0.0.0" } -pgt_text_size = { path = "./crates/pgt_text_size", version = "0.0.0" } -pgt_tokenizer = { path = "./crates/pgt_tokenizer", version = "0.0.0" } -pgt_treesitter = { path = "./crates/pgt_treesitter", version = "0.0.0" } -pgt_treesitter_grammar = { path = "./crates/pgt_treesitter_grammar", version = "0.0.0" } -pgt_typecheck = { path = "./crates/pgt_typecheck", version = "0.0.0" } -pgt_workspace = { path = "./crates/pgt_workspace", version = "0.0.0" } -pgt_workspace_macros = { path = "./crates/pgt_workspace_macros", version = "0.0.0" } +pgls_analyse = { path = "./crates/pgls_analyse", version = "0.0.0" } +pgls_analyser = { path = "./crates/pgls_analyser", version = "0.0.0" } +pgls_cli = { path = "./crates/pgls_cli", version = "0.0.0" } +pgls_completions = { path = "./crates/pgls_completions", version = "0.0.0" } +pgls_configuration = { path = "./crates/pgls_configuration", version = "0.0.0" } +pgls_console = { path = "./crates/pgls_console", version = "0.0.0" } +pgls_diagnostics = { path = "./crates/pgls_diagnostics", version = "0.0.0" } +pgls_diagnostics_categories = { path = "./crates/pgls_diagnostics_categories", version = "0.0.0" } +pgls_diagnostics_macros = { path = "./crates/pgls_diagnostics_macros", version = "0.0.0" } +pgls_flags = { path = "./crates/pgls_flags", version = "0.0.0" } +pgls_fs = { path = "./crates/pgls_fs", version = "0.0.0" } +pgls_hover = { path = "./crates/pgls_hover", version = "0.0.0" } +pgls_lexer = { path = "./crates/pgls_lexer", version = "0.0.0" } +pgls_lexer_codegen = { path = "./crates/pgls_lexer_codegen", version = "0.0.0" } +pgls_lsp = { path = "./crates/pgls_lsp", version = "0.0.0" } +pgls_markup = { path = "./crates/pgls_markup", version = "0.0.0" } +pgls_plpgsql_check = { path = "./crates/pgls_plpgsql_check", version = "0.0.0" } +pgls_query = { path = "./crates/pgls_query", version = "0.0.0" } +pgls_query_ext = { path = "./crates/pgls_query_ext", version = "0.0.0" } +pgls_query_macros = { path = "./crates/pgls_query_macros", version = "0.0.0" } +pgls_schema_cache = { path = "./crates/pgls_schema_cache", version = "0.0.0" } +pgls_statement_splitter = { path = "./crates/pgls_statement_splitter", version = "0.0.0" } +pgls_suppressions = { path = "./crates/pgls_suppressions", version = "0.0.0" } +pgls_text_edit = { path = "./crates/pgls_text_edit", version = "0.0.0" } +pgls_text_size = { path = "./crates/pgls_text_size", version = "0.0.0" } +pgls_tokenizer = { path = "./crates/pgls_tokenizer", version = "0.0.0" } +pgls_treesitter = { path = "./crates/pgls_treesitter", version = "0.0.0" } +pgls_treesitter_grammar = { path = "./crates/pgls_treesitter_grammar", version = "0.0.0" } +pgls_typecheck = { path = "./crates/pgls_typecheck", version = "0.0.0" } +pgls_workspace = { path = "./crates/pgls_workspace", version = "0.0.0" } +pgls_workspace_macros = { path = "./crates/pgls_workspace_macros", version = "0.0.0" } -pgt_test_macros = { path = "./crates/pgt_test_macros" } -pgt_test_utils = { path = "./crates/pgt_test_utils" } +pgls_test_macros = { path = "./crates/pgls_test_macros" } +pgls_test_utils = { path = "./crates/pgls_test_utils" } [profile.dev.package] insta.opt-level = 3 diff --git a/README.md b/README.md index fa18d0fec..d4f1a1eff 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ A collection of language tools and a Language Server Protocol (LSP) implementation for Postgres, focusing on developer experience and reliable SQL tooling. -Docs: [pgtools.dev](https://pgtools.dev/) +Docs: [pg-language-server.com](https://pg-language-server.com/) -Install: [instructions](https://pgtools.dev/#installation) +Install: [instructions](https://pg-language-server.com/#installation) - [CLI releases](https://github.com/supabase-community/postgres-language-server/releases) - [VSCode](https://marketplace.visualstudio.com/items?itemName=Supabase.postgrestools) diff --git a/agentic/rename_to_pgls.md b/agentic/rename_to_pgls.md new file mode 100644 index 000000000..648acfb75 --- /dev/null +++ b/agentic/rename_to_pgls.md @@ -0,0 +1,60 @@ +This project is currently named `postgrestools`, with `pg-language-server.com` as its domain, and `pgt` in short. Our config file is `postgres-language-server.jsonc`. + +We need to rename it to Postgres Language Server, with +- `pgls` as short +- `pg-language-server.com` as our domain and +- `pgls` as binary name +- `postgres-language-server.jsonc` as config name + +I want you to go through the repo and rename everything, including all of the above and specifically: +- `PgLSPath` -> `PgLSPath` +- `pgt_` crate prefix -> `pgls_` +- `PGT_` env vars -> `PGLS_` +- `@postgrestools/postgrestools` should become `@pgls/cli` +- `@postgrestools/backend-jsonrpc` -> `@pgls/backend-jsonrpc` + +## Full List + +### 1. File and Directory Renamings +- All crate directories: `crates/pgt_*` → `crates/pgls_*` (34 crates) +- Package directories: + - `packages/@postgrestools/postgrestools/` → `packages/@pgls/cli/` + - `packages/@postgrestools/backend-jsonrpc/` → `packages/@pgls/backend-jsonrpc/` +- Binary file: `packages/@postgrestools/postgrestools/bin/pgls` → `packages/@pgls/cli/bin/pgls` + +### 2. Code and Import Renamings +- All Rust crate imports: `use pgt_*` → `use pgls_*` +- All Cargo.toml package names: `name = "pgt_*"` → `name = "pgls_*"` +- All Cargo.toml dependencies: `pgt_*` → `pgls_*` +- Binary name in CLI: `pgls` → `pgls` + +### 3. Additional Environment Variables +- `PGLS_CACHE_PATH` → `PGLS_CACHE_PATH` +- `PGLS_CLI_CACHE` → `PGLS_CLI_CACHE` +- `PGLS_DAEMON_HOST` → `PGLS_DAEMON_HOST` +- `PGLS_DAEMON_PORT` → `PGLS_DAEMON_PORT` +- `PGLS_COLORS` → `PGLS_COLORS` + +### 4. Test and Snapshot Files +- All test snapshot files: `pgt_tokenizer__tests__*` → `pgls_tokenizer__tests__*` + +### 5. Documentation and Comments +- All references to "pgls" in docs, READMEs, and comments +- All URLs from pg-language-server.com to pg-language-server.com + +### 6. Lock and Build Files +- Cargo.lock will be updated automatically +- bun.lock, uv.lock, package-lock.json files will need regeneration + +### Summary +This refactoring will affect approximately: +- 43 files containing "pgls" +- 9 files containing "pg-language-server.com" +- 426+ files containing "pgt_" prefix +- 12 files containing "PGT_" prefix +- 23 files containing "PgLSPath" +- 12 files containing "@postgrestools" +- 34 crate directories +- Multiple lock files and build artifacts + +Please, go ahead and execute the renaming. diff --git a/crates/pgt_analyse/Cargo.toml b/crates/pgls_analyse/Cargo.toml similarity index 73% rename from crates/pgt_analyse/Cargo.toml rename to crates/pgls_analyse/Cargo.toml index 3da600343..073bbef1a 100644 --- a/crates/pgt_analyse/Cargo.toml +++ b/crates/pgls_analyse/Cargo.toml @@ -7,22 +7,22 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_analyse" +name = "pgls_analyse" repository.workspace = true version = "0.0.0" [dependencies] -pgt_console.workspace = true -pgt_diagnostics.workspace = true -pgt_query.workspace = true -pgt_schema_cache.workspace = true -rustc-hash = { workspace = true } +pgls_console.workspace = true +pgls_diagnostics.workspace = true +pgls_query.workspace = true +pgls_schema_cache.workspace = true +rustc-hash = { workspace = true } biome_deserialize = { workspace = true, optional = true } biome_deserialize_macros = { workspace = true, optional = true } enumflags2.workspace = true -pgt_text_size.workspace = true +pgls_text_size.workspace = true schemars = { workspace = true, optional = true } serde = { workspace = true, features = ["derive"], optional = true } diff --git a/crates/pgt_analyse/src/analysed_file_context.rs b/crates/pgls_analyse/src/analysed_file_context.rs similarity index 63% rename from crates/pgt_analyse/src/analysed_file_context.rs rename to crates/pgls_analyse/src/analysed_file_context.rs index 8bf21d99c..06ba041e0 100644 --- a/crates/pgt_analyse/src/analysed_file_context.rs +++ b/crates/pgls_analyse/src/analysed_file_context.rs @@ -1,15 +1,15 @@ pub struct AnalysedFileContext<'a> { - pub stmts: &'a Vec, + pub stmts: &'a Vec, pos: usize, } impl<'a> AnalysedFileContext<'a> { - pub fn new(stmts: &'a Vec) -> Self { + pub fn new(stmts: &'a Vec) -> Self { Self { stmts, pos: 0 } } - pub fn previous_stmts(&self) -> &[pgt_query::NodeEnum] { + pub fn previous_stmts(&self) -> &[pgls_query::NodeEnum] { &self.stmts[0..self.pos] } diff --git a/crates/pgt_analyse/src/categories.rs b/crates/pgls_analyse/src/categories.rs similarity index 98% rename from crates/pgt_analyse/src/categories.rs rename to crates/pgls_analyse/src/categories.rs index 02819a4ea..54625d415 100644 --- a/crates/pgt_analyse/src/categories.rs +++ b/crates/pgls_analyse/src/categories.rs @@ -72,7 +72,7 @@ impl ActionCategory { /// /// ``` /// use std::borrow::Cow; - /// use pgt_analyse::{ActionCategory, RefactorKind}; + /// use pgls_analyse::{ActionCategory, RefactorKind}; /// /// assert!(ActionCategory::QuickFix(Cow::from("quickfix")).matches("quickfix")); /// @@ -310,7 +310,7 @@ impl schemars::JsonSchema for RuleCategories { /// A convenient type create a [RuleCategories] type /// /// ``` -/// use pgt_analyse::{RuleCategoriesBuilder, RuleCategory}; +/// use pgls_analyse::{RuleCategoriesBuilder, RuleCategory}; /// let mut categories = RuleCategoriesBuilder::default().with_lint().build(); /// /// assert!(categories.contains(RuleCategory::Lint)); diff --git a/crates/pgt_analyse/src/context.rs b/crates/pgls_analyse/src/context.rs similarity index 93% rename from crates/pgt_analyse/src/context.rs rename to crates/pgls_analyse/src/context.rs index 17f47365a..bf3f48762 100644 --- a/crates/pgt_analyse/src/context.rs +++ b/crates/pgls_analyse/src/context.rs @@ -1,4 +1,4 @@ -use pgt_schema_cache::SchemaCache; +use pgls_schema_cache::SchemaCache; use crate::{ AnalysedFileContext, @@ -7,7 +7,7 @@ use crate::{ }; pub struct RuleContext<'a, R: Rule> { - stmt: &'a pgt_query::NodeEnum, + stmt: &'a pgls_query::NodeEnum, options: &'a R::Options, schema_cache: Option<&'a SchemaCache>, file_context: &'a AnalysedFileContext<'a>, @@ -19,7 +19,7 @@ where { #[allow(clippy::too_many_arguments)] pub fn new( - stmt: &'a pgt_query::NodeEnum, + stmt: &'a pgls_query::NodeEnum, options: &'a R::Options, schema_cache: Option<&'a SchemaCache>, file_context: &'a AnalysedFileContext, @@ -43,7 +43,7 @@ where } /// Returns the AST root - pub fn stmt(&self) -> &pgt_query::NodeEnum { + pub fn stmt(&self) -> &pgls_query::NodeEnum { self.stmt } diff --git a/crates/pgt_analyse/src/filter.rs b/crates/pgls_analyse/src/filter.rs similarity index 97% rename from crates/pgt_analyse/src/filter.rs rename to crates/pgls_analyse/src/filter.rs index 02844d3ec..bb9cdc27c 100644 --- a/crates/pgt_analyse/src/filter.rs +++ b/crates/pgls_analyse/src/filter.rs @@ -113,8 +113,8 @@ impl Display for RuleFilter<'_> { } } -impl pgt_console::fmt::Display for RuleFilter<'_> { - fn fmt(&self, fmt: &mut pgt_console::fmt::Formatter) -> std::io::Result<()> { +impl pgls_console::fmt::Display for RuleFilter<'_> { + fn fmt(&self, fmt: &mut pgls_console::fmt::Formatter) -> std::io::Result<()> { match self { RuleFilter::Group(group) => { write!(fmt, "{group}") diff --git a/crates/pgt_analyse/src/lib.rs b/crates/pgls_analyse/src/lib.rs similarity index 94% rename from crates/pgt_analyse/src/lib.rs rename to crates/pgls_analyse/src/lib.rs index 1d4ec6aee..29b18f362 100644 --- a/crates/pgt_analyse/src/lib.rs +++ b/crates/pgls_analyse/src/lib.rs @@ -8,7 +8,7 @@ mod registry; mod rule; // Re-exported for use in the `declare_group` macro -pub use pgt_diagnostics::category_concat; +pub use pgls_diagnostics::category_concat; pub use crate::analysed_file_context::AnalysedFileContext; pub use crate::categories::{ diff --git a/crates/pgt_analyse/src/macros.rs b/crates/pgls_analyse/src/macros.rs similarity index 98% rename from crates/pgt_analyse/src/macros.rs rename to crates/pgls_analyse/src/macros.rs index aa7b25c59..27c0c11c0 100644 --- a/crates/pgt_analyse/src/macros.rs +++ b/crates/pgls_analyse/src/macros.rs @@ -5,7 +5,7 @@ /// The macro itself expect the following syntax: /// /// ```rust,ignore -///use pgt_analyse::declare_rule; +///use pgls_analyse::declare_rule; /// /// declare_lint_rule! { /// /// Documentation @@ -28,7 +28,7 @@ macro_rules! declare_lint_rule { $( $key:ident: $value:expr_2021, )* } ) => { - pgt_analyse::declare_rule!( + pgls_analyse::declare_rule!( $( #[doc = $doc] )* $vis $id { version: $version, diff --git a/crates/pgt_analyse/src/options.rs b/crates/pgls_analyse/src/options.rs similarity index 95% rename from crates/pgt_analyse/src/options.rs rename to crates/pgls_analyse/src/options.rs index 211cb1dc2..e46b7104f 100644 --- a/crates/pgt_analyse/src/options.rs +++ b/crates/pgls_analyse/src/options.rs @@ -45,7 +45,7 @@ impl AnalyserRules { /// A set of information useful to the analyser infrastructure #[derive(Debug, Default)] pub struct AnalyserOptions { - /// A data structured derived from the [`postgrestools.jsonc`] file + /// A data structured derived from the [`postgres-language-server.jsonc`] file pub rules: AnalyserRules, } diff --git a/crates/pgt_analyse/src/registry.rs b/crates/pgls_analyse/src/registry.rs similarity index 97% rename from crates/pgt_analyse/src/registry.rs rename to crates/pgls_analyse/src/registry.rs index 8da24dbc8..3278c926d 100644 --- a/crates/pgt_analyse/src/registry.rs +++ b/crates/pgls_analyse/src/registry.rs @@ -157,10 +157,10 @@ impl RuleRegistry { } pub struct RegistryRuleParams<'a> { - pub root: &'a pgt_query::NodeEnum, + pub root: &'a pgls_query::NodeEnum, pub options: &'a AnalyserOptions, pub analysed_file_context: &'a AnalysedFileContext<'a>, - pub schema_cache: Option<&'a pgt_schema_cache::SchemaCache>, + pub schema_cache: Option<&'a pgls_schema_cache::SchemaCache>, } /// Executor for rule as a generic function pointer diff --git a/crates/pgt_analyse/src/rule.rs b/crates/pgls_analyse/src/rule.rs similarity index 98% rename from crates/pgt_analyse/src/rule.rs rename to crates/pgls_analyse/src/rule.rs index 40f87ce02..42a08cda3 100644 --- a/crates/pgt_analyse/src/rule.rs +++ b/crates/pgls_analyse/src/rule.rs @@ -1,11 +1,11 @@ -use pgt_console::fmt::Display; -use pgt_console::{MarkupBuf, markup}; -use pgt_diagnostics::advice::CodeSuggestionAdvice; -use pgt_diagnostics::{ +use pgls_console::fmt::Display; +use pgls_console::{MarkupBuf, markup}; +use pgls_diagnostics::advice::CodeSuggestionAdvice; +use pgls_diagnostics::{ Advices, Category, Diagnostic, DiagnosticTags, Location, LogCategory, MessageAndDescription, Severity, Visit, }; -use pgt_text_size::TextRange; +use pgls_text_size::TextRange; use std::cmp::Ordering; use std::fmt::Debug; diff --git a/crates/pgt_analyser/CONTRIBUTING.md b/crates/pgls_analyser/CONTRIBUTING.md similarity index 97% rename from crates/pgt_analyser/CONTRIBUTING.md rename to crates/pgls_analyser/CONTRIBUTING.md index b0929eda9..8eadbc4b1 100644 --- a/crates/pgt_analyser/CONTRIBUTING.md +++ b/crates/pgls_analyser/CONTRIBUTING.md @@ -81,7 +81,7 @@ Let's assume that the rule we implement support the following options: - `threshold`: an integer between 0 and 255; - `behaviorExceptions`: an array of strings. -We would like to set the options in the `postgrestools.jsonc` configuration file: +We would like to set the options in the `postgres-language-server.jsonc` configuration file: ```json { @@ -143,9 +143,9 @@ We currently require implementing _serde_'s traits `Deserialize`/`Serialize`. Also, we use other `serde` macros to adjust the JSON configuration: -- `rename_all = "camelCase"`: it renames all fields in camel-case, so they are in line with the naming style of the `postgrestools.jsonc`. +- `rename_all = "camelCase"`: it renames all fields in camel-case, so they are in line with the naming style of the `postgres-language-server.jsonc`. - `deny_unknown_fields`: it raises an error if the configuration contains extraneous fields. -- `default`: it uses the `Default` value when the field is missing from `postgrestools.jsonc`. This macro makes the field optional. +- `default`: it uses the `Default` value when the field is missing from `postgres-language-server.jsonc`. This macro makes the field optional. You can simply use a derive macros: diff --git a/crates/pgls_analyser/Cargo.toml b/crates/pgls_analyser/Cargo.toml new file mode 100644 index 000000000..ce9f0bf22 --- /dev/null +++ b/crates/pgls_analyser/Cargo.toml @@ -0,0 +1,29 @@ + +[package] +authors.workspace = true +categories.workspace = true +description = "" +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +name = "pgls_analyser" +repository.workspace = true +version = "0.0.0" + +[dependencies] +pgls_analyse = { workspace = true } +pgls_console = { workspace = true } +pgls_diagnostics = { workspace = true } +pgls_query = { workspace = true } +pgls_query_ext = { workspace = true } +pgls_schema_cache = { workspace = true } +pgls_text_size = { workspace = true } +serde = { workspace = true } + +[dev-dependencies] +insta = { version = "1.42.1" } +pgls_diagnostics = { workspace = true } +pgls_statement_splitter = { workspace = true } +pgls_test_macros = { workspace = true } +termcolor = { workspace = true } diff --git a/crates/pgt_analyser/src/lib.rs b/crates/pgls_analyser/src/lib.rs similarity index 88% rename from crates/pgt_analyser/src/lib.rs rename to crates/pgls_analyser/src/lib.rs index f559090ef..547ecb10a 100644 --- a/crates/pgt_analyser/src/lib.rs +++ b/crates/pgls_analyser/src/lib.rs @@ -1,6 +1,6 @@ use std::{ops::Deref, sync::LazyLock}; -use pgt_analyse::{ +use pgls_analyse::{ AnalysedFileContext, AnalyserOptions, AnalysisFilter, MetadataRegistry, RegistryRuleParams, RuleDiagnostic, RuleRegistry, }; @@ -32,13 +32,13 @@ pub struct Analyser<'a> { #[derive(Debug)] pub struct AnalysableStatement { - pub root: pgt_query::NodeEnum, - pub range: pgt_text_size::TextRange, + pub root: pgls_query::NodeEnum, + pub range: pgls_text_size::TextRange, } pub struct AnalyserParams<'a> { pub stmts: Vec, - pub schema_cache: Option<&'a pgt_schema_cache::SchemaCache>, + pub schema_cache: Option<&'a pgls_schema_cache::SchemaCache>, } pub struct AnalyserConfig<'a> { @@ -62,7 +62,8 @@ impl<'a> Analyser<'a> { pub fn run(&self, params: AnalyserParams) -> Vec { let mut diagnostics = vec![]; - let roots: Vec = params.stmts.iter().map(|s| s.root.clone()).collect(); + let roots: Vec = + params.stmts.iter().map(|s| s.root.clone()).collect(); let mut file_context = AnalysedFileContext::new(&roots); for (i, stmt) in params.stmts.into_iter().enumerate() { @@ -95,14 +96,14 @@ impl<'a> Analyser<'a> { mod tests { use core::slice; - use pgt_analyse::{AnalyserOptions, AnalysisFilter, RuleFilter}; - use pgt_console::{ + use pgls_analyse::{AnalyserOptions, AnalysisFilter, RuleFilter}; + use pgls_console::{ Markup, fmt::{Formatter, Termcolor}, markup, }; - use pgt_diagnostics::PrintDiagnostic; - use pgt_text_size::TextRange; + use pgls_diagnostics::PrintDiagnostic; + use pgls_text_size::TextRange; use termcolor::NoColor; use crate::{AnalysableStatement, Analyser}; @@ -127,7 +128,7 @@ mod tests { ..Default::default() }; - let ast = pgt_query::parse(SQL).expect("failed to parse SQL"); + let ast = pgls_query::parse(SQL).expect("failed to parse SQL"); let range = TextRange::new(0.into(), u32::try_from(SQL.len()).unwrap().into()); let options = AnalyserOptions::default(); diff --git a/crates/pgls_analyser/src/lint.rs b/crates/pgls_analyser/src/lint.rs new file mode 100644 index 000000000..6d109567a --- /dev/null +++ b/crates/pgls_analyser/src/lint.rs @@ -0,0 +1,4 @@ +//! Generated file, do not edit by hand, see `xtask/codegen` + +pub mod safety; +::pgls_analyse::declare_category! { pub Lint { kind : Lint , groups : [self :: safety :: Safety ,] } } diff --git a/crates/pgt_analyser/src/lint/safety.rs b/crates/pgls_analyser/src/lint/safety.rs similarity index 98% rename from crates/pgt_analyser/src/lint/safety.rs rename to crates/pgls_analyser/src/lint/safety.rs index 0ad0f2c56..9f49440ca 100644 --- a/crates/pgt_analyser/src/lint/safety.rs +++ b/crates/pgls_analyser/src/lint/safety.rs @@ -1,6 +1,6 @@ //! Generated file, do not edit by hand, see `xtask/codegen` -use pgt_analyse::declare_lint_group; +use pgls_analyse::declare_lint_group; pub mod adding_field_with_default; pub mod adding_foreign_key_constraint; pub mod adding_not_null_field; diff --git a/crates/pgt_analyser/src/lint/safety/adding_field_with_default.rs b/crates/pgls_analyser/src/lint/safety/adding_field_with_default.rs similarity index 82% rename from crates/pgt_analyser/src/lint/safety/adding_field_with_default.rs rename to crates/pgls_analyser/src/lint/safety/adding_field_with_default.rs index 7782689f6..604f60dab 100644 --- a/crates/pgt_analyser/src/lint/safety/adding_field_with_default.rs +++ b/crates/pgls_analyser/src/lint/safety/adding_field_with_default.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Adding a column with a DEFAULT value may lead to a table rewrite while holding an ACCESS EXCLUSIVE lock. @@ -47,24 +47,26 @@ impl Rule for AddingFieldWithDefault { // Check PostgreSQL version - in 11+, non-volatile defaults are safe let pg_version = ctx.schema_cache().and_then(|sc| sc.version.major_version); - if let pgt_query::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { + if let pgls_query::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { for cmd in &stmt.cmds { - if let Some(pgt_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { - if cmd.subtype() == pgt_query::protobuf::AlterTableType::AtAddColumn { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = + if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { + if cmd.subtype() == pgls_query::protobuf::AlterTableType::AtAddColumn { + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = &cmd.def.as_ref().and_then(|d| d.node.as_ref()) { let has_default = col_def.constraints.iter().any(|constraint| { - if let Some(pgt_query::NodeEnum::Constraint(c)) = &constraint.node { - c.contype() == pgt_query::protobuf::ConstrType::ConstrDefault + if let Some(pgls_query::NodeEnum::Constraint(c)) = &constraint.node + { + c.contype() == pgls_query::protobuf::ConstrType::ConstrDefault } else { false } }); let has_generated = col_def.constraints.iter().any(|constraint| { - if let Some(pgt_query::NodeEnum::Constraint(c)) = &constraint.node { - c.contype() == pgt_query::protobuf::ConstrType::ConstrGenerated + if let Some(pgls_query::NodeEnum::Constraint(c)) = &constraint.node + { + c.contype() == pgls_query::protobuf::ConstrType::ConstrGenerated } else { false } @@ -87,8 +89,8 @@ impl Rule for AddingFieldWithDefault { if pg_version.is_some_and(|v| v >= 11) { // Check if default is non-volatile let is_safe_default = col_def.constraints.iter().any(|constraint| { - if let Some(pgt_query::NodeEnum::Constraint(c)) = &constraint.node { - if c.contype() == pgt_query::protobuf::ConstrType::ConstrDefault { + if let Some(pgls_query::NodeEnum::Constraint(c)) = &constraint.node { + if c.contype() == pgls_query::protobuf::ConstrType::ConstrDefault { if let Some(raw_expr) = &c.raw_expr { return is_safe_default_expr(&raw_expr.node.as_ref().map(|n| Box::new(n.clone())), ctx.schema_cache()); } @@ -136,20 +138,20 @@ impl Rule for AddingFieldWithDefault { } fn is_safe_default_expr( - expr: &Option>, - schema_cache: Option<&pgt_schema_cache::SchemaCache>, + expr: &Option>, + schema_cache: Option<&pgls_schema_cache::SchemaCache>, ) -> bool { match expr { Some(node) => match node.as_ref() { // Constants are always safe - pgt_query::NodeEnum::AConst(_) => true, + pgls_query::NodeEnum::AConst(_) => true, // Type casts of constants are safe - pgt_query::NodeEnum::TypeCast(tc) => is_safe_default_expr( + pgls_query::NodeEnum::TypeCast(tc) => is_safe_default_expr( &tc.arg.as_ref().and_then(|a| a.node.clone()).map(Box::new), schema_cache, ), // function calls might be safe if they are non-volatile and have no args - pgt_query::NodeEnum::FuncCall(fc) => { + pgls_query::NodeEnum::FuncCall(fc) => { // must have no args if !fc.args.is_empty() { return false; @@ -159,7 +161,7 @@ fn is_safe_default_expr( return false; }; - let Some((schema, name)) = pgt_query_ext::utils::parse_name(&fc.funcname) else { + let Some((schema, name)) = pgls_query_ext::utils::parse_name(&fc.funcname) else { return false; }; @@ -171,7 +173,7 @@ fn is_safe_default_expr( } // must be non-volatile - if f.behavior == pgt_schema_cache::Behavior::Volatile { + if f.behavior == pgls_schema_cache::Behavior::Volatile { return false; } diff --git a/crates/pgt_analyser/src/lint/safety/adding_foreign_key_constraint.rs b/crates/pgls_analyser/src/lint/safety/adding_foreign_key_constraint.rs similarity index 83% rename from crates/pgt_analyser/src/lint/safety/adding_foreign_key_constraint.rs rename to crates/pgls_analyser/src/lint/safety/adding_foreign_key_constraint.rs index 81fecca56..58059b910 100644 --- a/crates/pgt_analyser/src/lint/safety/adding_foreign_key_constraint.rs +++ b/crates/pgls_analyser/src/lint/safety/adding_foreign_key_constraint.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Adding a foreign key constraint requires a table scan and a SHARE ROW EXCLUSIVE lock on both tables, which blocks writes. @@ -48,12 +48,12 @@ impl Rule for AddingForeignKeyConstraint { fn run(ctx: &RuleContext) -> Vec { let mut diagnostics = Vec::new(); - if let pgt_query::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { + if let pgls_query::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { for cmd in &stmt.cmds { - if let Some(pgt_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { + if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { match cmd.subtype() { - pgt_query::protobuf::AlterTableType::AtAddConstraint => { - if let Some(pgt_query::NodeEnum::Constraint(constraint)) = + pgls_query::protobuf::AlterTableType::AtAddConstraint => { + if let Some(pgls_query::NodeEnum::Constraint(constraint)) = cmd.def.as_ref().and_then(|d| d.node.as_ref()) { if let Some(diagnostic) = @@ -63,13 +63,13 @@ impl Rule for AddingForeignKeyConstraint { } } } - pgt_query::protobuf::AlterTableType::AtAddColumn => { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = + pgls_query::protobuf::AlterTableType::AtAddColumn => { + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = cmd.def.as_ref().and_then(|d| d.node.as_ref()) { // check constraints on the column for constraint in &col_def.constraints { - if let Some(pgt_query::NodeEnum::Constraint(constr)) = + if let Some(pgls_query::NodeEnum::Constraint(constr)) = &constraint.node { if let Some(diagnostic) = @@ -92,11 +92,11 @@ impl Rule for AddingForeignKeyConstraint { } fn check_foreign_key_constraint( - constraint: &pgt_query::protobuf::Constraint, + constraint: &pgls_query::protobuf::Constraint, is_column_constraint: bool, ) -> Option { // Only check foreign key constraints - if constraint.contype() != pgt_query::protobuf::ConstrType::ConstrForeign { + if constraint.contype() != pgls_query::protobuf::ConstrType::ConstrForeign { return None; } diff --git a/crates/pgt_analyser/src/lint/safety/adding_not_null_field.rs b/crates/pgls_analyser/src/lint/safety/adding_not_null_field.rs similarity index 86% rename from crates/pgt_analyser/src/lint/safety/adding_not_null_field.rs rename to crates/pgls_analyser/src/lint/safety/adding_not_null_field.rs index aa442088e..8b14d5227 100644 --- a/crates/pgt_analyser/src/lint/safety/adding_not_null_field.rs +++ b/crates/pgls_analyser/src/lint/safety/adding_not_null_field.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Setting a column NOT NULL blocks reads while the table is scanned. @@ -55,10 +55,10 @@ impl Rule for AddingNotNullField { return diagnostics; } - if let pgt_query::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { + if let pgls_query::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { for cmd in &stmt.cmds { - if let Some(pgt_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { - if cmd.subtype() == pgt_query::protobuf::AlterTableType::AtSetNotNull { + if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { + if cmd.subtype() == pgls_query::protobuf::AlterTableType::AtSetNotNull { diagnostics.push(RuleDiagnostic::new( rule_category!(), None, diff --git a/crates/pgt_analyser/src/lint/safety/adding_primary_key_constraint.rs b/crates/pgls_analyser/src/lint/safety/adding_primary_key_constraint.rs similarity index 79% rename from crates/pgt_analyser/src/lint/safety/adding_primary_key_constraint.rs rename to crates/pgls_analyser/src/lint/safety/adding_primary_key_constraint.rs index a4758a29f..129812035 100644 --- a/crates/pgt_analyser/src/lint/safety/adding_primary_key_constraint.rs +++ b/crates/pgls_analyser/src/lint/safety/adding_primary_key_constraint.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Adding a primary key constraint results in locks and table rewrites. @@ -45,13 +45,13 @@ impl Rule for AddingPrimaryKeyConstraint { fn run(ctx: &RuleContext) -> Vec { let mut diagnostics = Vec::new(); - if let pgt_query::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { + if let pgls_query::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { for cmd in &stmt.cmds { - if let Some(pgt_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { + if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { match cmd.subtype() { // Check for ADD CONSTRAINT PRIMARY KEY - pgt_query::protobuf::AlterTableType::AtAddConstraint => { - if let Some(pgt_query::NodeEnum::Constraint(constraint)) = + pgls_query::protobuf::AlterTableType::AtAddConstraint => { + if let Some(pgls_query::NodeEnum::Constraint(constraint)) = cmd.def.as_ref().and_then(|d| d.node.as_ref()) { if let Some(diagnostic) = @@ -62,12 +62,12 @@ impl Rule for AddingPrimaryKeyConstraint { } } // Check for ADD COLUMN with PRIMARY KEY - pgt_query::protobuf::AlterTableType::AtAddColumn => { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = + pgls_query::protobuf::AlterTableType::AtAddColumn => { + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = cmd.def.as_ref().and_then(|d| d.node.as_ref()) { for constraint in &col_def.constraints { - if let Some(pgt_query::NodeEnum::Constraint(constr)) = + if let Some(pgls_query::NodeEnum::Constraint(constr)) = &constraint.node { if let Some(diagnostic) = @@ -90,9 +90,9 @@ impl Rule for AddingPrimaryKeyConstraint { } fn check_for_primary_key_constraint( - constraint: &pgt_query::protobuf::Constraint, + constraint: &pgls_query::protobuf::Constraint, ) -> Option { - if constraint.contype() == pgt_query::protobuf::ConstrType::ConstrPrimary + if constraint.contype() == pgls_query::protobuf::ConstrType::ConstrPrimary && constraint.indexname.is_empty() { Some( diff --git a/crates/pgt_analyser/src/lint/safety/adding_required_field.rs b/crates/pgls_analyser/src/lint/safety/adding_required_field.rs similarity index 86% rename from crates/pgt_analyser/src/lint/safety/adding_required_field.rs rename to crates/pgls_analyser/src/lint/safety/adding_required_field.rs index d853d30a2..c39597d53 100644 --- a/crates/pgt_analyser/src/lint/safety/adding_required_field.rs +++ b/crates/pgls_analyser/src/lint/safety/adding_required_field.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Adding a new column that is NOT NULL and has no default value to an existing table effectively makes it required. @@ -30,7 +30,7 @@ impl Rule for AddingRequiredField { fn run(ctx: &RuleContext) -> Vec { let mut diagnostics = vec![]; - if let pgt_query::NodeEnum::AlterTableStmt(stmt) = ctx.stmt() { + if let pgls_query::NodeEnum::AlterTableStmt(stmt) = ctx.stmt() { // We are currently lacking a way to check if a `AtAddColumn` subtype sets a // not null constraint – so we'll need to check the plain SQL. let plain_sql = ctx.stmt().to_ref().deparse().unwrap().to_ascii_lowercase(); @@ -41,8 +41,9 @@ impl Rule for AddingRequiredField { } for cmd in &stmt.cmds { - if let Some(pgt_query::NodeEnum::AlterTableCmd(alter_table_cmd)) = &cmd.node { - if alter_table_cmd.subtype() == pgt_query::protobuf::AlterTableType::AtAddColumn + if let Some(pgls_query::NodeEnum::AlterTableCmd(alter_table_cmd)) = &cmd.node { + if alter_table_cmd.subtype() + == pgls_query::protobuf::AlterTableType::AtAddColumn { diagnostics.push( RuleDiagnostic::new( diff --git a/crates/pgt_analyser/src/lint/safety/ban_char_field.rs b/crates/pgls_analyser/src/lint/safety/ban_char_field.rs similarity index 78% rename from crates/pgt_analyser/src/lint/safety/ban_char_field.rs rename to crates/pgls_analyser/src/lint/safety/ban_char_field.rs index 12e113b4a..39b1cdbe6 100644 --- a/crates/pgt_analyser/src/lint/safety/ban_char_field.rs +++ b/crates/pgls_analyser/src/lint/safety/ban_char_field.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Using CHAR(n) or CHARACTER(n) types is discouraged. @@ -46,9 +46,9 @@ impl Rule for BanCharField { fn run(ctx: &RuleContext) -> Vec { let mut diagnostics = Vec::new(); - if let pgt_query::NodeEnum::CreateStmt(stmt) = &ctx.stmt() { + if let pgls_query::NodeEnum::CreateStmt(stmt) = &ctx.stmt() { for table_elt in &stmt.table_elts { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = &table_elt.node { + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = &table_elt.node { if let Some(diagnostic) = check_column_for_char_type(col_def) { diagnostics.push(diagnostic); } @@ -57,11 +57,11 @@ impl Rule for BanCharField { } // Also check ALTER TABLE ADD COLUMN statements - if let pgt_query::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { + if let pgls_query::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { for cmd in &stmt.cmds { - if let Some(pgt_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { - if cmd.subtype() == pgt_query::protobuf::AlterTableType::AtAddColumn { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = + if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { + if cmd.subtype() == pgls_query::protobuf::AlterTableType::AtAddColumn { + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = &cmd.def.as_ref().and_then(|d| d.node.as_ref()) { if let Some(diagnostic) = check_column_for_char_type(col_def) { @@ -77,10 +77,10 @@ impl Rule for BanCharField { } } -fn check_column_for_char_type(col_def: &pgt_query::protobuf::ColumnDef) -> Option { +fn check_column_for_char_type(col_def: &pgls_query::protobuf::ColumnDef) -> Option { if let Some(type_name) = &col_def.type_name { for name_node in &type_name.names { - if let Some(pgt_query::NodeEnum::String(name)) = &name_node.node { + if let Some(pgls_query::NodeEnum::String(name)) = &name_node.node { // Check for "bpchar" (internal name for CHAR type) // or "char" or "character" let type_str = name.sval.to_lowercase(); diff --git a/crates/pgt_analyser/src/lint/safety/ban_concurrent_index_creation_in_transaction.rs b/crates/pgls_analyser/src/lint/safety/ban_concurrent_index_creation_in_transaction.rs similarity index 89% rename from crates/pgt_analyser/src/lint/safety/ban_concurrent_index_creation_in_transaction.rs rename to crates/pgls_analyser/src/lint/safety/ban_concurrent_index_creation_in_transaction.rs index 565a7487f..2de0563d1 100644 --- a/crates/pgt_analyser/src/lint/safety/ban_concurrent_index_creation_in_transaction.rs +++ b/crates/pgls_analyser/src/lint/safety/ban_concurrent_index_creation_in_transaction.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Concurrent index creation is not allowed within a transaction. @@ -36,7 +36,7 @@ impl Rule for BanConcurrentIndexCreationInTransaction { // other statement in the same context (indicating a transaction block) // // since our analyser assumes we're always in a transaction context, we always flag concurrent indexes - if let pgt_query::NodeEnum::IndexStmt(stmt) = ctx.stmt() { + if let pgls_query::NodeEnum::IndexStmt(stmt) = ctx.stmt() { if stmt.concurrent && ctx.file_context().stmt_count() > 1 { diagnostics.push(RuleDiagnostic::new( rule_category!(), diff --git a/crates/pgt_analyser/src/lint/safety/ban_drop_column.rs b/crates/pgls_analyser/src/lint/safety/ban_drop_column.rs similarity index 77% rename from crates/pgt_analyser/src/lint/safety/ban_drop_column.rs rename to crates/pgls_analyser/src/lint/safety/ban_drop_column.rs index d73b39d24..868782a98 100644 --- a/crates/pgt_analyser/src/lint/safety/ban_drop_column.rs +++ b/crates/pgls_analyser/src/lint/safety/ban_drop_column.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Dropping a column may break existing clients. @@ -32,10 +32,10 @@ impl Rule for BanDropColumn { fn run(ctx: &RuleContext) -> Vec { let mut diagnostics = Vec::new(); - if let pgt_query::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { + if let pgls_query::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { for cmd in &stmt.cmds { - if let Some(pgt_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { - if cmd.subtype() == pgt_query::protobuf::AlterTableType::AtDropColumn { + if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { + if cmd.subtype() == pgls_query::protobuf::AlterTableType::AtDropColumn { diagnostics.push(RuleDiagnostic::new( rule_category!(), None, diff --git a/crates/pgt_analyser/src/lint/safety/ban_drop_database.rs b/crates/pgls_analyser/src/lint/safety/ban_drop_database.rs similarity index 81% rename from crates/pgt_analyser/src/lint/safety/ban_drop_database.rs rename to crates/pgls_analyser/src/lint/safety/ban_drop_database.rs index 3011cf88d..837cb8e77 100644 --- a/crates/pgt_analyser/src/lint/safety/ban_drop_database.rs +++ b/crates/pgls_analyser/src/lint/safety/ban_drop_database.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Dropping a database may break existing clients (and everything else, really). @@ -21,7 +21,7 @@ impl Rule for BanDropDatabase { fn run(ctx: &RuleContext) -> Vec { let mut diagnostics = vec![]; - if let pgt_query::NodeEnum::DropdbStmt(_) = &ctx.stmt() { + if let pgls_query::NodeEnum::DropdbStmt(_) = &ctx.stmt() { diagnostics.push( RuleDiagnostic::new( rule_category!(), diff --git a/crates/pgt_analyser/src/lint/safety/ban_drop_not_null.rs b/crates/pgls_analyser/src/lint/safety/ban_drop_not_null.rs similarity index 81% rename from crates/pgt_analyser/src/lint/safety/ban_drop_not_null.rs rename to crates/pgls_analyser/src/lint/safety/ban_drop_not_null.rs index c1e694618..ba4eb09c2 100644 --- a/crates/pgt_analyser/src/lint/safety/ban_drop_not_null.rs +++ b/crates/pgls_analyser/src/lint/safety/ban_drop_not_null.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Dropping a NOT NULL constraint may break existing clients. @@ -32,10 +32,10 @@ impl Rule for BanDropNotNull { fn run(ctx: &RuleContext) -> Vec { let mut diagnostics = Vec::new(); - if let pgt_query::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { + if let pgls_query::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { for cmd in &stmt.cmds { - if let Some(pgt_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { - if cmd.subtype() == pgt_query::protobuf::AlterTableType::AtDropNotNull { + if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { + if cmd.subtype() == pgls_query::protobuf::AlterTableType::AtDropNotNull { diagnostics.push(RuleDiagnostic::new( rule_category!(), None, diff --git a/crates/pgt_analyser/src/lint/safety/ban_drop_table.rs b/crates/pgls_analyser/src/lint/safety/ban_drop_table.rs similarity index 83% rename from crates/pgt_analyser/src/lint/safety/ban_drop_table.rs rename to crates/pgls_analyser/src/lint/safety/ban_drop_table.rs index bcf784533..f98bc6d26 100644 --- a/crates/pgt_analyser/src/lint/safety/ban_drop_table.rs +++ b/crates/pgls_analyser/src/lint/safety/ban_drop_table.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Dropping a table may break existing clients. @@ -31,8 +31,8 @@ impl Rule for BanDropTable { fn run(ctx: &RuleContext) -> Vec { let mut diagnostics = vec![]; - if let pgt_query::NodeEnum::DropStmt(stmt) = &ctx.stmt() { - if stmt.remove_type() == pgt_query::protobuf::ObjectType::ObjectTable { + if let pgls_query::NodeEnum::DropStmt(stmt) = &ctx.stmt() { + if stmt.remove_type() == pgls_query::protobuf::ObjectType::ObjectTable { diagnostics.push( RuleDiagnostic::new( rule_category!(), diff --git a/crates/pgt_analyser/src/lint/safety/ban_truncate_cascade.rs b/crates/pgls_analyser/src/lint/safety/ban_truncate_cascade.rs similarity index 84% rename from crates/pgt_analyser/src/lint/safety/ban_truncate_cascade.rs rename to crates/pgls_analyser/src/lint/safety/ban_truncate_cascade.rs index 1bc42d49b..892086a5f 100644 --- a/crates/pgt_analyser/src/lint/safety/ban_truncate_cascade.rs +++ b/crates/pgls_analyser/src/lint/safety/ban_truncate_cascade.rs @@ -1,7 +1,7 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; -use pgt_query::protobuf::DropBehavior; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; +use pgls_query::protobuf::DropBehavior; declare_lint_rule! { /// Using `TRUNCATE`'s `CASCADE` option will truncate any tables that are also foreign-keyed to the specified tables. @@ -34,7 +34,7 @@ impl Rule for BanTruncateCascade { fn run(ctx: &RuleContext) -> Vec { let mut diagnostics = Vec::new(); - if let pgt_query::NodeEnum::TruncateStmt(stmt) = &ctx.stmt() { + if let pgls_query::NodeEnum::TruncateStmt(stmt) = &ctx.stmt() { if stmt.behavior() == DropBehavior::DropCascade { diagnostics.push(RuleDiagnostic::new( rule_category!(), diff --git a/crates/pgt_analyser/src/lint/safety/changing_column_type.rs b/crates/pgls_analyser/src/lint/safety/changing_column_type.rs similarity index 80% rename from crates/pgt_analyser/src/lint/safety/changing_column_type.rs rename to crates/pgls_analyser/src/lint/safety/changing_column_type.rs index d6d00559f..9e7cc9e75 100644 --- a/crates/pgt_analyser/src/lint/safety/changing_column_type.rs +++ b/crates/pgls_analyser/src/lint/safety/changing_column_type.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Changing a column type may break existing clients. @@ -34,10 +34,10 @@ impl Rule for ChangingColumnType { fn run(ctx: &RuleContext) -> Vec { let mut diagnostics = Vec::new(); - if let pgt_query::NodeEnum::AlterTableStmt(stmt) = ctx.stmt() { + if let pgls_query::NodeEnum::AlterTableStmt(stmt) = ctx.stmt() { for cmd in &stmt.cmds { - if let Some(pgt_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { - if cmd.subtype() == pgt_query::protobuf::AlterTableType::AtAlterColumnType { + if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { + if cmd.subtype() == pgls_query::protobuf::AlterTableType::AtAlterColumnType { diagnostics.push(RuleDiagnostic::new( rule_category!(), None, diff --git a/crates/pgt_analyser/src/lint/safety/constraint_missing_not_valid.rs b/crates/pgls_analyser/src/lint/safety/constraint_missing_not_valid.rs similarity index 81% rename from crates/pgt_analyser/src/lint/safety/constraint_missing_not_valid.rs rename to crates/pgls_analyser/src/lint/safety/constraint_missing_not_valid.rs index 18a75e8c6..5599317ec 100644 --- a/crates/pgt_analyser/src/lint/safety/constraint_missing_not_valid.rs +++ b/crates/pgls_analyser/src/lint/safety/constraint_missing_not_valid.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Adding constraints without NOT VALID blocks all reads and writes. @@ -40,16 +40,16 @@ impl Rule for ConstraintMissingNotValid { fn run(ctx: &RuleContext) -> Vec { let mut diagnostics = Vec::new(); - let pgt_query::NodeEnum::AlterTableStmt(stmt) = ctx.stmt() else { + let pgls_query::NodeEnum::AlterTableStmt(stmt) = ctx.stmt() else { return diagnostics; }; for cmd in &stmt.cmds { - let Some(pgt_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node else { + let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node else { continue; }; - let Some(pgt_query::NodeEnum::Constraint(constraint)) = + let Some(pgls_query::NodeEnum::Constraint(constraint)) = cmd.def.as_ref().and_then(|d| d.node.as_ref()) else { continue; @@ -65,7 +65,7 @@ impl Rule for ConstraintMissingNotValid { } fn check_constraint_needs_not_valid( - constraint: &pgt_query::protobuf::Constraint, + constraint: &pgls_query::protobuf::Constraint, ) -> Option { // Skip if the constraint has NOT VALID if !constraint.initially_valid { @@ -74,8 +74,8 @@ fn check_constraint_needs_not_valid( // Only warn for CHECK and FOREIGN KEY constraints match constraint.contype() { - pgt_query::protobuf::ConstrType::ConstrCheck - | pgt_query::protobuf::ConstrType::ConstrForeign => Some( + pgls_query::protobuf::ConstrType::ConstrCheck + | pgls_query::protobuf::ConstrType::ConstrForeign => Some( RuleDiagnostic::new( rule_category!(), None, diff --git a/crates/pgt_analyser/src/lint/safety/disallow_unique_constraint.rs b/crates/pgls_analyser/src/lint/safety/disallow_unique_constraint.rs similarity index 82% rename from crates/pgt_analyser/src/lint/safety/disallow_unique_constraint.rs rename to crates/pgls_analyser/src/lint/safety/disallow_unique_constraint.rs index d72016f34..5fdf710c8 100644 --- a/crates/pgt_analyser/src/lint/safety/disallow_unique_constraint.rs +++ b/crates/pgls_analyser/src/lint/safety/disallow_unique_constraint.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Disallow adding a UNIQUE constraint without using an existing index. @@ -44,14 +44,14 @@ impl Rule for DisallowUniqueConstraint { fn run(ctx: &RuleContext) -> Vec { let mut diagnostics = Vec::new(); - if let pgt_query::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { + if let pgls_query::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { // Check if this table was created in the same transaction let table_name = stmt.relation.as_ref().map(|r| &r.relname); // Look for tables created in previous statements of this file let table_created_in_transaction = if let Some(table_name) = table_name { ctx.file_context().previous_stmts().iter().any(|prev_stmt| { - if let pgt_query::NodeEnum::CreateStmt(create) = prev_stmt { + if let pgls_query::NodeEnum::CreateStmt(create) = prev_stmt { create .relation .as_ref() @@ -66,15 +66,15 @@ impl Rule for DisallowUniqueConstraint { if !table_created_in_transaction { for cmd in &stmt.cmds { - if let Some(pgt_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { + if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { match cmd.subtype() { - pgt_query::protobuf::AlterTableType::AtAddConstraint => { - if let Some(pgt_query::NodeEnum::Constraint(constraint)) = + pgls_query::protobuf::AlterTableType::AtAddConstraint => { + if let Some(pgls_query::NodeEnum::Constraint(constraint)) = &cmd.def.as_ref().and_then(|d| d.node.as_ref()) { // Check if it's a unique constraint without an existing index if constraint.contype() - == pgt_query::protobuf::ConstrType::ConstrUnique + == pgls_query::protobuf::ConstrType::ConstrUnique && constraint.indexname.is_empty() { diagnostics.push( @@ -90,17 +90,17 @@ impl Rule for DisallowUniqueConstraint { } } } - pgt_query::protobuf::AlterTableType::AtAddColumn => { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = + pgls_query::protobuf::AlterTableType::AtAddColumn => { + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = &cmd.def.as_ref().and_then(|d| d.node.as_ref()) { // Check for inline unique constraints for constraint in &col_def.constraints { - if let Some(pgt_query::NodeEnum::Constraint(constr)) = + if let Some(pgls_query::NodeEnum::Constraint(constr)) = &constraint.node { if constr.contype() - == pgt_query::protobuf::ConstrType::ConstrUnique + == pgls_query::protobuf::ConstrType::ConstrUnique { diagnostics.push( RuleDiagnostic::new( diff --git a/crates/pgt_analyser/src/lint/safety/prefer_big_int.rs b/crates/pgls_analyser/src/lint/safety/prefer_big_int.rs similarity index 80% rename from crates/pgt_analyser/src/lint/safety/prefer_big_int.rs rename to crates/pgls_analyser/src/lint/safety/prefer_big_int.rs index b44cb72fb..c89a08b5a 100644 --- a/crates/pgt_analyser/src/lint/safety/prefer_big_int.rs +++ b/crates/pgls_analyser/src/lint/safety/prefer_big_int.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Prefer BIGINT over smaller integer types. @@ -58,21 +58,21 @@ impl Rule for PreferBigInt { let mut diagnostics = Vec::new(); match &ctx.stmt() { - pgt_query::NodeEnum::CreateStmt(stmt) => { + pgls_query::NodeEnum::CreateStmt(stmt) => { for table_elt in &stmt.table_elts { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = &table_elt.node { + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = &table_elt.node { check_column_def(&mut diagnostics, col_def); } } } - pgt_query::NodeEnum::AlterTableStmt(stmt) => { + pgls_query::NodeEnum::AlterTableStmt(stmt) => { for cmd in &stmt.cmds { - if let Some(pgt_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { - if cmd.subtype() == pgt_query::protobuf::AlterTableType::AtAddColumn + if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { + if cmd.subtype() == pgls_query::protobuf::AlterTableType::AtAddColumn || cmd.subtype() - == pgt_query::protobuf::AlterTableType::AtAlterColumnType + == pgls_query::protobuf::AlterTableType::AtAlterColumnType { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = &cmd.def.as_ref().and_then(|d| d.node.as_ref()) { check_column_def(&mut diagnostics, col_def); @@ -90,11 +90,11 @@ impl Rule for PreferBigInt { fn check_column_def( diagnostics: &mut Vec, - col_def: &pgt_query::protobuf::ColumnDef, + col_def: &pgls_query::protobuf::ColumnDef, ) { if let Some(type_name) = &col_def.type_name { for name_node in &type_name.names { - if let Some(pgt_query::NodeEnum::String(name)) = &name_node.node { + if let Some(pgls_query::NodeEnum::String(name)) = &name_node.node { let type_name_lower = name.sval.to_lowercase(); let is_small_int = matches!( type_name_lower.as_str(), diff --git a/crates/pgt_analyser/src/lint/safety/prefer_bigint_over_int.rs b/crates/pgls_analyser/src/lint/safety/prefer_bigint_over_int.rs similarity index 78% rename from crates/pgt_analyser/src/lint/safety/prefer_bigint_over_int.rs rename to crates/pgls_analyser/src/lint/safety/prefer_bigint_over_int.rs index 755b8f9b8..71db41684 100644 --- a/crates/pgt_analyser/src/lint/safety/prefer_bigint_over_int.rs +++ b/crates/pgls_analyser/src/lint/safety/prefer_bigint_over_int.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Prefer BIGINT over INT/INTEGER types. @@ -64,21 +64,21 @@ impl Rule for PreferBigintOverInt { let mut diagnostics = Vec::new(); match &ctx.stmt() { - pgt_query::NodeEnum::CreateStmt(stmt) => { + pgls_query::NodeEnum::CreateStmt(stmt) => { for table_elt in &stmt.table_elts { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = &table_elt.node { + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = &table_elt.node { check_column_def(&mut diagnostics, col_def); } } } - pgt_query::NodeEnum::AlterTableStmt(stmt) => { + pgls_query::NodeEnum::AlterTableStmt(stmt) => { for cmd in &stmt.cmds { - if let Some(pgt_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { - if cmd.subtype() == pgt_query::protobuf::AlterTableType::AtAddColumn + if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { + if cmd.subtype() == pgls_query::protobuf::AlterTableType::AtAddColumn || cmd.subtype() - == pgt_query::protobuf::AlterTableType::AtAlterColumnType + == pgls_query::protobuf::AlterTableType::AtAlterColumnType { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = &cmd.def.as_ref().and_then(|d| d.node.as_ref()) { check_column_def(&mut diagnostics, col_def); @@ -96,14 +96,14 @@ impl Rule for PreferBigintOverInt { fn check_column_def( diagnostics: &mut Vec, - col_def: &pgt_query::protobuf::ColumnDef, + col_def: &pgls_query::protobuf::ColumnDef, ) { let Some(type_name) = &col_def.type_name else { return; }; for name_node in &type_name.names { - let Some(pgt_query::NodeEnum::String(name)) = &name_node.node else { + let Some(pgls_query::NodeEnum::String(name)) = &name_node.node else { continue; }; diff --git a/crates/pgt_analyser/src/lint/safety/prefer_bigint_over_smallint.rs b/crates/pgls_analyser/src/lint/safety/prefer_bigint_over_smallint.rs similarity index 78% rename from crates/pgt_analyser/src/lint/safety/prefer_bigint_over_smallint.rs rename to crates/pgls_analyser/src/lint/safety/prefer_bigint_over_smallint.rs index cffcc5b74..06e92bb11 100644 --- a/crates/pgt_analyser/src/lint/safety/prefer_bigint_over_smallint.rs +++ b/crates/pgls_analyser/src/lint/safety/prefer_bigint_over_smallint.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Prefer BIGINT over SMALLINT types. @@ -58,21 +58,21 @@ impl Rule for PreferBigintOverSmallint { let mut diagnostics = Vec::new(); match &ctx.stmt() { - pgt_query::NodeEnum::CreateStmt(stmt) => { + pgls_query::NodeEnum::CreateStmt(stmt) => { for table_elt in &stmt.table_elts { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = &table_elt.node { + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = &table_elt.node { check_column_def(&mut diagnostics, col_def); } } } - pgt_query::NodeEnum::AlterTableStmt(stmt) => { + pgls_query::NodeEnum::AlterTableStmt(stmt) => { for cmd in &stmt.cmds { - if let Some(pgt_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { - if cmd.subtype() == pgt_query::protobuf::AlterTableType::AtAddColumn + if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { + if cmd.subtype() == pgls_query::protobuf::AlterTableType::AtAddColumn || cmd.subtype() - == pgt_query::protobuf::AlterTableType::AtAlterColumnType + == pgls_query::protobuf::AlterTableType::AtAlterColumnType { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = &cmd.def.as_ref().and_then(|d| d.node.as_ref()) { check_column_def(&mut diagnostics, col_def); @@ -90,14 +90,14 @@ impl Rule for PreferBigintOverSmallint { fn check_column_def( diagnostics: &mut Vec, - col_def: &pgt_query::protobuf::ColumnDef, + col_def: &pgls_query::protobuf::ColumnDef, ) { let Some(type_name) = &col_def.type_name else { return; }; for name_node in &type_name.names { - let Some(pgt_query::NodeEnum::String(name)) = &name_node.node else { + let Some(pgls_query::NodeEnum::String(name)) = &name_node.node else { continue; }; diff --git a/crates/pgt_analyser/src/lint/safety/prefer_identity.rs b/crates/pgls_analyser/src/lint/safety/prefer_identity.rs similarity index 79% rename from crates/pgt_analyser/src/lint/safety/prefer_identity.rs rename to crates/pgls_analyser/src/lint/safety/prefer_identity.rs index 4abf4c4d1..ddc378b5c 100644 --- a/crates/pgt_analyser/src/lint/safety/prefer_identity.rs +++ b/crates/pgls_analyser/src/lint/safety/prefer_identity.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Prefer using IDENTITY columns over serial columns. @@ -59,22 +59,22 @@ impl Rule for PreferIdentity { let mut diagnostics = Vec::new(); match ctx.stmt() { - pgt_query::NodeEnum::CreateStmt(stmt) => { + pgls_query::NodeEnum::CreateStmt(stmt) => { for table_elt in &stmt.table_elts { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = &table_elt.node { + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = &table_elt.node { check_column_def(&mut diagnostics, col_def); } } } - pgt_query::NodeEnum::AlterTableStmt(stmt) => { + pgls_query::NodeEnum::AlterTableStmt(stmt) => { for cmd in &stmt.cmds { - if let Some(pgt_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { + if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { if matches!( cmd.subtype(), - pgt_query::protobuf::AlterTableType::AtAddColumn - | pgt_query::protobuf::AlterTableType::AtAlterColumnType + pgls_query::protobuf::AlterTableType::AtAddColumn + | pgls_query::protobuf::AlterTableType::AtAlterColumnType ) { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = &cmd.def.as_ref().and_then(|d| d.node.as_ref()) { check_column_def(&mut diagnostics, col_def); @@ -92,14 +92,14 @@ impl Rule for PreferIdentity { fn check_column_def( diagnostics: &mut Vec, - col_def: &pgt_query::protobuf::ColumnDef, + col_def: &pgls_query::protobuf::ColumnDef, ) { let Some(type_name) = &col_def.type_name else { return; }; for name_node in &type_name.names { - let Some(pgt_query::NodeEnum::String(name)) = &name_node.node else { + let Some(pgls_query::NodeEnum::String(name)) = &name_node.node else { continue; }; diff --git a/crates/pgt_analyser/src/lint/safety/prefer_jsonb.rs b/crates/pgls_analyser/src/lint/safety/prefer_jsonb.rs similarity index 80% rename from crates/pgt_analyser/src/lint/safety/prefer_jsonb.rs rename to crates/pgls_analyser/src/lint/safety/prefer_jsonb.rs index 152795b6c..637d32f01 100644 --- a/crates/pgt_analyser/src/lint/safety/prefer_jsonb.rs +++ b/crates/pgls_analyser/src/lint/safety/prefer_jsonb.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Prefer JSONB over JSON types. @@ -67,21 +67,21 @@ impl Rule for PreferJsonb { let mut diagnostics = Vec::new(); match &ctx.stmt() { - pgt_query::NodeEnum::CreateStmt(stmt) => { + pgls_query::NodeEnum::CreateStmt(stmt) => { for table_elt in &stmt.table_elts { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = &table_elt.node { + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = &table_elt.node { check_column_def(&mut diagnostics, col_def); } } } - pgt_query::NodeEnum::AlterTableStmt(stmt) => { + pgls_query::NodeEnum::AlterTableStmt(stmt) => { for cmd in &stmt.cmds { - if let Some(pgt_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { - if cmd.subtype() == pgt_query::protobuf::AlterTableType::AtAddColumn + if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { + if cmd.subtype() == pgls_query::protobuf::AlterTableType::AtAddColumn || cmd.subtype() - == pgt_query::protobuf::AlterTableType::AtAlterColumnType + == pgls_query::protobuf::AlterTableType::AtAlterColumnType { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = &cmd.def.as_ref().and_then(|d| d.node.as_ref()) { check_column_def(&mut diagnostics, col_def); @@ -99,14 +99,14 @@ impl Rule for PreferJsonb { fn check_column_def( diagnostics: &mut Vec, - col_def: &pgt_query::protobuf::ColumnDef, + col_def: &pgls_query::protobuf::ColumnDef, ) { let Some(type_name) = &col_def.type_name else { return; }; for name_node in &type_name.names { - let Some(pgt_query::NodeEnum::String(name)) = &name_node.node else { + let Some(pgls_query::NodeEnum::String(name)) = &name_node.node else { continue; }; diff --git a/crates/pgt_analyser/src/lint/safety/prefer_robust_stmts.rs b/crates/pgls_analyser/src/lint/safety/prefer_robust_stmts.rs similarity index 93% rename from crates/pgt_analyser/src/lint/safety/prefer_robust_stmts.rs rename to crates/pgls_analyser/src/lint/safety/prefer_robust_stmts.rs index 3f0b66f0f..021c08473 100644 --- a/crates/pgt_analyser/src/lint/safety/prefer_robust_stmts.rs +++ b/crates/pgls_analyser/src/lint/safety/prefer_robust_stmts.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Prefer statements with guards for robustness in migrations. @@ -49,7 +49,7 @@ impl Rule for PreferRobustStmts { // Since we assume we're always in a transaction, we only check for // statements that explicitly run outside transactions match &ctx.stmt() { - pgt_query::NodeEnum::IndexStmt(stmt) => { + pgls_query::NodeEnum::IndexStmt(stmt) => { // Concurrent index creation runs outside transaction if stmt.concurrent { // Check for unnamed index @@ -80,7 +80,7 @@ impl Rule for PreferRobustStmts { } } } - pgt_query::NodeEnum::DropStmt(stmt) => { + pgls_query::NodeEnum::DropStmt(stmt) => { // Concurrent drop runs outside transaction if stmt.concurrent && !stmt.missing_ok { diagnostics.push( diff --git a/crates/pgt_analyser/src/lint/safety/prefer_text_field.rs b/crates/pgls_analyser/src/lint/safety/prefer_text_field.rs similarity index 78% rename from crates/pgt_analyser/src/lint/safety/prefer_text_field.rs rename to crates/pgls_analyser/src/lint/safety/prefer_text_field.rs index 46f5bc757..ce03c9958 100644 --- a/crates/pgt_analyser/src/lint/safety/prefer_text_field.rs +++ b/crates/pgls_analyser/src/lint/safety/prefer_text_field.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Prefer using TEXT over VARCHAR(n) types. @@ -51,20 +51,20 @@ impl Rule for PreferTextField { let mut diagnostics = Vec::new(); match &ctx.stmt() { - pgt_query::NodeEnum::CreateStmt(stmt) => { + pgls_query::NodeEnum::CreateStmt(stmt) => { for table_elt in &stmt.table_elts { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = &table_elt.node { + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = &table_elt.node { check_column_def(&mut diagnostics, col_def); } } } - pgt_query::NodeEnum::AlterTableStmt(stmt) => { + pgls_query::NodeEnum::AlterTableStmt(stmt) => { for cmd in &stmt.cmds { - if let Some(pgt_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { + if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { match cmd.subtype() { - pgt_query::protobuf::AlterTableType::AtAddColumn - | pgt_query::protobuf::AlterTableType::AtAlterColumnType => { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = + pgls_query::protobuf::AlterTableType::AtAddColumn + | pgls_query::protobuf::AlterTableType::AtAlterColumnType => { + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = &cmd.def.as_ref().and_then(|d| d.node.as_ref()) { check_column_def(&mut diagnostics, col_def); @@ -84,11 +84,11 @@ impl Rule for PreferTextField { fn check_column_def( diagnostics: &mut Vec, - col_def: &pgt_query::protobuf::ColumnDef, + col_def: &pgls_query::protobuf::ColumnDef, ) { if let Some(type_name) = &col_def.type_name { for name_node in &type_name.names { - if let Some(pgt_query::NodeEnum::String(name)) = &name_node.node { + if let Some(pgls_query::NodeEnum::String(name)) = &name_node.node { // Check if it's varchar with a size limit if name.sval.to_lowercase() == "varchar" && !type_name.typmods.is_empty() { diagnostics.push( diff --git a/crates/pgt_analyser/src/lint/safety/prefer_timestamptz.rs b/crates/pgls_analyser/src/lint/safety/prefer_timestamptz.rs similarity index 79% rename from crates/pgt_analyser/src/lint/safety/prefer_timestamptz.rs rename to crates/pgls_analyser/src/lint/safety/prefer_timestamptz.rs index fb34e61c4..7dc876783 100644 --- a/crates/pgt_analyser/src/lint/safety/prefer_timestamptz.rs +++ b/crates/pgls_analyser/src/lint/safety/prefer_timestamptz.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Prefer TIMESTAMPTZ over TIMESTAMP types. @@ -64,20 +64,20 @@ impl Rule for PreferTimestamptz { let mut diagnostics = Vec::new(); match &ctx.stmt() { - pgt_query::NodeEnum::CreateStmt(stmt) => { + pgls_query::NodeEnum::CreateStmt(stmt) => { for table_elt in &stmt.table_elts { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = &table_elt.node { + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = &table_elt.node { check_column_def(&mut diagnostics, col_def); } } } - pgt_query::NodeEnum::AlterTableStmt(stmt) => { + pgls_query::NodeEnum::AlterTableStmt(stmt) => { for cmd in &stmt.cmds { - if let Some(pgt_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { + if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { match cmd.subtype() { - pgt_query::protobuf::AlterTableType::AtAddColumn - | pgt_query::protobuf::AlterTableType::AtAlterColumnType => { - if let Some(pgt_query::NodeEnum::ColumnDef(col_def)) = + pgls_query::protobuf::AlterTableType::AtAddColumn + | pgls_query::protobuf::AlterTableType::AtAlterColumnType => { + if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) = &cmd.def.as_ref().and_then(|d| d.node.as_ref()) { check_column_def(&mut diagnostics, col_def); @@ -97,11 +97,11 @@ impl Rule for PreferTimestamptz { fn check_column_def( diagnostics: &mut Vec, - col_def: &pgt_query::protobuf::ColumnDef, + col_def: &pgls_query::protobuf::ColumnDef, ) { if let Some(type_name) = &col_def.type_name { if let Some(last_name) = type_name.names.last() { - if let Some(pgt_query::NodeEnum::String(name)) = &last_name.node { + if let Some(pgls_query::NodeEnum::String(name)) = &last_name.node { // Check for "timestamp" (without timezone) if name.sval.to_lowercase() == "timestamp" { diagnostics.push( diff --git a/crates/pgt_analyser/src/lint/safety/renaming_column.rs b/crates/pgls_analyser/src/lint/safety/renaming_column.rs similarity index 81% rename from crates/pgt_analyser/src/lint/safety/renaming_column.rs rename to crates/pgls_analyser/src/lint/safety/renaming_column.rs index 8ab079e37..a7d151480 100644 --- a/crates/pgt_analyser/src/lint/safety/renaming_column.rs +++ b/crates/pgls_analyser/src/lint/safety/renaming_column.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Renaming columns may break existing queries and application code. @@ -32,8 +32,8 @@ impl Rule for RenamingColumn { fn run(ctx: &RuleContext) -> Vec { let mut diagnostics = Vec::new(); - if let pgt_query::NodeEnum::RenameStmt(stmt) = &ctx.stmt() { - if stmt.rename_type() == pgt_query::protobuf::ObjectType::ObjectColumn { + if let pgls_query::NodeEnum::RenameStmt(stmt) = &ctx.stmt() { + if stmt.rename_type() == pgls_query::protobuf::ObjectType::ObjectColumn { diagnostics.push(RuleDiagnostic::new( rule_category!(), None, diff --git a/crates/pgt_analyser/src/lint/safety/renaming_table.rs b/crates/pgls_analyser/src/lint/safety/renaming_table.rs similarity index 81% rename from crates/pgt_analyser/src/lint/safety/renaming_table.rs rename to crates/pgls_analyser/src/lint/safety/renaming_table.rs index 072ef3dd8..6c3465da8 100644 --- a/crates/pgt_analyser/src/lint/safety/renaming_table.rs +++ b/crates/pgls_analyser/src/lint/safety/renaming_table.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Renaming tables may break existing queries and application code. @@ -32,8 +32,8 @@ impl Rule for RenamingTable { fn run(ctx: &RuleContext) -> Vec { let mut diagnostics = Vec::new(); - if let pgt_query::NodeEnum::RenameStmt(stmt) = &ctx.stmt() { - if stmt.rename_type() == pgt_query::protobuf::ObjectType::ObjectTable { + if let pgls_query::NodeEnum::RenameStmt(stmt) = &ctx.stmt() { + if stmt.rename_type() == pgls_query::protobuf::ObjectType::ObjectTable { diagnostics.push(RuleDiagnostic::new( rule_category!(), None, diff --git a/crates/pgt_analyser/src/lint/safety/require_concurrent_index_creation.rs b/crates/pgls_analyser/src/lint/safety/require_concurrent_index_creation.rs similarity index 87% rename from crates/pgt_analyser/src/lint/safety/require_concurrent_index_creation.rs rename to crates/pgls_analyser/src/lint/safety/require_concurrent_index_creation.rs index 80a78a439..e2289ea8a 100644 --- a/crates/pgt_analyser/src/lint/safety/require_concurrent_index_creation.rs +++ b/crates/pgls_analyser/src/lint/safety/require_concurrent_index_creation.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Creating indexes non-concurrently can lock the table for writes. @@ -38,7 +38,7 @@ impl Rule for RequireConcurrentIndexCreation { fn run(ctx: &RuleContext) -> Vec { let mut diagnostics = Vec::new(); - let pgt_query::NodeEnum::IndexStmt(stmt) = &ctx.stmt() else { + let pgls_query::NodeEnum::IndexStmt(stmt) = &ctx.stmt() else { return diagnostics; }; @@ -75,12 +75,12 @@ impl Rule for RequireConcurrentIndexCreation { } fn is_table_created_in_file( - file_context: &pgt_analyse::AnalysedFileContext, + file_context: &pgls_analyse::AnalysedFileContext, table_name: &str, ) -> bool { // Check all statements in the file to see if this table was created for stmt in file_context.stmts { - if let pgt_query::NodeEnum::CreateStmt(create_stmt) = stmt { + if let pgls_query::NodeEnum::CreateStmt(create_stmt) = stmt { if let Some(relation) = &create_stmt.relation { if relation.relname == table_name { return true; diff --git a/crates/pgt_analyser/src/lint/safety/require_concurrent_index_deletion.rs b/crates/pgls_analyser/src/lint/safety/require_concurrent_index_deletion.rs similarity index 83% rename from crates/pgt_analyser/src/lint/safety/require_concurrent_index_deletion.rs rename to crates/pgls_analyser/src/lint/safety/require_concurrent_index_deletion.rs index 63f70de72..cac317170 100644 --- a/crates/pgt_analyser/src/lint/safety/require_concurrent_index_deletion.rs +++ b/crates/pgls_analyser/src/lint/safety/require_concurrent_index_deletion.rs @@ -1,6 +1,6 @@ -use pgt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Dropping indexes non-concurrently can lock the table for reads. @@ -38,9 +38,9 @@ impl Rule for RequireConcurrentIndexDeletion { fn run(ctx: &RuleContext) -> Vec { let mut diagnostics = Vec::new(); - if let pgt_query::NodeEnum::DropStmt(stmt) = &ctx.stmt() { + if let pgls_query::NodeEnum::DropStmt(stmt) = &ctx.stmt() { if !stmt.concurrent - && stmt.remove_type() == pgt_query::protobuf::ObjectType::ObjectIndex + && stmt.remove_type() == pgls_query::protobuf::ObjectType::ObjectIndex { diagnostics.push(RuleDiagnostic::new( rule_category!(), diff --git a/crates/pgt_analyser/src/lint/safety/transaction_nesting.rs b/crates/pgls_analyser/src/lint/safety/transaction_nesting.rs similarity index 79% rename from crates/pgt_analyser/src/lint/safety/transaction_nesting.rs rename to crates/pgls_analyser/src/lint/safety/transaction_nesting.rs index 209d47314..4f76c99db 100644 --- a/crates/pgt_analyser/src/lint/safety/transaction_nesting.rs +++ b/crates/pgls_analyser/src/lint/safety/transaction_nesting.rs @@ -1,8 +1,8 @@ -use pgt_analyse::{ +use pgls_analyse::{ AnalysedFileContext, Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule, }; -use pgt_console::markup; -use pgt_diagnostics::Severity; +use pgls_console::markup; +use pgls_diagnostics::Severity; declare_lint_rule! { /// Detects problematic transaction nesting that could lead to unexpected behavior. @@ -41,10 +41,10 @@ impl Rule for TransactionNesting { fn run(ctx: &RuleContext) -> Vec { let mut diagnostics = Vec::new(); - if let pgt_query::NodeEnum::TransactionStmt(stmt) = &ctx.stmt() { + if let pgls_query::NodeEnum::TransactionStmt(stmt) = &ctx.stmt() { match stmt.kind() { - pgt_query::protobuf::TransactionStmtKind::TransStmtBegin - | pgt_query::protobuf::TransactionStmtKind::TransStmtStart => { + pgls_query::protobuf::TransactionStmtKind::TransStmtBegin + | pgls_query::protobuf::TransactionStmtKind::TransStmtStart => { // Check if there's already a BEGIN in previous statements if has_transaction_start_before(ctx.file_context()) { diagnostics.push(RuleDiagnostic::new( @@ -65,8 +65,8 @@ impl Rule for TransactionNesting { ).detail(None, "Migration tools manage transactions automatically. Remove explicit transaction control.") .note("Put migration statements in separate files to have them be in separate transactions.")); } - pgt_query::protobuf::TransactionStmtKind::TransStmtCommit - | pgt_query::protobuf::TransactionStmtKind::TransStmtRollback => { + pgls_query::protobuf::TransactionStmtKind::TransStmtCommit + | pgls_query::protobuf::TransactionStmtKind::TransStmtRollback => { // Always warn about COMMIT/ROLLBACK since we assume we're in a transaction diagnostics.push(RuleDiagnostic::new( rule_category!(), @@ -87,12 +87,12 @@ impl Rule for TransactionNesting { fn has_transaction_start_before(file_context: &AnalysedFileContext) -> bool { for stmt in file_context.previous_stmts() { - if let pgt_query::NodeEnum::TransactionStmt(tx_stmt) = stmt { + if let pgls_query::NodeEnum::TransactionStmt(tx_stmt) = stmt { match tx_stmt.kind() { - pgt_query::protobuf::TransactionStmtKind::TransStmtBegin - | pgt_query::protobuf::TransactionStmtKind::TransStmtStart => return true, - pgt_query::protobuf::TransactionStmtKind::TransStmtCommit - | pgt_query::protobuf::TransactionStmtKind::TransStmtRollback => return false, + pgls_query::protobuf::TransactionStmtKind::TransStmtBegin + | pgls_query::protobuf::TransactionStmtKind::TransStmtStart => return true, + pgls_query::protobuf::TransactionStmtKind::TransStmtCommit + | pgls_query::protobuf::TransactionStmtKind::TransStmtRollback => return false, _ => {} } } diff --git a/crates/pgt_analyser/src/options.rs b/crates/pgls_analyser/src/options.rs similarity index 55% rename from crates/pgt_analyser/src/options.rs rename to crates/pgls_analyser/src/options.rs index 693e20b4c..3f432b281 100644 --- a/crates/pgt_analyser/src/options.rs +++ b/crates/pgls_analyser/src/options.rs @@ -2,46 +2,46 @@ use crate::lint; pub type AddingFieldWithDefault = - ::Options; -pub type AddingForeignKeyConstraint = < lint :: safety :: adding_foreign_key_constraint :: AddingForeignKeyConstraint as pgt_analyse :: Rule > :: Options ; + ::Options; +pub type AddingForeignKeyConstraint = < lint :: safety :: adding_foreign_key_constraint :: AddingForeignKeyConstraint as pgls_analyse :: Rule > :: Options ; pub type AddingNotNullField = - ::Options; -pub type AddingPrimaryKeyConstraint = < lint :: safety :: adding_primary_key_constraint :: AddingPrimaryKeyConstraint as pgt_analyse :: Rule > :: Options ; + ::Options; +pub type AddingPrimaryKeyConstraint = < lint :: safety :: adding_primary_key_constraint :: AddingPrimaryKeyConstraint as pgls_analyse :: Rule > :: Options ; pub type AddingRequiredField = - ::Options; -pub type BanCharField = ::Options; -pub type BanConcurrentIndexCreationInTransaction = < lint :: safety :: ban_concurrent_index_creation_in_transaction :: BanConcurrentIndexCreationInTransaction as pgt_analyse :: Rule > :: Options ; + ::Options; +pub type BanCharField = ::Options; +pub type BanConcurrentIndexCreationInTransaction = < lint :: safety :: ban_concurrent_index_creation_in_transaction :: BanConcurrentIndexCreationInTransaction as pgls_analyse :: Rule > :: Options ; pub type BanDropColumn = - ::Options; + ::Options; pub type BanDropDatabase = - ::Options; + ::Options; pub type BanDropNotNull = - ::Options; -pub type BanDropTable = ::Options; + ::Options; +pub type BanDropTable = ::Options; pub type BanTruncateCascade = - ::Options; + ::Options; pub type ChangingColumnType = - ::Options; -pub type ConstraintMissingNotValid = < lint :: safety :: constraint_missing_not_valid :: ConstraintMissingNotValid as pgt_analyse :: Rule > :: Options ; -pub type DisallowUniqueConstraint = < lint :: safety :: disallow_unique_constraint :: DisallowUniqueConstraint as pgt_analyse :: Rule > :: Options ; -pub type PreferBigInt = ::Options; + ::Options; +pub type ConstraintMissingNotValid = < lint :: safety :: constraint_missing_not_valid :: ConstraintMissingNotValid as pgls_analyse :: Rule > :: Options ; +pub type DisallowUniqueConstraint = < lint :: safety :: disallow_unique_constraint :: DisallowUniqueConstraint as pgls_analyse :: Rule > :: Options ; +pub type PreferBigInt = ::Options; pub type PreferBigintOverInt = - ::Options; -pub type PreferBigintOverSmallint = < lint :: safety :: prefer_bigint_over_smallint :: PreferBigintOverSmallint as pgt_analyse :: Rule > :: Options ; + ::Options; +pub type PreferBigintOverSmallint = < lint :: safety :: prefer_bigint_over_smallint :: PreferBigintOverSmallint as pgls_analyse :: Rule > :: Options ; pub type PreferIdentity = - ::Options; -pub type PreferJsonb = ::Options; + ::Options; +pub type PreferJsonb = ::Options; pub type PreferRobustStmts = - ::Options; + ::Options; pub type PreferTextField = - ::Options; + ::Options; pub type PreferTimestamptz = - ::Options; + ::Options; pub type RenamingColumn = - ::Options; + ::Options; pub type RenamingTable = - ::Options; -pub type RequireConcurrentIndexCreation = < lint :: safety :: require_concurrent_index_creation :: RequireConcurrentIndexCreation as pgt_analyse :: Rule > :: Options ; -pub type RequireConcurrentIndexDeletion = < lint :: safety :: require_concurrent_index_deletion :: RequireConcurrentIndexDeletion as pgt_analyse :: Rule > :: Options ; + ::Options; +pub type RequireConcurrentIndexCreation = < lint :: safety :: require_concurrent_index_creation :: RequireConcurrentIndexCreation as pgls_analyse :: Rule > :: Options ; +pub type RequireConcurrentIndexDeletion = < lint :: safety :: require_concurrent_index_deletion :: RequireConcurrentIndexDeletion as pgls_analyse :: Rule > :: Options ; pub type TransactionNesting = - ::Options; + ::Options; diff --git a/crates/pgt_analyser/src/registry.rs b/crates/pgls_analyser/src/registry.rs similarity index 83% rename from crates/pgt_analyser/src/registry.rs rename to crates/pgls_analyser/src/registry.rs index fb549575d..4978e40fd 100644 --- a/crates/pgt_analyser/src/registry.rs +++ b/crates/pgls_analyser/src/registry.rs @@ -1,6 +1,6 @@ //! Generated file, do not edit by hand, see `xtask/codegen` -use pgt_analyse::RegistryVisitor; +use pgls_analyse::RegistryVisitor; pub fn visit_registry(registry: &mut V) { registry.record_category::(); } diff --git a/crates/pgt_analyser/tests/rules_tests.rs b/crates/pgls_analyser/tests/rules_tests.rs similarity index 92% rename from crates/pgt_analyser/tests/rules_tests.rs rename to crates/pgls_analyser/tests/rules_tests.rs index 5334246b8..5aa8e0513 100644 --- a/crates/pgt_analyser/tests/rules_tests.rs +++ b/crates/pgls_analyser/tests/rules_tests.rs @@ -1,12 +1,12 @@ use core::slice; use std::{collections::HashMap, fmt::Write, fs::read_to_string, path::Path}; -use pgt_analyse::{AnalyserOptions, AnalysisFilter, RuleDiagnostic, RuleFilter}; -use pgt_analyser::{AnalysableStatement, Analyser, AnalyserConfig, AnalyserParams}; -use pgt_console::StdDisplay; -use pgt_diagnostics::PrintDiagnostic; +use pgls_analyse::{AnalyserOptions, AnalysisFilter, RuleDiagnostic, RuleFilter}; +use pgls_analyser::{AnalysableStatement, Analyser, AnalyserConfig, AnalyserParams}; +use pgls_console::StdDisplay; +use pgls_diagnostics::PrintDiagnostic; -pgt_test_macros::gen_tests! { +pgls_test_macros::gen_tests! { "tests/specs/**/*.sql", crate::rule_test } @@ -31,14 +31,14 @@ fn rule_test(full_path: &'static str, _: &str, _: &str) { filter, }); - let split = pgt_statement_splitter::split(&query); + let split = pgls_statement_splitter::split(&query); let stmts = split .ranges .iter() .map(|r| { let text = &query[*r]; - let ast = pgt_query::parse(text).expect("failed to parse SQL"); + let ast = pgls_query::parse(text).expect("failed to parse SQL"); AnalysableStatement { root: ast.into_root().expect("Failed to convert AST to root node"), diff --git a/crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/basic.sql b/crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/basic.sql rename to crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/generated_column.sql b/crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/generated_column.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/generated_column.sql rename to crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/generated_column.sql diff --git a/crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/generated_column.sql.snap b/crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/generated_column.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/generated_column.sql.snap rename to crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/generated_column.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/no_default.sql b/crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/no_default.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/no_default.sql rename to crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/no_default.sql diff --git a/crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/no_default.sql.snap b/crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/no_default.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/no_default.sql.snap rename to crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/no_default.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/non_volatile_default.sql b/crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/non_volatile_default.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/non_volatile_default.sql rename to crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/non_volatile_default.sql diff --git a/crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/non_volatile_default.sql.snap b/crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/non_volatile_default.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/non_volatile_default.sql.snap rename to crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/non_volatile_default.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/volatile_default.sql b/crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/volatile_default.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/volatile_default.sql rename to crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/volatile_default.sql diff --git a/crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/volatile_default.sql.snap b/crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/volatile_default.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingFieldWithDefault/volatile_default.sql.snap rename to crates/pgls_analyser/tests/specs/safety/addingFieldWithDefault/volatile_default.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/addingForeignKeyConstraint/basic.sql b/crates/pgls_analyser/tests/specs/safety/addingForeignKeyConstraint/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingForeignKeyConstraint/basic.sql rename to crates/pgls_analyser/tests/specs/safety/addingForeignKeyConstraint/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/addingForeignKeyConstraint/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/addingForeignKeyConstraint/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingForeignKeyConstraint/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/addingForeignKeyConstraint/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/addingNotNullField/basic.sql b/crates/pgls_analyser/tests/specs/safety/addingNotNullField/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingNotNullField/basic.sql rename to crates/pgls_analyser/tests/specs/safety/addingNotNullField/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/addingNotNullField/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/addingNotNullField/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingNotNullField/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/addingNotNullField/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/addingPrimaryKeyConstraint/basic.sql b/crates/pgls_analyser/tests/specs/safety/addingPrimaryKeyConstraint/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingPrimaryKeyConstraint/basic.sql rename to crates/pgls_analyser/tests/specs/safety/addingPrimaryKeyConstraint/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/addingPrimaryKeyConstraint/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/addingPrimaryKeyConstraint/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingPrimaryKeyConstraint/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/addingPrimaryKeyConstraint/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/addingPrimaryKeyConstraint/serial_column.sql b/crates/pgls_analyser/tests/specs/safety/addingPrimaryKeyConstraint/serial_column.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingPrimaryKeyConstraint/serial_column.sql rename to crates/pgls_analyser/tests/specs/safety/addingPrimaryKeyConstraint/serial_column.sql diff --git a/crates/pgt_analyser/tests/specs/safety/addingPrimaryKeyConstraint/serial_column.sql.snap b/crates/pgls_analyser/tests/specs/safety/addingPrimaryKeyConstraint/serial_column.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingPrimaryKeyConstraint/serial_column.sql.snap rename to crates/pgls_analyser/tests/specs/safety/addingPrimaryKeyConstraint/serial_column.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/addingPrimaryKeyConstraint/using_index.sql b/crates/pgls_analyser/tests/specs/safety/addingPrimaryKeyConstraint/using_index.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingPrimaryKeyConstraint/using_index.sql rename to crates/pgls_analyser/tests/specs/safety/addingPrimaryKeyConstraint/using_index.sql diff --git a/crates/pgt_analyser/tests/specs/safety/addingPrimaryKeyConstraint/using_index.sql.snap b/crates/pgls_analyser/tests/specs/safety/addingPrimaryKeyConstraint/using_index.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingPrimaryKeyConstraint/using_index.sql.snap rename to crates/pgls_analyser/tests/specs/safety/addingPrimaryKeyConstraint/using_index.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/addingRequiredField/basic.sql b/crates/pgls_analyser/tests/specs/safety/addingRequiredField/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingRequiredField/basic.sql rename to crates/pgls_analyser/tests/specs/safety/addingRequiredField/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/addingRequiredField/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/addingRequiredField/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingRequiredField/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/addingRequiredField/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/addingRequiredField/with_default.sql b/crates/pgls_analyser/tests/specs/safety/addingRequiredField/with_default.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingRequiredField/with_default.sql rename to crates/pgls_analyser/tests/specs/safety/addingRequiredField/with_default.sql diff --git a/crates/pgt_analyser/tests/specs/safety/addingRequiredField/with_default.sql.snap b/crates/pgls_analyser/tests/specs/safety/addingRequiredField/with_default.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingRequiredField/with_default.sql.snap rename to crates/pgls_analyser/tests/specs/safety/addingRequiredField/with_default.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/addingRequiredField/without_required.sql b/crates/pgls_analyser/tests/specs/safety/addingRequiredField/without_required.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingRequiredField/without_required.sql rename to crates/pgls_analyser/tests/specs/safety/addingRequiredField/without_required.sql diff --git a/crates/pgt_analyser/tests/specs/safety/addingRequiredField/without_required.sql.snap b/crates/pgls_analyser/tests/specs/safety/addingRequiredField/without_required.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/addingRequiredField/without_required.sql.snap rename to crates/pgls_analyser/tests/specs/safety/addingRequiredField/without_required.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/banCharField/alter_table.sql b/crates/pgls_analyser/tests/specs/safety/banCharField/alter_table.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banCharField/alter_table.sql rename to crates/pgls_analyser/tests/specs/safety/banCharField/alter_table.sql diff --git a/crates/pgt_analyser/tests/specs/safety/banCharField/alter_table.sql.snap b/crates/pgls_analyser/tests/specs/safety/banCharField/alter_table.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banCharField/alter_table.sql.snap rename to crates/pgls_analyser/tests/specs/safety/banCharField/alter_table.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/banCharField/basic.sql b/crates/pgls_analyser/tests/specs/safety/banCharField/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banCharField/basic.sql rename to crates/pgls_analyser/tests/specs/safety/banCharField/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/banCharField/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/banCharField/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banCharField/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/banCharField/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/banCharField/bpchar.sql b/crates/pgls_analyser/tests/specs/safety/banCharField/bpchar.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banCharField/bpchar.sql rename to crates/pgls_analyser/tests/specs/safety/banCharField/bpchar.sql diff --git a/crates/pgt_analyser/tests/specs/safety/banCharField/bpchar.sql.snap b/crates/pgls_analyser/tests/specs/safety/banCharField/bpchar.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banCharField/bpchar.sql.snap rename to crates/pgls_analyser/tests/specs/safety/banCharField/bpchar.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/banCharField/varchar_valid.sql b/crates/pgls_analyser/tests/specs/safety/banCharField/varchar_valid.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banCharField/varchar_valid.sql rename to crates/pgls_analyser/tests/specs/safety/banCharField/varchar_valid.sql diff --git a/crates/pgt_analyser/tests/specs/safety/banCharField/varchar_valid.sql.snap b/crates/pgls_analyser/tests/specs/safety/banCharField/varchar_valid.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banCharField/varchar_valid.sql.snap rename to crates/pgls_analyser/tests/specs/safety/banCharField/varchar_valid.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/banConcurrentIndexCreationInTransaction/basic.sql b/crates/pgls_analyser/tests/specs/safety/banConcurrentIndexCreationInTransaction/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banConcurrentIndexCreationInTransaction/basic.sql rename to crates/pgls_analyser/tests/specs/safety/banConcurrentIndexCreationInTransaction/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/banConcurrentIndexCreationInTransaction/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/banConcurrentIndexCreationInTransaction/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banConcurrentIndexCreationInTransaction/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/banConcurrentIndexCreationInTransaction/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/banDropColumn/basic.sql b/crates/pgls_analyser/tests/specs/safety/banDropColumn/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banDropColumn/basic.sql rename to crates/pgls_analyser/tests/specs/safety/banDropColumn/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/banDropColumn/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/banDropColumn/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banDropColumn/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/banDropColumn/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/banDropDatabase/basic.sql b/crates/pgls_analyser/tests/specs/safety/banDropDatabase/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banDropDatabase/basic.sql rename to crates/pgls_analyser/tests/specs/safety/banDropDatabase/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/banDropDatabase/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/banDropDatabase/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banDropDatabase/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/banDropDatabase/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/banDropNotNull/basic.sql b/crates/pgls_analyser/tests/specs/safety/banDropNotNull/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banDropNotNull/basic.sql rename to crates/pgls_analyser/tests/specs/safety/banDropNotNull/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/banDropNotNull/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/banDropNotNull/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banDropNotNull/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/banDropNotNull/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/banDropTable/basic.sql b/crates/pgls_analyser/tests/specs/safety/banDropTable/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banDropTable/basic.sql rename to crates/pgls_analyser/tests/specs/safety/banDropTable/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/banDropTable/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/banDropTable/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banDropTable/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/banDropTable/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/banTruncateCascade/basic.sql b/crates/pgls_analyser/tests/specs/safety/banTruncateCascade/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banTruncateCascade/basic.sql rename to crates/pgls_analyser/tests/specs/safety/banTruncateCascade/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/banTruncateCascade/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/banTruncateCascade/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/banTruncateCascade/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/banTruncateCascade/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/changingColumnType/basic.sql b/crates/pgls_analyser/tests/specs/safety/changingColumnType/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/changingColumnType/basic.sql rename to crates/pgls_analyser/tests/specs/safety/changingColumnType/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/changingColumnType/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/changingColumnType/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/changingColumnType/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/changingColumnType/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/constraintMissingNotValid/basic.sql b/crates/pgls_analyser/tests/specs/safety/constraintMissingNotValid/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/constraintMissingNotValid/basic.sql rename to crates/pgls_analyser/tests/specs/safety/constraintMissingNotValid/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/constraintMissingNotValid/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/constraintMissingNotValid/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/constraintMissingNotValid/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/constraintMissingNotValid/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/constraintMissingNotValid/check_constraint.sql b/crates/pgls_analyser/tests/specs/safety/constraintMissingNotValid/check_constraint.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/constraintMissingNotValid/check_constraint.sql rename to crates/pgls_analyser/tests/specs/safety/constraintMissingNotValid/check_constraint.sql diff --git a/crates/pgt_analyser/tests/specs/safety/constraintMissingNotValid/check_constraint.sql.snap b/crates/pgls_analyser/tests/specs/safety/constraintMissingNotValid/check_constraint.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/constraintMissingNotValid/check_constraint.sql.snap rename to crates/pgls_analyser/tests/specs/safety/constraintMissingNotValid/check_constraint.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/constraintMissingNotValid/with_not_valid.sql b/crates/pgls_analyser/tests/specs/safety/constraintMissingNotValid/with_not_valid.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/constraintMissingNotValid/with_not_valid.sql rename to crates/pgls_analyser/tests/specs/safety/constraintMissingNotValid/with_not_valid.sql diff --git a/crates/pgt_analyser/tests/specs/safety/constraintMissingNotValid/with_not_valid.sql.snap b/crates/pgls_analyser/tests/specs/safety/constraintMissingNotValid/with_not_valid.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/constraintMissingNotValid/with_not_valid.sql.snap rename to crates/pgls_analyser/tests/specs/safety/constraintMissingNotValid/with_not_valid.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/preferBigInt/basic.sql b/crates/pgls_analyser/tests/specs/safety/preferBigInt/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferBigInt/basic.sql rename to crates/pgls_analyser/tests/specs/safety/preferBigInt/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/preferBigInt/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/preferBigInt/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferBigInt/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/preferBigInt/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/preferBigintOverInt/basic.sql b/crates/pgls_analyser/tests/specs/safety/preferBigintOverInt/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferBigintOverInt/basic.sql rename to crates/pgls_analyser/tests/specs/safety/preferBigintOverInt/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/preferBigintOverInt/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/preferBigintOverInt/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferBigintOverInt/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/preferBigintOverInt/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/preferBigintOverSmallint/basic.sql b/crates/pgls_analyser/tests/specs/safety/preferBigintOverSmallint/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferBigintOverSmallint/basic.sql rename to crates/pgls_analyser/tests/specs/safety/preferBigintOverSmallint/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/preferBigintOverSmallint/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/preferBigintOverSmallint/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferBigintOverSmallint/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/preferBigintOverSmallint/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/preferIdentity/alter_table.sql b/crates/pgls_analyser/tests/specs/safety/preferIdentity/alter_table.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferIdentity/alter_table.sql rename to crates/pgls_analyser/tests/specs/safety/preferIdentity/alter_table.sql diff --git a/crates/pgt_analyser/tests/specs/safety/preferIdentity/alter_table.sql.snap b/crates/pgls_analyser/tests/specs/safety/preferIdentity/alter_table.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferIdentity/alter_table.sql.snap rename to crates/pgls_analyser/tests/specs/safety/preferIdentity/alter_table.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/preferIdentity/basic.sql b/crates/pgls_analyser/tests/specs/safety/preferIdentity/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferIdentity/basic.sql rename to crates/pgls_analyser/tests/specs/safety/preferIdentity/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/preferIdentity/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/preferIdentity/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferIdentity/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/preferIdentity/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/preferIdentity/bigserial.sql b/crates/pgls_analyser/tests/specs/safety/preferIdentity/bigserial.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferIdentity/bigserial.sql rename to crates/pgls_analyser/tests/specs/safety/preferIdentity/bigserial.sql diff --git a/crates/pgt_analyser/tests/specs/safety/preferIdentity/bigserial.sql.snap b/crates/pgls_analyser/tests/specs/safety/preferIdentity/bigserial.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferIdentity/bigserial.sql.snap rename to crates/pgls_analyser/tests/specs/safety/preferIdentity/bigserial.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/preferIdentity/valid.sql b/crates/pgls_analyser/tests/specs/safety/preferIdentity/valid.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferIdentity/valid.sql rename to crates/pgls_analyser/tests/specs/safety/preferIdentity/valid.sql diff --git a/crates/pgt_analyser/tests/specs/safety/preferIdentity/valid.sql.snap b/crates/pgls_analyser/tests/specs/safety/preferIdentity/valid.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferIdentity/valid.sql.snap rename to crates/pgls_analyser/tests/specs/safety/preferIdentity/valid.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/preferJsonb/basic.sql b/crates/pgls_analyser/tests/specs/safety/preferJsonb/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferJsonb/basic.sql rename to crates/pgls_analyser/tests/specs/safety/preferJsonb/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/preferJsonb/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/preferJsonb/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferJsonb/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/preferJsonb/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/preferRobustStmts/basic.sql b/crates/pgls_analyser/tests/specs/safety/preferRobustStmts/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferRobustStmts/basic.sql rename to crates/pgls_analyser/tests/specs/safety/preferRobustStmts/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/preferRobustStmts/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/preferRobustStmts/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferRobustStmts/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/preferRobustStmts/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/preferRobustStmts/drop_without_if_exists.sql b/crates/pgls_analyser/tests/specs/safety/preferRobustStmts/drop_without_if_exists.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferRobustStmts/drop_without_if_exists.sql rename to crates/pgls_analyser/tests/specs/safety/preferRobustStmts/drop_without_if_exists.sql diff --git a/crates/pgt_analyser/tests/specs/safety/preferRobustStmts/drop_without_if_exists.sql.snap b/crates/pgls_analyser/tests/specs/safety/preferRobustStmts/drop_without_if_exists.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferRobustStmts/drop_without_if_exists.sql.snap rename to crates/pgls_analyser/tests/specs/safety/preferRobustStmts/drop_without_if_exists.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/preferRobustStmts/robust_statements.sql b/crates/pgls_analyser/tests/specs/safety/preferRobustStmts/robust_statements.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferRobustStmts/robust_statements.sql rename to crates/pgls_analyser/tests/specs/safety/preferRobustStmts/robust_statements.sql diff --git a/crates/pgt_analyser/tests/specs/safety/preferRobustStmts/robust_statements.sql.snap b/crates/pgls_analyser/tests/specs/safety/preferRobustStmts/robust_statements.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/preferRobustStmts/robust_statements.sql.snap rename to crates/pgls_analyser/tests/specs/safety/preferRobustStmts/robust_statements.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/renamingColumn/basic.sql b/crates/pgls_analyser/tests/specs/safety/renamingColumn/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/renamingColumn/basic.sql rename to crates/pgls_analyser/tests/specs/safety/renamingColumn/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/renamingColumn/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/renamingColumn/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/renamingColumn/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/renamingColumn/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/renamingTable/basic.sql b/crates/pgls_analyser/tests/specs/safety/renamingTable/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/renamingTable/basic.sql rename to crates/pgls_analyser/tests/specs/safety/renamingTable/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/renamingTable/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/renamingTable/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/renamingTable/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/renamingTable/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexCreation/basic.sql b/crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexCreation/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexCreation/basic.sql rename to crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexCreation/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexCreation/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexCreation/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexCreation/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexCreation/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexCreation/concurrent_valid.sql b/crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexCreation/concurrent_valid.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexCreation/concurrent_valid.sql rename to crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexCreation/concurrent_valid.sql diff --git a/crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexCreation/concurrent_valid.sql.snap b/crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexCreation/concurrent_valid.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexCreation/concurrent_valid.sql.snap rename to crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexCreation/concurrent_valid.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexCreation/new_table_valid.sql b/crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexCreation/new_table_valid.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexCreation/new_table_valid.sql rename to crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexCreation/new_table_valid.sql diff --git a/crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexCreation/new_table_valid.sql.snap b/crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexCreation/new_table_valid.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexCreation/new_table_valid.sql.snap rename to crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexCreation/new_table_valid.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexDeletion/basic.sql b/crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexDeletion/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexDeletion/basic.sql rename to crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexDeletion/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexDeletion/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexDeletion/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexDeletion/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexDeletion/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexDeletion/concurrent_valid.sql b/crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexDeletion/concurrent_valid.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexDeletion/concurrent_valid.sql rename to crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexDeletion/concurrent_valid.sql diff --git a/crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexDeletion/concurrent_valid.sql.snap b/crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexDeletion/concurrent_valid.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/requireConcurrentIndexDeletion/concurrent_valid.sql.snap rename to crates/pgls_analyser/tests/specs/safety/requireConcurrentIndexDeletion/concurrent_valid.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/transactionNesting/basic.sql b/crates/pgls_analyser/tests/specs/safety/transactionNesting/basic.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/transactionNesting/basic.sql rename to crates/pgls_analyser/tests/specs/safety/transactionNesting/basic.sql diff --git a/crates/pgt_analyser/tests/specs/safety/transactionNesting/basic.sql.snap b/crates/pgls_analyser/tests/specs/safety/transactionNesting/basic.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/transactionNesting/basic.sql.snap rename to crates/pgls_analyser/tests/specs/safety/transactionNesting/basic.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/transactionNesting/begin_commit_combined.sql b/crates/pgls_analyser/tests/specs/safety/transactionNesting/begin_commit_combined.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/transactionNesting/begin_commit_combined.sql rename to crates/pgls_analyser/tests/specs/safety/transactionNesting/begin_commit_combined.sql diff --git a/crates/pgt_analyser/tests/specs/safety/transactionNesting/begin_commit_combined.sql.snap b/crates/pgls_analyser/tests/specs/safety/transactionNesting/begin_commit_combined.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/transactionNesting/begin_commit_combined.sql.snap rename to crates/pgls_analyser/tests/specs/safety/transactionNesting/begin_commit_combined.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/transactionNesting/commit.sql b/crates/pgls_analyser/tests/specs/safety/transactionNesting/commit.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/transactionNesting/commit.sql rename to crates/pgls_analyser/tests/specs/safety/transactionNesting/commit.sql diff --git a/crates/pgt_analyser/tests/specs/safety/transactionNesting/commit.sql.snap b/crates/pgls_analyser/tests/specs/safety/transactionNesting/commit.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/transactionNesting/commit.sql.snap rename to crates/pgls_analyser/tests/specs/safety/transactionNesting/commit.sql.snap diff --git a/crates/pgt_analyser/tests/specs/safety/transactionNesting/rollback.sql b/crates/pgls_analyser/tests/specs/safety/transactionNesting/rollback.sql similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/transactionNesting/rollback.sql rename to crates/pgls_analyser/tests/specs/safety/transactionNesting/rollback.sql diff --git a/crates/pgt_analyser/tests/specs/safety/transactionNesting/rollback.sql.snap b/crates/pgls_analyser/tests/specs/safety/transactionNesting/rollback.sql.snap similarity index 100% rename from crates/pgt_analyser/tests/specs/safety/transactionNesting/rollback.sql.snap rename to crates/pgls_analyser/tests/specs/safety/transactionNesting/rollback.sql.snap diff --git a/crates/pgt_cli/Cargo.toml b/crates/pgls_cli/Cargo.toml similarity index 79% rename from crates/pgt_cli/Cargo.toml rename to crates/pgls_cli/Cargo.toml index f2a3fa181..0ee1de72e 100644 --- a/crates/pgt_cli/Cargo.toml +++ b/crates/pgls_cli/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_cli" +name = "pgls_cli" repository.workspace = true version = "0.0.0" @@ -20,15 +20,15 @@ crossbeam = { workspace = true } dashmap = "5.5.3" hdrhistogram = { version = "7.5.4", default-features = false } path-absolutize = { version = "3.1.1", optional = false, features = ["use_unix_paths_on_wasm"] } -pgt_analyse = { workspace = true } -pgt_configuration = { workspace = true } -pgt_console = { workspace = true } -pgt_diagnostics = { workspace = true } -pgt_flags = { workspace = true } -pgt_fs = { workspace = true } -pgt_lsp = { workspace = true } -pgt_text_edit = { workspace = true } -pgt_workspace = { workspace = true } +pgls_analyse = { workspace = true } +pgls_configuration = { workspace = true } +pgls_console = { workspace = true } +pgls_diagnostics = { workspace = true } +pgls_flags = { workspace = true } +pgls_fs = { workspace = true } +pgls_lsp = { workspace = true } +pgls_text_edit = { workspace = true } +pgls_workspace = { workspace = true } quick-junit = "0.5.0" rayon = { workspace = true } rustc-hash = { workspace = true } @@ -59,5 +59,5 @@ predicates = "3.1.3" doctest = false [[bin]] -name = "postgrestools" +name = "pgls" path = "src/main.rs" diff --git a/crates/pgt_cli/src/changed.rs b/crates/pgls_cli/src/changed.rs similarity index 92% rename from crates/pgt_cli/src/changed.rs rename to crates/pgls_cli/src/changed.rs index a18502dd7..11f7e3b68 100644 --- a/crates/pgt_cli/src/changed.rs +++ b/crates/pgls_cli/src/changed.rs @@ -1,7 +1,7 @@ use crate::CliDiagnostic; -use pgt_configuration::PartialConfiguration; -use pgt_fs::FileSystem; -use pgt_workspace::DynRef; +use pgls_configuration::PartialConfiguration; +use pgls_fs::FileSystem; +use pgls_workspace::DynRef; use std::ffi::OsString; pub(crate) fn get_changed_files( diff --git a/crates/pgt_cli/src/cli_options.rs b/crates/pgls_cli/src/cli_options.rs similarity index 95% rename from crates/pgt_cli/src/cli_options.rs rename to crates/pgls_cli/src/cli_options.rs index 5c41c7fc1..c9947c2c6 100644 --- a/crates/pgt_cli/src/cli_options.rs +++ b/crates/pgls_cli/src/cli_options.rs @@ -1,8 +1,8 @@ use crate::LoggingLevel; use crate::logging::LoggingKind; use bpaf::Bpaf; -use pgt_configuration::ConfigurationPathHint; -use pgt_diagnostics::Severity; +use pgls_configuration::ConfigurationPathHint; +use pgls_diagnostics::Severity; use std::fmt::{Display, Formatter}; use std::path::PathBuf; use std::str::FromStr; @@ -22,7 +22,7 @@ pub struct CliOptions { #[bpaf(long("verbose"), switch, fallback(false))] pub verbose: bool, - /// Set the file path to the configuration file, or the directory path to find `postgrestools.jsonc`. + /// Set the file path to the configuration file, or the directory path to find `postgres-language-server.jsonc`. /// If used, it disables the default configuration file resolution. #[bpaf(long("config-path"), argument("PATH"), optional)] pub config_path: Option, @@ -44,7 +44,7 @@ pub struct CliOptions { #[bpaf(long("no-errors-on-unmatched"), switch)] pub no_errors_on_unmatched: bool, - /// Tell Postgres Tools to exit with an error code if some diagnostics emit warnings. + /// Tell Postgres Language Server to exit with an error code if some diagnostics emit warnings. #[bpaf(long("error-on-warnings"), switch)] pub error_on_warnings: bool, @@ -83,7 +83,7 @@ pub struct CliOptions { fallback(Severity::default()), display_fallback )] - /// The level of diagnostics to show. In order, from the lowest to the most important: info, warn, error. Passing `--diagnostic-level=error` will cause Postgres Tools to print only diagnostics that contain only errors. + /// The level of diagnostics to show. In order, from the lowest to the most important: info, warn, error. Passing `--diagnostic-level=error` will cause Postgres Language Server to print only diagnostics that contain only errors. pub diagnostic_level: Severity, } diff --git a/crates/pgt_cli/src/commands/check.rs b/crates/pgls_cli/src/commands/check.rs similarity index 91% rename from crates/pgt_cli/src/commands/check.rs rename to crates/pgls_cli/src/commands/check.rs index 468196244..1296b88e3 100644 --- a/crates/pgt_cli/src/commands/check.rs +++ b/crates/pgls_cli/src/commands/check.rs @@ -1,10 +1,10 @@ use crate::cli_options::CliOptions; use crate::{CliDiagnostic, Execution, TraversalMode}; use biome_deserialize::Merge; -use pgt_configuration::PartialConfiguration; -use pgt_console::Console; -use pgt_fs::FileSystem; -use pgt_workspace::{DynRef, Workspace, WorkspaceError, configuration::LoadedConfiguration}; +use pgls_configuration::PartialConfiguration; +use pgls_console::Console; +use pgls_fs::FileSystem; +use pgls_workspace::{DynRef, Workspace, WorkspaceError, configuration::LoadedConfiguration}; use std::ffi::OsString; use super::{CommandRunner, get_files_to_process_with_cli_options}; diff --git a/crates/pgt_cli/src/commands/clean.rs b/crates/pgls_cli/src/commands/clean.rs similarity index 94% rename from crates/pgt_cli/src/commands/clean.rs rename to crates/pgls_cli/src/commands/clean.rs index e401f3077..b98c51389 100644 --- a/crates/pgt_cli/src/commands/clean.rs +++ b/crates/pgls_cli/src/commands/clean.rs @@ -1,6 +1,6 @@ use crate::commands::daemon::default_pgt_log_path; use crate::{CliDiagnostic, CliSession}; -use pgt_flags::pgt_env; +use pgls_flags::pgt_env; use std::fs::{create_dir, remove_dir_all}; use std::path::PathBuf; diff --git a/crates/pgt_cli/src/commands/daemon.rs b/crates/pgls_cli/src/commands/daemon.rs similarity index 96% rename from crates/pgt_cli/src/commands/daemon.rs rename to crates/pgls_cli/src/commands/daemon.rs index 988286f46..18b832a60 100644 --- a/crates/pgt_cli/src/commands/daemon.rs +++ b/crates/pgls_cli/src/commands/daemon.rs @@ -2,9 +2,9 @@ use crate::{ CliDiagnostic, CliSession, open_transport, service::{self, ensure_daemon, open_socket, run_daemon}, }; -use pgt_console::{ConsoleExt, markup}; -use pgt_lsp::ServerFactory; -use pgt_workspace::{TransportError, WorkspaceError, workspace::WorkspaceClient}; +use pgls_console::{ConsoleExt, markup}; +use pgls_lsp::ServerFactory; +use pgls_workspace::{TransportError, WorkspaceError, workspace::WorkspaceClient}; use std::{env, path::PathBuf}; use tokio::io; use tokio::runtime::Runtime; @@ -189,7 +189,7 @@ fn setup_tracing_subscriber( log_level: Option, log_kind: Option, ) { - let pgt_log_path = log_path.unwrap_or(pgt_fs::ensure_cache_dir().join("pgt-logs")); + let pgt_log_path = log_path.unwrap_or(pgls_fs::ensure_cache_dir().join("pgt-logs")); let appender_builder = tracing_appender::rolling::RollingFileAppender::builder(); @@ -236,7 +236,7 @@ fn setup_tracing_subscriber( pub fn default_pgt_log_path() -> PathBuf { match env::var_os("PGT_LOG_PATH") { Some(directory) => PathBuf::from(directory), - None => pgt_fs::ensure_cache_dir().join("pgt-logs"), + None => pgls_fs::ensure_cache_dir().join("pgt-logs"), } } diff --git a/crates/pgt_cli/src/commands/init.rs b/crates/pgls_cli/src/commands/init.rs similarity index 77% rename from crates/pgt_cli/src/commands/init.rs rename to crates/pgls_cli/src/commands/init.rs index 15b1b8a50..94f602e01 100644 --- a/crates/pgt_cli/src/commands/init.rs +++ b/crates/pgls_cli/src/commands/init.rs @@ -1,8 +1,8 @@ use crate::{CliDiagnostic, CliSession}; -use pgt_configuration::PartialConfiguration; -use pgt_console::{ConsoleExt, markup}; -use pgt_fs::ConfigName; -use pgt_workspace::configuration::create_config; +use pgls_configuration::PartialConfiguration; +use pgls_console::{ConsoleExt, markup}; +use pgls_fs::ConfigName; +use pgls_workspace::configuration::create_config; pub(crate) fn init(mut session: CliSession) -> Result<(), CliDiagnostic> { let fs = &mut session.app.fs; diff --git a/crates/pgt_cli/src/commands/mod.rs b/crates/pgls_cli/src/commands/mod.rs similarity index 92% rename from crates/pgt_cli/src/commands/mod.rs rename to crates/pgls_cli/src/commands/mod.rs index 19dc56ade..89f0adfb1 100644 --- a/crates/pgt_cli/src/commands/mod.rs +++ b/crates/pgls_cli/src/commands/mod.rs @@ -6,13 +6,13 @@ use crate::{ CliDiagnostic, CliSession, Execution, LoggingLevel, VERSION, execute_mode, setup_cli_subscriber, }; use bpaf::Bpaf; -use pgt_configuration::{PartialConfiguration, partial_configuration}; -use pgt_console::Console; -use pgt_fs::FileSystem; -use pgt_workspace::PartialConfigurationExt; -use pgt_workspace::configuration::{LoadedConfiguration, load_configuration}; -use pgt_workspace::workspace::{RegisterProjectFolderParams, UpdateSettingsParams}; -use pgt_workspace::{DynRef, Workspace, WorkspaceError}; +use pgls_configuration::{PartialConfiguration, partial_configuration}; +use pgls_console::Console; +use pgls_fs::FileSystem; +use pgls_workspace::PartialConfigurationExt; +use pgls_workspace::configuration::{LoadedConfiguration, load_configuration}; +use pgls_workspace::workspace::{RegisterProjectFolderParams, UpdateSettingsParams}; +use pgls_workspace::{DynRef, Workspace, WorkspaceError}; use std::ffi::OsString; use std::path::PathBuf; pub(crate) mod check; @@ -24,7 +24,7 @@ pub(crate) mod version; #[derive(Debug, Clone, Bpaf)] #[bpaf(options, version(VERSION))] #[allow(clippy::large_enum_variant)] -/// Postgres Tools official CLI. Use it to check the health of your project or run it to check single files. +/// Postgres Language Server official CLI. Use it to check the health of your project or run it to check single files. pub enum PgtCommand { /// Shows the version information and quit. #[bpaf(command)] @@ -43,7 +43,7 @@ pub enum PgtCommand { /// /// The file doesn't need to exist on disk, what matters is the extension of the file. Based on the extension, we know how to check the code. /// - /// Example: `echo 'let a;' | pgt_cli check --stdin-file-path=test.sql` + /// Example: `echo 'let a;' | pgls_cli check --stdin-file-path=test.sql` #[bpaf(long("stdin-file-path"), argument("PATH"), hide_usage)] stdin_file_path: Option, @@ -58,7 +58,7 @@ pub enum PgtCommand { changed: bool, /// Use this to specify the base branch to compare against when you're using the --changed - /// flag and the `defaultBranch` is not set in your `postgrestools.jsonc` + /// flag and the `defaultBranch` is not set in your `postgres-language-server.jsonc` #[bpaf(long("since"), argument("REF"))] since: Option, @@ -87,11 +87,11 @@ pub enum PgtCommand { long("log-path"), argument("PATH"), hide_usage, - fallback(pgt_fs::ensure_cache_dir().join("pgt-logs")), + fallback(pgls_fs::ensure_cache_dir().join("pgt-logs")), )] log_path: PathBuf, /// Allows to set a custom file path to the configuration file, - /// or a custom directory path to find `postgrestools.jsonc` + /// or a custom directory path to find `postgres-language-server.jsonc` #[bpaf(env("PGT_LOG_PREFIX_NAME"), long("config-path"), argument("PATH"))] config_path: Option, }, @@ -123,11 +123,11 @@ pub enum PgtCommand { long("log-path"), argument("PATH"), hide_usage, - fallback(pgt_fs::ensure_cache_dir().join("pgt-logs")), + fallback(pgls_fs::ensure_cache_dir().join("pgt-logs")), )] log_path: PathBuf, /// Allows to set a custom file path to the configuration file, - /// or a custom directory path to find `postgrestools.jsonc` + /// or a custom directory path to find `postgres-language-server.jsonc` #[bpaf(env("PGT_CONFIG_PATH"), long("config-path"), argument("PATH"))] config_path: Option, /// Bogus argument to make the command work with vscode-languageclient @@ -158,7 +158,7 @@ pub enum PgtCommand { long("log-path"), argument("PATH"), hide_usage, - fallback(pgt_fs::ensure_cache_dir().join("pgt-logs")), + fallback(pgls_fs::ensure_cache_dir().join("pgt-logs")), )] log_path: PathBuf, @@ -183,7 +183,7 @@ pub enum PgtCommand { #[bpaf(long("stop-on-disconnect"), hide_usage)] stop_on_disconnect: bool, /// Allows to set a custom file path to the configuration file, - /// or a custom directory path to find `postgrestools.jsonc` + /// or a custom directory path to find `postgres-language-server.jsonc` #[bpaf(env("PGT_CONFIG_PATH"), long("config-path"), argument("PATH"))] config_path: Option, }, @@ -216,7 +216,7 @@ impl PgtCommand { } // We want force colors in CI, to give e better UX experience // Unless users explicitly set the colors flag - // if matches!(self, Postgres ToolsCommand::Ci { .. }) && cli_options.colors.is_none() { + // if matches!(self, Postgres Language ServerCommand::Ci { .. }) && cli_options.colors.is_none() { // return Some(&ColorsArg::Force); // } // Normal behaviors diff --git a/crates/pgt_cli/src/commands/version.rs b/crates/pgls_cli/src/commands/version.rs similarity index 89% rename from crates/pgt_cli/src/commands/version.rs rename to crates/pgls_cli/src/commands/version.rs index 685684a31..59794e77a 100644 --- a/crates/pgt_cli/src/commands/version.rs +++ b/crates/pgls_cli/src/commands/version.rs @@ -1,6 +1,6 @@ -use pgt_console::fmt::Formatter; -use pgt_console::{ConsoleExt, fmt, markup}; -use pgt_workspace::workspace::ServerInfo; +use pgls_console::fmt::Formatter; +use pgls_console::{ConsoleExt, fmt, markup}; +use pgls_workspace::workspace::ServerInfo; use crate::{CliDiagnostic, CliSession, VERSION}; diff --git a/crates/pgt_cli/src/diagnostics.rs b/crates/pgls_cli/src/diagnostics.rs similarity index 96% rename from crates/pgt_cli/src/diagnostics.rs rename to crates/pgls_cli/src/diagnostics.rs index 20d32113c..4bcde3a97 100644 --- a/crates/pgt_cli/src/diagnostics.rs +++ b/crates/pgls_cli/src/diagnostics.rs @@ -1,9 +1,9 @@ -use pgt_console::markup; -use pgt_diagnostics::adapters::{BpafError, IoError, SerdeJsonError}; -use pgt_diagnostics::{ +use pgls_console::markup; +use pgls_diagnostics::adapters::{BpafError, IoError, SerdeJsonError}; +use pgls_diagnostics::{ Advices, Category, Diagnostic, Error, LogCategory, MessageAndDescription, Severity, Visit, }; -use pgt_workspace::WorkspaceError; +use pgls_workspace::WorkspaceError; use std::process::{ExitCode, Termination}; use std::{env::current_exe, fmt::Debug}; @@ -11,10 +11,10 @@ fn command_name() -> String { current_exe() .ok() .and_then(|path| Some(path.file_name()?.to_str()?.to_string())) - .unwrap_or_else(|| String::from("postgrestools")) + .unwrap_or_else(|| String::from("pgls")) } -/// A diagnostic that is emitted when running Postgres Tools via CLI. +/// A diagnostic that is emitted when running Postgres Language Server via CLI. /// /// When displaying the diagnostic, #[derive(Debug, Diagnostic)] @@ -47,7 +47,7 @@ pub enum CliDiagnostic { IoError(IoDiagnostic), /// The daemon is not running ServerNotRunning(ServerNotRunning), - /// The end configuration (`postgrestools.jsonc` + other options) is incompatible with the command + /// The end configuration (`postgres-language-server.jsonc` + other options) is incompatible with the command IncompatibleEndConfiguration(IncompatibleEndConfiguration), /// No files processed during the file system traversal NoFilesWereProcessed(NoFilesWereProcessed), @@ -390,7 +390,7 @@ impl CliDiagnostic { Self::ServerNotRunning(ServerNotRunning) } - /// Emitted when the end configuration (`postgrestools.jsonc` file + CLI arguments + LSP configuration) + /// Emitted when the end configuration (`postgres-language-server.jsonc` file + CLI arguments + LSP configuration) /// results in a combination of options that doesn't allow to run the command correctly. /// /// A reason needs to be provided diff --git a/crates/pgt_cli/src/execute/diagnostics.rs b/crates/pgls_cli/src/execute/diagnostics.rs similarity index 93% rename from crates/pgt_cli/src/execute/diagnostics.rs rename to crates/pgls_cli/src/execute/diagnostics.rs index a355abeca..ee6635281 100644 --- a/crates/pgt_cli/src/execute/diagnostics.rs +++ b/crates/pgls_cli/src/execute/diagnostics.rs @@ -1,5 +1,5 @@ -use pgt_diagnostics::adapters::{IoError, StdError}; -use pgt_diagnostics::{Category, Diagnostic, DiagnosticExt, DiagnosticTags, Error}; +use pgls_diagnostics::adapters::{IoError, StdError}; +use pgls_diagnostics::{Category, Diagnostic, DiagnosticExt, DiagnosticTags, Error}; use std::io; #[derive(Debug, Diagnostic)] diff --git a/crates/pgt_cli/src/execute/mod.rs b/crates/pgls_cli/src/execute/mod.rs similarity index 99% rename from crates/pgt_cli/src/execute/mod.rs rename to crates/pgls_cli/src/execute/mod.rs index 6cb01ca7a..c6a9aae5d 100644 --- a/crates/pgt_cli/src/execute/mod.rs +++ b/crates/pgls_cli/src/execute/mod.rs @@ -10,7 +10,7 @@ use crate::reporter::gitlab::{GitLabReporter, GitLabReporterVisitor}; use crate::reporter::junit::{JunitReporter, JunitReporterVisitor}; use crate::reporter::terminal::{ConsoleReporter, ConsoleReporterVisitor}; use crate::{CliDiagnostic, CliSession, DiagnosticsPayload, Reporter}; -use pgt_diagnostics::{Category, category}; +use pgls_diagnostics::{Category, category}; use std::borrow::Borrow; use std::ffi::OsString; use std::fmt::{Display, Formatter}; diff --git a/crates/pgt_cli/src/execute/process_file.rs b/crates/pgls_cli/src/execute/process_file.rs similarity index 97% rename from crates/pgt_cli/src/execute/process_file.rs rename to crates/pgls_cli/src/execute/process_file.rs index 421f9bb31..2a5029fb2 100644 --- a/crates/pgt_cli/src/execute/process_file.rs +++ b/crates/pgls_cli/src/execute/process_file.rs @@ -4,8 +4,8 @@ pub(crate) mod workspace_file; use crate::execute::TraversalMode; use crate::execute::traverse::TraversalOptions; use check::check_file; -use pgt_diagnostics::Error; -use pgt_fs::PgTPath; +use pgls_diagnostics::Error; +use pgls_fs::PgLSPath; use std::marker::PhantomData; use std::ops::Deref; @@ -103,7 +103,7 @@ impl<'ctx, 'app> Deref for SharedTraversalOptions<'ctx, 'app> { /// diagnostics were emitted, or compare the formatted code with the original /// content of the file and emit a diff or write the new content to the disk if /// write mode is enabled -pub(crate) fn process_file(ctx: &TraversalOptions, pgt_path: &PgTPath) -> FileResult { +pub(crate) fn process_file(ctx: &TraversalOptions, pgt_path: &PgLSPath) -> FileResult { tracing::trace_span!("process_file", path = ?pgt_path).in_scope(move || { let shared_context = &SharedTraversalOptions::new(ctx); diff --git a/crates/pgt_cli/src/execute/process_file/check.rs b/crates/pgls_cli/src/execute/process_file/check.rs similarity index 96% rename from crates/pgt_cli/src/execute/process_file/check.rs rename to crates/pgls_cli/src/execute/process_file/check.rs index c48d0c4cf..de7d67c71 100644 --- a/crates/pgt_cli/src/execute/process_file/check.rs +++ b/crates/pgls_cli/src/execute/process_file/check.rs @@ -1,5 +1,5 @@ -use pgt_analyse::RuleCategoriesBuilder; -use pgt_diagnostics::{Error, category}; +use pgls_analyse::RuleCategoriesBuilder; +use pgls_diagnostics::{Error, category}; use crate::execute::diagnostics::ResultExt; use crate::execute::process_file::workspace_file::WorkspaceFile; diff --git a/crates/pgt_cli/src/execute/process_file/workspace_file.rs b/crates/pgls_cli/src/execute/process_file/workspace_file.rs similarity index 88% rename from crates/pgt_cli/src/execute/process_file/workspace_file.rs rename to crates/pgls_cli/src/execute/process_file/workspace_file.rs index 9f78c7cf1..af7c5acdd 100644 --- a/crates/pgt_cli/src/execute/process_file/workspace_file.rs +++ b/crates/pgls_cli/src/execute/process_file/workspace_file.rs @@ -1,9 +1,9 @@ use crate::execute::diagnostics::{ResultExt, ResultIoExt}; use crate::execute::process_file::SharedTraversalOptions; -use pgt_diagnostics::{Error, category}; -use pgt_fs::{File, OpenOptions, PgTPath}; -use pgt_workspace::workspace::{FileGuard, OpenFileParams}; -use pgt_workspace::{Workspace, WorkspaceError}; +use pgls_diagnostics::{Error, category}; +use pgls_fs::{File, OpenOptions, PgLSPath}; +use pgls_workspace::workspace::{FileGuard, OpenFileParams}; +use pgls_workspace::{Workspace, WorkspaceError}; use std::path::{Path, PathBuf}; /// Small wrapper that holds information and operations around the current processed file @@ -21,7 +21,7 @@ impl<'ctx, 'app> WorkspaceFile<'ctx, 'app> { ctx: &SharedTraversalOptions<'ctx, 'app>, path: &Path, ) -> Result { - let pgt_path = PgTPath::new(path); + let pgt_path = PgLSPath::new(path); let open_options = OpenOptions::default() .read(true) .write(ctx.execution.requires_write_access()); diff --git a/crates/pgt_cli/src/execute/std_in.rs b/crates/pgls_cli/src/execute/std_in.rs similarity index 88% rename from crates/pgt_cli/src/execute/std_in.rs rename to crates/pgls_cli/src/execute/std_in.rs index f9346f6a1..61f0f0cef 100644 --- a/crates/pgt_cli/src/execute/std_in.rs +++ b/crates/pgls_cli/src/execute/std_in.rs @@ -1,7 +1,7 @@ //! In here, there are the operations that run via standard input //! use crate::{CliDiagnostic, CliSession}; -use pgt_console::{ConsoleExt, markup}; +use pgls_console::{ConsoleExt, markup}; pub(crate) fn run(session: CliSession, content: &str) -> Result<(), CliDiagnostic> { let console = &mut *session.app.console; diff --git a/crates/pgt_cli/src/execute/traverse.rs b/crates/pgls_cli/src/execute/traverse.rs similarity index 95% rename from crates/pgt_cli/src/execute/traverse.rs rename to crates/pgls_cli/src/execute/traverse.rs index 5673810c9..631b7b398 100644 --- a/crates/pgt_cli/src/execute/traverse.rs +++ b/crates/pgls_cli/src/execute/traverse.rs @@ -5,13 +5,13 @@ use crate::execute::diagnostics::PanicDiagnostic; use crate::reporter::TraversalSummary; use crate::{CliDiagnostic, CliSession}; use crossbeam::channel::{Receiver, Sender, unbounded}; -use pgt_diagnostics::DiagnosticTags; -use pgt_diagnostics::{DiagnosticExt, Error, Resource, Severity}; -use pgt_fs::{FileSystem, PathInterner, PgTPath}; -use pgt_fs::{TraversalContext, TraversalScope}; -use pgt_workspace::dome::Dome; -use pgt_workspace::workspace::IsPathIgnoredParams; -use pgt_workspace::{Workspace, WorkspaceError}; +use pgls_diagnostics::DiagnosticTags; +use pgls_diagnostics::{DiagnosticExt, Error, Resource, Severity}; +use pgls_fs::{FileSystem, PathInterner, PgLSPath}; +use pgls_fs::{TraversalContext, TraversalScope}; +use pgls_workspace::dome::Dome; +use pgls_workspace::workspace::IsPathIgnoredParams; +use pgls_workspace::{Workspace, WorkspaceError}; use rustc_hash::FxHashSet; use std::collections::BTreeSet; use std::sync::RwLock; @@ -31,7 +31,7 @@ use std::{ pub(crate) struct TraverseResult { pub(crate) summary: TraversalSummary, - pub(crate) evaluated_paths: BTreeSet, + pub(crate) evaluated_paths: BTreeSet, pub(crate) diagnostics: Vec, } @@ -160,7 +160,7 @@ fn traverse_inputs( fs: &dyn FileSystem, inputs: Vec, ctx: &TraversalOptions, -) -> (Duration, BTreeSet) { +) -> (Duration, BTreeSet) { let start = Instant::now(); fs.traversal(Box::new(move |scope: &dyn TraversalScope| { for input in inputs { @@ -413,11 +413,11 @@ pub(crate) struct TraversalOptions<'ctx, 'app> { pub(crate) remaining_diagnostics: &'ctx AtomicU32, /// List of paths that should be processed - pub(crate) evaluated_paths: RwLock>, + pub(crate) evaluated_paths: RwLock>, } impl TraversalOptions<'_, '_> { - pub(crate) fn increment_changed(&self, path: &PgTPath) { + pub(crate) fn increment_changed(&self, path: &PgLSPath) { self.changed.fetch_add(1, Ordering::Relaxed); self.evaluated_paths .write() @@ -443,7 +443,7 @@ impl TraversalContext for TraversalOptions<'_, '_> { &self.interner } - fn evaluated_paths(&self) -> BTreeSet { + fn evaluated_paths(&self) -> BTreeSet { self.evaluated_paths.read().unwrap().clone() } @@ -451,7 +451,7 @@ impl TraversalContext for TraversalOptions<'_, '_> { self.push_message(error); } - fn can_handle(&self, pgt_path: &PgTPath) -> bool { + fn can_handle(&self, pgt_path: &PgLSPath) -> bool { let path = pgt_path.as_path(); let is_valid_file = self.fs.path_is_file(path) @@ -489,22 +489,22 @@ impl TraversalContext for TraversalOptions<'_, '_> { } } - fn handle_path(&self, path: PgTPath) { + fn handle_path(&self, path: PgLSPath) { handle_file(self, &path) } - fn store_path(&self, path: PgTPath) { + fn store_path(&self, path: PgLSPath) { self.evaluated_paths .write() .unwrap() - .insert(PgTPath::new(path.as_path())); + .insert(PgLSPath::new(path.as_path())); } } /// This function wraps the [process_file] function implementing the traversal /// in a [catch_unwind] block and emit diagnostics in case of error (either the /// traversal function returns Err or panics) -fn handle_file(ctx: &TraversalOptions, path: &PgTPath) { +fn handle_file(ctx: &TraversalOptions, path: &PgLSPath) { match catch_unwind(move || process_file(ctx, path)) { Ok(Ok(FileStatus::Changed)) => { ctx.increment_changed(path); diff --git a/crates/pgt_cli/src/lib.rs b/crates/pgls_cli/src/lib.rs similarity index 97% rename from crates/pgt_cli/src/lib.rs rename to crates/pgls_cli/src/lib.rs index f8a042440..97b1e99b8 100644 --- a/crates/pgt_cli/src/lib.rs +++ b/crates/pgls_cli/src/lib.rs @@ -7,9 +7,9 @@ use cli_options::CliOptions; use commands::CommandRunner; use commands::check::CheckCommandPayload; -use pgt_console::{ColorMode, Console}; -use pgt_fs::OsFileSystem; -use pgt_workspace::{App, DynRef, Workspace, WorkspaceRef}; +use pgls_console::{ColorMode, Console}; +use pgls_fs::OsFileSystem; +use pgls_workspace::{App, DynRef, Workspace, WorkspaceRef}; use std::env; mod changed; diff --git a/crates/pgt_cli/src/logging.rs b/crates/pgls_cli/src/logging.rs similarity index 100% rename from crates/pgt_cli/src/logging.rs rename to crates/pgls_cli/src/logging.rs diff --git a/crates/pgt_cli/src/main.rs b/crates/pgls_cli/src/main.rs similarity index 92% rename from crates/pgt_cli/src/main.rs rename to crates/pgls_cli/src/main.rs index 704b43bb2..f19a16218 100644 --- a/crates/pgt_cli/src/main.rs +++ b/crates/pgls_cli/src/main.rs @@ -1,12 +1,12 @@ //! This is the main binary -use pgt_cli::{ +use pgls_cli::{ CliDiagnostic, CliSession, PgtCommand, open_transport, pgt_command, setup_panic_handler, to_color_mode, }; -use pgt_console::{ConsoleExt, EnvConsole, markup}; -use pgt_diagnostics::{Diagnostic, PrintDiagnostic, set_bottom_frame}; -use pgt_workspace::workspace; +use pgls_console::{ConsoleExt, EnvConsole, markup}; +use pgls_diagnostics::{Diagnostic, PrintDiagnostic, set_bottom_frame}; +use pgls_workspace::workspace; use std::process::{ExitCode, Termination}; use tokio::runtime::Runtime; diff --git a/crates/pgt_cli/src/metrics.rs b/crates/pgls_cli/src/metrics.rs similarity index 100% rename from crates/pgt_cli/src/metrics.rs rename to crates/pgls_cli/src/metrics.rs diff --git a/crates/pgt_cli/src/panic.rs b/crates/pgls_cli/src/panic.rs similarity index 100% rename from crates/pgt_cli/src/panic.rs rename to crates/pgls_cli/src/panic.rs diff --git a/crates/pgt_cli/src/reporter/github.rs b/crates/pgls_cli/src/reporter/github.rs similarity index 93% rename from crates/pgt_cli/src/reporter/github.rs rename to crates/pgls_cli/src/reporter/github.rs index 1faa97414..bc2679a9d 100644 --- a/crates/pgt_cli/src/reporter/github.rs +++ b/crates/pgls_cli/src/reporter/github.rs @@ -1,6 +1,6 @@ use crate::{DiagnosticsPayload, Execution, Reporter, ReporterVisitor, TraversalSummary}; -use pgt_console::{Console, ConsoleExt, markup}; -use pgt_diagnostics::PrintGitHubDiagnostic; +use pgls_console::{Console, ConsoleExt, markup}; +use pgls_diagnostics::PrintGitHubDiagnostic; use std::io; pub(crate) struct GithubReporter { diff --git a/crates/pgt_cli/src/reporter/gitlab.rs b/crates/pgls_cli/src/reporter/gitlab.rs similarity index 97% rename from crates/pgt_cli/src/reporter/gitlab.rs rename to crates/pgls_cli/src/reporter/gitlab.rs index fc35a8e0e..c688358eb 100644 --- a/crates/pgt_cli/src/reporter/gitlab.rs +++ b/crates/pgls_cli/src/reporter/gitlab.rs @@ -1,9 +1,9 @@ use crate::{DiagnosticsPayload, Execution, Reporter, ReporterVisitor, TraversalSummary}; use path_absolutize::Absolutize; -use pgt_console::fmt::{Display, Formatter}; -use pgt_console::{Console, ConsoleExt, markup}; -use pgt_diagnostics::display::SourceFile; -use pgt_diagnostics::{Error, PrintDescription, Resource, Severity}; +use pgls_console::fmt::{Display, Formatter}; +use pgls_console::{Console, ConsoleExt, markup}; +use pgls_diagnostics::display::SourceFile; +use pgls_diagnostics::{Error, PrintDescription, Resource, Severity}; use serde::Serialize; use std::sync::RwLock; use std::{ diff --git a/crates/pgt_cli/src/reporter/junit.rs b/crates/pgls_cli/src/reporter/junit.rs similarity index 95% rename from crates/pgt_cli/src/reporter/junit.rs rename to crates/pgls_cli/src/reporter/junit.rs index 670bf8d40..d846cb0e2 100644 --- a/crates/pgt_cli/src/reporter/junit.rs +++ b/crates/pgls_cli/src/reporter/junit.rs @@ -1,7 +1,7 @@ use crate::{DiagnosticsPayload, Execution, Reporter, ReporterVisitor, TraversalSummary}; -use pgt_console::{Console, ConsoleExt, markup}; -use pgt_diagnostics::display::SourceFile; -use pgt_diagnostics::{Error, Resource}; +use pgls_console::{Console, ConsoleExt, markup}; +use pgls_diagnostics::display::SourceFile; +use pgls_diagnostics::{Error, Resource}; use quick_junit::{NonSuccessKind, Report, TestCase, TestCaseStatus, TestSuite}; use std::fmt::{Display, Formatter}; use std::io; @@ -34,7 +34,7 @@ pub(crate) struct JunitReporterVisitor<'a>(pub(crate) Report, pub(crate) &'a mut impl<'a> JunitReporterVisitor<'a> { pub(crate) fn new(console: &'a mut dyn Console) -> Self { - let report = Report::new("PostgresTools"); + let report = Report::new("Postgres Language Server"); Self(report, console) } } diff --git a/crates/pgt_cli/src/reporter/mod.rs b/crates/pgls_cli/src/reporter/mod.rs similarity index 94% rename from crates/pgt_cli/src/reporter/mod.rs rename to crates/pgls_cli/src/reporter/mod.rs index ed265f9b0..d8a7f7b18 100644 --- a/crates/pgt_cli/src/reporter/mod.rs +++ b/crates/pgls_cli/src/reporter/mod.rs @@ -4,8 +4,8 @@ pub(crate) mod junit; pub(crate) mod terminal; use crate::execute::Execution; -use pgt_diagnostics::{Error, Severity}; -use pgt_fs::PgTPath; +use pgls_diagnostics::{Error, Severity}; +use pgls_fs::PgLSPath; use serde::Serialize; use std::collections::BTreeSet; use std::io; @@ -49,7 +49,7 @@ pub trait ReporterVisitor { ) -> io::Result<()>; /// Writes the paths that were handled during a run. - fn report_handled_paths(&mut self, evaluated_paths: BTreeSet) -> io::Result<()> { + fn report_handled_paths(&mut self, evaluated_paths: BTreeSet) -> io::Result<()> { let _ = evaluated_paths; Ok(()) } diff --git a/crates/pgt_cli/src/reporter/terminal.rs b/crates/pgls_cli/src/reporter/terminal.rs similarity index 94% rename from crates/pgt_cli/src/reporter/terminal.rs rename to crates/pgls_cli/src/reporter/terminal.rs index 6e10efc84..85704f270 100644 --- a/crates/pgt_cli/src/reporter/terminal.rs +++ b/crates/pgls_cli/src/reporter/terminal.rs @@ -1,11 +1,11 @@ use crate::Reporter; use crate::execute::{Execution, TraversalMode}; use crate::reporter::{DiagnosticsPayload, ReporterVisitor, TraversalSummary}; -use pgt_console::fmt::Formatter; -use pgt_console::{Console, ConsoleExt, fmt, markup}; -use pgt_diagnostics::advice::ListAdvice; -use pgt_diagnostics::{Diagnostic, PrintDiagnostic}; -use pgt_fs::PgTPath; +use pgls_console::fmt::Formatter; +use pgls_console::{Console, ConsoleExt, fmt, markup}; +use pgls_diagnostics::advice::ListAdvice; +use pgls_diagnostics::{Diagnostic, PrintDiagnostic}; +use pgls_fs::PgLSPath; use std::collections::BTreeSet; use std::io; use std::time::Duration; @@ -14,7 +14,7 @@ pub(crate) struct ConsoleReporter { pub(crate) summary: TraversalSummary, pub(crate) diagnostics_payload: DiagnosticsPayload, pub(crate) execution: Execution, - pub(crate) evaluated_paths: BTreeSet, + pub(crate) evaluated_paths: BTreeSet, } impl Reporter for ConsoleReporter { @@ -66,7 +66,7 @@ impl ReporterVisitor for ConsoleReporterVisitor<'_> { Ok(()) } - fn report_handled_paths(&mut self, evaluated_paths: BTreeSet) -> io::Result<()> { + fn report_handled_paths(&mut self, evaluated_paths: BTreeSet) -> io::Result<()> { let evaluated_paths_diagnostic = EvaluatedPathsDiagnostic { advice: ListAdvice { list: evaluated_paths diff --git a/crates/pgt_cli/src/service/mod.rs b/crates/pgls_cli/src/service/mod.rs similarity index 99% rename from crates/pgt_cli/src/service/mod.rs rename to crates/pgls_cli/src/service/mod.rs index b05f72de2..75b636ee3 100644 --- a/crates/pgt_cli/src/service/mod.rs +++ b/crates/pgls_cli/src/service/mod.rs @@ -17,7 +17,7 @@ use std::{ use anyhow::{Context, Error, bail, ensure}; use dashmap::DashMap; -use pgt_workspace::{ +use pgls_workspace::{ TransportError, workspace::{TransportRequest, WorkspaceTransport}, }; diff --git a/crates/pgt_cli/src/service/unix.rs b/crates/pgls_cli/src/service/unix.rs similarity index 97% rename from crates/pgt_cli/src/service/unix.rs rename to crates/pgls_cli/src/service/unix.rs index 2ff7adb07..f25654a22 100644 --- a/crates/pgt_cli/src/service/unix.rs +++ b/crates/pgls_cli/src/service/unix.rs @@ -6,7 +6,7 @@ use std::{ time::Duration, }; -use pgt_lsp::{ServerConnection, ServerFactory}; +use pgls_lsp::{ServerConnection, ServerFactory}; use tokio::{ io::Interest, net::{ @@ -21,12 +21,12 @@ use tracing::{Instrument, debug, info}; /// Returns the filesystem path of the global socket used to communicate with /// the server daemon fn get_socket_name() -> PathBuf { - pgt_fs::ensure_cache_dir().join(format!("pgt-socket-{}", pgt_configuration::VERSION)) + pgls_fs::ensure_cache_dir().join(format!("pgt-socket-{}", pgls_configuration::VERSION)) } #[allow(dead_code)] pub(crate) fn enumerate_pipes() -> io::Result> { - fs::read_dir(pgt_fs::ensure_cache_dir()).map(|iter| { + fs::read_dir(pgls_fs::ensure_cache_dir()).map(|iter| { iter.filter_map(|entry| { let entry = entry.ok()?.path(); let file_name = entry.file_name()?; diff --git a/crates/pgt_cli/src/service/windows.rs b/crates/pgls_cli/src/service/windows.rs similarity index 98% rename from crates/pgt_cli/src/service/windows.rs rename to crates/pgls_cli/src/service/windows.rs index e6fc48f4b..f93eee9d1 100644 --- a/crates/pgt_cli/src/service/windows.rs +++ b/crates/pgls_cli/src/service/windows.rs @@ -13,7 +13,7 @@ use std::{ time::Duration, }; -use pgt_lsp::{ServerConnection, ServerFactory}; +use pgls_lsp::{ServerConnection, ServerFactory}; use tokio::{ io::{AsyncRead, AsyncWrite, ReadBuf}, net::windows::named_pipe::{ClientOptions, NamedPipeClient, NamedPipeServer, ServerOptions}, @@ -24,7 +24,7 @@ use tracing::Instrument; /// Returns the name of the global named pipe used to communicate with the /// server daemon fn get_pipe_name() -> String { - format!(r"\\.\pipe\pgt-service-{}", pgt_configuration::VERSION) + format!(r"\\.\pipe\pgt-service-{}", pgls_configuration::VERSION) } #[allow(dead_code)] diff --git a/crates/pgt_cli/tests/assert_cmd.rs b/crates/pgls_cli/tests/assert_cmd.rs similarity index 84% rename from crates/pgt_cli/tests/assert_cmd.rs rename to crates/pgls_cli/tests/assert_cmd.rs index a7ddc17fb..09b96c8e7 100644 --- a/crates/pgt_cli/tests/assert_cmd.rs +++ b/crates/pgls_cli/tests/assert_cmd.rs @@ -5,7 +5,7 @@ use predicates::prelude::*; #[test] fn test_cli_check_command() { - let mut cmd = Command::cargo_bin("postgrestools").unwrap(); + let mut cmd = Command::cargo_bin("pgls").unwrap(); let test_sql_path = PathBuf::from("tests/fixtures/test.sql"); diff --git a/crates/pgt_cli/tests/commands/check.rs b/crates/pgls_cli/tests/commands/check.rs similarity index 84% rename from crates/pgt_cli/tests/commands/check.rs rename to crates/pgls_cli/tests/commands/check.rs index ce0de03da..1cdcaaa52 100644 --- a/crates/pgt_cli/tests/commands/check.rs +++ b/crates/pgls_cli/tests/commands/check.rs @@ -2,9 +2,9 @@ use bpaf::Args; use std::path::Path; use crate::run_cli; -use pgt_console::BufferConsole; -use pgt_fs::MemoryFileSystem; -use pgt_workspace::DynRef; +use pgls_console::BufferConsole; +use pgls_fs::MemoryFileSystem; +use pgls_workspace::DynRef; #[test] fn syntax_error() { diff --git a/crates/pgt_cli/tests/commands/mod.rs b/crates/pgls_cli/tests/commands/mod.rs similarity index 100% rename from crates/pgt_cli/tests/commands/mod.rs rename to crates/pgls_cli/tests/commands/mod.rs diff --git a/crates/pgt_cli/tests/fixtures/test.sql b/crates/pgls_cli/tests/fixtures/test.sql similarity index 100% rename from crates/pgt_cli/tests/fixtures/test.sql rename to crates/pgls_cli/tests/fixtures/test.sql diff --git a/crates/pgt_cli/tests/main.rs b/crates/pgls_cli/tests/main.rs similarity index 83% rename from crates/pgt_cli/tests/main.rs rename to crates/pgls_cli/tests/main.rs index 4ab061727..7a86adb8f 100644 --- a/crates/pgt_cli/tests/main.rs +++ b/crates/pgls_cli/tests/main.rs @@ -1,10 +1,10 @@ mod commands; use bpaf::ParseFailure; -use pgt_cli::{CliDiagnostic, CliSession, pgt_command}; -use pgt_console::{Console, ConsoleExt, markup}; -use pgt_fs::FileSystem; -use pgt_workspace::{App, DynRef}; +use pgls_cli::{CliDiagnostic, CliSession, pgt_command}; +use pgls_console::{Console, ConsoleExt, markup}; +use pgls_fs::FileSystem; +use pgls_workspace::{App, DynRef}; /// Create an [App] instance using the provided [FileSystem] and [Console] /// instance, and using an in-process "remote" instance of the workspace @@ -13,9 +13,9 @@ pub(crate) fn run_cli<'app>( console: &'app mut dyn Console, args: bpaf::Args, ) -> Result<(), CliDiagnostic> { - use pgt_cli::SocketTransport; - use pgt_lsp::ServerFactory; - use pgt_workspace::{WorkspaceRef, workspace}; + use pgls_cli::SocketTransport; + use pgls_lsp::ServerFactory; + use pgls_workspace::{WorkspaceRef, workspace}; use tokio::{ io::{duplex, split}, runtime::Runtime, diff --git a/crates/pgls_completions/Cargo.toml b/crates/pgls_completions/Cargo.toml new file mode 100644 index 000000000..ef88e263d --- /dev/null +++ b/crates/pgls_completions/Cargo.toml @@ -0,0 +1,45 @@ +[package] +authors.workspace = true +categories.workspace = true +description = "" +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +name = "pgls_completions" +repository.workspace = true +version = "0.0.0" + + +[dependencies] +async-std = "1.12.0" + +pgls_schema_cache.workspace = true +pgls_text_size.workspace = true +pgls_treesitter.workspace = true + +fuzzy-matcher = "0.3.7" +pgls_treesitter_grammar.workspace = true +schemars = { workspace = true, optional = true } +serde = { workspace = true, features = ["derive"] } +serde_json = { workspace = true } +tracing = { workspace = true } +tree-sitter.workspace = true + +sqlx.workspace = true + +tokio = { version = "1.41.1", features = ["full"] } + +[dev-dependencies] +criterion = "0.5.1" +pgls_test_utils.workspace = true + +[lib] +doctest = false + +[features] +schema = ["dep:schemars"] + +[[bench]] +harness = false +name = "sanitization" diff --git a/crates/pgt_completions/README.md b/crates/pgls_completions/README.md similarity index 100% rename from crates/pgt_completions/README.md rename to crates/pgls_completions/README.md diff --git a/crates/pgt_completions/benches/sanitization.rs b/crates/pgls_completions/benches/sanitization.rs similarity index 97% rename from crates/pgt_completions/benches/sanitization.rs rename to crates/pgls_completions/benches/sanitization.rs index 5a31a50a5..532bdd294 100644 --- a/crates/pgt_completions/benches/sanitization.rs +++ b/crates/pgls_completions/benches/sanitization.rs @@ -1,7 +1,7 @@ use criterion::{Criterion, black_box, criterion_group, criterion_main}; -use pgt_completions::{CompletionParams, benchmark_sanitization}; -use pgt_schema_cache::SchemaCache; -use pgt_text_size::TextSize; +use pgls_completions::{CompletionParams, benchmark_sanitization}; +use pgls_schema_cache::SchemaCache; +use pgls_text_size::TextSize; static CURSOR_POS: &str = "€"; @@ -13,7 +13,7 @@ fn sql_and_pos(sql: &str) -> (String, usize) { fn get_tree(sql: &str) -> tree_sitter::Tree { let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .unwrap(); parser.parse(sql, None).unwrap() } diff --git a/crates/pgt_completions/src/builder.rs b/crates/pgls_completions/src/builder.rs similarity index 98% rename from crates/pgt_completions/src/builder.rs rename to crates/pgls_completions/src/builder.rs index ed884ee95..f948ede77 100644 --- a/crates/pgt_completions/src/builder.rs +++ b/crates/pgls_completions/src/builder.rs @@ -4,7 +4,7 @@ use crate::{ relevance::{filtering::CompletionFilter, scoring::CompletionScore}, }; -use pgt_treesitter::TreesitterContext; +use pgls_treesitter::TreesitterContext; #[derive(Debug)] pub(crate) struct PossibleCompletionItem<'a> { diff --git a/crates/pgt_completions/src/complete.rs b/crates/pgls_completions/src/complete.rs similarity index 89% rename from crates/pgt_completions/src/complete.rs rename to crates/pgls_completions/src/complete.rs index e18589af0..78f5eecdb 100644 --- a/crates/pgt_completions/src/complete.rs +++ b/crates/pgls_completions/src/complete.rs @@ -1,6 +1,6 @@ -use pgt_text_size::TextSize; +use pgls_text_size::TextSize; -use pgt_treesitter::{TreeSitterContextParams, context::TreesitterContext}; +use pgls_treesitter::{TreeSitterContextParams, context::TreesitterContext}; use crate::{ builder::CompletionBuilder, @@ -17,7 +17,7 @@ pub const LIMIT: usize = 50; #[derive(Debug)] pub struct CompletionParams<'a> { pub position: TextSize, - pub schema: &'a pgt_schema_cache::SchemaCache, + pub schema: &'a pgls_schema_cache::SchemaCache, pub text: String, pub tree: &'a tree_sitter::Tree, } diff --git a/crates/pgt_completions/src/item.rs b/crates/pgls_completions/src/item.rs similarity index 98% rename from crates/pgt_completions/src/item.rs rename to crates/pgls_completions/src/item.rs index 766e436c5..d92454c26 100644 --- a/crates/pgt_completions/src/item.rs +++ b/crates/pgls_completions/src/item.rs @@ -1,6 +1,6 @@ use std::fmt::Display; -use pgt_text_size::TextRange; +use pgls_text_size::TextRange; use serde::{Deserialize, Serialize}; #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] diff --git a/crates/pgt_completions/src/lib.rs b/crates/pgls_completions/src/lib.rs similarity index 100% rename from crates/pgt_completions/src/lib.rs rename to crates/pgls_completions/src/lib.rs diff --git a/crates/pgt_completions/src/providers/columns.rs b/crates/pgls_completions/src/providers/columns.rs similarity index 97% rename from crates/pgt_completions/src/providers/columns.rs rename to crates/pgls_completions/src/providers/columns.rs index 1f404627c..713fb656d 100644 --- a/crates/pgt_completions/src/providers/columns.rs +++ b/crates/pgls_completions/src/providers/columns.rs @@ -1,5 +1,5 @@ -use pgt_schema_cache::{Column, SchemaCache}; -use pgt_treesitter::TreesitterContext; +use pgls_schema_cache::{Column, SchemaCache}; +use pgls_treesitter::TreesitterContext; use crate::{ CompletionItemKind, CompletionText, @@ -52,7 +52,7 @@ fn get_completion_text(ctx: &TreesitterContext, col: &Column) -> CompletionText mod tests { use std::vec; - use pgt_text_size::TextRange; + use pgls_text_size::TextRange; use sqlx::{Executor, PgPool}; use crate::{ @@ -63,7 +63,7 @@ mod tests { }, }; - use pgt_test_utils::QueryWithCursorPosition; + use pgls_test_utils::QueryWithCursorPosition; struct TestCase { query: String, @@ -79,7 +79,7 @@ mod tests { } } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn completes_columns(pool: PgPool) { let setup = r#" create schema private; @@ -158,7 +158,7 @@ mod tests { } } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn shows_multiple_columns_if_no_relation_specified(pool: PgPool) { let setup = r#" create schema private; @@ -224,7 +224,7 @@ mod tests { assert_eq!(labels, expected); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn suggests_relevant_columns_without_letters(pool: PgPool) { let setup = r#" create table users ( @@ -275,7 +275,7 @@ mod tests { ); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn ignores_cols_in_from_clause(pool: PgPool) { let setup = r#" create schema private; @@ -309,7 +309,7 @@ mod tests { ); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn prefers_columns_of_mentioned_tables(pool: PgPool) { let setup = r#" create schema private; @@ -381,7 +381,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn filters_out_by_aliases(pool: PgPool) { let setup = r#" create schema auth; @@ -449,7 +449,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn does_not_complete_cols_in_join_clauses(pool: PgPool) { let setup = r#" create schema auth; @@ -489,7 +489,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn completes_in_join_on_clause(pool: PgPool) { let setup = r#" create schema auth; @@ -546,7 +546,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn prefers_not_mentioned_columns(pool: PgPool) { let setup = r#" create schema auth; @@ -638,7 +638,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn suggests_columns_in_insert_clause(pool: PgPool) { let setup = r#" create table instruments ( @@ -731,7 +731,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn suggests_columns_in_where_clause(pool: PgPool) { let setup = r#" create table instruments ( @@ -818,7 +818,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn suggests_columns_in_alter_table_and_drop_table(pool: PgPool) { let setup = r#" create table instruments ( @@ -888,7 +888,7 @@ mod tests { } } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn suggests_columns_policy_using_clause(pool: PgPool) { let setup = r#" create table instruments ( @@ -936,7 +936,7 @@ mod tests { } } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn completes_quoted_columns(pool: PgPool) { let setup = r#" create schema if not exists private; @@ -1020,7 +1020,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn completes_quoted_columns_with_aliases(pool: PgPool) { let setup = r#" create schema if not exists private; diff --git a/crates/pgt_completions/src/providers/functions.rs b/crates/pgls_completions/src/providers/functions.rs similarity index 95% rename from crates/pgt_completions/src/providers/functions.rs rename to crates/pgls_completions/src/providers/functions.rs index 7636d3595..fd25b2a9f 100644 --- a/crates/pgt_completions/src/providers/functions.rs +++ b/crates/pgls_completions/src/providers/functions.rs @@ -1,5 +1,5 @@ -use pgt_schema_cache::{Function, SchemaCache}; -use pgt_treesitter::TreesitterContext; +use pgls_schema_cache::{Function, SchemaCache}; +use pgls_treesitter::TreesitterContext; use crate::{ CompletionItemKind, CompletionText, @@ -73,7 +73,7 @@ fn get_completion_text(ctx: &TreesitterContext, func: &Function) -> CompletionTe #[cfg(test)] mod tests { - use pgt_text_size::TextRange; + use pgls_text_size::TextRange; use sqlx::{Executor, PgPool}; use crate::{ @@ -83,9 +83,9 @@ mod tests { }, }; - use pgt_test_utils::QueryWithCursorPosition; + use pgls_test_utils::QueryWithCursorPosition; - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn completes_fn(pool: PgPool) { let setup = r#" create or replace function cool() @@ -113,7 +113,7 @@ mod tests { assert_eq!(label, "cool"); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn prefers_fn_if_invocation(pool: PgPool) { let setup = r#" create table coos ( @@ -150,7 +150,7 @@ mod tests { assert_eq!(kind, CompletionItemKind::Function); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn prefers_fn_in_select_clause(pool: PgPool) { let setup = r#" create table coos ( @@ -184,7 +184,7 @@ mod tests { assert_eq!(kind, CompletionItemKind::Function); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn prefers_function_in_from_clause_if_invocation(pool: PgPool) { let setup = r#" create table coos ( @@ -221,7 +221,7 @@ mod tests { assert_eq!(kind, CompletionItemKind::Function); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn only_allows_functions_and_procedures_in_policy_checks(pool: PgPool) { let setup = r#" create table coos ( @@ -301,7 +301,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn autocompletes_after_schema_in_quotes(pool: PgPool) { let setup = r#" create schema auth; diff --git a/crates/pgt_completions/src/providers/helper.rs b/crates/pgls_completions/src/providers/helper.rs similarity index 96% rename from crates/pgt_completions/src/providers/helper.rs rename to crates/pgls_completions/src/providers/helper.rs index 002e8649e..eddb6afda 100644 --- a/crates/pgt_completions/src/providers/helper.rs +++ b/crates/pgls_completions/src/providers/helper.rs @@ -1,5 +1,5 @@ -use pgt_text_size::{TextRange, TextSize}; -use pgt_treesitter::TreesitterContext; +use pgls_text_size::{TextRange, TextSize}; +use pgls_treesitter::TreesitterContext; use crate::{is_sanitized_token_with_quote, remove_sanitized_token}; diff --git a/crates/pgt_completions/src/providers/mod.rs b/crates/pgls_completions/src/providers/mod.rs similarity index 100% rename from crates/pgt_completions/src/providers/mod.rs rename to crates/pgls_completions/src/providers/mod.rs diff --git a/crates/pgt_completions/src/providers/policies.rs b/crates/pgls_completions/src/providers/policies.rs similarity index 94% rename from crates/pgt_completions/src/providers/policies.rs rename to crates/pgls_completions/src/providers/policies.rs index b903155e6..dce1e26d3 100644 --- a/crates/pgt_completions/src/providers/policies.rs +++ b/crates/pgls_completions/src/providers/policies.rs @@ -1,5 +1,5 @@ -use pgt_schema_cache::SchemaCache; -use pgt_treesitter::TreesitterContext; +use pgls_schema_cache::SchemaCache; +use pgls_treesitter::TreesitterContext; use crate::{ CompletionItemKind, CompletionText, @@ -53,9 +53,9 @@ mod tests { use sqlx::{Executor, PgPool}; use crate::test_helper::{CompletionAssertion, assert_complete_results}; - use pgt_test_utils::QueryWithCursorPosition; + use pgls_test_utils::QueryWithCursorPosition; - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn completes_within_quotation_marks(pool: PgPool) { let setup = r#" create schema private; diff --git a/crates/pgt_completions/src/providers/roles.rs b/crates/pgls_completions/src/providers/roles.rs similarity index 95% rename from crates/pgt_completions/src/providers/roles.rs rename to crates/pgls_completions/src/providers/roles.rs index b7664349c..7de071535 100644 --- a/crates/pgt_completions/src/providers/roles.rs +++ b/crates/pgls_completions/src/providers/roles.rs @@ -3,8 +3,8 @@ use crate::{ builder::{CompletionBuilder, PossibleCompletionItem}, relevance::{CompletionRelevanceData, filtering::CompletionFilter, scoring::CompletionScore}, }; -use pgt_schema_cache::SchemaCache; -use pgt_treesitter::TreesitterContext; +use pgls_schema_cache::SchemaCache; +use pgls_treesitter::TreesitterContext; pub fn complete_roles<'a>( _ctx: &TreesitterContext<'a>, @@ -36,7 +36,7 @@ mod tests { use crate::test_helper::{CompletionAssertion, assert_complete_results}; - use pgt_test_utils::QueryWithCursorPosition; + use pgls_test_utils::QueryWithCursorPosition; const SETUP: &str = r#" create table users ( @@ -46,7 +46,7 @@ mod tests { ); "#; - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn works_in_drop_role(pool: PgPool) { assert_complete_results( format!("drop role {}", QueryWithCursorPosition::cursor_marker()).as_str(), @@ -67,7 +67,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn works_in_alter_role(pool: PgPool) { assert_complete_results( format!("alter role {}", QueryWithCursorPosition::cursor_marker()).as_str(), @@ -88,7 +88,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn works_in_set_statement(pool: PgPool) { pool.execute(SETUP).await.unwrap(); @@ -133,7 +133,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn works_in_policies(pool: PgPool) { pool.execute(SETUP).await.unwrap(); @@ -188,7 +188,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn works_in_grant_statements(pool: PgPool) { pool.execute(SETUP).await.unwrap(); @@ -266,7 +266,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn works_in_revoke_statements(pool: PgPool) { pool.execute(SETUP).await.unwrap(); diff --git a/crates/pgt_completions/src/providers/schemas.rs b/crates/pgls_completions/src/providers/schemas.rs similarity index 93% rename from crates/pgt_completions/src/providers/schemas.rs rename to crates/pgls_completions/src/providers/schemas.rs index 43c523875..410205f89 100644 --- a/crates/pgt_completions/src/providers/schemas.rs +++ b/crates/pgls_completions/src/providers/schemas.rs @@ -2,8 +2,8 @@ use crate::{ builder::{CompletionBuilder, PossibleCompletionItem}, relevance::{CompletionRelevanceData, filtering::CompletionFilter, scoring::CompletionScore}, }; -use pgt_schema_cache::SchemaCache; -use pgt_treesitter::TreesitterContext; +use pgls_schema_cache::SchemaCache; +use pgls_treesitter::TreesitterContext; pub fn complete_schemas<'a>( _ctx: &'a TreesitterContext, @@ -39,9 +39,9 @@ mod tests { test_helper::{CompletionAssertion, assert_complete_results}, }; - use pgt_test_utils::QueryWithCursorPosition; + use pgls_test_utils::QueryWithCursorPosition; - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn autocompletes_schemas(pool: PgPool) { let setup = r#" create schema private; @@ -90,7 +90,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn suggests_tables_and_schemas_with_matching_keys(pool: PgPool) { let setup = r#" create schema ultimate; diff --git a/crates/pgt_completions/src/providers/tables.rs b/crates/pgls_completions/src/providers/tables.rs similarity index 95% rename from crates/pgt_completions/src/providers/tables.rs rename to crates/pgls_completions/src/providers/tables.rs index 6ef9a6b90..48ff5d8a1 100644 --- a/crates/pgt_completions/src/providers/tables.rs +++ b/crates/pgls_completions/src/providers/tables.rs @@ -1,5 +1,5 @@ -use pgt_schema_cache::{SchemaCache, Table}; -use pgt_treesitter::TreesitterContext; +use pgls_schema_cache::{SchemaCache, Table}; +use pgls_treesitter::TreesitterContext; use crate::{ CompletionText, @@ -22,11 +22,11 @@ pub fn complete_tables<'a>( let relevance = CompletionRelevanceData::Table(table); let detail: Option = match table.table_kind { - pgt_schema_cache::TableKind::Ordinary | pgt_schema_cache::TableKind::Partitioned => { + pgls_schema_cache::TableKind::Ordinary | pgls_schema_cache::TableKind::Partitioned => { None } - pgt_schema_cache::TableKind::View => Some("View".into()), - pgt_schema_cache::TableKind::MaterializedView => Some("MView".into()), + pgls_schema_cache::TableKind::View => Some("View".into()), + pgls_schema_cache::TableKind::MaterializedView => Some("MView".into()), }; let item = PossibleCompletionItem { @@ -58,7 +58,7 @@ fn get_completion_text(ctx: &TreesitterContext, table: &Table) -> CompletionText #[cfg(test)] mod tests { - use pgt_text_size::TextRange; + use pgls_text_size::TextRange; use sqlx::{Executor, PgPool}; use crate::{ @@ -69,9 +69,9 @@ mod tests { }, }; - use pgt_test_utils::QueryWithCursorPosition; + use pgls_test_utils::QueryWithCursorPosition; - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn autocompletes_simple_table(pool: PgPool) { let setup = r#" create table users ( @@ -101,7 +101,7 @@ mod tests { ) } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn autocompletes_table_alphanumerically(pool: PgPool) { let setup = r#" create table addresses ( @@ -160,7 +160,7 @@ mod tests { } } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn autocompletes_table_with_schema(pool: PgPool) { let setup = r#" create schema customer_support; @@ -222,7 +222,7 @@ mod tests { } } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn prefers_table_in_from_clause(pool: PgPool) { let setup = r#" create table coos ( @@ -259,7 +259,7 @@ mod tests { assert_eq!(kind, CompletionItemKind::Table); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn suggests_tables_in_update(pool: PgPool) { let setup = r#" create table coos ( @@ -334,7 +334,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn suggests_tables_in_delete(pool: PgPool) { let setup = r#" create table coos ( @@ -391,7 +391,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn suggests_tables_in_join(pool: PgPool) { let setup = r#" create schema auth; @@ -429,7 +429,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn suggests_tables_in_alter_and_drop_statements(pool: PgPool) { let setup = r#" create schema auth; @@ -512,7 +512,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn suggests_tables_in_insert_into(pool: PgPool) { let setup = r#" create schema auth; @@ -571,7 +571,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn after_quoted_schemas(pool: PgPool) { let setup = r#" create schema auth; diff --git a/crates/pgls_completions/src/relevance.rs b/crates/pgls_completions/src/relevance.rs new file mode 100644 index 000000000..9899f1c1d --- /dev/null +++ b/crates/pgls_completions/src/relevance.rs @@ -0,0 +1,12 @@ +pub(crate) mod filtering; +pub(crate) mod scoring; + +#[derive(Debug, Clone)] +pub(crate) enum CompletionRelevanceData<'a> { + Table(&'a pgls_schema_cache::Table), + Function(&'a pgls_schema_cache::Function), + Column(&'a pgls_schema_cache::Column), + Schema(&'a pgls_schema_cache::Schema), + Policy(&'a pgls_schema_cache::Policy), + Role(&'a pgls_schema_cache::Role), +} diff --git a/crates/pgt_completions/src/relevance/filtering.rs b/crates/pgls_completions/src/relevance/filtering.rs similarity index 97% rename from crates/pgt_completions/src/relevance/filtering.rs rename to crates/pgls_completions/src/relevance/filtering.rs index e386bc5ea..8a887ea71 100644 --- a/crates/pgt_completions/src/relevance/filtering.rs +++ b/crates/pgls_completions/src/relevance/filtering.rs @@ -1,6 +1,6 @@ -use pgt_schema_cache::ProcKind; +use pgls_schema_cache::ProcKind; -use pgt_treesitter::context::{NodeUnderCursor, TreesitterContext, WrappingClause, WrappingNode}; +use pgls_treesitter::context::{NodeUnderCursor, TreesitterContext, WrappingClause, WrappingNode}; use super::CompletionRelevanceData; @@ -280,9 +280,9 @@ mod tests { CompletionAssertion, assert_complete_results, assert_no_complete_results, }; - use pgt_test_utils::QueryWithCursorPosition; + use pgls_test_utils::QueryWithCursorPosition; - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn completion_after_asterisk(pool: PgPool) { let setup = r#" create table users ( @@ -315,7 +315,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn completion_after_create_table(pool: PgPool) { assert_no_complete_results( format!("create table {}", QueryWithCursorPosition::cursor_marker()).as_str(), @@ -325,7 +325,7 @@ mod tests { .await; } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn completion_in_column_definitions(pool: PgPool) { let query = format!( r#"create table instruments ( {} )"#, diff --git a/crates/pgt_completions/src/relevance/scoring.rs b/crates/pgls_completions/src/relevance/scoring.rs similarity index 99% rename from crates/pgt_completions/src/relevance/scoring.rs rename to crates/pgls_completions/src/relevance/scoring.rs index e4f8eb5a2..075265860 100644 --- a/crates/pgt_completions/src/relevance/scoring.rs +++ b/crates/pgls_completions/src/relevance/scoring.rs @@ -1,6 +1,6 @@ use fuzzy_matcher::{FuzzyMatcher, skim::SkimMatcherV2}; -use pgt_treesitter::context::{TreesitterContext, WrappingClause, WrappingNode}; +use pgls_treesitter::context::{TreesitterContext, WrappingClause, WrappingNode}; use crate::sanitization; diff --git a/crates/pgt_completions/src/sanitization.rs b/crates/pgls_completions/src/sanitization.rs similarity index 98% rename from crates/pgt_completions/src/sanitization.rs rename to crates/pgls_completions/src/sanitization.rs index 2dcb220ae..045eaae65 100644 --- a/crates/pgt_completions/src/sanitization.rs +++ b/crates/pgls_completions/src/sanitization.rs @@ -1,6 +1,6 @@ use std::{borrow::Cow, cmp::max}; -use pgt_text_size::TextSize; +use pgls_text_size::TextSize; use crate::CompletionParams; @@ -11,7 +11,7 @@ static SANITIZED_TOKEN_WITH_QUOTE: &str = r#"REPLACED_TOKEN_WITH_QUOTE""#; pub(crate) struct SanitizedCompletionParams<'a> { pub position: TextSize, pub text: String, - pub schema: &'a pgt_schema_cache::SchemaCache, + pub schema: &'a pgls_schema_cache::SchemaCache, pub tree: Cow<'a, tree_sitter::Tree>, } @@ -112,7 +112,7 @@ where let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .expect("Error loading sql language"); let tree = parser.parse(sql.clone(), None).unwrap(); @@ -300,8 +300,8 @@ fn cursor_after_opened_quote(sql: &str, position: TextSize) -> bool { #[cfg(test)] mod tests { - use pgt_schema_cache::SchemaCache; - use pgt_text_size::TextSize; + use pgls_schema_cache::SchemaCache; + use pgls_text_size::TextSize; use crate::{ CompletionParams, SanitizedCompletionParams, @@ -314,7 +314,7 @@ mod tests { fn get_test_params(input: &str, position: TextSize) -> CompletionParams { let mut ts = tree_sitter::Parser::new(); - ts.set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + ts.set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .unwrap(); let tree = Box::new(ts.parse(input, None).unwrap()); @@ -496,7 +496,7 @@ mod tests { let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .expect("Error loading sql language"); let tree = parser.parse(input, None).unwrap(); diff --git a/crates/pgt_completions/src/test_helper.rs b/crates/pgls_completions/src/test_helper.rs similarity index 93% rename from crates/pgt_completions/src/test_helper.rs rename to crates/pgls_completions/src/test_helper.rs index e01c5c65d..c57ba996e 100644 --- a/crates/pgt_completions/src/test_helper.rs +++ b/crates/pgls_completions/src/test_helper.rs @@ -1,6 +1,6 @@ -use pgt_schema_cache::SchemaCache; -use pgt_test_utils::QueryWithCursorPosition; -use pgt_text_size::TextRange; +use pgls_schema_cache::SchemaCache; +use pgls_test_utils::QueryWithCursorPosition; +use pgls_text_size::TextRange; use sqlx::{Executor, PgPool}; use crate::{CompletionItem, CompletionItemKind, CompletionParams, complete}; @@ -9,7 +9,7 @@ pub(crate) async fn get_test_deps( setup: Option<&str>, input: QueryWithCursorPosition, test_db: &PgPool, -) -> (tree_sitter::Tree, pgt_schema_cache::SchemaCache) { +) -> (tree_sitter::Tree, pgls_schema_cache::SchemaCache) { if let Some(setup) = setup { test_db .execute(setup) @@ -23,7 +23,7 @@ pub(crate) async fn get_test_deps( let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .expect("Error loading sql language"); let tree = parser.parse(input.to_string(), None).unwrap(); @@ -37,7 +37,7 @@ pub(crate) async fn get_test_deps( pub(crate) async fn test_against_connection_string( conn_str: &str, input: QueryWithCursorPosition, -) -> (tree_sitter::Tree, pgt_schema_cache::SchemaCache) { +) -> (tree_sitter::Tree, pgls_schema_cache::SchemaCache) { let pool = sqlx::PgPool::connect(conn_str) .await .expect("Unable to connect to database."); @@ -48,7 +48,7 @@ pub(crate) async fn test_against_connection_string( let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .expect("Error loading sql language"); let tree = parser.parse(input.to_string(), None).unwrap(); @@ -58,7 +58,7 @@ pub(crate) async fn test_against_connection_string( pub(crate) fn get_test_params<'a>( tree: &'a tree_sitter::Tree, - schema_cache: &'a pgt_schema_cache::SchemaCache, + schema_cache: &'a pgls_schema_cache::SchemaCache, sql: QueryWithCursorPosition, ) -> CompletionParams<'a> { let (position, text) = sql.get_text_and_position(); diff --git a/crates/pgt_configuration/Cargo.toml b/crates/pgls_configuration/Cargo.toml similarity index 76% rename from crates/pgt_configuration/Cargo.toml rename to crates/pgls_configuration/Cargo.toml index 3bd685fa5..00e24d187 100644 --- a/crates/pgt_configuration/Cargo.toml +++ b/crates/pgls_configuration/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_configuration" +name = "pgls_configuration" repository.workspace = true version = "0.0.0" @@ -17,11 +17,11 @@ biome_deserialize_macros = { workspace = true } bpaf = { workspace = true } indexmap = { workspace = true } oxc_resolver = { workspace = true } -pgt_analyse = { workspace = true } -pgt_analyser = { workspace = true } -pgt_console = { workspace = true } -pgt_diagnostics = { workspace = true } -pgt_text_size = { workspace = true } +pgls_analyse = { workspace = true } +pgls_analyser = { workspace = true } +pgls_console = { workspace = true } +pgls_diagnostics = { workspace = true } +pgls_text_size = { workspace = true } rustc-hash = { workspace = true } schemars = { workspace = true, features = ["indexmap1"], optional = true } serde = { workspace = true, features = ["derive"] } diff --git a/crates/pgt_configuration/src/analyser/linter/mod.rs b/crates/pgls_configuration/src/analyser/linter/mod.rs similarity index 100% rename from crates/pgt_configuration/src/analyser/linter/mod.rs rename to crates/pgls_configuration/src/analyser/linter/mod.rs diff --git a/crates/pgt_configuration/src/analyser/linter/rules.rs b/crates/pgls_configuration/src/analyser/linter/rules.rs similarity index 91% rename from crates/pgt_configuration/src/analyser/linter/rules.rs rename to crates/pgls_configuration/src/analyser/linter/rules.rs index 8b23048fa..7923c8ac0 100644 --- a/crates/pgt_configuration/src/analyser/linter/rules.rs +++ b/crates/pgls_configuration/src/analyser/linter/rules.rs @@ -2,8 +2,8 @@ use crate::analyser::{RuleConfiguration, RulePlainConfiguration}; use biome_deserialize_macros::Merge; -use pgt_analyse::{RuleFilter, options::RuleOptions}; -use pgt_diagnostics::{Category, Severity}; +use pgls_analyse::{RuleFilter, options::RuleOptions}; +use pgls_diagnostics::{Category, Severity}; use rustc_hash::FxHashSet; #[cfg(feature = "schema")] use schemars::JsonSchema; @@ -56,15 +56,15 @@ pub struct Rules { pub safety: Option, } impl Rules { - #[doc = r" Checks if the code coming from [pgt_diagnostics::Diagnostic] corresponds to a rule."] + #[doc = r" Checks if the code coming from [pgls_diagnostics::Diagnostic] corresponds to a rule."] #[doc = r" Usually the code is built like {group}/{rule_name}"] pub fn has_rule(group: RuleGroup, rule_name: &str) -> Option<&'static str> { match group { RuleGroup::Safety => Safety::has_rule(rule_name), } } - #[doc = r" Given a category coming from [Diagnostic](pgt_diagnostics::Diagnostic), this function returns"] - #[doc = r" the [Severity](pgt_diagnostics::Severity) associated to the rule, if the configuration changed it."] + #[doc = r" Given a category coming from [Diagnostic](pgls_diagnostics::Diagnostic), this function returns"] + #[doc = r" the [Severity](pgls_diagnostics::Severity) associated to the rule, if the configuration changed it."] #[doc = r" If the severity is off or not set, then the function returns the default severity of the rule,"] #[doc = r" which is configured at the rule definition."] #[doc = r" The function can return `None` if the rule is not properly configured."] @@ -144,98 +144,99 @@ pub struct Safety { #[doc = "Adding a column with a DEFAULT value may lead to a table rewrite while holding an ACCESS EXCLUSIVE lock."] #[serde(skip_serializing_if = "Option::is_none")] pub adding_field_with_default: - Option>, + Option>, #[doc = "Adding a foreign key constraint requires a table scan and a SHARE ROW EXCLUSIVE lock on both tables, which blocks writes."] #[serde(skip_serializing_if = "Option::is_none")] pub adding_foreign_key_constraint: - Option>, + Option>, #[doc = "Setting a column NOT NULL blocks reads while the table is scanned."] #[serde(skip_serializing_if = "Option::is_none")] - pub adding_not_null_field: Option>, + pub adding_not_null_field: + Option>, #[doc = "Adding a primary key constraint results in locks and table rewrites."] #[serde(skip_serializing_if = "Option::is_none")] pub adding_primary_key_constraint: - Option>, + Option>, #[doc = "Adding a new column that is NOT NULL and has no default value to an existing table effectively makes it required."] #[serde(skip_serializing_if = "Option::is_none")] pub adding_required_field: - Option>, + Option>, #[doc = "Using CHAR(n) or CHARACTER(n) types is discouraged."] #[serde(skip_serializing_if = "Option::is_none")] - pub ban_char_field: Option>, + pub ban_char_field: Option>, #[doc = "Concurrent index creation is not allowed within a transaction."] #[serde(skip_serializing_if = "Option::is_none")] pub ban_concurrent_index_creation_in_transaction: - Option>, + Option>, #[doc = "Dropping a column may break existing clients."] #[serde(skip_serializing_if = "Option::is_none")] - pub ban_drop_column: Option>, + pub ban_drop_column: Option>, #[doc = "Dropping a database may break existing clients (and everything else, really)."] #[serde(skip_serializing_if = "Option::is_none")] - pub ban_drop_database: Option>, + pub ban_drop_database: Option>, #[doc = "Dropping a NOT NULL constraint may break existing clients."] #[serde(skip_serializing_if = "Option::is_none")] - pub ban_drop_not_null: Option>, + pub ban_drop_not_null: Option>, #[doc = "Dropping a table may break existing clients."] #[serde(skip_serializing_if = "Option::is_none")] - pub ban_drop_table: Option>, + pub ban_drop_table: Option>, #[doc = "Using TRUNCATE's CASCADE option will truncate any tables that are also foreign-keyed to the specified tables."] #[serde(skip_serializing_if = "Option::is_none")] - pub ban_truncate_cascade: Option>, + pub ban_truncate_cascade: Option>, #[doc = "Changing a column type may break existing clients."] #[serde(skip_serializing_if = "Option::is_none")] - pub changing_column_type: Option>, + pub changing_column_type: Option>, #[doc = "Adding constraints without NOT VALID blocks all reads and writes."] #[serde(skip_serializing_if = "Option::is_none")] pub constraint_missing_not_valid: - Option>, + Option>, #[doc = "Disallow adding a UNIQUE constraint without using an existing index."] #[serde(skip_serializing_if = "Option::is_none")] pub disallow_unique_constraint: - Option>, + Option>, #[doc = "Prefer BIGINT over smaller integer types."] #[serde(skip_serializing_if = "Option::is_none")] - pub prefer_big_int: Option>, + pub prefer_big_int: Option>, #[doc = "Prefer BIGINT over INT/INTEGER types."] #[serde(skip_serializing_if = "Option::is_none")] pub prefer_bigint_over_int: - Option>, + Option>, #[doc = "Prefer BIGINT over SMALLINT types."] #[serde(skip_serializing_if = "Option::is_none")] pub prefer_bigint_over_smallint: - Option>, + Option>, #[doc = "Prefer using IDENTITY columns over serial columns."] #[serde(skip_serializing_if = "Option::is_none")] - pub prefer_identity: Option>, + pub prefer_identity: Option>, #[doc = "Prefer JSONB over JSON types."] #[serde(skip_serializing_if = "Option::is_none")] - pub prefer_jsonb: Option>, + pub prefer_jsonb: Option>, #[doc = "Prefer statements with guards for robustness in migrations."] #[serde(skip_serializing_if = "Option::is_none")] - pub prefer_robust_stmts: Option>, + pub prefer_robust_stmts: Option>, #[doc = "Prefer using TEXT over VARCHAR(n) types."] #[serde(skip_serializing_if = "Option::is_none")] - pub prefer_text_field: Option>, + pub prefer_text_field: Option>, #[doc = "Prefer TIMESTAMPTZ over TIMESTAMP types."] #[serde(skip_serializing_if = "Option::is_none")] - pub prefer_timestamptz: Option>, + pub prefer_timestamptz: Option>, #[doc = "Renaming columns may break existing queries and application code."] #[serde(skip_serializing_if = "Option::is_none")] - pub renaming_column: Option>, + pub renaming_column: Option>, #[doc = "Renaming tables may break existing queries and application code."] #[serde(skip_serializing_if = "Option::is_none")] - pub renaming_table: Option>, + pub renaming_table: Option>, #[doc = "Creating indexes non-concurrently can lock the table for writes."] #[serde(skip_serializing_if = "Option::is_none")] pub require_concurrent_index_creation: - Option>, + Option>, #[doc = "Dropping indexes non-concurrently can lock the table for reads."] #[serde(skip_serializing_if = "Option::is_none")] pub require_concurrent_index_deletion: - Option>, + Option>, #[doc = "Detects problematic transaction nesting that could lead to unexpected behavior."] #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_nesting: Option>, + pub transaction_nesting: Option>, } impl Safety { const GROUP_NAME: &'static str = "safety"; diff --git a/crates/pgt_configuration/src/analyser/mod.rs b/crates/pgls_configuration/src/analyser/mod.rs similarity index 99% rename from crates/pgt_configuration/src/analyser/mod.rs rename to crates/pgls_configuration/src/analyser/mod.rs index 2d43fca42..b6ac67e91 100644 --- a/crates/pgt_configuration/src/analyser/mod.rs +++ b/crates/pgls_configuration/src/analyser/mod.rs @@ -3,9 +3,9 @@ pub mod linter; pub use crate::analyser::linter::*; use biome_deserialize::Merge; use biome_deserialize_macros::Deserializable; -use pgt_analyse::RuleFilter; -use pgt_analyse::options::RuleOptions; -use pgt_diagnostics::Severity; +use pgls_analyse::RuleFilter; +use pgls_analyse::options::RuleOptions; +use pgls_diagnostics::Severity; #[cfg(feature = "schema")] use schemars::JsonSchema; use serde::{Deserialize, Serialize}; diff --git a/crates/pgt_configuration/src/database.rs b/crates/pgls_configuration/src/database.rs similarity index 100% rename from crates/pgt_configuration/src/database.rs rename to crates/pgls_configuration/src/database.rs diff --git a/crates/pgt_configuration/src/diagnostics.rs b/crates/pgls_configuration/src/diagnostics.rs similarity index 96% rename from crates/pgt_configuration/src/diagnostics.rs rename to crates/pgls_configuration/src/diagnostics.rs index 79fd77142..2be6b21a1 100644 --- a/crates/pgt_configuration/src/diagnostics.rs +++ b/crates/pgls_configuration/src/diagnostics.rs @@ -1,8 +1,8 @@ -use pgt_console::fmt::Display; -use pgt_console::{MarkupBuf, markup}; -use pgt_diagnostics::adapters::ResolveError; +use pgls_console::fmt::Display; +use pgls_console::{MarkupBuf, markup}; +use pgls_diagnostics::adapters::ResolveError; -use pgt_diagnostics::{Advices, Diagnostic, Error, LogCategory, MessageAndDescription, Visit}; +use pgls_diagnostics::{Advices, Diagnostic, Error, LogCategory, MessageAndDescription, Visit}; use serde::{Deserialize, Serialize}; use std::fmt::{Debug, Formatter}; diff --git a/crates/pgt_configuration/src/files.rs b/crates/pgls_configuration/src/files.rs similarity index 100% rename from crates/pgt_configuration/src/files.rs rename to crates/pgls_configuration/src/files.rs diff --git a/crates/pgt_configuration/src/generated.rs b/crates/pgls_configuration/src/generated.rs similarity index 100% rename from crates/pgt_configuration/src/generated.rs rename to crates/pgls_configuration/src/generated.rs diff --git a/crates/pgt_configuration/src/generated/linter.rs b/crates/pgls_configuration/src/generated/linter.rs similarity index 92% rename from crates/pgt_configuration/src/generated/linter.rs rename to crates/pgls_configuration/src/generated/linter.rs index 142284f6d..4f4ece03d 100644 --- a/crates/pgt_configuration/src/generated/linter.rs +++ b/crates/pgls_configuration/src/generated/linter.rs @@ -1,7 +1,7 @@ //! Generated file, do not edit by hand, see `xtask/codegen` use crate::analyser::linter::*; -use pgt_analyse::{AnalyserRules, MetadataRegistry}; +use pgls_analyse::{AnalyserRules, MetadataRegistry}; pub fn push_to_analyser_rules( rules: &Rules, metadata: &MetadataRegistry, diff --git a/crates/pgt_configuration/src/lib.rs b/crates/pgls_configuration/src/lib.rs similarity index 97% rename from crates/pgt_configuration/src/lib.rs rename to crates/pgls_configuration/src/lib.rs index 8cac0c3f2..db31f27c9 100644 --- a/crates/pgt_configuration/src/lib.rs +++ b/crates/pgls_configuration/src/lib.rs @@ -1,4 +1,4 @@ -//! This module contains the configuration of `postgrestools.jsonc` +//! This module contains the configuration of `postgres-language-server.jsonc` //! //! The configuration is divided by "tool", and then it's possible to further customise it //! by language. The language might further options divided by tool. @@ -106,7 +106,9 @@ impl PartialConfiguration { /// Returns the initial configuration. pub fn init() -> Self { Self { - schema: Some(format!("https://pgtools.dev/schemas/{VERSION}/schema.json")), + schema: Some(format!( + "https://pg-language-server.com/schemas/{VERSION}/schema.json" + )), extends: Some(StringSet::default()), files: Some(PartialFilesConfiguration { ignore: Some(Default::default()), diff --git a/crates/pgt_configuration/src/migrations.rs b/crates/pgls_configuration/src/migrations.rs similarity index 100% rename from crates/pgt_configuration/src/migrations.rs rename to crates/pgls_configuration/src/migrations.rs diff --git a/crates/pgt_configuration/src/plpgsql_check.rs b/crates/pgls_configuration/src/plpgsql_check.rs similarity index 100% rename from crates/pgt_configuration/src/plpgsql_check.rs rename to crates/pgls_configuration/src/plpgsql_check.rs diff --git a/crates/pgt_configuration/src/typecheck.rs b/crates/pgls_configuration/src/typecheck.rs similarity index 100% rename from crates/pgt_configuration/src/typecheck.rs rename to crates/pgls_configuration/src/typecheck.rs diff --git a/crates/pgt_configuration/src/vcs.rs b/crates/pgls_configuration/src/vcs.rs similarity index 98% rename from crates/pgt_configuration/src/vcs.rs rename to crates/pgls_configuration/src/vcs.rs index b665a36f5..1dfc5245a 100644 --- a/crates/pgt_configuration/src/vcs.rs +++ b/crates/pgls_configuration/src/vcs.rs @@ -28,7 +28,7 @@ pub struct VcsConfiguration { pub use_ignore_file: bool, /// The folder where we should check for VCS files. By default, we will use the same - /// folder where `postgrestools.jsonc` was found. + /// folder where `postgres-language-server.jsonc` was found. /// /// If we can't find the configuration, it will attempt to use the current working directory. /// If no current working directory can't be found, we won't use the VCS integration, and a diagnostic diff --git a/crates/pgt_console/Cargo.toml b/crates/pgls_console/Cargo.toml similarity index 79% rename from crates/pgt_console/Cargo.toml rename to crates/pgls_console/Cargo.toml index 174a70ea4..7e27ee400 100644 --- a/crates/pgt_console/Cargo.toml +++ b/crates/pgls_console/Cargo.toml @@ -6,14 +6,14 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_console" +name = "pgls_console" repository.workspace = true version = "0.0.0" [dependencies] -pgt_markup = { workspace = true } -pgt_text_size = { workspace = true } +pgls_markup = { workspace = true } +pgls_text_size = { workspace = true } schemars = { workspace = true, optional = true } serde = { workspace = true, optional = true, features = ["derive"] } @@ -25,7 +25,7 @@ unicode-width = { workspace = true } trybuild = "1.0.99" [features] -schema = ["dep:schemars", "pgt_text_size/schema"] +schema = ["dep:schemars", "pgls_text_size/schema"] serde = ["dep:serde"] [lib] diff --git a/crates/pgt_console/README.md b/crates/pgls_console/README.md similarity index 100% rename from crates/pgt_console/README.md rename to crates/pgls_console/README.md diff --git a/crates/pgt_console/src/fmt.rs b/crates/pgls_console/src/fmt.rs similarity index 98% rename from crates/pgt_console/src/fmt.rs rename to crates/pgls_console/src/fmt.rs index 82e82157b..89c9203a1 100644 --- a/crates/pgt_console/src/fmt.rs +++ b/crates/pgls_console/src/fmt.rs @@ -38,7 +38,7 @@ impl<'a> MarkupElements<'a> { } } -/// The [Formatter] is the `pgt_console` equivalent to [std::fmt::Formatter]: +/// The [Formatter] is the `pgls_console` equivalent to [std::fmt::Formatter]: /// it's never constructed directly by consumers, and can only be used through /// the mutable reference passed to implementations of the [Display] trait). /// It manages the state of the markup to print, and implementations of @@ -99,13 +99,13 @@ impl<'fmt> Formatter<'fmt> { } } -/// Formatting trait for types to be displayed as markup, the `pgt_console` +/// Formatting trait for types to be displayed as markup, the `pgls_console` /// equivalent to [std::fmt::Display] /// /// # Example /// Implementing `Display` on a custom struct /// ``` -/// use pgt_console::{ +/// use pgls_console::{ /// fmt::{Display, Formatter}, /// markup, /// }; @@ -204,7 +204,7 @@ impl_std_display!(usize); impl Display for Duration { fn fmt(&self, fmt: &mut Formatter) -> io::Result<()> { - use crate as pgt_console; + use crate as pgls_console; let secs = self.as_secs(); if secs > 1 { diff --git a/crates/pgt_console/src/lib.rs b/crates/pgls_console/src/lib.rs similarity index 99% rename from crates/pgt_console/src/lib.rs rename to crates/pgls_console/src/lib.rs index 50498a03d..e235bc56a 100644 --- a/crates/pgt_console/src/lib.rs +++ b/crates/pgls_console/src/lib.rs @@ -1,4 +1,4 @@ -//! # pgt_console +//! # pgls_console use std::io; use std::io::{IsTerminal, Read, Write}; @@ -12,7 +12,7 @@ mod utils; mod write; pub use self::markup::{Markup, MarkupBuf, MarkupElement, MarkupNode}; -pub use pgt_markup::markup; +pub use pgls_markup::markup; pub use utils::*; /// Determines the "output stream" a message should get printed to diff --git a/crates/pgt_console/src/markup.rs b/crates/pgls_console/src/markup.rs similarity index 99% rename from crates/pgt_console/src/markup.rs rename to crates/pgls_console/src/markup.rs index 59cfb6f01..afc7b569e 100644 --- a/crates/pgt_console/src/markup.rs +++ b/crates/pgls_console/src/markup.rs @@ -4,7 +4,7 @@ use std::{ io, }; -use pgt_text_size::TextSize; +use pgls_text_size::TextSize; use termcolor::{Color, ColorSpec}; use crate::fmt::{Display, Formatter, MarkupElements, Write}; diff --git a/crates/pgt_console/src/utils.rs b/crates/pgls_console/src/utils.rs similarity index 97% rename from crates/pgt_console/src/utils.rs rename to crates/pgls_console/src/utils.rs index 957565162..624efa49d 100644 --- a/crates/pgt_console/src/utils.rs +++ b/crates/pgls_console/src/utils.rs @@ -5,7 +5,7 @@ use crate::{Markup, markup}; use std::io; /// Adapter type providing a std::fmt::Display implementation for any type that -/// implements pgt_console::fmt::Display. +/// implements pgls_console::fmt::Display. pub struct StdDisplay(pub T); impl std::fmt::Display for StdDisplay @@ -45,7 +45,7 @@ where T: std::fmt::Debug, { fn fmt(&self, fmt: &mut Formatter) -> io::Result<()> { - use crate as pgt_console; + use crate as pgls_console; match &self.0 { Some(value) => { diff --git a/crates/pgt_console/src/write.rs b/crates/pgls_console/src/write.rs similarity index 100% rename from crates/pgt_console/src/write.rs rename to crates/pgls_console/src/write.rs diff --git a/crates/pgt_console/src/write/html.rs b/crates/pgls_console/src/write/html.rs similarity index 99% rename from crates/pgt_console/src/write/html.rs rename to crates/pgls_console/src/write/html.rs index 88825e9f1..c9e604e59 100644 --- a/crates/pgt_console/src/write/html.rs +++ b/crates/pgls_console/src/write/html.rs @@ -144,9 +144,9 @@ impl io::Write for HtmlAdapter { #[cfg(test)] mod test { - use crate as pgt_console; + use crate as pgls_console; use crate::fmt::Formatter; - use pgt_markup::markup; + use pgls_markup::markup; #[test] fn test_mdx_new_lines() { diff --git a/crates/pgt_console/src/write/termcolor.rs b/crates/pgls_console/src/write/termcolor.rs similarity index 100% rename from crates/pgt_console/src/write/termcolor.rs rename to crates/pgls_console/src/write/termcolor.rs diff --git a/crates/pgt_console/tests/macro.rs b/crates/pgls_console/tests/macro.rs similarity index 90% rename from crates/pgt_console/tests/macro.rs rename to crates/pgls_console/tests/macro.rs index 177a20e34..7326bcc33 100644 --- a/crates/pgt_console/tests/macro.rs +++ b/crates/pgls_console/tests/macro.rs @@ -1,4 +1,4 @@ -use pgt_console::{Markup, MarkupElement}; +use pgls_console::{Markup, MarkupElement}; #[test] fn test_macro() { @@ -7,7 +7,7 @@ fn test_macro() { match // Due to how MarkupNode is implemented, the result of the markup macro // cannot be stored in a binding and must be matched upon immediately - pgt_markup::markup! { + pgls_markup::markup! { {category}" Commands" } { @@ -25,7 +25,7 @@ fn test_macro() { #[test] fn test_macro_attributes() { - pgt_markup::markup! { + pgls_markup::markup! { "link" }; } diff --git a/crates/pgt_console/tests/markup/closing_element_standalone.rs b/crates/pgls_console/tests/markup/closing_element_standalone.rs similarity index 58% rename from crates/pgt_console/tests/markup/closing_element_standalone.rs rename to crates/pgls_console/tests/markup/closing_element_standalone.rs index 815d2c4ae..71d4d660c 100644 --- a/crates/pgt_console/tests/markup/closing_element_standalone.rs +++ b/crates/pgls_console/tests/markup/closing_element_standalone.rs @@ -1,5 +1,5 @@ fn main() { - pgt_console::markup! { + pgls_console::markup! { } } diff --git a/crates/pgt_console/tests/markup/closing_element_standalone.stderr b/crates/pgls_console/tests/markup/closing_element_standalone.stderr similarity index 100% rename from crates/pgt_console/tests/markup/closing_element_standalone.stderr rename to crates/pgls_console/tests/markup/closing_element_standalone.stderr diff --git a/crates/pgt_console/tests/markup/element_non_ident_name.rs b/crates/pgls_console/tests/markup/element_non_ident_name.rs similarity index 60% rename from crates/pgt_console/tests/markup/element_non_ident_name.rs rename to crates/pgls_console/tests/markup/element_non_ident_name.rs index 84aa0bca5..61acd65f4 100644 --- a/crates/pgt_console/tests/markup/element_non_ident_name.rs +++ b/crates/pgls_console/tests/markup/element_non_ident_name.rs @@ -1,5 +1,5 @@ fn main() { - pgt_console::markup! { + pgls_console::markup! { <"Literal" /> } } diff --git a/crates/pgt_console/tests/markup/element_non_ident_name.stderr b/crates/pgls_console/tests/markup/element_non_ident_name.stderr similarity index 100% rename from crates/pgt_console/tests/markup/element_non_ident_name.stderr rename to crates/pgls_console/tests/markup/element_non_ident_name.stderr diff --git a/crates/pgt_console/tests/markup/invalid_group.rs b/crates/pgls_console/tests/markup/invalid_group.rs similarity index 52% rename from crates/pgt_console/tests/markup/invalid_group.rs rename to crates/pgls_console/tests/markup/invalid_group.rs index c53c44948..8f4156135 100644 --- a/crates/pgt_console/tests/markup/invalid_group.rs +++ b/crates/pgls_console/tests/markup/invalid_group.rs @@ -1,5 +1,5 @@ fn main() { - pgt_console::markup! { + pgls_console::markup! { [] } } diff --git a/crates/pgt_console/tests/markup/invalid_group.stderr b/crates/pgls_console/tests/markup/invalid_group.stderr similarity index 100% rename from crates/pgt_console/tests/markup/invalid_group.stderr rename to crates/pgls_console/tests/markup/invalid_group.stderr diff --git a/crates/pgt_console/tests/markup/invalid_punct.rs b/crates/pgls_console/tests/markup/invalid_punct.rs similarity index 51% rename from crates/pgt_console/tests/markup/invalid_punct.rs rename to crates/pgls_console/tests/markup/invalid_punct.rs index 311bab6c5..022104806 100644 --- a/crates/pgt_console/tests/markup/invalid_punct.rs +++ b/crates/pgls_console/tests/markup/invalid_punct.rs @@ -1,5 +1,5 @@ fn main() { - pgt_console::markup! { + pgls_console::markup! { ! } } diff --git a/crates/pgt_console/tests/markup/invalid_punct.stderr b/crates/pgls_console/tests/markup/invalid_punct.stderr similarity index 100% rename from crates/pgt_console/tests/markup/invalid_punct.stderr rename to crates/pgls_console/tests/markup/invalid_punct.stderr diff --git a/crates/pgt_console/tests/markup/open_element_improper_close_1.rs b/crates/pgls_console/tests/markup/open_element_improper_close_1.rs similarity index 59% rename from crates/pgt_console/tests/markup/open_element_improper_close_1.rs rename to crates/pgls_console/tests/markup/open_element_improper_close_1.rs index a95674571..71eaeb8c3 100644 --- a/crates/pgt_console/tests/markup/open_element_improper_close_1.rs +++ b/crates/pgls_console/tests/markup/open_element_improper_close_1.rs @@ -1,5 +1,5 @@ fn main() { - pgt_console::markup! { + pgls_console::markup! { } } diff --git a/crates/pgt_console/tests/markup/open_element_improper_prop_value.stderr b/crates/pgls_console/tests/markup/open_element_improper_prop_value.stderr similarity index 100% rename from crates/pgt_console/tests/markup/open_element_improper_prop_value.stderr rename to crates/pgls_console/tests/markup/open_element_improper_prop_value.stderr diff --git a/crates/pgt_console/tests/markup/open_element_missing_prop_value.rs b/crates/pgls_console/tests/markup/open_element_missing_prop_value.rs similarity index 64% rename from crates/pgt_console/tests/markup/open_element_missing_prop_value.rs rename to crates/pgls_console/tests/markup/open_element_missing_prop_value.rs index 73423ffd6..219c48bd9 100644 --- a/crates/pgt_console/tests/markup/open_element_missing_prop_value.rs +++ b/crates/pgls_console/tests/markup/open_element_missing_prop_value.rs @@ -1,5 +1,5 @@ fn main() { - pgt_console::markup! { + pgls_console::markup! { } } diff --git a/crates/pgt_console/tests/markup/open_element_missing_prop_value.stderr b/crates/pgls_console/tests/markup/open_element_missing_prop_value.stderr similarity index 100% rename from crates/pgt_console/tests/markup/open_element_missing_prop_value.stderr rename to crates/pgls_console/tests/markup/open_element_missing_prop_value.stderr diff --git a/crates/pgt_console/tests/markup/open_element_unfinished_1.rs b/crates/pgls_console/tests/markup/open_element_unfinished_1.rs similarity index 51% rename from crates/pgt_console/tests/markup/open_element_unfinished_1.rs rename to crates/pgls_console/tests/markup/open_element_unfinished_1.rs index 0c155fc7b..1371b9db0 100644 --- a/crates/pgt_console/tests/markup/open_element_unfinished_1.rs +++ b/crates/pgls_console/tests/markup/open_element_unfinished_1.rs @@ -1,5 +1,5 @@ fn main() { - pgt_console::markup! { + pgls_console::markup! { < } } diff --git a/crates/pgt_console/tests/markup/open_element_unfinished_1.stderr b/crates/pgls_console/tests/markup/open_element_unfinished_1.stderr similarity index 100% rename from crates/pgt_console/tests/markup/open_element_unfinished_1.stderr rename to crates/pgls_console/tests/markup/open_element_unfinished_1.stderr diff --git a/crates/pgt_console/tests/markup/open_element_unfinished_2.rs b/crates/pgls_console/tests/markup/open_element_unfinished_2.rs similarity index 57% rename from crates/pgt_console/tests/markup/open_element_unfinished_2.rs rename to crates/pgls_console/tests/markup/open_element_unfinished_2.rs index e8d3bbf2a..1199ee8c3 100644 --- a/crates/pgt_console/tests/markup/open_element_unfinished_2.rs +++ b/crates/pgls_console/tests/markup/open_element_unfinished_2.rs @@ -1,5 +1,5 @@ fn main() { - pgt_console::markup! { + pgls_console::markup! { } } diff --git a/crates/pgt_console/tests/markup/unclosed_element.stderr b/crates/pgls_console/tests/markup/unclosed_element.stderr similarity index 100% rename from crates/pgt_console/tests/markup/unclosed_element.stderr rename to crates/pgls_console/tests/markup/unclosed_element.stderr diff --git a/crates/pgls_diagnostics/Cargo.toml b/crates/pgls_diagnostics/Cargo.toml new file mode 100644 index 000000000..0e3d7f51c --- /dev/null +++ b/crates/pgls_diagnostics/Cargo.toml @@ -0,0 +1,36 @@ +[package] +authors.workspace = true +categories.workspace = true +description = "" +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +name = "pgls_diagnostics" +repository.workspace = true +version = "0.0.0" + + +[dependencies] +backtrace = "0.3.74" +bpaf = { workspace = true } +enumflags2 = { workspace = true } +oxc_resolver = { workspace = true } +pgls_console = { workspace = true, features = ["serde"] } +pgls_diagnostics_categories = { workspace = true, features = ["serde"] } +pgls_diagnostics_macros = { workspace = true } +pgls_text_edit = { workspace = true, features = ["serde"] } +pgls_text_size.workspace = true +schemars = { workspace = true, optional = true } +serde = { workspace = true, features = ["derive"] } +serde_json = { workspace = true } +termcolor = { workspace = true } +unicode-width = { workspace = true } + +[features] +schema = ["dep:schemars", "pgls_text_edit/schema", "pgls_diagnostics_categories/schema", "pgls_console/schema"] + +[dev-dependencies] + +[lib] +doctest = false diff --git a/crates/pgt_diagnostics/src/adapters.rs b/crates/pgls_diagnostics/src/adapters.rs similarity index 99% rename from crates/pgt_diagnostics/src/adapters.rs rename to crates/pgls_diagnostics/src/adapters.rs index 5c3dcdd58..215249743 100644 --- a/crates/pgt_diagnostics/src/adapters.rs +++ b/crates/pgls_diagnostics/src/adapters.rs @@ -4,7 +4,7 @@ use std::io; -use pgt_console::{ +use pgls_console::{ fmt::{self}, markup, }; diff --git a/crates/pgt_diagnostics/src/advice.rs b/crates/pgls_diagnostics/src/advice.rs similarity index 98% rename from crates/pgt_diagnostics/src/advice.rs rename to crates/pgls_diagnostics/src/advice.rs index 3720ff671..8ac06b363 100644 --- a/crates/pgt_diagnostics/src/advice.rs +++ b/crates/pgls_diagnostics/src/advice.rs @@ -4,9 +4,9 @@ use crate::{ display::Backtrace, location::{AsResource, AsSourceCode, AsSpan}, }; -use pgt_console::fmt::{self, Display}; -use pgt_console::{MarkupBuf, markup}; -use pgt_text_edit::TextEdit; +use pgls_console::fmt::{self, Display}; +use pgls_console::{MarkupBuf, markup}; +use pgls_text_edit::TextEdit; use serde::{Deserialize, Serialize}; use std::io; diff --git a/crates/pgt_diagnostics/src/context.rs b/crates/pgls_diagnostics/src/context.rs similarity index 99% rename from crates/pgt_diagnostics/src/context.rs rename to crates/pgls_diagnostics/src/context.rs index 88a64661f..6cefb2d11 100644 --- a/crates/pgt_diagnostics/src/context.rs +++ b/crates/pgls_diagnostics/src/context.rs @@ -1,4 +1,4 @@ -use pgt_console::fmt; +use pgls_console::fmt; use crate::context::internal::{SeverityDiagnostic, TagsDiagnostic}; use crate::{ @@ -249,9 +249,9 @@ mod internal { use std::{fmt::Debug, io}; - use pgt_console::{fmt, markup}; - use pgt_text_edit::TextEdit; - use pgt_text_size::TextRange; + use pgls_console::{fmt, markup}; + use pgls_text_edit::TextEdit; + use pgls_text_size::TextRange; use crate::{ Advices, Backtrace, Category, Diagnostic, DiagnosticTags, LineIndex, LineIndexBuf, @@ -260,7 +260,7 @@ mod internal { }; /// This trait is inherited by `DiagnosticExt` and `Context`, since it's - /// not visible outside of `pgt_diagnostics` this prevents these extension + /// not visible outside of `pgls_diagnostics` this prevents these extension /// traits from being implemented on other types outside of this module /// /// Making these traits "sealed" is mainly intended as a stability diff --git a/crates/pgt_diagnostics/src/diagnostic.rs b/crates/pgls_diagnostics/src/diagnostic.rs similarity index 98% rename from crates/pgt_diagnostics/src/diagnostic.rs rename to crates/pgls_diagnostics/src/diagnostic.rs index 3f365aed7..433a82817 100644 --- a/crates/pgt_diagnostics/src/diagnostic.rs +++ b/crates/pgls_diagnostics/src/diagnostic.rs @@ -10,7 +10,7 @@ use bpaf::Bpaf; use enumflags2::{BitFlags, bitflags, make_bitflags}; use serde::{Deserialize, Serialize}; -use pgt_console::fmt; +use pgls_console::fmt; use crate::{Category, Location, Visit}; @@ -23,7 +23,7 @@ use crate::{Category, Location, Visit}; /// instead rely on the `Diagnostic` derive macro also provided by this crate: /// /// ``` -/// # use pgt_diagnostics::Diagnostic; +/// # use pgls_diagnostics::Diagnostic; /// #[derive(Debug, Diagnostic)] /// #[diagnostic(category = "lint/style/noShoutyConstants", tags(FIXABLE))] /// struct ExampleDiagnostic { @@ -250,7 +250,7 @@ pub(crate) mod internal { /// trait (as that would conflict with the implementation of `From for T` /// in the standard library). The [AsDiagnostic] exists as an internal /// implementation detail to bridge this gap and allow various types and - /// functions in `pgt_diagnostics` to be generic over all diagnostics + + /// functions in `pgls_diagnostics` to be generic over all diagnostics + /// `Error`. pub trait AsDiagnostic: Debug { type Diagnostic: Diagnostic + ?Sized; diff --git a/crates/pgt_diagnostics/src/display.rs b/crates/pgls_diagnostics/src/display.rs similarity index 98% rename from crates/pgt_diagnostics/src/display.rs rename to crates/pgls_diagnostics/src/display.rs index d270d08f4..b19707f89 100644 --- a/crates/pgt_diagnostics/src/display.rs +++ b/crates/pgls_diagnostics/src/display.rs @@ -1,8 +1,8 @@ -use pgt_console::fmt::MarkupElements; -use pgt_console::{ +use pgls_console::fmt::MarkupElements; +use pgls_console::{ HorizontalLine, Markup, MarkupBuf, MarkupElement, MarkupNode, Padding, fmt, markup, }; -use pgt_text_edit::TextEdit; +use pgls_text_edit::TextEdit; use std::path::Path; use std::{env, io, iter}; use unicode_width::UnicodeWidthStr; @@ -35,7 +35,7 @@ impl std::fmt::Display for PrintDescription<'_, D> { } /// Helper struct for printing a diagnostic as markup into any formatter -/// implementing [pgt_console::fmt::Write]. +/// implementing [pgls_console::fmt::Write]. pub struct PrintDiagnostic<'fmt, D: ?Sized> { diag: &'fmt D, verbose: bool, @@ -665,14 +665,14 @@ impl fmt::Write for IndentWriter<'_, W> { mod tests { use std::io; - use pgt_console::{fmt, markup}; - use pgt_diagnostics::{DiagnosticTags, Severity}; - use pgt_diagnostics_categories::{Category, category}; - use pgt_text_edit::TextEdit; - use pgt_text_size::{TextRange, TextSize}; + use pgls_console::{fmt, markup}; + use pgls_diagnostics::{DiagnosticTags, Severity}; + use pgls_diagnostics_categories::{Category, category}; + use pgls_text_edit::TextEdit; + use pgls_text_size::{TextRange, TextSize}; use serde_json::{from_value, json}; - use crate::{self as pgt_diagnostics}; + use crate::{self as pgls_diagnostics}; use crate::{ Advices, Diagnostic, Location, LogCategory, PrintDiagnostic, Resource, SourceCode, Visit, }; diff --git a/crates/pgt_diagnostics/src/display/backtrace.rs b/crates/pgls_diagnostics/src/display/backtrace.rs similarity index 99% rename from crates/pgt_diagnostics/src/display/backtrace.rs rename to crates/pgls_diagnostics/src/display/backtrace.rs index ad9addbfb..a49ab5b67 100644 --- a/crates/pgt_diagnostics/src/display/backtrace.rs +++ b/crates/pgls_diagnostics/src/display/backtrace.rs @@ -1,7 +1,7 @@ use std::{borrow::Cow, path::PathBuf}; use std::{cell::Cell, fmt::Write as _, io, os::raw::c_void, path::Path, slice}; -use pgt_console::{fmt, markup}; +use pgls_console::{fmt, markup}; use serde::{Deserialize, Serialize}; use super::IndentWriter; @@ -208,7 +208,7 @@ thread_local! { /// /// On the main thread: /// ``` -/// # use pgt_diagnostics::set_bottom_frame; +/// # use pgls_diagnostics::set_bottom_frame; /// # #[allow(clippy::needless_doctest_main)] /// pub fn main() { /// set_bottom_frame(main as usize); @@ -219,7 +219,7 @@ thread_local! { /// /// On worker threads: /// ``` -/// # use pgt_diagnostics::set_bottom_frame; +/// # use pgls_diagnostics::set_bottom_frame; /// fn worker_thread() { /// set_bottom_frame(worker_thread as usize); /// diff --git a/crates/pgt_diagnostics/src/display/diff.rs b/crates/pgls_diagnostics/src/display/diff.rs similarity index 99% rename from crates/pgt_diagnostics/src/display/diff.rs rename to crates/pgls_diagnostics/src/display/diff.rs index 1e01044ab..47151aa33 100644 --- a/crates/pgt_diagnostics/src/display/diff.rs +++ b/crates/pgls_diagnostics/src/display/diff.rs @@ -3,8 +3,8 @@ use std::{ io, slice, }; -use pgt_console::{MarkupElement, fmt, markup}; -use pgt_text_edit::{ChangeTag, CompressedOp, TextEdit}; +use pgls_console::{MarkupElement, fmt, markup}; +use pgls_text_edit::{ChangeTag, CompressedOp, TextEdit}; use super::frame::{ CODE_FRAME_CONTEXT_LINES, IntoIter, OneIndexed, PrintInvisiblesOptions, calculate_print_width, @@ -665,8 +665,8 @@ impl fmt::Write for ElementWrapper<'_, W> { #[cfg(test)] mod tests { use super::print_diff; - use pgt_console::{MarkupBuf, fmt, markup}; - use pgt_text_edit::TextEdit; + use pgls_console::{MarkupBuf, fmt, markup}; + use pgls_text_edit::TextEdit; use termcolor::Buffer; fn assert_eq_markup(actual: &MarkupBuf, expected: &MarkupBuf) { diff --git a/crates/pgt_diagnostics/src/display/frame.rs b/crates/pgls_diagnostics/src/display/frame.rs similarity index 99% rename from crates/pgt_diagnostics/src/display/frame.rs rename to crates/pgls_diagnostics/src/display/frame.rs index 56577e01b..7ab16f925 100644 --- a/crates/pgt_diagnostics/src/display/frame.rs +++ b/crates/pgls_diagnostics/src/display/frame.rs @@ -6,8 +6,8 @@ use std::{ ops::{Bound, RangeBounds}, }; -use pgt_console::{fmt, markup}; -use pgt_text_size::{TextLen, TextRange, TextSize}; +use pgls_console::{fmt, markup}; +use pgls_text_size::{TextLen, TextRange, TextSize}; use unicode_width::UnicodeWidthChar; use crate::{ diff --git a/crates/pgt_diagnostics/src/display/message.rs b/crates/pgls_diagnostics/src/display/message.rs similarity index 92% rename from crates/pgt_diagnostics/src/display/message.rs rename to crates/pgls_diagnostics/src/display/message.rs index 20c039a9d..61411bd87 100644 --- a/crates/pgt_diagnostics/src/display/message.rs +++ b/crates/pgls_diagnostics/src/display/message.rs @@ -1,5 +1,5 @@ -use pgt_console::fmt::{Formatter, Termcolor}; -use pgt_console::{MarkupBuf, markup}; +use pgls_console::fmt::{Formatter, Termcolor}; +use pgls_console::{MarkupBuf, markup}; use serde::{Deserialize, Serialize}; use termcolor::NoColor; @@ -9,7 +9,7 @@ use termcolor::NoColor; /// ## Examples /// /// ``` -/// use pgt_diagnostics::{Diagnostic, MessageAndDescription}; +/// use pgls_diagnostics::{Diagnostic, MessageAndDescription}; /// /// #[derive(Debug, Diagnostic)] /// struct TestDiagnostic { @@ -78,7 +78,7 @@ impl std::fmt::Debug for MessageAndDescription { } } -impl pgt_console::fmt::Display for MessageAndDescription { +impl pgls_console::fmt::Display for MessageAndDescription { fn fmt(&self, fmt: &mut Formatter<'_>) -> std::io::Result<()> { fmt.write_markup(markup! {{self.message}}) } diff --git a/crates/pgt_diagnostics/src/display_github.rs b/crates/pgls_diagnostics/src/display_github.rs similarity index 97% rename from crates/pgt_diagnostics/src/display_github.rs rename to crates/pgls_diagnostics/src/display_github.rs index b7d5f058e..6d8383a89 100644 --- a/crates/pgt_diagnostics/src/display_github.rs +++ b/crates/pgls_diagnostics/src/display_github.rs @@ -1,11 +1,11 @@ use crate::display::frame::SourceFile; use crate::{Diagnostic, Resource, Severity, diagnostic::internal::AsDiagnostic}; -use pgt_console::{MarkupBuf, fmt, markup}; -use pgt_text_size::{TextRange, TextSize}; +use pgls_console::{MarkupBuf, fmt, markup}; +use pgls_text_size::{TextRange, TextSize}; use std::io; /// Helper struct for printing a diagnostic as markup into any formatter -/// implementing [pgt_console::fmt::Write]. +/// implementing [pgls_console::fmt::Write]. pub struct PrintGitHubDiagnostic<'fmt, D: ?Sized>(pub &'fmt D); impl fmt::Display for PrintGitHubDiagnostic<'_, D> { diff --git a/crates/pgt_diagnostics/src/error.rs b/crates/pgls_diagnostics/src/error.rs similarity index 99% rename from crates/pgt_diagnostics/src/error.rs rename to crates/pgls_diagnostics/src/error.rs index 1c0cbe301..7900b3040 100644 --- a/crates/pgt_diagnostics/src/error.rs +++ b/crates/pgls_diagnostics/src/error.rs @@ -14,7 +14,7 @@ use std::{ io, }; -use pgt_console::fmt; +use pgls_console::fmt; use crate::{ Category, Diagnostic, DiagnosticTags, Location, Severity, Visit, diff --git a/crates/pgt_diagnostics/src/lib.rs b/crates/pgls_diagnostics/src/lib.rs similarity index 88% rename from crates/pgt_diagnostics/src/lib.rs rename to crates/pgls_diagnostics/src/lib.rs index b6aad22ab..ffb9f5f58 100644 --- a/crates/pgt_diagnostics/src/lib.rs +++ b/crates/pgls_diagnostics/src/lib.rs @@ -20,11 +20,11 @@ pub use termcolor; #[doc(hidden)] // Convenience re-export for procedural macro -pub use pgt_console as console; +pub use pgls_console as console; // Re-export macros from utility crates -pub use pgt_diagnostics_categories::{Category, category, category_concat}; -pub use pgt_diagnostics_macros::Diagnostic; +pub use pgls_diagnostics_categories::{Category, category, category_concat}; +pub use pgls_diagnostics_macros::Diagnostic; pub use crate::advice::{ Advices, CodeFrameAdvice, CommandAdvice, DiffAdvice, LogAdvice, LogCategory, Visit, @@ -37,13 +37,13 @@ pub use crate::display::{ pub use crate::display_github::PrintGitHubDiagnostic; pub use crate::error::{Error, Result}; pub use crate::location::{LineIndex, LineIndexBuf, Location, Resource, SourceCode}; -use pgt_console::fmt::{Formatter, Termcolor}; -use pgt_console::markup; +use pgls_console::fmt::{Formatter, Termcolor}; +use pgls_console::markup; use std::fmt::Write; pub mod prelude { //! Anonymously re-exports all the traits declared by this module, this is - //! intended to be imported as `use pgt_diagnostics::prelude::*;` to + //! intended to be imported as `use pgls_diagnostics::prelude::*;` to //! automatically bring all these traits into the ambient context pub use crate::advice::{Advices as _, Visit as _}; diff --git a/crates/pgt_diagnostics/src/location.rs b/crates/pgls_diagnostics/src/location.rs similarity index 99% rename from crates/pgt_diagnostics/src/location.rs rename to crates/pgls_diagnostics/src/location.rs index e17ace9c3..40597e8ef 100644 --- a/crates/pgt_diagnostics/src/location.rs +++ b/crates/pgls_diagnostics/src/location.rs @@ -1,4 +1,4 @@ -use pgt_text_size::{TextRange, TextSize}; +use pgls_text_size::{TextRange, TextSize}; use serde::{Deserialize, Serialize}; use std::fmt::Debug; use std::ops::Range; @@ -344,7 +344,7 @@ impl AsSourceCode for String { #[cfg(test)] mod tests { - use pgt_text_size::TextSize; + use pgls_text_size::TextSize; use super::LineIndexBuf; diff --git a/crates/pgt_diagnostics/src/panic.rs b/crates/pgls_diagnostics/src/panic.rs similarity index 100% rename from crates/pgt_diagnostics/src/panic.rs rename to crates/pgls_diagnostics/src/panic.rs diff --git a/crates/pgt_diagnostics/src/serde.rs b/crates/pgls_diagnostics/src/serde.rs similarity index 98% rename from crates/pgt_diagnostics/src/serde.rs rename to crates/pgls_diagnostics/src/serde.rs index 57ed3e280..7e0e7a098 100644 --- a/crates/pgt_diagnostics/src/serde.rs +++ b/crates/pgls_diagnostics/src/serde.rs @@ -1,8 +1,8 @@ use std::io; -use pgt_console::{MarkupBuf, fmt, markup}; -use pgt_text_edit::TextEdit; -use pgt_text_size::{TextRange, TextSize}; +use pgls_console::{MarkupBuf, fmt, markup}; +use pgls_text_edit::TextEdit; +use pgls_text_size::{TextRange, TextSize}; use serde::{ Deserialize, Deserializer, Serialize, Serializer, de::{self, SeqAccess}, @@ -374,12 +374,12 @@ impl schemars::JsonSchema for DiagnosticTags { mod tests { use std::io; - use pgt_text_size::{TextRange, TextSize}; + use pgls_text_size::{TextRange, TextSize}; use crate::{ - self as pgt_diagnostics, {Advices, LogCategory, Visit}, + self as pgls_diagnostics, {Advices, LogCategory, Visit}, }; - use pgt_diagnostics_macros::Diagnostic; + use pgls_diagnostics_macros::Diagnostic; #[derive(Debug, Diagnostic)] #[diagnostic( diff --git a/crates/pgt_diagnostics/src/suggestion.rs b/crates/pgls_diagnostics/src/suggestion.rs similarity index 91% rename from crates/pgt_diagnostics/src/suggestion.rs rename to crates/pgls_diagnostics/src/suggestion.rs index 6368d305e..1f6f20206 100644 --- a/crates/pgt_diagnostics/src/suggestion.rs +++ b/crates/pgls_diagnostics/src/suggestion.rs @@ -1,7 +1,7 @@ use ::serde::{Deserialize, Serialize}; -use pgt_console::MarkupBuf; -use pgt_text_edit::TextEdit; -use pgt_text_size::TextRange; +use pgls_console::MarkupBuf; +use pgls_text_edit::TextEdit; +use pgls_text_size::TextRange; /// Indicates how a tool should manage this suggestion. #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] diff --git a/crates/pgt_diagnostics_categories/Cargo.toml b/crates/pgls_diagnostics_categories/Cargo.toml similarity index 90% rename from crates/pgt_diagnostics_categories/Cargo.toml rename to crates/pgls_diagnostics_categories/Cargo.toml index 5f86d4561..edff6d0f8 100644 --- a/crates/pgt_diagnostics_categories/Cargo.toml +++ b/crates/pgls_diagnostics_categories/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_diagnostics_categories" +name = "pgls_diagnostics_categories" repository.workspace = true version = "0.0.0" diff --git a/crates/pgt_diagnostics_categories/build.rs b/crates/pgls_diagnostics_categories/build.rs similarity index 93% rename from crates/pgt_diagnostics_categories/build.rs rename to crates/pgls_diagnostics_categories/build.rs index 59e5cda73..2cdef1efd 100644 --- a/crates/pgt_diagnostics_categories/build.rs +++ b/crates/pgls_diagnostics_categories/build.rs @@ -85,7 +85,7 @@ pub fn main() -> io::Result<()> { /// # Example /// /// ``` - /// # use pgt_diagnostics_categories::{Category, category}; + /// # use pgls_diagnostics_categories::{Category, category}; /// let category: &'static Category = category!("internalError/io"); /// assert_eq!(category.name(), "internalError/io"); /// assert_eq!(category.link(), None); @@ -95,7 +95,7 @@ pub fn main() -> io::Result<()> { #( #macro_arms )* ( $name:literal ) => { - compile_error!(concat!("Unregistered diagnostic category \"", $name, "\", please add it to \"crates/pgt_diagnostics_categories/src/categories.rs\"")) + compile_error!(concat!("Unregistered diagnostic category \"", $name, "\", please add it to \"crates/pgls_diagnostics_categories/src/categories.rs\"")) }; ( $( $parts:tt )* ) => { compile_error!(concat!("Invalid diagnostic category `", stringify!($( $parts )*), "`, expected a single string literal")) @@ -110,7 +110,7 @@ pub fn main() -> io::Result<()> { #( #concat_macro_arms )* ( @compile_error $( $parts:tt )* ) => { - compile_error!(concat!("Unregistered diagnostic category \"", $( $parts, )* "\", please add it to \"crates/pgt_diagnostics_categories/src/categories.rs\"")) + compile_error!(concat!("Unregistered diagnostic category \"", $( $parts, )* "\", please add it to \"crates/pgls_diagnostics_categories/src/categories.rs\"")) }; ( $( $parts:tt ),* ) => { $crate::category_concat!( @compile_error $( $parts )"/"* ) diff --git a/crates/pgls_diagnostics_categories/src/categories.rs b/crates/pgls_diagnostics_categories/src/categories.rs new file mode 100644 index 000000000..8b1371b0c --- /dev/null +++ b/crates/pgls_diagnostics_categories/src/categories.rs @@ -0,0 +1,67 @@ +// This file contains the list of all diagnostic categories for the pg +// toolchain +// +// The `define_categories` macro is preprocessed in the build script for the +// crate in order to generate the static registry. The body of the macro +// consists of a list of key-value pairs defining the categories that have an +// associated hyperlink, then a list of string literals defining the remaining +// categories without a link. + +// PLEASE, DON'T EDIT THIS FILE BY HAND. +// Use `just new-lintrule` to create a new rule. +// lint rules are lexicographically sorted and +// must be between `define_categories! {\n` and `\n ;\n`. + +define_categories! { + "lint/safety/addingFieldWithDefault": "https://pg-language-server.com/latest/rules/adding-field-with-default", + "lint/safety/addingForeignKeyConstraint": "https://pg-language-server.com/latest/rules/adding-foreign-key-constraint", + "lint/safety/addingNotNullField": "https://pg-language-server.com/latest/rules/adding-not-null-field", + "lint/safety/addingPrimaryKeyConstraint": "https://pg-language-server.com/latest/rules/adding-primary-key-constraint", + "lint/safety/addingRequiredField": "https://pg-language-server.com/latest/rules/adding-required-field", + "lint/safety/banCharField": "https://pg-language-server.com/latest/rules/ban-char-field", + "lint/safety/banConcurrentIndexCreationInTransaction": "https://pg-language-server.com/latest/rules/ban-concurrent-index-creation-in-transaction", + "lint/safety/banDropColumn": "https://pg-language-server.com/latest/rules/ban-drop-column", + "lint/safety/banDropDatabase": "https://pg-language-server.com/latest/rules/ban-drop-database", + "lint/safety/banDropNotNull": "https://pg-language-server.com/latest/rules/ban-drop-not-null", + "lint/safety/banDropTable": "https://pg-language-server.com/latest/rules/ban-drop-table", + "lint/safety/banTruncateCascade": "https://pg-language-server.com/latest/rules/ban-truncate-cascade", + "lint/safety/changingColumnType": "https://pg-language-server.com/latest/rules/changing-column-type", + "lint/safety/constraintMissingNotValid": "https://pg-language-server.com/latest/rules/constraint-missing-not-valid", + "lint/safety/disallowUniqueConstraint": "https://pg-language-server.com/latest/rules/disallow-unique-constraint", + "lint/safety/preferBigInt": "https://pg-language-server.com/latest/rules/prefer-big-int", + "lint/safety/preferBigintOverInt": "https://pg-language-server.com/latest/rules/prefer-bigint-over-int", + "lint/safety/preferBigintOverSmallint": "https://pg-language-server.com/latest/rules/prefer-bigint-over-smallint", + "lint/safety/preferIdentity": "https://pg-language-server.com/latest/rules/prefer-identity", + "lint/safety/preferJsonb": "https://pg-language-server.com/latest/rules/prefer-jsonb", + "lint/safety/preferRobustStmts": "https://pg-language-server.com/latest/rules/prefer-robust-stmts", + "lint/safety/preferTextField": "https://pg-language-server.com/latest/rules/prefer-text-field", + "lint/safety/preferTimestamptz": "https://pg-language-server.com/latest/rules/prefer-timestamptz", + "lint/safety/renamingColumn": "https://pg-language-server.com/latest/rules/renaming-column", + "lint/safety/renamingTable": "https://pg-language-server.com/latest/rules/renaming-table", + "lint/safety/requireConcurrentIndexCreation": "https://pg-language-server.com/latest/rules/require-concurrent-index-creation", + "lint/safety/requireConcurrentIndexDeletion": "https://pg-language-server.com/latest/rules/require-concurrent-index-deletion", + "lint/safety/transactionNesting": "https://pg-language-server.com/latest/rules/transaction-nesting", + // end lint rules + ; + // General categories + "stdin", + "check", + "configuration", + "database/connection", + "internalError/io", + "internalError/runtime", + "internalError/fs", + "flags/invalid", + "project", + "typecheck", + "plpgsql_check", + "internalError/panic", + "syntax", + "dummy", + + // Lint groups start + "lint", + "lint/performance", + "lint/safety", + // Lint groups end +} diff --git a/crates/pgt_diagnostics_categories/src/lib.rs b/crates/pgls_diagnostics_categories/src/lib.rs similarity index 96% rename from crates/pgt_diagnostics_categories/src/lib.rs rename to crates/pgls_diagnostics_categories/src/lib.rs index 5cf217347..13da47456 100644 --- a/crates/pgt_diagnostics_categories/src/lib.rs +++ b/crates/pgls_diagnostics_categories/src/lib.rs @@ -5,7 +5,7 @@ use std::{ /// Metadata for a diagnostic category /// -/// This type cannot be instantiated outside of the `pgt_diagnostics_categories` +/// This type cannot be instantiated outside of the `pgls_diagnostics_categories` /// crate, which serves as a registry for all known diagnostic categories /// (currently this registry is fully static and generated at compile time) #[derive(Debug)] diff --git a/crates/pgt_diagnostics_macros/Cargo.toml b/crates/pgls_diagnostics_macros/Cargo.toml similarity index 91% rename from crates/pgt_diagnostics_macros/Cargo.toml rename to crates/pgls_diagnostics_macros/Cargo.toml index 70e1555fd..8c6606370 100644 --- a/crates/pgt_diagnostics_macros/Cargo.toml +++ b/crates/pgls_diagnostics_macros/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_diagnostics_macros" +name = "pgls_diagnostics_macros" repository.workspace = true version = "0.0.0" diff --git a/crates/pgt_diagnostics_macros/src/generate.rs b/crates/pgls_diagnostics_macros/src/generate.rs similarity index 69% rename from crates/pgt_diagnostics_macros/src/generate.rs rename to crates/pgls_diagnostics_macros/src/generate.rs index 4ee12948e..1173ab197 100644 --- a/crates/pgt_diagnostics_macros/src/generate.rs +++ b/crates/pgls_diagnostics_macros/src/generate.rs @@ -37,7 +37,7 @@ fn generate_struct_diagnostic(input: DeriveStructInput) -> TokenStream { let generics = input.generics; quote! { - impl #generic_params pgt_diagnostics::Diagnostic for #ident #generics { + impl #generic_params pgls_diagnostics::Diagnostic for #ident #generics { #category #severity #description @@ -54,7 +54,7 @@ fn generate_struct_diagnostic(input: DeriveStructInput) -> TokenStream { fn generate_category(input: &DeriveStructInput) -> TokenStream { let category = match &input.category { Some(StaticOrDynamic::Static(value)) => quote! { - pgt_diagnostics::category!(#value) + pgls_diagnostics::category!(#value) }, Some(StaticOrDynamic::Dynamic(value)) => quote! { self.#value @@ -63,7 +63,7 @@ fn generate_category(input: &DeriveStructInput) -> TokenStream { }; quote! { - fn category(&self) -> Option<&'static pgt_diagnostics::Category> { + fn category(&self) -> Option<&'static pgls_diagnostics::Category> { Some(#category) } } @@ -72,7 +72,7 @@ fn generate_category(input: &DeriveStructInput) -> TokenStream { fn generate_severity(input: &DeriveStructInput) -> TokenStream { let severity = match &input.severity { Some(StaticOrDynamic::Static(value)) => quote! { - pgt_diagnostics::Severity::#value + pgls_diagnostics::Severity::#value }, Some(StaticOrDynamic::Dynamic(value)) => quote! { self.#value @@ -81,7 +81,7 @@ fn generate_severity(input: &DeriveStructInput) -> TokenStream { }; quote! { - fn severity(&self) -> pgt_diagnostics::Severity { + fn severity(&self) -> pgls_diagnostics::Severity { #severity } } @@ -137,12 +137,12 @@ fn generate_description(input: &DeriveStructInput) -> TokenStream { Some(StaticOrDynamic::Static(StringOrMarkup::Markup(markup))) => quote! { let mut buffer = Vec::new(); - let write = pgt_diagnostics::termcolor::NoColor::new(&mut buffer); - let mut write = pgt_diagnostics::console::fmt::Termcolor(write); - let mut write = pgt_diagnostics::console::fmt::Formatter::new(&mut write); + let write = pgls_diagnostics::termcolor::NoColor::new(&mut buffer); + let mut write = pgls_diagnostics::console::fmt::Termcolor(write); + let mut write = pgls_diagnostics::console::fmt::Formatter::new(&mut write); - use pgt_diagnostics::console as pgt_console; - write.write_markup(&pgt_diagnostics::console::markup!{ #markup }) + use pgls_diagnostics::console as pgls_console; + write.write_markup(&pgls_diagnostics::console::markup!{ #markup }) .map_err(|_| ::std::fmt::Error)?; fmt.write_str(::std::str::from_utf8(&buffer).map_err(|_| ::std::fmt::Error)?) @@ -166,17 +166,17 @@ fn generate_message(input: &DeriveStructInput) -> TokenStream { fmt.write_str(#value) }, Some(StaticOrDynamic::Static(StringOrMarkup::Markup(markup))) => quote! { - use pgt_diagnostics::console as pgt_console; - fmt.write_markup(pgt_diagnostics::console::markup!{ #markup }) + use pgls_diagnostics::console as pgls_console; + fmt.write_markup(pgls_diagnostics::console::markup!{ #markup }) }, Some(StaticOrDynamic::Dynamic(value)) => quote! { - pgt_diagnostics::console::fmt::Display::fmt(&self.#value, fmt) + pgls_diagnostics::console::fmt::Display::fmt(&self.#value, fmt) }, None => return quote!(), }; quote! { - fn message(&self, fmt: &mut pgt_diagnostics::console::fmt::Formatter<'_>) -> ::std::io::Result<()> { + fn message(&self, fmt: &mut pgls_diagnostics::console::fmt::Formatter<'_>) -> ::std::io::Result<()> { #message } } @@ -190,8 +190,8 @@ fn generate_advices(input: &DeriveStructInput) -> TokenStream { let advices = input.advices.iter(); quote! { - fn advices(&self, visitor: &mut dyn pgt_diagnostics::Visit) -> ::std::io::Result<()> { - #( pgt_diagnostics::Advices::record(&self.#advices, visitor)?; )* + fn advices(&self, visitor: &mut dyn pgls_diagnostics::Visit) -> ::std::io::Result<()> { + #( pgls_diagnostics::Advices::record(&self.#advices, visitor)?; )* Ok(()) } } @@ -205,8 +205,8 @@ fn generate_verbose_advices(input: &DeriveStructInput) -> TokenStream { let verbose_advices = input.verbose_advices.iter(); quote! { - fn verbose_advices(&self, visitor: &mut dyn pgt_diagnostics::Visit) -> ::std::io::Result<()> { - #( pgt_diagnostics::Advices::record(&self.#verbose_advices, visitor)?; )* + fn verbose_advices(&self, visitor: &mut dyn pgls_diagnostics::Visit) -> ::std::io::Result<()> { + #( pgls_diagnostics::Advices::record(&self.#verbose_advices, visitor)?; )* Ok(()) } } @@ -221,8 +221,8 @@ fn generate_location(input: &DeriveStructInput) -> TokenStream { let method = input.location.iter().map(|(_, method)| method); quote! { - fn location(&self) -> pgt_diagnostics::Location<'_> { - pgt_diagnostics::Location::builder() + fn location(&self) -> pgls_diagnostics::Location<'_> { + pgls_diagnostics::Location::builder() #( .#method(&self.#field) )* .build() } @@ -234,7 +234,7 @@ fn generate_tags(input: &DeriveStructInput) -> TokenStream { Some(StaticOrDynamic::Static(value)) => { let values = value.iter(); quote! { - #( pgt_diagnostics::DiagnosticTags::#values )|* + #( pgls_diagnostics::DiagnosticTags::#values )|* } } Some(StaticOrDynamic::Dynamic(value)) => quote! { @@ -244,7 +244,7 @@ fn generate_tags(input: &DeriveStructInput) -> TokenStream { }; quote! { - fn tags(&self) -> pgt_diagnostics::DiagnosticTags { + fn tags(&self) -> pgls_diagnostics::DiagnosticTags { #tags } } @@ -253,7 +253,7 @@ fn generate_tags(input: &DeriveStructInput) -> TokenStream { fn generate_source(input: &DeriveStructInput) -> TokenStream { match &input.source { Some(value) => quote! { - fn source(&self) -> Option<&dyn pgt_diagnostics::Diagnostic> { + fn source(&self) -> Option<&dyn pgls_diagnostics::Diagnostic> { self.#value.as_deref() } }, @@ -280,58 +280,58 @@ fn generate_enum_diagnostic(input: DeriveEnumInput) -> TokenStream { .collect(); quote! { - impl #generic_params pgt_diagnostics::Diagnostic for #ident #generics { - fn category(&self) -> Option<&'static pgt_diagnostics::Category> { + impl #generic_params pgls_diagnostics::Diagnostic for #ident #generics { + fn category(&self) -> Option<&'static pgls_diagnostics::Category> { match self { - #(Self::#variants(error) => pgt_diagnostics::Diagnostic::category(error),)* + #(Self::#variants(error) => pgls_diagnostics::Diagnostic::category(error),)* } } fn description(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - #(Self::#variants(error) => pgt_diagnostics::Diagnostic::description(error, fmt),)* + #(Self::#variants(error) => pgls_diagnostics::Diagnostic::description(error, fmt),)* } } - fn message(&self, fmt: &mut pgt_console::fmt::Formatter<'_>) -> std::io::Result<()> { + fn message(&self, fmt: &mut pgls_console::fmt::Formatter<'_>) -> std::io::Result<()> { match self { - #(Self::#variants(error) => pgt_diagnostics::Diagnostic::message(error, fmt),)* + #(Self::#variants(error) => pgls_diagnostics::Diagnostic::message(error, fmt),)* } } - fn severity(&self) -> pgt_diagnostics::Severity { + fn severity(&self) -> pgls_diagnostics::Severity { match self { - #(Self::#variants(error) => pgt_diagnostics::Diagnostic::severity(error),)* + #(Self::#variants(error) => pgls_diagnostics::Diagnostic::severity(error),)* } } - fn tags(&self) -> pgt_diagnostics::DiagnosticTags { + fn tags(&self) -> pgls_diagnostics::DiagnosticTags { match self { - #(Self::#variants(error) => pgt_diagnostics::Diagnostic::tags(error),)* + #(Self::#variants(error) => pgls_diagnostics::Diagnostic::tags(error),)* } } - fn location(&self) -> pgt_diagnostics::Location<'_> { + fn location(&self) -> pgls_diagnostics::Location<'_> { match self { - #(Self::#variants(error) => pgt_diagnostics::Diagnostic::location(error),)* + #(Self::#variants(error) => pgls_diagnostics::Diagnostic::location(error),)* } } - fn source(&self) -> Option<&dyn pgt_diagnostics::Diagnostic> { + fn source(&self) -> Option<&dyn pgls_diagnostics::Diagnostic> { match self { - #(Self::#variants(error) => pgt_diagnostics::Diagnostic::source(error),)* + #(Self::#variants(error) => pgls_diagnostics::Diagnostic::source(error),)* } } - fn advices(&self, visitor: &mut dyn pgt_diagnostics::Visit) -> std::io::Result<()> { + fn advices(&self, visitor: &mut dyn pgls_diagnostics::Visit) -> std::io::Result<()> { match self { - #(Self::#variants(error) => pgt_diagnostics::Diagnostic::advices(error, visitor),)* + #(Self::#variants(error) => pgls_diagnostics::Diagnostic::advices(error, visitor),)* } } - fn verbose_advices(&self, visitor: &mut dyn pgt_diagnostics::Visit) -> std::io::Result<()> { + fn verbose_advices(&self, visitor: &mut dyn pgls_diagnostics::Visit) -> std::io::Result<()> { match self { - #(Self::#variants(error) => pgt_diagnostics::Diagnostic::verbose_advices(error, visitor),)* + #(Self::#variants(error) => pgls_diagnostics::Diagnostic::verbose_advices(error, visitor),)* } } } diff --git a/crates/pgt_diagnostics_macros/src/lib.rs b/crates/pgls_diagnostics_macros/src/lib.rs similarity index 100% rename from crates/pgt_diagnostics_macros/src/lib.rs rename to crates/pgls_diagnostics_macros/src/lib.rs diff --git a/crates/pgt_diagnostics_macros/src/parse.rs b/crates/pgls_diagnostics_macros/src/parse.rs similarity index 100% rename from crates/pgt_diagnostics_macros/src/parse.rs rename to crates/pgls_diagnostics_macros/src/parse.rs diff --git a/crates/pgt_flags/Cargo.toml b/crates/pgls_flags/Cargo.toml similarity index 81% rename from crates/pgt_flags/Cargo.toml rename to crates/pgls_flags/Cargo.toml index 6a96719c9..46e2d1fea 100644 --- a/crates/pgt_flags/Cargo.toml +++ b/crates/pgls_flags/Cargo.toml @@ -6,12 +6,12 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_flags" +name = "pgls_flags" repository.workspace = true version = "0.0.0" [dependencies] -pgt_console = { workspace = true } +pgls_console = { workspace = true } [dev-dependencies] diff --git a/crates/pgt_flags/src/lib.rs b/crates/pgls_flags/src/lib.rs similarity index 96% rename from crates/pgt_flags/src/lib.rs rename to crates/pgls_flags/src/lib.rs index 133df7776..8a8df701c 100644 --- a/crates/pgt_flags/src/lib.rs +++ b/crates/pgls_flags/src/lib.rs @@ -1,7 +1,7 @@ //! A simple implementation of feature flags. -use pgt_console::fmt::{Display, Formatter}; -use pgt_console::{DebugDisplay, KeyValuePair, markup}; +use pgls_console::fmt::{Display, Formatter}; +use pgls_console::{DebugDisplay, KeyValuePair, markup}; use std::env; use std::ops::Deref; use std::sync::{LazyLock, OnceLock}; diff --git a/crates/pgls_fs/Cargo.toml b/crates/pgls_fs/Cargo.toml new file mode 100644 index 000000000..4eada5c80 --- /dev/null +++ b/crates/pgls_fs/Cargo.toml @@ -0,0 +1,33 @@ +[package] +authors.workspace = true +categories.workspace = true +description = "" +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +name = "pgls_fs" +repository.workspace = true +version = "0.0.0" + + +[dependencies] +crossbeam = { workspace = true } +directories = "5.0.1" +enumflags2 = { workspace = true } +oxc_resolver = { workspace = true } +parking_lot = { version = "0.12.3", features = ["arc_lock"] } +pgls_diagnostics = { workspace = true } +rayon = { workspace = true } +rustc-hash = { workspace = true } +schemars = { workspace = true, optional = true } +serde = { workspace = true, optional = true } +smallvec = { workspace = true } +tracing = { workspace = true } + +[features] +schema = ["dep:schemars", "pgls_diagnostics/schema"] +serde = ["dep:serde"] + +[lib] +doctest = false diff --git a/crates/pgt_fs/src/dir.rs b/crates/pgls_fs/src/dir.rs similarity index 100% rename from crates/pgt_fs/src/dir.rs rename to crates/pgls_fs/src/dir.rs diff --git a/crates/pgt_fs/src/fs.rs b/crates/pgls_fs/src/fs.rs similarity index 97% rename from crates/pgt_fs/src/fs.rs rename to crates/pgls_fs/src/fs.rs index 2bfd2e51b..5d9b4a80e 100644 --- a/crates/pgt_fs/src/fs.rs +++ b/crates/pgls_fs/src/fs.rs @@ -1,9 +1,9 @@ -use crate::{PathInterner, PgTPath}; +use crate::{PathInterner, PgLSPath}; pub use memory::{ErrorEntry, MemoryFileSystem}; pub use os::OsFileSystem; use oxc_resolver::{Resolution, ResolveError}; -use pgt_diagnostics::{Advices, Diagnostic, LogCategory, Visit, console}; -use pgt_diagnostics::{Error, Severity}; +use pgls_diagnostics::{Advices, Diagnostic, LogCategory, Visit, console}; +use pgls_diagnostics::{Error, Severity}; use serde::{Deserialize, Serialize}; use std::collections::BTreeSet; use std::fmt::{Debug, Display, Formatter}; @@ -19,7 +19,7 @@ mod os; pub struct ConfigName; impl ConfigName { - const PGT_JSONC: [&'static str; 1] = ["postgrestools.jsonc"]; + const PGT_JSONC: [&'static str; 1] = ["postgres-language-server.jsonc"]; pub const fn pgt_jsonc() -> &'static str { Self::PGT_JSONC[0] @@ -309,18 +309,18 @@ pub trait TraversalContext: Sync { /// Checks if the traversal context can handle a particular path, used as /// an optimization to bail out of scheduling a file handler if it wouldn't /// be able to process the file anyway - fn can_handle(&self, path: &PgTPath) -> bool; + fn can_handle(&self, path: &PgLSPath) -> bool; /// This method will be called by the traversal for each file it finds /// where [TraversalContext::can_handle] returned true - fn handle_path(&self, path: PgTPath); + fn handle_path(&self, path: PgLSPath); /// This method will be called by the traversal for each file it finds /// where [TraversalContext::store_path] returned true - fn store_path(&self, path: PgTPath); + fn store_path(&self, path: PgLSPath); /// Returns the paths that should be handled - fn evaluated_paths(&self) -> BTreeSet; + fn evaluated_paths(&self) -> BTreeSet; } impl FileSystem for Arc diff --git a/crates/pgt_fs/src/fs/memory.rs b/crates/pgls_fs/src/fs/memory.rs similarity index 95% rename from crates/pgt_fs/src/fs/memory.rs rename to crates/pgls_fs/src/fs/memory.rs index a744e575f..672aef9ad 100644 --- a/crates/pgt_fs/src/fs/memory.rs +++ b/crates/pgls_fs/src/fs/memory.rs @@ -8,10 +8,10 @@ use std::str; use std::sync::Arc; use parking_lot::{Mutex, RawMutex, RwLock, lock_api::ArcMutexGuard}; -use pgt_diagnostics::{Error, Severity}; +use pgls_diagnostics::{Error, Severity}; use crate::fs::OpenOptions; -use crate::{FileSystem, PgTPath, TraversalContext, TraversalScope}; +use crate::{FileSystem, PgLSPath, TraversalContext, TraversalScope}; use super::{BoxedTraversal, ErrorKind, File, FileSystemDiagnostic}; @@ -307,7 +307,7 @@ impl<'scope> TraversalScope<'scope> for MemoryTraversalScope<'scope> { if should_process_file { let _ = ctx.interner().intern_path(path.into()); - let pgt_path = PgTPath::new(path); + let pgt_path = PgLSPath::new(path); if !ctx.can_handle(&pgt_path) { continue; } @@ -338,7 +338,7 @@ impl<'scope> TraversalScope<'scope> for MemoryTraversalScope<'scope> { } fn handle(&self, context: &'scope dyn TraversalContext, path: PathBuf) { - context.handle_path(PgTPath::new(path)); + context.handle_path(PgLSPath::new(path)); } } @@ -352,9 +352,9 @@ mod tests { }; use parking_lot::Mutex; - use pgt_diagnostics::Error; + use pgls_diagnostics::Error; - use crate::{FileSystem, MemoryFileSystem, PathInterner, PgTPath, TraversalContext}; + use crate::{FileSystem, MemoryFileSystem, PathInterner, PgLSPath, TraversalContext}; use crate::{OpenOptions, fs::FileSystemExt}; #[test] @@ -521,7 +521,7 @@ mod tests { struct TestContext { interner: PathInterner, - visited: Mutex>, + visited: Mutex>, } impl TraversalContext for TestContext { @@ -533,19 +533,19 @@ mod tests { panic!("unexpected error {err:?}") } - fn can_handle(&self, _: &PgTPath) -> bool { + fn can_handle(&self, _: &PgLSPath) -> bool { true } - fn handle_path(&self, path: PgTPath) { + fn handle_path(&self, path: PgLSPath) { self.visited.lock().insert(path.to_written()); } - fn store_path(&self, path: PgTPath) { + fn store_path(&self, path: PgLSPath) { self.visited.lock().insert(path); } - fn evaluated_paths(&self) -> BTreeSet { + fn evaluated_paths(&self) -> BTreeSet { let lock = self.visited.lock(); lock.clone() } @@ -566,8 +566,8 @@ mod tests { swap(&mut visited, ctx.visited.get_mut()); assert_eq!(visited.len(), 2); - assert!(visited.contains(&PgTPath::new("dir1/file1"))); - assert!(visited.contains(&PgTPath::new("dir1/file2"))); + assert!(visited.contains(&PgLSPath::new("dir1/file1"))); + assert!(visited.contains(&PgLSPath::new("dir1/file2"))); // Traverse a single file fs.traversal(Box::new(|scope| { @@ -578,6 +578,6 @@ mod tests { swap(&mut visited, ctx.visited.get_mut()); assert_eq!(visited.len(), 1); - assert!(visited.contains(&PgTPath::new("dir2/file2"))); + assert!(visited.contains(&PgLSPath::new("dir2/file2"))); } } diff --git a/crates/pgt_fs/src/fs/os.rs b/crates/pgls_fs/src/fs/os.rs similarity index 97% rename from crates/pgt_fs/src/fs/os.rs rename to crates/pgls_fs/src/fs/os.rs index 5033f296f..439c2db54 100644 --- a/crates/pgt_fs/src/fs/os.rs +++ b/crates/pgls_fs/src/fs/os.rs @@ -2,11 +2,11 @@ use super::{BoxedTraversal, ErrorKind, File, FileSystemDiagnostic}; use crate::fs::OpenOptions; use crate::{ - FileSystem, PgTPath, + FileSystem, PgLSPath, fs::{TraversalContext, TraversalScope}, }; use oxc_resolver::{Resolution, ResolveError, ResolveOptions, Resolver}; -use pgt_diagnostics::{DiagnosticExt, Error, Severity, adapters::IoError}; +use pgls_diagnostics::{DiagnosticExt, Error, Severity, adapters::IoError}; use rayon::{Scope, scope}; use std::fs::{DirEntry, FileType}; use std::panic::AssertUnwindSafe; @@ -211,7 +211,7 @@ impl<'scope> TraversalScope<'scope> for OsTraversalScope<'scope> { fn handle(&self, context: &'scope dyn TraversalContext, path: PathBuf) { self.scope.spawn(move |_| { - context.handle_path(PgTPath::new(path)); + context.handle_path(PgLSPath::new(path)); }); } } @@ -289,7 +289,7 @@ fn handle_any_file<'scope>( } if file_type.is_symlink() { - if !ctx.can_handle(&PgTPath::new(path.clone())) { + if !ctx.can_handle(&PgLSPath::new(path.clone())) { return; } let Ok((target_path, target_file_type)) = expand_symbolic_link(path.clone(), ctx) else { @@ -320,7 +320,7 @@ fn handle_any_file<'scope>( if let Some(file_name) = path.file_name() { let new_origin_path = old_origin_path.join(file_name); origin_path = Some(new_origin_path.clone()); - PgTPath::new(new_origin_path) + PgLSPath::new(new_origin_path) } else { ctx.push_diagnostic(Error::from(FileSystemDiagnostic { path: path.to_string_lossy().to_string(), @@ -330,7 +330,7 @@ fn handle_any_file<'scope>( return; } } else { - PgTPath::new(&path) + PgLSPath::new(&path) }; // Performing this check here let's us skip unsupported @@ -351,7 +351,7 @@ fn handle_any_file<'scope>( if file_type.is_file() { scope.spawn(move |_| { - ctx.store_path(PgTPath::new(path)); + ctx.store_path(PgLSPath::new(path)); }); return; } diff --git a/crates/pgt_fs/src/interner.rs b/crates/pgls_fs/src/interner.rs similarity index 100% rename from crates/pgt_fs/src/interner.rs rename to crates/pgls_fs/src/interner.rs diff --git a/crates/pgt_fs/src/lib.rs b/crates/pgls_fs/src/lib.rs similarity index 89% rename from crates/pgt_fs/src/lib.rs rename to crates/pgls_fs/src/lib.rs index 0988e7b53..352f40a1a 100644 --- a/crates/pgt_fs/src/lib.rs +++ b/crates/pgls_fs/src/lib.rs @@ -1,4 +1,4 @@ -//! # pgt_fs +//! # pgls_fs mod dir; mod fs; @@ -7,7 +7,7 @@ mod path; pub use dir::ensure_cache_dir; pub use interner::PathInterner; -pub use path::PgTPath; +pub use path::PgLSPath; pub use fs::{ AutoSearchResult, ConfigName, ErrorEntry, File, FileSystem, FileSystemDiagnostic, diff --git a/crates/pgt_fs/src/path.rs b/crates/pgls_fs/src/path.rs similarity index 90% rename from crates/pgt_fs/src/path.rs rename to crates/pgls_fs/src/path.rs index 811bebe59..39c87407f 100644 --- a/crates/pgt_fs/src/path.rs +++ b/crates/pgls_fs/src/path.rs @@ -21,7 +21,7 @@ use crate::ConfigName; #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] // NOTE: The order of the variants is important, the one on the top has the highest priority pub enum FileKind { - /// A configuration file has the highest priority. It's usually `postgrestools.jsonc` + /// A configuration file has the highest priority. It's usually `postgres-language-server.jsonc` /// /// Other third-party configuration files might be added in the future Config, @@ -85,15 +85,15 @@ impl From for FileKinds { #[derive(Debug, Clone, Eq, PartialEq, Hash, Default)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] -pub struct PgTPath { +pub struct PgLSPath { path: PathBuf, - /// Determines the kind of the file inside Postgres Tools. Some files are considered as configuration files, others as manifest files, and others as files to handle + /// Determines the kind of the file inside Postgres Language Server. Some files are considered as configuration files, others as manifest files, and others as files to handle kind: FileKinds, /// Whether this path (usually a file) was fixed as a result of a format/lint/check command with the `--write` filag. was_written: bool, } -impl Deref for PgTPath { +impl Deref for PgLSPath { type Target = PathBuf; fn deref(&self) -> &Self::Target { @@ -101,13 +101,13 @@ impl Deref for PgTPath { } } -impl PartialOrd for PgTPath { +impl PartialOrd for PgLSPath { fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } -impl Ord for PgTPath { +impl Ord for PgLSPath { fn cmp(&self, other: &Self) -> Ordering { match self.kind.cmp(&other.kind) { Ordering::Equal => self.path.cmp(&other.path), @@ -116,7 +116,7 @@ impl Ord for PgTPath { } } -impl PgTPath { +impl PgLSPath { pub fn new(path_to_file: impl Into) -> Self { let path = path_to_file.into(); let kind = path.file_name().map(Self::priority).unwrap_or_default(); @@ -137,7 +137,7 @@ impl PgTPath { } } - /// Creates a new [PgTPath], marked as fixed + /// Creates a new [PgLSPath], marked as fixed pub fn to_written(&self) -> Self { Self { path: self.path.clone(), @@ -160,7 +160,7 @@ impl PgTPath { /// Returns the contents of a file, if it exists /// /// ## Error - /// If Postgres Tools doesn't have permissions to read the file + /// If Postgres Language Server doesn't have permissions to read the file pub fn get_buffer_from_file(&mut self) -> String { // we assume we have permissions read_to_string(&self.path).expect("cannot read the file to format") @@ -173,7 +173,7 @@ impl PgTPath { } /// The priority of the file. - /// - `postgrestools.jsonc` has the highest priority + /// - `postgres-language-server.jsonc` has the highest priority /// - Other files are considered as files to handle fn priority(file_name: &OsStr) -> FileKinds { if file_name == ConfigName::pgt_jsonc() { diff --git a/crates/pgls_hover/Cargo.toml b/crates/pgls_hover/Cargo.toml new file mode 100644 index 000000000..b1008ebc6 --- /dev/null +++ b/crates/pgls_hover/Cargo.toml @@ -0,0 +1,37 @@ +[package] +authors.workspace = true +categories.workspace = true +description = "" +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +name = "pgls_hover" +repository.workspace = true +version = "0.0.0" + + +[dependencies] +humansize = { version = "2.1.3" } +pgls_query.workspace = true +pgls_schema_cache.workspace = true +pgls_text_size.workspace = true +pgls_treesitter.workspace = true +pgls_treesitter_grammar.workspace = true +schemars = { workspace = true, optional = true } +serde = { workspace = true, features = ["derive"] } +serde_json = { workspace = true } +sqlx.workspace = true +tokio = { version = "1.41.1", features = ["full"] } +tracing = { workspace = true } +tree-sitter.workspace = true + +[dev-dependencies] +insta = { version = "1.42.1" } +pgls_test_utils.workspace = true + +[lib] +doctest = false + +[features] +schema = ["dep:schemars"] diff --git a/crates/pgt_hover/src/contextual_priority.rs b/crates/pgls_hover/src/contextual_priority.rs similarity index 96% rename from crates/pgt_hover/src/contextual_priority.rs rename to crates/pgls_hover/src/contextual_priority.rs index 86e04c8a4..851c3ab40 100644 --- a/crates/pgt_hover/src/contextual_priority.rs +++ b/crates/pgls_hover/src/contextual_priority.rs @@ -1,4 +1,4 @@ -use pgt_treesitter::context::TreesitterContext; +use pgls_treesitter::context::TreesitterContext; pub(crate) trait ContextualPriority { fn relevance_score(&self, ctx: &TreesitterContext) -> f32; diff --git a/crates/pgt_hover/src/hoverables/column.rs b/crates/pgls_hover/src/hoverables/column.rs similarity index 95% rename from crates/pgt_hover/src/hoverables/column.rs rename to crates/pgls_hover/src/hoverables/column.rs index 913aae86e..462900c3b 100644 --- a/crates/pgt_hover/src/hoverables/column.rs +++ b/crates/pgls_hover/src/hoverables/column.rs @@ -1,11 +1,11 @@ use std::fmt::Write; -use pgt_schema_cache::Column; -use pgt_treesitter::TreesitterContext; +use pgls_schema_cache::Column; +use pgls_treesitter::TreesitterContext; use crate::{contextual_priority::ContextualPriority, to_markdown::ToHoverMarkdown}; -impl ToHoverMarkdown for pgt_schema_cache::Column { +impl ToHoverMarkdown for pgls_schema_cache::Column { fn hover_headline(&self, writer: &mut W) -> Result<(), std::fmt::Error> { write!( writer, @@ -98,7 +98,7 @@ impl ContextualPriority for Column { #[cfg(test)] mod tests { - use pgt_test_utils::QueryWithCursorPosition; + use pgls_test_utils::QueryWithCursorPosition; use crate::{ contextual_priority::prioritize_by_context, hoverables::test_helper::create_test_context, @@ -112,7 +112,7 @@ mod tests { name: name.to_string(), table_name: table.to_string(), table_oid: 1, - class_kind: pgt_schema_cache::ColumnClassKind::OrdinaryTable, + class_kind: pgls_schema_cache::ColumnClassKind::OrdinaryTable, schema_name: schema.to_string(), type_id: 23, type_name: Some("integer".to_string()), diff --git a/crates/pgt_hover/src/hoverables/function.rs b/crates/pgls_hover/src/hoverables/function.rs similarity index 80% rename from crates/pgt_hover/src/hoverables/function.rs rename to crates/pgls_hover/src/hoverables/function.rs index 54bfcc75d..c18838530 100644 --- a/crates/pgt_hover/src/hoverables/function.rs +++ b/crates/pgls_hover/src/hoverables/function.rs @@ -1,7 +1,7 @@ use std::fmt::Write; -use pgt_schema_cache::Function; -use pgt_treesitter::TreesitterContext; +use pgls_schema_cache::Function; +use pgls_treesitter::TreesitterContext; use crate::{contextual_priority::ContextualPriority, to_markdown::ToHoverMarkdown}; @@ -30,18 +30,18 @@ impl ToHoverMarkdown for Function { fn hover_body(&self, writer: &mut W) -> Result { let kind_text = match self.kind { - pgt_schema_cache::ProcKind::Function => "Function", - pgt_schema_cache::ProcKind::Procedure => "Procedure", - pgt_schema_cache::ProcKind::Aggregate => "Aggregate", - pgt_schema_cache::ProcKind::Window => "Window", + pgls_schema_cache::ProcKind::Function => "Function", + pgls_schema_cache::ProcKind::Procedure => "Procedure", + pgls_schema_cache::ProcKind::Aggregate => "Aggregate", + pgls_schema_cache::ProcKind::Window => "Window", }; write!(writer, "{}", kind_text)?; let behavior_text = match self.behavior { - pgt_schema_cache::Behavior::Immutable => " - Immutable", - pgt_schema_cache::Behavior::Stable => " - Stable", - pgt_schema_cache::Behavior::Volatile => "", + pgls_schema_cache::Behavior::Immutable => " - Immutable", + pgls_schema_cache::Behavior::Stable => " - Stable", + pgls_schema_cache::Behavior::Volatile => "", }; write!(writer, "{}", behavior_text)?; @@ -121,10 +121,10 @@ impl ContextualPriority for Function { // aggregate and window functions are commonly used match self.kind { - pgt_schema_cache::ProcKind::Aggregate => score += 20.0, - pgt_schema_cache::ProcKind::Window => score += 15.0, - pgt_schema_cache::ProcKind::Function => score += 10.0, - pgt_schema_cache::ProcKind::Procedure => score += 5.0, + pgls_schema_cache::ProcKind::Aggregate => score += 20.0, + pgls_schema_cache::ProcKind::Window => score += 15.0, + pgls_schema_cache::ProcKind::Function => score += 10.0, + pgls_schema_cache::ProcKind::Procedure => score += 5.0, } score diff --git a/crates/pgt_hover/src/hoverables/mod.rs b/crates/pgls_hover/src/hoverables/mod.rs similarity index 79% rename from crates/pgt_hover/src/hoverables/mod.rs rename to crates/pgls_hover/src/hoverables/mod.rs index 675c1366a..6067dba60 100644 --- a/crates/pgt_hover/src/hoverables/mod.rs +++ b/crates/pgls_hover/src/hoverables/mod.rs @@ -11,45 +11,45 @@ mod test_helper; /// Mapper type that will be used for filtering and turning data to markdown. #[derive(Debug)] pub enum Hoverable<'a> { - Table(&'a pgt_schema_cache::Table), - Column(&'a pgt_schema_cache::Column), - Function(&'a pgt_schema_cache::Function), - Role(&'a pgt_schema_cache::Role), - Schema(&'a pgt_schema_cache::Schema), + Table(&'a pgls_schema_cache::Table), + Column(&'a pgls_schema_cache::Column), + Function(&'a pgls_schema_cache::Function), + Role(&'a pgls_schema_cache::Role), + Schema(&'a pgls_schema_cache::Schema), } -impl<'a> From<&'a pgt_schema_cache::Schema> for Hoverable<'a> { - fn from(value: &'a pgt_schema_cache::Schema) -> Self { +impl<'a> From<&'a pgls_schema_cache::Schema> for Hoverable<'a> { + fn from(value: &'a pgls_schema_cache::Schema) -> Self { Hoverable::Schema(value) } } -impl<'a> From<&'a pgt_schema_cache::Table> for Hoverable<'a> { - fn from(value: &'a pgt_schema_cache::Table) -> Self { +impl<'a> From<&'a pgls_schema_cache::Table> for Hoverable<'a> { + fn from(value: &'a pgls_schema_cache::Table) -> Self { Hoverable::Table(value) } } -impl<'a> From<&'a pgt_schema_cache::Column> for Hoverable<'a> { - fn from(value: &'a pgt_schema_cache::Column) -> Self { +impl<'a> From<&'a pgls_schema_cache::Column> for Hoverable<'a> { + fn from(value: &'a pgls_schema_cache::Column) -> Self { Hoverable::Column(value) } } -impl<'a> From<&'a pgt_schema_cache::Function> for Hoverable<'a> { - fn from(value: &'a pgt_schema_cache::Function) -> Self { +impl<'a> From<&'a pgls_schema_cache::Function> for Hoverable<'a> { + fn from(value: &'a pgls_schema_cache::Function) -> Self { Hoverable::Function(value) } } -impl<'a> From<&'a pgt_schema_cache::Role> for Hoverable<'a> { - fn from(value: &'a pgt_schema_cache::Role) -> Self { +impl<'a> From<&'a pgls_schema_cache::Role> for Hoverable<'a> { + fn from(value: &'a pgls_schema_cache::Role) -> Self { Hoverable::Role(value) } } impl ContextualPriority for Hoverable<'_> { - fn relevance_score(&self, ctx: &pgt_treesitter::TreesitterContext) -> f32 { + fn relevance_score(&self, ctx: &pgls_treesitter::TreesitterContext) -> f32 { match self { Hoverable::Table(table) => table.relevance_score(ctx), Hoverable::Column(column) => column.relevance_score(ctx), diff --git a/crates/pgt_hover/src/hoverables/role.rs b/crates/pgls_hover/src/hoverables/role.rs similarity index 95% rename from crates/pgt_hover/src/hoverables/role.rs rename to crates/pgls_hover/src/hoverables/role.rs index 9908f08c3..ab615e23a 100644 --- a/crates/pgt_hover/src/hoverables/role.rs +++ b/crates/pgls_hover/src/hoverables/role.rs @@ -1,11 +1,11 @@ use std::fmt::Write; -use pgt_schema_cache::Role; -use pgt_treesitter::TreesitterContext; +use pgls_schema_cache::Role; +use pgls_treesitter::TreesitterContext; use crate::{contextual_priority::ContextualPriority, to_markdown::ToHoverMarkdown}; -impl ToHoverMarkdown for pgt_schema_cache::Role { +impl ToHoverMarkdown for pgls_schema_cache::Role { fn hover_headline(&self, writer: &mut W) -> Result<(), std::fmt::Error> { write!(writer, "`{}`", self.name)?; diff --git a/crates/pgt_hover/src/hoverables/schema.rs b/crates/pgls_hover/src/hoverables/schema.rs similarity index 96% rename from crates/pgt_hover/src/hoverables/schema.rs rename to crates/pgls_hover/src/hoverables/schema.rs index cb45a3c9b..5967c1a80 100644 --- a/crates/pgt_hover/src/hoverables/schema.rs +++ b/crates/pgls_hover/src/hoverables/schema.rs @@ -1,7 +1,7 @@ use std::fmt::Write; -use pgt_schema_cache::Schema; -use pgt_treesitter::TreesitterContext; +use pgls_schema_cache::Schema; +use pgls_treesitter::TreesitterContext; use crate::{contextual_priority::ContextualPriority, to_markdown::ToHoverMarkdown}; diff --git a/crates/pgt_hover/src/hoverables/table.rs b/crates/pgls_hover/src/hoverables/table.rs similarity index 85% rename from crates/pgt_hover/src/hoverables/table.rs rename to crates/pgls_hover/src/hoverables/table.rs index 4c457c28d..ddcc330b4 100644 --- a/crates/pgt_hover/src/hoverables/table.rs +++ b/crates/pgls_hover/src/hoverables/table.rs @@ -1,8 +1,8 @@ use std::fmt::Write; use humansize::DECIMAL; -use pgt_schema_cache::Table; -use pgt_treesitter::TreesitterContext; +use pgls_schema_cache::Table; +use pgls_treesitter::TreesitterContext; use crate::{contextual_priority::ContextualPriority, to_markdown::ToHoverMarkdown}; @@ -11,10 +11,10 @@ impl ToHoverMarkdown for Table { write!(writer, "`{}.{}`", self.schema, self.name)?; let table_kind = match self.table_kind { - pgt_schema_cache::TableKind::View => " (View)", - pgt_schema_cache::TableKind::MaterializedView => " (M.View)", - pgt_schema_cache::TableKind::Partitioned => " (Partitioned)", - pgt_schema_cache::TableKind::Ordinary => "", + pgls_schema_cache::TableKind::View => " (View)", + pgls_schema_cache::TableKind::MaterializedView => " (M.View)", + pgls_schema_cache::TableKind::Partitioned => " (Partitioned)", + pgls_schema_cache::TableKind::Ordinary => "", }; write!(writer, "{}", table_kind)?; diff --git a/crates/pgt_hover/src/hoverables/test_helper.rs b/crates/pgls_hover/src/hoverables/test_helper.rs similarity index 67% rename from crates/pgt_hover/src/hoverables/test_helper.rs rename to crates/pgls_hover/src/hoverables/test_helper.rs index c53a109ef..72f40f48a 100644 --- a/crates/pgt_hover/src/hoverables/test_helper.rs +++ b/crates/pgls_hover/src/hoverables/test_helper.rs @@ -1,18 +1,18 @@ #[cfg(test)] -use pgt_test_utils::QueryWithCursorPosition; +use pgls_test_utils::QueryWithCursorPosition; #[cfg(test)] -use pgt_treesitter::TreesitterContext; +use pgls_treesitter::TreesitterContext; #[cfg(test)] pub(crate) fn create_test_context(query: QueryWithCursorPosition) -> TreesitterContext<'static> { - use pgt_text_size::TextSize; - use pgt_treesitter::TreeSitterContextParams; + use pgls_text_size::TextSize; + use pgls_treesitter::TreeSitterContextParams; let (pos, sql) = query.get_text_and_position(); let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .unwrap(); let tree = parser.parse(sql.clone(), None).unwrap(); @@ -22,7 +22,7 @@ pub(crate) fn create_test_context(query: QueryWithCursorPosition) -> TreesitterC let position = TextSize::new(pos.try_into().unwrap()); - let ctx = pgt_treesitter::context::TreesitterContext::new(TreeSitterContextParams { + let ctx = pgls_treesitter::context::TreesitterContext::new(TreeSitterContextParams { position, text: leaked_sql, tree: leaked_tree, diff --git a/crates/pgt_hover/src/hovered_node.rs b/crates/pgls_hover/src/hovered_node.rs similarity index 97% rename from crates/pgt_hover/src/hovered_node.rs rename to crates/pgls_hover/src/hovered_node.rs index 6814f5245..3132b5e41 100644 --- a/crates/pgt_hover/src/hovered_node.rs +++ b/crates/pgls_hover/src/hovered_node.rs @@ -19,7 +19,7 @@ pub(crate) enum HoveredNode { } impl HoveredNode { - pub(crate) fn get(ctx: &pgt_treesitter::context::TreesitterContext) -> Option { + pub(crate) fn get(ctx: &pgls_treesitter::context::TreesitterContext) -> Option { let node_content = ctx.get_node_under_cursor_content()?; let under_cursor = ctx.node_under_cursor.as_ref()?; diff --git a/crates/pgt_hover/src/lib.rs b/crates/pgls_hover/src/lib.rs similarity index 94% rename from crates/pgt_hover/src/lib.rs rename to crates/pgls_hover/src/lib.rs index d20adc3c6..7d3dd5cf3 100644 --- a/crates/pgt_hover/src/lib.rs +++ b/crates/pgls_hover/src/lib.rs @@ -1,6 +1,6 @@ -use pgt_schema_cache::SchemaCache; -use pgt_text_size::TextSize; -use pgt_treesitter::TreeSitterContextParams; +use pgls_schema_cache::SchemaCache; +use pgls_text_size::TextSize; +use pgls_treesitter::TreeSitterContextParams; use crate::{ contextual_priority::prioritize_by_context, hoverables::Hoverable, hovered_node::HoveredNode, @@ -16,7 +16,7 @@ pub struct OnHoverParams<'a> { pub position: TextSize, pub schema_cache: &'a SchemaCache, pub stmt_sql: &'a str, - pub ast: Option<&'a pgt_query::NodeEnum>, + pub ast: Option<&'a pgls_query::NodeEnum>, pub ts_tree: &'a tree_sitter::Tree, } @@ -25,7 +25,7 @@ pub struct OnHoverParams<'a> { position = params.position.to_string() ))] pub fn on_hover(params: OnHoverParams) -> Vec { - let ctx = pgt_treesitter::context::TreesitterContext::new(TreeSitterContextParams { + let ctx = pgls_treesitter::context::TreesitterContext::new(TreeSitterContextParams { position: params.position, text: params.stmt_sql, tree: params.ts_tree, diff --git a/crates/pgt_hover/src/to_markdown.rs b/crates/pgls_hover/src/to_markdown.rs similarity index 100% rename from crates/pgt_hover/src/to_markdown.rs rename to crates/pgls_hover/src/to_markdown.rs diff --git a/crates/pgt_hover/tests/hover_integration_tests.rs b/crates/pgls_hover/tests/hover_integration_tests.rs similarity index 89% rename from crates/pgt_hover/tests/hover_integration_tests.rs rename to crates/pgls_hover/tests/hover_integration_tests.rs index 58ffdc3e3..1d61c8670 100644 --- a/crates/pgt_hover/tests/hover_integration_tests.rs +++ b/crates/pgls_hover/tests/hover_integration_tests.rs @@ -1,7 +1,7 @@ -use pgt_hover::{OnHoverParams, on_hover}; -use pgt_schema_cache::SchemaCache; -use pgt_test_utils::QueryWithCursorPosition; -use pgt_text_size::TextSize; +use pgls_hover::{OnHoverParams, on_hover}; +use pgls_schema_cache::SchemaCache; +use pgls_test_utils::QueryWithCursorPosition; +use pgls_text_size::TextSize; use sqlx::{Executor, PgPool}; async fn test_hover_at_cursor(name: &str, query: String, setup: Option<&str>, test_db: &PgPool) { @@ -20,11 +20,11 @@ async fn test_hover_at_cursor(name: &str, query: String, setup: Option<&str>, te let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .expect("Error loading sql language"); let tree = parser.parse(&sql, None).unwrap(); - let ast = pgt_query::parse(&sql) + let ast = pgls_query::parse(&sql) .ok() .map(|parsed| parsed.into_root().unwrap()); @@ -70,7 +70,7 @@ async fn test_hover_at_cursor(name: &str, query: String, setup: Option<&str>, te }); } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_function_hover_builtin_count(test_db: PgPool) { let query = format!( "select cou{}nt(*) from users", @@ -80,7 +80,7 @@ async fn test_function_hover_builtin_count(test_db: PgPool) { test_hover_at_cursor("builtin_count", query, None, &test_db).await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_function_hover_builtin_now(test_db: PgPool) { let query = format!( "select n{}ow() from users", @@ -90,7 +90,7 @@ async fn test_function_hover_builtin_now(test_db: PgPool) { test_hover_at_cursor("builtin_now", query, None, &test_db).await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_function_hover_builtin_max(test_db: PgPool) { let query = format!( "select m{}ax(id) from users", @@ -100,7 +100,7 @@ async fn test_function_hover_builtin_max(test_db: PgPool) { test_hover_at_cursor("builtin_max", query, None, &test_db).await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_function_hover_custom_function(test_db: PgPool) { let setup = r#" create or replace function custom_add(a integer, b integer) @@ -122,7 +122,7 @@ async fn test_function_hover_custom_function(test_db: PgPool) { test_hover_at_cursor("custom_function", query, Some(setup), &test_db).await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_function_hover_with_schema(test_db: PgPool) { let setup = r#" create schema test_schema; @@ -143,7 +143,7 @@ async fn test_function_hover_with_schema(test_db: PgPool) { test_hover_at_cursor("function_with_schema", query, Some(setup), &test_db).await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_column_hover_with_table_ref(test_db: PgPool) { let setup = r#" create table users ( @@ -160,7 +160,7 @@ async fn test_column_hover_with_table_ref(test_db: PgPool) { test_hover_at_cursor("column_hover", query, Some(setup), &test_db).await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_column_hover_in_join(test_db: PgPool) { let setup = r#" create table users ( @@ -183,7 +183,7 @@ async fn test_column_hover_in_join(test_db: PgPool) { test_hover_at_cursor("column_hover_join", query, Some(setup), &test_db).await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_table_hover_works(test_db: PgPool) { let setup = r#" create table users ( @@ -200,7 +200,7 @@ async fn test_table_hover_works(test_db: PgPool) { test_hover_at_cursor("table_hover", query, Some(setup), &test_db).await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_no_hover_on_keyword(test_db: PgPool) { let setup = r#" create table users ( @@ -217,7 +217,7 @@ async fn test_no_hover_on_keyword(test_db: PgPool) { test_hover_at_cursor("no_hover_keyword", query, Some(setup), &test_db).await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn shortens_lengthy_functions(test_db: PgPool) { let setup = r#" create or replace function public.func(cool_stuff text, something_else int,a_third_thing text) @@ -279,7 +279,7 @@ async fn shortens_lengthy_functions(test_db: PgPool) { test_hover_at_cursor("lenghty_function", query, Some(setup), &test_db).await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_role_hover_create_role(test_db: PgPool) { let query = format!( "create role alternate_ow{}ner with superuser createdb login", @@ -289,7 +289,7 @@ async fn test_role_hover_create_role(test_db: PgPool) { test_hover_at_cursor("role_create", query, None, &test_db).await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_role_hover_alter_role(test_db: PgPool) { let query = format!( "alter role test_log{}in set work_mem = '256MB'", @@ -299,7 +299,7 @@ async fn test_role_hover_alter_role(test_db: PgPool) { test_hover_at_cursor("role_alter", query, None, &test_db).await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_table_hover_with_quoted_schema(test_db: PgPool) { let setup = r#" create schema auth; @@ -317,7 +317,7 @@ async fn test_table_hover_with_quoted_schema(test_db: PgPool) { test_hover_at_cursor("table_hover_quoted_schema", query, Some(setup), &test_db).await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_function_hover_with_quoted_schema(test_db: PgPool) { let setup = r#" create schema auth; @@ -340,7 +340,7 @@ async fn test_function_hover_with_quoted_schema(test_db: PgPool) { test_hover_at_cursor("function_hover_quoted_schema", query, Some(setup), &test_db).await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_column_hover_with_quoted_schema_table(test_db: PgPool) { let setup = r#" create schema auth; @@ -366,7 +366,7 @@ async fn test_column_hover_with_quoted_schema_table(test_db: PgPool) { .await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_table_hover_with_quoted_table_name(test_db: PgPool) { let setup = r#" create schema auth; @@ -390,7 +390,7 @@ async fn test_table_hover_with_quoted_table_name(test_db: PgPool) { .await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_column_hover_with_quoted_column_name(test_db: PgPool) { let setup = r#" create schema auth; @@ -414,7 +414,7 @@ async fn test_column_hover_with_quoted_column_name(test_db: PgPool) { .await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_column_hover_with_quoted_column_name_with_table(test_db: PgPool) { let setup = r#" create table users ( @@ -443,7 +443,7 @@ async fn test_column_hover_with_quoted_column_name_with_table(test_db: PgPool) { .await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn hover_on_schemas(test_db: PgPool) { let setup = r#" create schema auth; @@ -462,7 +462,7 @@ async fn hover_on_schemas(test_db: PgPool) { test_hover_at_cursor("hover_on_schemas", query, Some(setup), &test_db).await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_policy_table_hover(test_db: PgPool) { let setup = r#" create table users ( @@ -481,7 +481,7 @@ async fn test_policy_table_hover(test_db: PgPool) { test_hover_at_cursor("create_policy", query, None, &test_db).await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_revoke_table_hover(test_db: PgPool) { let setup = r#" create table users ( @@ -500,7 +500,7 @@ async fn test_revoke_table_hover(test_db: PgPool) { test_hover_at_cursor("revoke_select", query, None, &test_db).await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_grant_table_hover(test_db: PgPool) { let setup = r#" create table users ( diff --git a/crates/pgt_hover/tests/snapshots/builtin_count.snap b/crates/pgls_hover/tests/snapshots/builtin_count.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/builtin_count.snap rename to crates/pgls_hover/tests/snapshots/builtin_count.snap diff --git a/crates/pgt_hover/tests/snapshots/builtin_max.snap b/crates/pgls_hover/tests/snapshots/builtin_max.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/builtin_max.snap rename to crates/pgls_hover/tests/snapshots/builtin_max.snap diff --git a/crates/pgt_hover/tests/snapshots/builtin_now.snap b/crates/pgls_hover/tests/snapshots/builtin_now.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/builtin_now.snap rename to crates/pgls_hover/tests/snapshots/builtin_now.snap diff --git a/crates/pgt_hover/tests/snapshots/column_hover.snap b/crates/pgls_hover/tests/snapshots/column_hover.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/column_hover.snap rename to crates/pgls_hover/tests/snapshots/column_hover.snap diff --git a/crates/pgt_hover/tests/snapshots/column_hover_join.snap b/crates/pgls_hover/tests/snapshots/column_hover_join.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/column_hover_join.snap rename to crates/pgls_hover/tests/snapshots/column_hover_join.snap diff --git a/crates/pgt_hover/tests/snapshots/column_hover_quoted_column_name.snap b/crates/pgls_hover/tests/snapshots/column_hover_quoted_column_name.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/column_hover_quoted_column_name.snap rename to crates/pgls_hover/tests/snapshots/column_hover_quoted_column_name.snap diff --git a/crates/pgt_hover/tests/snapshots/column_hover_quoted_column_name_with_table.snap b/crates/pgls_hover/tests/snapshots/column_hover_quoted_column_name_with_table.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/column_hover_quoted_column_name_with_table.snap rename to crates/pgls_hover/tests/snapshots/column_hover_quoted_column_name_with_table.snap diff --git a/crates/pgt_hover/tests/snapshots/column_hover_quoted_schema_table.snap b/crates/pgls_hover/tests/snapshots/column_hover_quoted_schema_table.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/column_hover_quoted_schema_table.snap rename to crates/pgls_hover/tests/snapshots/column_hover_quoted_schema_table.snap diff --git a/crates/pgt_hover/tests/snapshots/create_policy.snap b/crates/pgls_hover/tests/snapshots/create_policy.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/create_policy.snap rename to crates/pgls_hover/tests/snapshots/create_policy.snap diff --git a/crates/pgt_hover/tests/snapshots/custom_function.snap b/crates/pgls_hover/tests/snapshots/custom_function.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/custom_function.snap rename to crates/pgls_hover/tests/snapshots/custom_function.snap diff --git a/crates/pgt_hover/tests/snapshots/function_hover_quoted_schema.snap b/crates/pgls_hover/tests/snapshots/function_hover_quoted_schema.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/function_hover_quoted_schema.snap rename to crates/pgls_hover/tests/snapshots/function_hover_quoted_schema.snap diff --git a/crates/pgt_hover/tests/snapshots/function_with_schema.snap b/crates/pgls_hover/tests/snapshots/function_with_schema.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/function_with_schema.snap rename to crates/pgls_hover/tests/snapshots/function_with_schema.snap diff --git a/crates/pgt_hover/tests/snapshots/grant_select.snap b/crates/pgls_hover/tests/snapshots/grant_select.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/grant_select.snap rename to crates/pgls_hover/tests/snapshots/grant_select.snap diff --git a/crates/pgt_hover/tests/snapshots/hover_on_schemas.snap b/crates/pgls_hover/tests/snapshots/hover_on_schemas.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/hover_on_schemas.snap rename to crates/pgls_hover/tests/snapshots/hover_on_schemas.snap diff --git a/crates/pgt_hover/tests/snapshots/lenghty_function.snap b/crates/pgls_hover/tests/snapshots/lenghty_function.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/lenghty_function.snap rename to crates/pgls_hover/tests/snapshots/lenghty_function.snap diff --git a/crates/pgt_hover/tests/snapshots/no_hover_keyword.snap b/crates/pgls_hover/tests/snapshots/no_hover_keyword.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/no_hover_keyword.snap rename to crates/pgls_hover/tests/snapshots/no_hover_keyword.snap diff --git a/crates/pgt_hover/tests/snapshots/revoke_select.snap b/crates/pgls_hover/tests/snapshots/revoke_select.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/revoke_select.snap rename to crates/pgls_hover/tests/snapshots/revoke_select.snap diff --git a/crates/pgt_hover/tests/snapshots/role_alter.snap b/crates/pgls_hover/tests/snapshots/role_alter.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/role_alter.snap rename to crates/pgls_hover/tests/snapshots/role_alter.snap diff --git a/crates/pgt_hover/tests/snapshots/role_create.snap b/crates/pgls_hover/tests/snapshots/role_create.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/role_create.snap rename to crates/pgls_hover/tests/snapshots/role_create.snap diff --git a/crates/pgt_hover/tests/snapshots/table_hover.snap b/crates/pgls_hover/tests/snapshots/table_hover.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/table_hover.snap rename to crates/pgls_hover/tests/snapshots/table_hover.snap diff --git a/crates/pgt_hover/tests/snapshots/table_hover_quoted_schema.snap b/crates/pgls_hover/tests/snapshots/table_hover_quoted_schema.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/table_hover_quoted_schema.snap rename to crates/pgls_hover/tests/snapshots/table_hover_quoted_schema.snap diff --git a/crates/pgt_hover/tests/snapshots/table_hover_quoted_table_name.snap b/crates/pgls_hover/tests/snapshots/table_hover_quoted_table_name.snap similarity index 100% rename from crates/pgt_hover/tests/snapshots/table_hover_quoted_table_name.snap rename to crates/pgls_hover/tests/snapshots/table_hover_quoted_table_name.snap diff --git a/crates/pgt_lexer/Cargo.toml b/crates/pgls_lexer/Cargo.toml similarity index 65% rename from crates/pgt_lexer/Cargo.toml rename to crates/pgls_lexer/Cargo.toml index 7f4ada43f..82747523e 100644 --- a/crates/pgt_lexer/Cargo.toml +++ b/crates/pgls_lexer/Cargo.toml @@ -6,16 +6,16 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_lexer" +name = "pgls_lexer" repository.workspace = true version = "0.0.0" [dependencies] -pgt_diagnostics.workspace = true -pgt_lexer_codegen.workspace = true -pgt_text_size.workspace = true -pgt_tokenizer.workspace = true +pgls_diagnostics.workspace = true +pgls_lexer_codegen.workspace = true +pgls_text_size.workspace = true +pgls_tokenizer.workspace = true [dev-dependencies] insta.workspace = true diff --git a/crates/pgt_lexer/README.md b/crates/pgls_lexer/README.md similarity index 100% rename from crates/pgt_lexer/README.md rename to crates/pgls_lexer/README.md diff --git a/crates/pgt_lexer/src/codegen/mod.rs b/crates/pgls_lexer/src/codegen/mod.rs similarity index 100% rename from crates/pgt_lexer/src/codegen/mod.rs rename to crates/pgls_lexer/src/codegen/mod.rs diff --git a/crates/pgls_lexer/src/codegen/syntax_kind.rs b/crates/pgls_lexer/src/codegen/syntax_kind.rs new file mode 100644 index 000000000..ba8df074b --- /dev/null +++ b/crates/pgls_lexer/src/codegen/syntax_kind.rs @@ -0,0 +1 @@ +pgls_lexer_codegen::syntax_kind_codegen!(); diff --git a/crates/pgt_lexer/src/lexed.rs b/crates/pgls_lexer/src/lexed.rs similarity index 96% rename from crates/pgt_lexer/src/lexed.rs rename to crates/pgls_lexer/src/lexed.rs index 6f0a273f9..9a71bcb76 100644 --- a/crates/pgt_lexer/src/lexed.rs +++ b/crates/pgls_lexer/src/lexed.rs @@ -1,5 +1,5 @@ -use pgt_diagnostics::{Diagnostic, MessageAndDescription}; -use pgt_text_size::TextRange; +use pgls_diagnostics::{Diagnostic, MessageAndDescription}; +use pgls_text_size::TextRange; use crate::SyntaxKind; diff --git a/crates/pgt_lexer/src/lexer.rs b/crates/pgls_lexer/src/lexer.rs similarity index 57% rename from crates/pgt_lexer/src/lexer.rs rename to crates/pgls_lexer/src/lexer.rs index 03d5693b1..df2dfe9cd 100644 --- a/crates/pgt_lexer/src/lexer.rs +++ b/crates/pgls_lexer/src/lexer.rs @@ -1,4 +1,4 @@ -use pgt_tokenizer::tokenize; +use pgls_tokenizer::tokenize; use crate::SyntaxKind; use crate::lexed::{LexError, Lexed}; @@ -71,81 +71,81 @@ impl<'a> Lexer<'a> { } } - fn extend_token(&mut self, kind: &pgt_tokenizer::TokenKind, token_text: &str) { + fn extend_token(&mut self, kind: &pgls_tokenizer::TokenKind, token_text: &str) { let mut err = ""; let mut line_ending_count = None; let syntax_kind = { match kind { - pgt_tokenizer::TokenKind::LineComment => SyntaxKind::COMMENT, - pgt_tokenizer::TokenKind::BlockComment { terminated } => { + pgls_tokenizer::TokenKind::LineComment => SyntaxKind::COMMENT, + pgls_tokenizer::TokenKind::BlockComment { terminated } => { if !terminated { err = "Missing trailing `*/` symbols to terminate the block comment"; } SyntaxKind::COMMENT } - pgt_tokenizer::TokenKind::Space => SyntaxKind::SPACE, - pgt_tokenizer::TokenKind::Tab => SyntaxKind::TAB, - pgt_tokenizer::TokenKind::LineEnding { count } => { + pgls_tokenizer::TokenKind::Space => SyntaxKind::SPACE, + pgls_tokenizer::TokenKind::Tab => SyntaxKind::TAB, + pgls_tokenizer::TokenKind::LineEnding { count } => { line_ending_count = Some(*count); SyntaxKind::LINE_ENDING } - pgt_tokenizer::TokenKind::VerticalTab => SyntaxKind::VERTICAL_TAB, - pgt_tokenizer::TokenKind::FormFeed => SyntaxKind::FORM_FEED, - pgt_tokenizer::TokenKind::Ident => { + pgls_tokenizer::TokenKind::VerticalTab => SyntaxKind::VERTICAL_TAB, + pgls_tokenizer::TokenKind::FormFeed => SyntaxKind::FORM_FEED, + pgls_tokenizer::TokenKind::Ident => { SyntaxKind::from_keyword(token_text).unwrap_or(SyntaxKind::IDENT) } - pgt_tokenizer::TokenKind::Literal { kind, .. } => { + pgls_tokenizer::TokenKind::Literal { kind, .. } => { self.extend_literal(token_text.len(), kind); return; } - pgt_tokenizer::TokenKind::Semi => SyntaxKind::SEMICOLON, - pgt_tokenizer::TokenKind::Comma => SyntaxKind::COMMA, - pgt_tokenizer::TokenKind::Dot => SyntaxKind::DOT, - pgt_tokenizer::TokenKind::OpenParen => SyntaxKind::L_PAREN, - pgt_tokenizer::TokenKind::CloseParen => SyntaxKind::R_PAREN, - pgt_tokenizer::TokenKind::OpenBracket => SyntaxKind::L_BRACK, - pgt_tokenizer::TokenKind::CloseBracket => SyntaxKind::R_BRACK, - pgt_tokenizer::TokenKind::At => SyntaxKind::AT, - pgt_tokenizer::TokenKind::Pound => SyntaxKind::POUND, - pgt_tokenizer::TokenKind::Tilde => SyntaxKind::TILDE, - pgt_tokenizer::TokenKind::Question => SyntaxKind::QUESTION, - pgt_tokenizer::TokenKind::Colon => SyntaxKind::COLON, - pgt_tokenizer::TokenKind::DoubleColon => SyntaxKind::DOUBLE_COLON, - pgt_tokenizer::TokenKind::Eq => SyntaxKind::EQ, - pgt_tokenizer::TokenKind::Bang => SyntaxKind::BANG, - pgt_tokenizer::TokenKind::Lt => SyntaxKind::L_ANGLE, - pgt_tokenizer::TokenKind::Gt => SyntaxKind::R_ANGLE, - pgt_tokenizer::TokenKind::Minus => SyntaxKind::MINUS, - pgt_tokenizer::TokenKind::And => SyntaxKind::AMP, - pgt_tokenizer::TokenKind::Or => SyntaxKind::PIPE, - pgt_tokenizer::TokenKind::Plus => SyntaxKind::PLUS, - pgt_tokenizer::TokenKind::Star => SyntaxKind::STAR, - pgt_tokenizer::TokenKind::Slash => SyntaxKind::SLASH, - pgt_tokenizer::TokenKind::Caret => SyntaxKind::CARET, - pgt_tokenizer::TokenKind::Percent => SyntaxKind::PERCENT, - pgt_tokenizer::TokenKind::Unknown => SyntaxKind::ERROR, - pgt_tokenizer::TokenKind::Backslash => SyntaxKind::BACKSLASH, - pgt_tokenizer::TokenKind::UnknownPrefix => { + pgls_tokenizer::TokenKind::Semi => SyntaxKind::SEMICOLON, + pgls_tokenizer::TokenKind::Comma => SyntaxKind::COMMA, + pgls_tokenizer::TokenKind::Dot => SyntaxKind::DOT, + pgls_tokenizer::TokenKind::OpenParen => SyntaxKind::L_PAREN, + pgls_tokenizer::TokenKind::CloseParen => SyntaxKind::R_PAREN, + pgls_tokenizer::TokenKind::OpenBracket => SyntaxKind::L_BRACK, + pgls_tokenizer::TokenKind::CloseBracket => SyntaxKind::R_BRACK, + pgls_tokenizer::TokenKind::At => SyntaxKind::AT, + pgls_tokenizer::TokenKind::Pound => SyntaxKind::POUND, + pgls_tokenizer::TokenKind::Tilde => SyntaxKind::TILDE, + pgls_tokenizer::TokenKind::Question => SyntaxKind::QUESTION, + pgls_tokenizer::TokenKind::Colon => SyntaxKind::COLON, + pgls_tokenizer::TokenKind::DoubleColon => SyntaxKind::DOUBLE_COLON, + pgls_tokenizer::TokenKind::Eq => SyntaxKind::EQ, + pgls_tokenizer::TokenKind::Bang => SyntaxKind::BANG, + pgls_tokenizer::TokenKind::Lt => SyntaxKind::L_ANGLE, + pgls_tokenizer::TokenKind::Gt => SyntaxKind::R_ANGLE, + pgls_tokenizer::TokenKind::Minus => SyntaxKind::MINUS, + pgls_tokenizer::TokenKind::And => SyntaxKind::AMP, + pgls_tokenizer::TokenKind::Or => SyntaxKind::PIPE, + pgls_tokenizer::TokenKind::Plus => SyntaxKind::PLUS, + pgls_tokenizer::TokenKind::Star => SyntaxKind::STAR, + pgls_tokenizer::TokenKind::Slash => SyntaxKind::SLASH, + pgls_tokenizer::TokenKind::Caret => SyntaxKind::CARET, + pgls_tokenizer::TokenKind::Percent => SyntaxKind::PERCENT, + pgls_tokenizer::TokenKind::Unknown => SyntaxKind::ERROR, + pgls_tokenizer::TokenKind::Backslash => SyntaxKind::BACKSLASH, + pgls_tokenizer::TokenKind::UnknownPrefix => { err = "unknown literal prefix"; SyntaxKind::IDENT } - pgt_tokenizer::TokenKind::Eof => SyntaxKind::EOF, - pgt_tokenizer::TokenKind::Backtick => SyntaxKind::BACKTICK, - pgt_tokenizer::TokenKind::PositionalParam => SyntaxKind::POSITIONAL_PARAM, - pgt_tokenizer::TokenKind::NamedParam { kind } => { + pgls_tokenizer::TokenKind::Eof => SyntaxKind::EOF, + pgls_tokenizer::TokenKind::Backtick => SyntaxKind::BACKTICK, + pgls_tokenizer::TokenKind::PositionalParam => SyntaxKind::POSITIONAL_PARAM, + pgls_tokenizer::TokenKind::NamedParam { kind } => { match kind { - pgt_tokenizer::NamedParamKind::ColonIdentifier { terminated: false } => { + pgls_tokenizer::NamedParamKind::ColonIdentifier { terminated: false } => { err = "Missing trailing \" to terminate the named parameter"; } - pgt_tokenizer::NamedParamKind::ColonString { terminated: false } => { + pgls_tokenizer::NamedParamKind::ColonString { terminated: false } => { err = "Missing trailing ' to terminate the named parameter"; } _ => {} }; SyntaxKind::NAMED_PARAM } - pgt_tokenizer::TokenKind::QuotedIdent { terminated } => { + pgls_tokenizer::TokenKind::QuotedIdent { terminated } => { if !terminated { err = "Missing trailing \" to terminate the quoted identifier" } @@ -158,17 +158,17 @@ impl<'a> Lexer<'a> { self.push(syntax_kind, token_text.len(), err, line_ending_count); } - fn extend_literal(&mut self, len: usize, kind: &pgt_tokenizer::LiteralKind) { + fn extend_literal(&mut self, len: usize, kind: &pgls_tokenizer::LiteralKind) { let mut err = ""; let syntax_kind = match *kind { - pgt_tokenizer::LiteralKind::Int { empty_int, base: _ } => { + pgls_tokenizer::LiteralKind::Int { empty_int, base: _ } => { if empty_int { err = "Missing digits after the integer base prefix"; } SyntaxKind::INT_NUMBER } - pgt_tokenizer::LiteralKind::Float { + pgls_tokenizer::LiteralKind::Float { empty_exponent, base: _, } => { @@ -177,37 +177,37 @@ impl<'a> Lexer<'a> { } SyntaxKind::FLOAT_NUMBER } - pgt_tokenizer::LiteralKind::Str { terminated } => { + pgls_tokenizer::LiteralKind::Str { terminated } => { if !terminated { err = "Missing trailing `'` symbol to terminate the string literal"; } SyntaxKind::STRING } - pgt_tokenizer::LiteralKind::ByteStr { terminated } => { + pgls_tokenizer::LiteralKind::ByteStr { terminated } => { if !terminated { err = "Missing trailing `'` symbol to terminate the hex bit string literal"; } SyntaxKind::BYTE_STRING } - pgt_tokenizer::LiteralKind::BitStr { terminated } => { + pgls_tokenizer::LiteralKind::BitStr { terminated } => { if !terminated { err = "Missing trailing `'` symbol to terminate the bit string literal"; } SyntaxKind::BIT_STRING } - pgt_tokenizer::LiteralKind::DollarQuotedString { terminated } => { + pgls_tokenizer::LiteralKind::DollarQuotedString { terminated } => { if !terminated { err = "Unterminated dollar quoted string literal"; } SyntaxKind::DOLLAR_QUOTED_STRING } - pgt_tokenizer::LiteralKind::UnicodeEscStr { terminated } => { + pgls_tokenizer::LiteralKind::UnicodeEscStr { terminated } => { if !terminated { err = "Missing trailing `'` symbol to terminate the unicode escape string literal"; } SyntaxKind::BYTE_STRING } - pgt_tokenizer::LiteralKind::EscStr { terminated } => { + pgls_tokenizer::LiteralKind::EscStr { terminated } => { if !terminated { err = "Missing trailing `'` symbol to terminate the escape string literal"; } diff --git a/crates/pgt_lexer/src/lib.rs b/crates/pgls_lexer/src/lib.rs similarity index 100% rename from crates/pgt_lexer/src/lib.rs rename to crates/pgls_lexer/src/lib.rs diff --git a/crates/pgt_lexer_codegen/Cargo.toml b/crates/pgls_lexer_codegen/Cargo.toml similarity index 93% rename from crates/pgt_lexer_codegen/Cargo.toml rename to crates/pgls_lexer_codegen/Cargo.toml index b50465b07..29e53b2fe 100644 --- a/crates/pgt_lexer_codegen/Cargo.toml +++ b/crates/pgls_lexer_codegen/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_lexer_codegen" +name = "pgls_lexer_codegen" repository.workspace = true version = "0.0.0" diff --git a/crates/pgt_lexer_codegen/README.md b/crates/pgls_lexer_codegen/README.md similarity index 100% rename from crates/pgt_lexer_codegen/README.md rename to crates/pgls_lexer_codegen/README.md diff --git a/crates/pgt_lexer_codegen/build.rs b/crates/pgls_lexer_codegen/build.rs similarity index 100% rename from crates/pgt_lexer_codegen/build.rs rename to crates/pgls_lexer_codegen/build.rs diff --git a/crates/pgt_lexer_codegen/src/keywords.rs b/crates/pgls_lexer_codegen/src/keywords.rs similarity index 100% rename from crates/pgt_lexer_codegen/src/keywords.rs rename to crates/pgls_lexer_codegen/src/keywords.rs diff --git a/crates/pgt_lexer_codegen/src/lib.rs b/crates/pgls_lexer_codegen/src/lib.rs similarity index 100% rename from crates/pgt_lexer_codegen/src/lib.rs rename to crates/pgls_lexer_codegen/src/lib.rs diff --git a/crates/pgt_lexer_codegen/src/syntax_kind.rs b/crates/pgls_lexer_codegen/src/syntax_kind.rs similarity index 100% rename from crates/pgt_lexer_codegen/src/syntax_kind.rs rename to crates/pgls_lexer_codegen/src/syntax_kind.rs diff --git a/crates/pgt_lexer_codegen/vendor/17-latest/kwlist.h b/crates/pgls_lexer_codegen/vendor/17-latest/kwlist.h similarity index 100% rename from crates/pgt_lexer_codegen/vendor/17-latest/kwlist.h rename to crates/pgls_lexer_codegen/vendor/17-latest/kwlist.h diff --git a/crates/pgls_lsp/Cargo.toml b/crates/pgls_lsp/Cargo.toml new file mode 100644 index 000000000..2345c5a35 --- /dev/null +++ b/crates/pgls_lsp/Cargo.toml @@ -0,0 +1,43 @@ +[package] +authors.workspace = true +categories.workspace = true +description = "" +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +name = "pgls_lsp" +repository.workspace = true +version = "0.0.0" + + +[dependencies] +anyhow = { workspace = true } +biome_deserialize = { workspace = true } +futures = "0.3.31" +pgls_analyse = { workspace = true } +pgls_completions = { workspace = true } +pgls_configuration = { workspace = true } +pgls_console = { workspace = true } +pgls_diagnostics = { workspace = true } +pgls_fs = { workspace = true } +pgls_text_edit = { workspace = true } +pgls_text_size.workspace = true +pgls_workspace = { workspace = true } +rustc-hash = { workspace = true } +serde = { workspace = true, features = ["derive"] } +serde_json = { workspace = true } +strum = { workspace = true } +tokio = { workspace = true, features = ["rt", "io-std"] } +tower-lsp = { version = "0.20.0" } +tracing = { workspace = true, features = ["attributes"] } + +[dev-dependencies] +pgls_test_utils = { workspace = true } +sqlx = { workspace = true } +test-log = { workspace = true } +tokio = { workspace = true, features = ["macros"] } +tower = { version = "0.4.13", features = ["timeout"] } + +[lib] +doctest = false diff --git a/crates/pgt_lsp/src/adapters/from_lsp.rs b/crates/pgls_lsp/src/adapters/from_lsp.rs similarity index 96% rename from crates/pgt_lsp/src/adapters/from_lsp.rs rename to crates/pgls_lsp/src/adapters/from_lsp.rs index ce764a9e1..cfd5aaf1b 100644 --- a/crates/pgt_lsp/src/adapters/from_lsp.rs +++ b/crates/pgls_lsp/src/adapters/from_lsp.rs @@ -1,7 +1,7 @@ use crate::adapters::line_index::LineIndex; use crate::adapters::{LineCol, PositionEncoding, WideLineCol}; use anyhow::{Context, Result}; -use pgt_text_size::{TextRange, TextSize}; +use pgls_text_size::{TextRange, TextSize}; use tower_lsp::lsp_types; /// The function is used to convert a LSP position to TextSize. diff --git a/crates/pgt_lsp/src/adapters/line_index.rs b/crates/pgls_lsp/src/adapters/line_index.rs similarity index 99% rename from crates/pgt_lsp/src/adapters/line_index.rs rename to crates/pgls_lsp/src/adapters/line_index.rs index 79a48b106..a5a8c619c 100644 --- a/crates/pgt_lsp/src/adapters/line_index.rs +++ b/crates/pgls_lsp/src/adapters/line_index.rs @@ -3,7 +3,7 @@ use std::mem; -use pgt_text_size::TextSize; +use pgls_text_size::TextSize; use rustc_hash::FxHashMap; use crate::adapters::{LineCol, WideChar, WideEncoding, WideLineCol}; diff --git a/crates/pgt_lsp/src/adapters/mod.rs b/crates/pgls_lsp/src/adapters/mod.rs similarity index 99% rename from crates/pgt_lsp/src/adapters/mod.rs rename to crates/pgls_lsp/src/adapters/mod.rs index a53751808..10cf155c8 100644 --- a/crates/pgt_lsp/src/adapters/mod.rs +++ b/crates/pgls_lsp/src/adapters/mod.rs @@ -1,6 +1,6 @@ //! The crate contains a set of converters to translate between `lsp-types` and `text_size` (and vice versa) types. -use pgt_text_size::TextSize; +use pgls_text_size::TextSize; use tower_lsp::lsp_types::{ClientCapabilities, Position, PositionEncodingKind, Url}; use crate::session::Session; @@ -116,7 +116,7 @@ mod tests { use crate::adapters::line_index::LineIndex; use crate::adapters::to_lsp::position; use crate::adapters::{LineCol, PositionEncoding, WideEncoding}; - use pgt_text_size::TextSize; + use pgls_text_size::TextSize; use tower_lsp::lsp_types::Position; macro_rules! check_conversion { diff --git a/crates/pgt_lsp/src/adapters/to_lsp.rs b/crates/pgls_lsp/src/adapters/to_lsp.rs similarity index 96% rename from crates/pgt_lsp/src/adapters/to_lsp.rs rename to crates/pgls_lsp/src/adapters/to_lsp.rs index 71a6b3c4d..96b25b48c 100644 --- a/crates/pgt_lsp/src/adapters/to_lsp.rs +++ b/crates/pgls_lsp/src/adapters/to_lsp.rs @@ -1,7 +1,7 @@ use crate::adapters::PositionEncoding; use crate::adapters::line_index::LineIndex; use anyhow::{Context, Result}; -use pgt_text_size::{TextRange, TextSize}; +use pgls_text_size::{TextRange, TextSize}; use tower_lsp::lsp_types; /// The function is used to convert TextSize to a LSP position. diff --git a/crates/pgt_lsp/src/capabilities.rs b/crates/pgls_lsp/src/capabilities.rs similarity index 97% rename from crates/pgt_lsp/src/capabilities.rs rename to crates/pgls_lsp/src/capabilities.rs index 3bbb062de..a5e5641fc 100644 --- a/crates/pgt_lsp/src/capabilities.rs +++ b/crates/pgls_lsp/src/capabilities.rs @@ -1,6 +1,6 @@ use crate::adapters::{PositionEncoding, WideEncoding, negotiated_encoding}; use crate::handlers::code_actions::command_id; -use pgt_workspace::features::code_actions::CommandActionCategory; +use pgls_workspace::features::code_actions::CommandActionCategory; use strum::IntoEnumIterator; use tower_lsp::lsp_types::{ ClientCapabilities, CompletionOptions, ExecuteCommandOptions, HoverProviderCapability, diff --git a/crates/pgt_lsp/src/diagnostics.rs b/crates/pgls_lsp/src/diagnostics.rs similarity index 82% rename from crates/pgt_lsp/src/diagnostics.rs rename to crates/pgls_lsp/src/diagnostics.rs index 2c7acbba8..3459f8aeb 100644 --- a/crates/pgt_lsp/src/diagnostics.rs +++ b/crates/pgls_lsp/src/diagnostics.rs @@ -1,12 +1,12 @@ use anyhow::Error; -use pgt_workspace::WorkspaceError; +use pgls_workspace::WorkspaceError; use std::fmt::{Display, Formatter}; #[derive(Debug)] pub enum LspError { WorkspaceError(WorkspaceError), Anyhow(anyhow::Error), - Error(pgt_diagnostics::Error), + Error(pgls_diagnostics::Error), } impl From for LspError { @@ -15,8 +15,8 @@ impl From for LspError { } } -impl From for LspError { - fn from(value: pgt_diagnostics::Error) -> Self { +impl From for LspError { + fn from(value: pgls_diagnostics::Error) -> Self { Self::Error(value) } } diff --git a/crates/pgt_lsp/src/documents.rs b/crates/pgls_lsp/src/documents.rs similarity index 100% rename from crates/pgt_lsp/src/documents.rs rename to crates/pgls_lsp/src/documents.rs diff --git a/crates/pgt_lsp/src/handlers.rs b/crates/pgls_lsp/src/handlers.rs similarity index 100% rename from crates/pgt_lsp/src/handlers.rs rename to crates/pgls_lsp/src/handlers.rs diff --git a/crates/pgt_lsp/src/handlers/code_actions.rs b/crates/pgls_lsp/src/handlers/code_actions.rs similarity index 96% rename from crates/pgt_lsp/src/handlers/code_actions.rs rename to crates/pgls_lsp/src/handlers/code_actions.rs index a10bee03a..5fd1546d9 100644 --- a/crates/pgt_lsp/src/handlers/code_actions.rs +++ b/crates/pgls_lsp/src/handlers/code_actions.rs @@ -5,7 +5,7 @@ use tower_lsp::lsp_types::{ MessageType, }; -use pgt_workspace::features::code_actions::{ +use pgls_workspace::features::code_actions::{ CodeActionKind, CodeActionsParams, CommandActionCategory, ExecuteStatementParams, }; @@ -81,7 +81,7 @@ pub async fn execute_command( match command.as_str() { "pgt.executeStatement" => { - let statement_id = serde_json::from_value::( + let statement_id = serde_json::from_value::( params.arguments[0].clone(), )?; let doc_url: lsp_types::Url = serde_json::from_value(params.arguments[1].clone())?; diff --git a/crates/pgt_lsp/src/handlers/completions.rs b/crates/pgls_lsp/src/handlers/completions.rs similarity index 78% rename from crates/pgt_lsp/src/handlers/completions.rs rename to crates/pgls_lsp/src/handlers/completions.rs index 4a035fcf8..d4969ce8c 100644 --- a/crates/pgt_lsp/src/handlers/completions.rs +++ b/crates/pgls_lsp/src/handlers/completions.rs @@ -4,7 +4,7 @@ use crate::{ session::Session, }; use anyhow::Result; -use pgt_workspace::{WorkspaceError, features::completions::GetCompletionsParams}; +use pgls_workspace::{WorkspaceError, features::completions::GetCompletionsParams}; use tower_lsp::lsp_types::{ self, CompletionItem, CompletionItemLabelDetails, InsertTextFormat, TextEdit, }; @@ -68,14 +68,14 @@ pub fn get_completions( } fn to_lsp_types_completion_item_kind( - pg_comp_kind: pgt_completions::CompletionItemKind, + pg_comp_kind: pgls_completions::CompletionItemKind, ) -> lsp_types::CompletionItemKind { match pg_comp_kind { - pgt_completions::CompletionItemKind::Function => lsp_types::CompletionItemKind::FUNCTION, - pgt_completions::CompletionItemKind::Table => lsp_types::CompletionItemKind::CLASS, - pgt_completions::CompletionItemKind::Column => lsp_types::CompletionItemKind::FIELD, - pgt_completions::CompletionItemKind::Schema => lsp_types::CompletionItemKind::CLASS, - pgt_completions::CompletionItemKind::Policy => lsp_types::CompletionItemKind::CONSTANT, - pgt_completions::CompletionItemKind::Role => lsp_types::CompletionItemKind::CONSTANT, + pgls_completions::CompletionItemKind::Function => lsp_types::CompletionItemKind::FUNCTION, + pgls_completions::CompletionItemKind::Table => lsp_types::CompletionItemKind::CLASS, + pgls_completions::CompletionItemKind::Column => lsp_types::CompletionItemKind::FIELD, + pgls_completions::CompletionItemKind::Schema => lsp_types::CompletionItemKind::CLASS, + pgls_completions::CompletionItemKind::Policy => lsp_types::CompletionItemKind::CONSTANT, + pgls_completions::CompletionItemKind::Role => lsp_types::CompletionItemKind::CONSTANT, } } diff --git a/crates/pgt_lsp/src/handlers/hover.rs b/crates/pgls_lsp/src/handlers/hover.rs similarity index 95% rename from crates/pgt_lsp/src/handlers/hover.rs rename to crates/pgls_lsp/src/handlers/hover.rs index ed7173551..9155207f0 100644 --- a/crates/pgt_lsp/src/handlers/hover.rs +++ b/crates/pgls_lsp/src/handlers/hover.rs @@ -1,4 +1,4 @@ -use pgt_workspace::{WorkspaceError, features::on_hover::OnHoverParams}; +use pgls_workspace::{WorkspaceError, features::on_hover::OnHoverParams}; use tower_lsp::lsp_types::{self, MarkedString, MarkupContent}; use crate::{adapters::get_cursor_position, diagnostics::LspError, session::Session}; diff --git a/crates/pgt_lsp/src/handlers/text_document.rs b/crates/pgls_lsp/src/handlers/text_document.rs similarity index 98% rename from crates/pgt_lsp/src/handlers/text_document.rs rename to crates/pgls_lsp/src/handlers/text_document.rs index 1c5a9a115..ba78e0b14 100644 --- a/crates/pgt_lsp/src/handlers/text_document.rs +++ b/crates/pgls_lsp/src/handlers/text_document.rs @@ -1,6 +1,6 @@ use crate::{documents::Document, session::Session, utils::apply_document_changes}; use anyhow::Result; -use pgt_workspace::workspace::{ +use pgls_workspace::workspace::{ ChangeFileParams, CloseFileParams, GetFileContentParams, OpenFileParams, }; use tower_lsp::lsp_types; diff --git a/crates/pgt_lsp/src/lib.rs b/crates/pgls_lsp/src/lib.rs similarity index 100% rename from crates/pgt_lsp/src/lib.rs rename to crates/pgls_lsp/src/lib.rs diff --git a/crates/pgt_lsp/src/server.rs b/crates/pgls_lsp/src/server.rs similarity index 98% rename from crates/pgt_lsp/src/server.rs rename to crates/pgls_lsp/src/server.rs index 76d9bd9a6..165a46eb0 100644 --- a/crates/pgt_lsp/src/server.rs +++ b/crates/pgls_lsp/src/server.rs @@ -6,9 +6,9 @@ use crate::session::{ use crate::utils::{into_lsp_error, panic_to_lsp_error}; use futures::FutureExt; use futures::future::ready; -use pgt_fs::{ConfigName, FileSystem, OsFileSystem}; -use pgt_workspace::workspace::{RegisterProjectFolderParams, UnregisterProjectFolderParams}; -use pgt_workspace::{DynRef, Workspace, workspace}; +use pgls_fs::{ConfigName, FileSystem, OsFileSystem}; +use pgls_workspace::workspace::{RegisterProjectFolderParams, UnregisterProjectFolderParams}; +use pgls_workspace::{DynRef, Workspace, workspace}; use rustc_hash::FxHashMap; use serde_json::json; use std::panic::RefUnwindSafe; @@ -123,7 +123,7 @@ impl LanguageServer for LSPServer { capabilities: server_capabilities, server_info: Some(ServerInfo { name: String::from(env!("CARGO_PKG_NAME")), - version: Some(pgt_configuration::VERSION.to_string()), + version: Some(pgls_configuration::VERSION.to_string()), }), }; diff --git a/crates/pgt_lsp/src/session.rs b/crates/pgls_lsp/src/session.rs similarity index 95% rename from crates/pgt_lsp/src/session.rs rename to crates/pgls_lsp/src/session.rs index ede0469f2..2d18b7261 100644 --- a/crates/pgt_lsp/src/session.rs +++ b/crates/pgls_lsp/src/session.rs @@ -6,16 +6,16 @@ use anyhow::Result; use biome_deserialize::Merge; use futures::StreamExt; use futures::stream::FuturesUnordered; -use pgt_analyse::RuleCategoriesBuilder; -use pgt_configuration::{ConfigurationPathHint, PartialConfiguration}; -use pgt_diagnostics::{DiagnosticExt, Error}; -use pgt_fs::{FileSystem, PgTPath}; -use pgt_workspace::PartialConfigurationExt; -use pgt_workspace::Workspace; -use pgt_workspace::configuration::{LoadedConfiguration, load_configuration}; -use pgt_workspace::features; -use pgt_workspace::workspace::{RegisterProjectFolderParams, UpdateSettingsParams}; -use pgt_workspace::{DynRef, WorkspaceError}; +use pgls_analyse::RuleCategoriesBuilder; +use pgls_configuration::{ConfigurationPathHint, PartialConfiguration}; +use pgls_diagnostics::{DiagnosticExt, Error}; +use pgls_fs::{FileSystem, PgLSPath}; +use pgls_workspace::PartialConfigurationExt; +use pgls_workspace::Workspace; +use pgls_workspace::configuration::{LoadedConfiguration, load_configuration}; +use pgls_workspace::features; +use pgls_workspace::workspace::{RegisterProjectFolderParams, UpdateSettingsParams}; +use pgls_workspace::{DynRef, WorkspaceError}; use rustc_hash::FxHashMap; use serde_json::Value; use std::path::PathBuf; @@ -345,7 +345,7 @@ impl Session { self.documents.write().unwrap().remove(url); } - pub(crate) fn file_path(&self, url: &lsp_types::Url) -> Result { + pub(crate) fn file_path(&self, url: &lsp_types::Url) -> Result { let path_to_file = match url.to_file_path() { Err(_) => { // If we can't create a path, it's probably because the file doesn't exist. @@ -355,7 +355,7 @@ impl Session { Ok(path) => path, }; - Ok(PgTPath::new(path_to_file)) + Ok(PgLSPath::new(path_to_file)) } /// True if the client supports dynamic registration of "workspace/didChangeConfiguration" requests @@ -398,7 +398,7 @@ impl Session { .map(|params| ¶ms.client_capabilities) } - /// This function attempts to read the `postgrestools.jsonc` configuration file from + /// This function attempts to read the `postgres-language-server.jsonc` configuration file from /// the root URI and update the workspace settings accordingly #[tracing::instrument(level = "trace", skip(self))] pub(crate) async fn load_workspace_settings(&self, extra_config: Option) { @@ -406,7 +406,7 @@ impl Session { if let Some(config_path) = &self.config_path { let base_path = ConfigurationPathHint::FromUser(config_path.clone()); let status = self - .load_pgt_configuration_file(base_path, extra_config) + .load_pgls_configuration_file(base_path, extra_config) .await; self.set_configuration_status(status); } else if let Some(folders) = self.get_workspace_folders() { @@ -418,7 +418,7 @@ impl Session { match base_path { Ok(base_path) => { let status = self - .load_pgt_configuration_file( + .load_pgls_configuration_file( ConfigurationPathHint::FromWorkspace(base_path), extra_config.clone(), ) @@ -439,13 +439,13 @@ impl Session { Some(path) => ConfigurationPathHint::FromLsp(path), }; let status = self - .load_pgt_configuration_file(base_path, extra_config) + .load_pgls_configuration_file(base_path, extra_config) .await; self.set_configuration_status(status); } } - async fn load_pgt_configuration_file( + async fn load_pgls_configuration_file( &self, base_path: ConfigurationPathHint, extra_config: Option, diff --git a/crates/pgt_lsp/src/utils.rs b/crates/pgls_lsp/src/utils.rs similarity index 96% rename from crates/pgt_lsp/src/utils.rs rename to crates/pgls_lsp/src/utils.rs index 8361cf08e..51913d9e6 100644 --- a/crates/pgt_lsp/src/utils.rs +++ b/crates/pgls_lsp/src/utils.rs @@ -2,12 +2,12 @@ use crate::adapters::from_lsp::text_range; use crate::adapters::line_index::LineIndex; use crate::adapters::{PositionEncoding, to_lsp}; use anyhow::{Context, Result, ensure}; -use pgt_console::MarkupBuf; -use pgt_console::fmt::Termcolor; -use pgt_console::fmt::{self, Formatter}; -use pgt_diagnostics::termcolor::NoColor; -use pgt_diagnostics::{Diagnostic, DiagnosticTags, Location, PrintDescription, Severity, Visit}; -use pgt_text_size::{TextRange, TextSize}; +use pgls_console::MarkupBuf; +use pgls_console::fmt::Termcolor; +use pgls_console::fmt::{self, Formatter}; +use pgls_diagnostics::termcolor::NoColor; +use pgls_diagnostics::{Diagnostic, DiagnosticTags, Location, PrintDescription, Severity, Visit}; +use pgls_text_size::{TextRange, TextSize}; use std::any::Any; use std::borrow::Cow; use std::fmt::{Debug, Display}; @@ -18,7 +18,7 @@ use tower_lsp::lsp_types; use tower_lsp::lsp_types::{self as lsp, CodeDescription, Url}; use tracing::error; -/// Convert an [pgt_diagnostics::Diagnostic] to a [lsp::Diagnostic], using the span +/// Convert an [pgls_diagnostics::Diagnostic] to a [lsp::Diagnostic], using the span /// of the diagnostic's primary label as the diagnostic range. /// Requires a [LineIndex] to convert a byte offset range to the line/col range /// expected by LSP. @@ -239,8 +239,8 @@ mod tests { use crate::adapters::line_index::LineIndex; use crate::adapters::{PositionEncoding, to_lsp}; use anyhow::Result; - use pgt_text_edit::{CompressedOp, DiffOp, TextEdit}; - use pgt_text_size::TextSize; + use pgls_text_edit::{CompressedOp, DiffOp, TextEdit}; + use pgls_text_size::TextSize; use tower_lsp::lsp_types as lsp; fn text_edit( diff --git a/crates/pgt_lsp/tests/server.rs b/crates/pgls_lsp/tests/server.rs similarity index 96% rename from crates/pgt_lsp/tests/server.rs rename to crates/pgls_lsp/tests/server.rs index 1f972395b..7135541fb 100644 --- a/crates/pgt_lsp/tests/server.rs +++ b/crates/pgls_lsp/tests/server.rs @@ -9,12 +9,12 @@ use futures::SinkExt; use futures::Stream; use futures::StreamExt; use futures::channel::mpsc::{Sender, channel}; -use pgt_configuration::PartialConfiguration; -use pgt_configuration::database::PartialDatabaseConfiguration; -use pgt_fs::MemoryFileSystem; -use pgt_lsp::LSPServer; -use pgt_lsp::ServerFactory; -use pgt_workspace::DynRef; +use pgls_configuration::PartialConfiguration; +use pgls_configuration::database::PartialDatabaseConfiguration; +use pgls_fs::MemoryFileSystem; +use pgls_lsp::LSPServer; +use pgls_lsp::ServerFactory; +use pgls_workspace::DynRef; use serde::Serialize; use serde::de::DeserializeOwned; use serde_json::Value; @@ -395,7 +395,7 @@ async fn basic_lifecycle() -> Result<()> { Ok(()) } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_database_connection(test_db: PgPool) -> Result<()> { let factory = ServerFactory::default(); let mut fs = MemoryFileSystem::default(); @@ -427,7 +427,9 @@ async fn test_database_connection(test_db: PgPool) -> Result<()> { ..Default::default() }); fs.insert( - url!("postgrestools.jsonc").to_file_path().unwrap(), + url!("postgres-language-server.jsonc") + .to_file_path() + .unwrap(), serde_json::to_string_pretty(&conf).unwrap(), ); @@ -506,7 +508,7 @@ async fn server_shutdown() -> Result<()> { Ok(()) } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_completions(test_db: PgPool) -> Result<()> { let factory = ServerFactory::default(); let mut fs = MemoryFileSystem::default(); @@ -538,7 +540,9 @@ async fn test_completions(test_db: PgPool) -> Result<()> { ..Default::default() }); fs.insert( - url!("postgrestools.jsonc").to_file_path().unwrap(), + url!("postgres-language-server.jsonc") + .to_file_path() + .unwrap(), serde_json::to_string_pretty(&conf).unwrap(), ); @@ -606,7 +610,7 @@ async fn test_completions(test_db: PgPool) -> Result<()> { Ok(()) } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_issue_271(test_db: PgPool) -> Result<()> { let factory = ServerFactory::default(); let mut fs = MemoryFileSystem::default(); @@ -638,7 +642,9 @@ async fn test_issue_271(test_db: PgPool) -> Result<()> { ..Default::default() }); fs.insert( - url!("postgrestools.jsonc").to_file_path().unwrap(), + url!("postgres-language-server.jsonc") + .to_file_path() + .unwrap(), serde_json::to_string_pretty(&conf).unwrap(), ); @@ -807,7 +813,7 @@ async fn test_issue_271(test_db: PgPool) -> Result<()> { Ok(()) } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_execute_statement(test_db: PgPool) -> Result<()> { let factory = ServerFactory::default(); let mut fs = MemoryFileSystem::default(); @@ -830,7 +836,9 @@ async fn test_execute_statement(test_db: PgPool) -> Result<()> { }); fs.insert( - url!("postgrestools.jsonc").to_file_path().unwrap(), + url!("postgres-language-server.jsonc") + .to_file_path() + .unwrap(), serde_json::to_string_pretty(&conf).unwrap(), ); @@ -945,7 +953,7 @@ async fn test_execute_statement(test_db: PgPool) -> Result<()> { Ok(()) } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_issue_281(test_db: PgPool) -> Result<()> { let factory = ServerFactory::default(); let mut fs = MemoryFileSystem::default(); @@ -977,7 +985,9 @@ async fn test_issue_281(test_db: PgPool) -> Result<()> { ..Default::default() }); fs.insert( - url!("postgrestools.jsonc").to_file_path().unwrap(), + url!("postgres-language-server.jsonc") + .to_file_path() + .unwrap(), serde_json::to_string_pretty(&conf).unwrap(), ); @@ -1028,7 +1038,7 @@ async fn test_issue_281(test_db: PgPool) -> Result<()> { Ok(()) } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_issue_303(test_db: PgPool) -> Result<()> { let factory = ServerFactory::default(); let mut fs = MemoryFileSystem::default(); @@ -1060,7 +1070,9 @@ async fn test_issue_303(test_db: PgPool) -> Result<()> { ..Default::default() }); fs.insert( - url!("postgrestools.jsonc").to_file_path().unwrap(), + url!("postgres-language-server.jsonc") + .to_file_path() + .unwrap(), serde_json::to_string_pretty(&conf).unwrap(), ); @@ -1158,7 +1170,7 @@ async fn test_issue_303(test_db: PgPool) -> Result<()> { Ok(()) } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn multiple_projects(test_db: PgPool) -> Result<()> { let factory = ServerFactory::default(); let mut fs = MemoryFileSystem::default(); @@ -1192,7 +1204,9 @@ async fn multiple_projects(test_db: PgPool) -> Result<()> { ..Default::default() }); fs.insert( - url!("test_one/postgrestools.jsonc").to_file_path().unwrap(), + url!("test_one/postgres-language-server.jsonc") + .to_file_path() + .unwrap(), serde_json::to_string_pretty(&conf_with_db).unwrap(), ); @@ -1206,7 +1220,9 @@ async fn multiple_projects(test_db: PgPool) -> Result<()> { ..Default::default() }); fs.insert( - url!("test_two/postgrestools.jsonc").to_file_path().unwrap(), + url!("test_two/postgres-language-server.jsonc") + .to_file_path() + .unwrap(), serde_json::to_string_pretty(&conf_without_db).unwrap(), ); @@ -1337,7 +1353,7 @@ async fn multiple_projects(test_db: PgPool) -> Result<()> { Ok(()) } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn extends_config(test_db: PgPool) -> Result<()> { let factory = ServerFactory::default(); let mut fs = MemoryFileSystem::default(); @@ -1357,14 +1373,16 @@ async fn extends_config(test_db: PgPool) -> Result<()> { // shared config with default db connection let conf_with_db = PartialConfiguration::init(); fs.insert( - url!("postgrestools.jsonc").to_file_path().unwrap(), + url!("postgres-language-server.jsonc") + .to_file_path() + .unwrap(), serde_json::to_string_pretty(&conf_with_db).unwrap(), ); let relative_path = if cfg!(windows) { - "..\\postgrestools.jsonc" + "..\\postgres-language-server.jsonc" } else { - "../postgrestools.jsonc" + "../postgres-language-server.jsonc" }; // test_one extends the shared config but sets our test db @@ -1385,7 +1403,9 @@ async fn extends_config(test_db: PgPool) -> Result<()> { }); fs.insert( - url!("test_one/postgrestools.jsonc").to_file_path().unwrap(), + url!("test_one/postgres-language-server.jsonc") + .to_file_path() + .unwrap(), serde_json::to_string_pretty(&conf_with_db).unwrap(), ); @@ -1396,7 +1416,9 @@ async fn extends_config(test_db: PgPool) -> Result<()> { ..Default::default() }); fs.insert( - url!("test_two/postgrestools.jsonc").to_file_path().unwrap(), + url!("test_two/postgres-language-server.jsonc") + .to_file_path() + .unwrap(), serde_json::to_string_pretty(&conf_without_db).unwrap(), ); @@ -1543,7 +1565,7 @@ async fn extends_config(test_db: PgPool) -> Result<()> { Ok(()) } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_multiple_content_changes_single_request(test_db: PgPool) -> Result<()> { let factory = ServerFactory::default(); let mut fs = MemoryFileSystem::default(); @@ -1585,7 +1607,9 @@ async fn test_multiple_content_changes_single_request(test_db: PgPool) -> Result ..Default::default() }); fs.insert( - url!("postgrestools.jsonc").to_file_path().unwrap(), + url!("postgres-language-server.jsonc") + .to_file_path() + .unwrap(), serde_json::to_string_pretty(&conf).unwrap(), ); @@ -1692,7 +1716,7 @@ ALTER TABLE ONLY "public"."campaign_contact_list" Ok(()) } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_plpgsql(test_db: PgPool) -> Result<()> { let factory = ServerFactory::default(); let mut fs = MemoryFileSystem::default(); @@ -1712,7 +1736,9 @@ async fn test_plpgsql(test_db: PgPool) -> Result<()> { ..Default::default() }); fs.insert( - url!("postgrestools.jsonc").to_file_path().unwrap(), + url!("postgres-language-server.jsonc") + .to_file_path() + .unwrap(), serde_json::to_string_pretty(&conf).unwrap(), ); diff --git a/crates/pgt_markup/Cargo.toml b/crates/pgls_markup/Cargo.toml similarity index 92% rename from crates/pgt_markup/Cargo.toml rename to crates/pgls_markup/Cargo.toml index 348bccf0e..ae779d2a7 100644 --- a/crates/pgt_markup/Cargo.toml +++ b/crates/pgls_markup/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_markup" +name = "pgls_markup" repository.workspace = true version = "0.0.0" diff --git a/crates/pgt_markup/README.md b/crates/pgls_markup/README.md similarity index 100% rename from crates/pgt_markup/README.md rename to crates/pgls_markup/README.md diff --git a/crates/pgt_markup/src/lib.rs b/crates/pgls_markup/src/lib.rs similarity index 95% rename from crates/pgt_markup/src/lib.rs rename to crates/pgls_markup/src/lib.rs index eb253078f..44cb6dee0 100644 --- a/crates/pgt_markup/src/lib.rs +++ b/crates/pgls_markup/src/lib.rs @@ -11,7 +11,7 @@ impl ToTokens for StackEntry { fn to_tokens(&self, tokens: &mut TokenStream) { let name = &self.name; tokens.extend(quote! { - pgt_console::MarkupElement::#name + pgls_console::MarkupElement::#name }); if !self.attributes.is_empty() { @@ -137,7 +137,7 @@ pub fn markup(input: proc_macro::TokenStream) -> proc_macro::TokenStream { .collect(); output.push(quote! { - pgt_console::MarkupNode { + pgls_console::MarkupNode { elements: &[ #( #elements ),* ], content: &(#literal), } @@ -149,9 +149,9 @@ pub fn markup(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let body = group.stream(); output.push(quote! { - pgt_console::MarkupNode { + pgls_console::MarkupNode { elements: &[ #( #elements ),* ], - content: &(#body) as &dyn pgt_console::fmt::Display, + content: &(#body) as &dyn pgls_console::fmt::Display, } }); } @@ -165,5 +165,5 @@ pub fn markup(input: proc_macro::TokenStream) -> proc_macro::TokenStream { abort!(top.name.span(), "unclosed element"); } - quote! { pgt_console::Markup(&[ #( #output ),* ]) }.into() + quote! { pgls_console::Markup(&[ #( #output ),* ]) }.into() } diff --git a/crates/pgls_plpgsql_check/Cargo.toml b/crates/pgls_plpgsql_check/Cargo.toml new file mode 100644 index 000000000..6c59c80a6 --- /dev/null +++ b/crates/pgls_plpgsql_check/Cargo.toml @@ -0,0 +1,30 @@ +[package] +authors.workspace = true +categories.workspace = true +description = "" +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +name = "pgls_plpgsql_check" +repository.workspace = true +version = "0.0.0" + + +[dependencies] +pgls_console = { workspace = true } +pgls_diagnostics = { workspace = true } +pgls_query = { workspace = true } +pgls_query_ext = { workspace = true } +pgls_schema_cache = { workspace = true } +pgls_text_size = { workspace = true } +regex = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +sqlx = { workspace = true } +tree-sitter = { workspace = true } + +[dev-dependencies] +pgls_test_utils = { workspace = true } + +[lib] diff --git a/crates/pgt_plpgsql_check/src/diagnostics.rs b/crates/pgls_plpgsql_check/src/diagnostics.rs similarity index 98% rename from crates/pgt_plpgsql_check/src/diagnostics.rs rename to crates/pgls_plpgsql_check/src/diagnostics.rs index b426719aa..9edcffb0f 100644 --- a/crates/pgt_plpgsql_check/src/diagnostics.rs +++ b/crates/pgls_plpgsql_check/src/diagnostics.rs @@ -1,8 +1,8 @@ use std::io; -use pgt_console::markup; -use pgt_diagnostics::{Advices, Diagnostic, LogCategory, MessageAndDescription, Severity, Visit}; -use pgt_text_size::TextRange; +use pgls_console::markup; +use pgls_diagnostics::{Advices, Diagnostic, LogCategory, MessageAndDescription, Severity, Visit}; +use pgls_text_size::TextRange; use crate::{PlpgSqlCheckIssue, PlpgSqlCheckResult}; diff --git a/crates/pgt_plpgsql_check/src/lib.rs b/crates/pgls_plpgsql_check/src/lib.rs similarity index 91% rename from crates/pgt_plpgsql_check/src/lib.rs rename to crates/pgls_plpgsql_check/src/lib.rs index e6f2524fc..4b7d0d36b 100644 --- a/crates/pgt_plpgsql_check/src/lib.rs +++ b/crates/pgls_plpgsql_check/src/lib.rs @@ -2,7 +2,7 @@ mod diagnostics; pub use diagnostics::PlPgSqlCheckDiagnostic; use diagnostics::create_diagnostics_from_check_result; -use pgt_query::protobuf::CreateFunctionStmt; +use pgls_query::protobuf::CreateFunctionStmt; use regex::Regex; use serde::Deserialize; pub use sqlx::postgres::PgSeverity; @@ -12,8 +12,8 @@ use sqlx::{Acquire, PgPool, Postgres, Transaction}; pub struct PlPgSqlCheckParams<'a> { pub conn: &'a PgPool, pub sql: &'a str, - pub ast: &'a pgt_query::NodeEnum, - pub schema_cache: &'a pgt_schema_cache::SchemaCache, + pub ast: &'a pgls_query::NodeEnum, + pub schema_cache: &'a pgls_schema_cache::SchemaCache, } #[derive(Debug, Deserialize)] @@ -47,15 +47,16 @@ pub struct Query { /// check if the given node is a plpgsql function that should be checked fn should_check_function<'a>( - ast: &'a pgt_query::NodeEnum, - schema_cache: &pgt_schema_cache::SchemaCache, + ast: &'a pgls_query::NodeEnum, + schema_cache: &pgls_schema_cache::SchemaCache, ) -> Option<&'a CreateFunctionStmt> { let create_fn = match ast { - pgt_query::NodeEnum::CreateFunctionStmt(stmt) => stmt, + pgls_query::NodeEnum::CreateFunctionStmt(stmt) => stmt, _ => return None, }; - if pgt_query_ext::utils::find_option_value(create_fn, "language") != Some("plpgsql".to_string()) + if pgls_query_ext::utils::find_option_value(create_fn, "language") + != Some("plpgsql".to_string()) { return None; } @@ -78,7 +79,7 @@ fn is_trigger_function(create_fn: &CreateFunctionStmt) -> bool { .as_ref() .map(|n| { matches!( - pgt_query_ext::utils::parse_name(&n.names), + pgls_query_ext::utils::parse_name(&n.names), Some((None, name)) if name == "trigger" ) }) @@ -96,11 +97,11 @@ fn build_function_identifier( .iter() .filter_map(|arg| { let node = match &arg.node { - Some(pgt_query::NodeEnum::FunctionParameter(n)) => n, + Some(pgls_query::NodeEnum::FunctionParameter(n)) => n, _ => return None, }; let type_name_node = node.arg_type.as_ref()?; - let type_name = match pgt_query_ext::utils::parse_name(&type_name_node.names) { + let type_name = match pgls_query_ext::utils::parse_name(&type_name_node.names) { Some((schema, name)) => match schema { Some(s) => format!("{}.{}", s, name), None => name, @@ -136,14 +137,14 @@ pub async fn check_plpgsql( None => return Ok(vec![]), }; - let (fn_schema, fn_name) = match pgt_query_ext::utils::parse_name(&create_fn.funcname) { + let (fn_schema, fn_name) = match pgls_query_ext::utils::parse_name(&create_fn.funcname) { Some(n) => n, None => return Ok(vec![]), }; let fn_identifier = build_function_identifier(create_fn, &fn_schema, &fn_name); - let fn_body = pgt_query_ext::utils::find_option_value(create_fn, "as") + let fn_body = pgls_query_ext::utils::find_option_value(create_fn, "as") .ok_or_else(|| sqlx::Error::Protocol("Failed to find function body".to_string()))?; let offset = params .sql @@ -244,10 +245,10 @@ mod tests { { test_db.execute(setup_sql).await?; - let ast = pgt_query::parse(create_fn_sql)? + let ast = pgls_query::parse(create_fn_sql)? .into_root() .ok_or("Failed to parse SQL root")?; - let schema_cache = pgt_schema_cache::SchemaCache::load(test_db).await?; + let schema_cache = pgls_schema_cache::SchemaCache::load(test_db).await?; let diagnostics = super::check_plpgsql(super::PlPgSqlCheckParams { conn: test_db, @@ -271,7 +272,7 @@ mod tests { Ok((diagnostics, span_texts)) } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_plpgsql_check_composite_types(test_db: PgPool) { let setup = r#" create extension if not exists plpgsql_check; @@ -304,7 +305,7 @@ mod tests { assert_eq!(diagnostics.len(), 0); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_plpgsql_check_if_expr(test_db: PgPool) { let setup = r#" create extension if not exists plpgsql_check; @@ -335,7 +336,7 @@ mod tests { assert_eq!(diagnostics.len(), 1); assert!(matches!( diagnostics[0].severity, - pgt_diagnostics::Severity::Error + pgls_diagnostics::Severity::Error )); assert_eq!( span_texts[0].as_deref(), @@ -343,7 +344,7 @@ mod tests { ); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_plpgsql_check_missing_var(test_db: PgPool) { let setup = r#" create extension if not exists plpgsql_check; @@ -368,12 +369,12 @@ mod tests { assert_eq!(diagnostics.len(), 1); assert!(matches!( diagnostics[0].severity, - pgt_diagnostics::Severity::Error + pgls_diagnostics::Severity::Error )); assert_eq!(span_texts[0].as_deref(), Some("v_c")); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_plpgsql_check_missing_col_if_stmt(test_db: PgPool) { let setup = r#" create extension if not exists plpgsql_check; @@ -400,12 +401,12 @@ mod tests { assert_eq!(diagnostics.len(), 1); assert!(matches!( diagnostics[0].severity, - pgt_diagnostics::Severity::Error + pgls_diagnostics::Severity::Error )); assert_eq!(span_texts[0].as_deref(), Some("c")); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_entire_body_broken(test_db: PgPool) { let setup = r#" create extension if not exists plpgsql_check; @@ -431,7 +432,7 @@ mod tests { assert_eq!(diagnostics.len(), 1); assert!(matches!( diagnostics[0].severity, - pgt_diagnostics::Severity::Error + pgls_diagnostics::Severity::Error )); assert_eq!( span_texts[0].as_deref(), @@ -445,7 +446,7 @@ mod tests { ); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_plpgsql_check(test_db: PgPool) { let setup = r#" create extension if not exists plpgsql_check; @@ -475,12 +476,12 @@ mod tests { assert_eq!(diagnostics.len(), 1); assert!(matches!( diagnostics[0].severity, - pgt_diagnostics::Severity::Error + pgls_diagnostics::Severity::Error )); assert_eq!(span_texts[0].as_deref(), Some("RAISE NOTICE '%', r.c;")); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_plpgsql_check_stacked_diagnostics(test_db: PgPool) { let setup = r#" create extension if not exists plpgsql_check; @@ -509,12 +510,12 @@ mod tests { assert!(!diagnostics.is_empty()); assert!(matches!( diagnostics[0].severity, - pgt_diagnostics::Severity::Error + pgls_diagnostics::Severity::Error )); assert_eq!(span_texts[0].as_deref(), Some("get stacked diagnostics")); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_plpgsql_check_constant_refcursor(test_db: PgPool) { let setup = r#" create extension if not exists plpgsql_check; @@ -539,7 +540,7 @@ mod tests { assert!(!diagnostics.is_empty()); assert!(matches!( diagnostics[0].severity, - pgt_diagnostics::Severity::Error + pgls_diagnostics::Severity::Error )); assert_eq!( span_texts[0].as_deref(), @@ -547,7 +548,7 @@ mod tests { ); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_plpgsql_check_constant_assignment(test_db: PgPool) { let setup = r#" create extension if not exists plpgsql_check; @@ -577,12 +578,12 @@ mod tests { assert!(!diagnostics.is_empty()); assert!(matches!( diagnostics[0].severity, - pgt_diagnostics::Severity::Error + pgls_diagnostics::Severity::Error )); assert_eq!(span_texts[0].as_deref(), Some("call p1(10, b);")); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_plpgsql_check_missing_procedure(test_db: PgPool) { let setup = r#" create extension if not exists plpgsql_check; @@ -605,12 +606,12 @@ mod tests { assert!(!diagnostics.is_empty()); assert!(matches!( diagnostics[0].severity, - pgt_diagnostics::Severity::Error + pgls_diagnostics::Severity::Error )); assert_eq!(span_texts[0].as_deref(), Some("p1")); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_plpgsql_check_dml_in_stable_function(test_db: PgPool) { let setup = r#" create extension if not exists plpgsql_check; @@ -640,7 +641,7 @@ mod tests { assert_eq!(diagnostics[0].advices.code.as_deref(), Some("0A000")); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_plpgsql_check_record_field_assignment(test_db: PgPool) { let setup = r#" create extension if not exists plpgsql_check; @@ -672,12 +673,12 @@ mod tests { assert!(!diagnostics.is_empty()); assert!(matches!( diagnostics[0].severity, - pgt_diagnostics::Severity::Error + pgls_diagnostics::Severity::Error )); assert!(span_texts[0].is_some()); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_plpgsql_check_trigger_basic(test_db: PgPool) { let setup = r#" create extension if not exists plpgsql_check; @@ -727,7 +728,7 @@ mod tests { assert!(!diagnostics.is_empty()); assert!(matches!( diagnostics[0].severity, - pgt_diagnostics::Severity::Error + pgls_diagnostics::Severity::Error )); assert!(diagnostics[0].advices.relation.is_some()); assert_eq!( @@ -737,7 +738,7 @@ mod tests { assert_eq!(span_texts[0].as_deref(), Some("audit_log")); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_plpgsql_check_trigger_missing_column(test_db: PgPool) { let setup = r#" create extension if not exists plpgsql_check; @@ -789,7 +790,7 @@ mod tests { assert!(!diagnostics.is_empty()); assert!(matches!( diagnostics[0].severity, - pgt_diagnostics::Severity::Error + pgls_diagnostics::Severity::Error )); assert!(span_texts[0].as_deref().unwrap().contains("category")); assert_eq!( @@ -798,7 +799,7 @@ mod tests { ); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_plpgsql_check_trigger_multiple_tables(test_db: PgPool) { let setup = r#" create extension if not exists plpgsql_check; diff --git a/crates/pgt_query/Cargo.toml b/crates/pgls_query/Cargo.toml similarity index 89% rename from crates/pgt_query/Cargo.toml rename to crates/pgls_query/Cargo.toml index 8fdbe6ca1..4b0ed6f5e 100644 --- a/crates/pgt_query/Cargo.toml +++ b/crates/pgls_query/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_query" +name = "pgls_query" repository.workspace = true version = "0.0.0" @@ -14,7 +14,7 @@ version = "0.0.0" prost = { workspace = true } thiserror = { workspace = true } -pgt_query_macros = { workspace = true } +pgls_query_macros = { workspace = true } [features] diff --git a/crates/pgt_query/build.rs b/crates/pgls_query/build.rs similarity index 100% rename from crates/pgt_query/build.rs rename to crates/pgls_query/build.rs diff --git a/crates/pgt_query/examples/api_example.rs b/crates/pgls_query/examples/api_example.rs similarity index 91% rename from crates/pgt_query/examples/api_example.rs rename to crates/pgls_query/examples/api_example.rs index d71b1c0fe..432b9ac3c 100644 --- a/crates/pgt_query/examples/api_example.rs +++ b/crates/pgls_query/examples/api_example.rs @@ -1,4 +1,4 @@ -use pgt_query::{NodeRef, parse}; +use pgls_query::{NodeRef, parse}; fn main() { let mut result = parse("SELECT * FROM users WHERE id IN (SELECT id FROM admins)").unwrap(); @@ -27,7 +27,7 @@ fn main() { // Now we can iterate mutably without cloning for mut_node in stmt.iter_mut() { // Modify nodes here if needed - if let pgt_query::NodeMut::SelectStmt(_select) = mut_node { + if let pgls_query::NodeMut::SelectStmt(_select) = mut_node { println!("Found a SELECT statement to modify"); // You can modify _select here } diff --git a/crates/pgt_query/src/deparse.rs b/crates/pgls_query/src/deparse.rs similarity index 98% rename from crates/pgt_query/src/deparse.rs rename to crates/pgls_query/src/deparse.rs index 91f3d4503..c47f36737 100644 --- a/crates/pgt_query/src/deparse.rs +++ b/crates/pgls_query/src/deparse.rs @@ -12,7 +12,7 @@ use prost::Message; /// # Example /// /// ```rust -/// use pgt_query::{parse, NodeEnum, NodeRef}; +/// use pgls_query::{parse, NodeEnum, NodeRef}; /// /// let result = parse("INSERT INTO other (name) SELECT name FROM contacts"); /// let result = result.unwrap(); diff --git a/crates/pgt_query/src/error.rs b/crates/pgls_query/src/error.rs similarity index 100% rename from crates/pgt_query/src/error.rs rename to crates/pgls_query/src/error.rs diff --git a/crates/pgt_query/src/fingerprint.rs b/crates/pgls_query/src/fingerprint.rs similarity index 99% rename from crates/pgt_query/src/fingerprint.rs rename to crates/pgls_query/src/fingerprint.rs index 127b6ca6a..617eafa2e 100644 --- a/crates/pgt_query/src/fingerprint.rs +++ b/crates/pgls_query/src/fingerprint.rs @@ -16,7 +16,7 @@ pub struct Fingerprint { /// # Example /// /// ```rust -/// let result = pgt_query::fingerprint("SELECT * FROM contacts WHERE name='Paul'"); +/// let result = pgls_query::fingerprint("SELECT * FROM contacts WHERE name='Paul'"); /// assert!(result.is_ok()); /// let result = result.unwrap(); /// assert_eq!(result.hex, "0e2581a461ece536"); diff --git a/crates/pgls_query/src/iter_mut.rs b/crates/pgls_query/src/iter_mut.rs new file mode 100644 index 000000000..96c0872c5 --- /dev/null +++ b/crates/pgls_query/src/iter_mut.rs @@ -0,0 +1 @@ +pgls_query_macros::iter_mut_codegen!(); diff --git a/crates/pgls_query/src/iter_ref.rs b/crates/pgls_query/src/iter_ref.rs new file mode 100644 index 000000000..c9fe4d159 --- /dev/null +++ b/crates/pgls_query/src/iter_ref.rs @@ -0,0 +1 @@ +pgls_query_macros::iter_ref_codegen!(); diff --git a/crates/pgt_query/src/lib.rs b/crates/pgls_query/src/lib.rs similarity index 100% rename from crates/pgt_query/src/lib.rs rename to crates/pgls_query/src/lib.rs diff --git a/crates/pgt_query/src/node_enum.rs b/crates/pgls_query/src/node_enum.rs similarity index 95% rename from crates/pgt_query/src/node_enum.rs rename to crates/pgls_query/src/node_enum.rs index 5d5b6bf71..0a3e04a16 100644 --- a/crates/pgt_query/src/node_enum.rs +++ b/crates/pgls_query/src/node_enum.rs @@ -3,7 +3,7 @@ use crate::*; use protobuf::Node; pub use protobuf::node::Node as NodeEnum; -pgt_query_macros::node_enum_codegen!(); +pgls_query_macros::node_enum_codegen!(); impl NodeEnum { pub fn deparse(&self) -> Result { diff --git a/crates/pgt_query/src/node_mut.rs b/crates/pgls_query/src/node_mut.rs similarity index 94% rename from crates/pgt_query/src/node_mut.rs rename to crates/pgls_query/src/node_mut.rs index f2da254b2..e5e7255be 100644 --- a/crates/pgt_query/src/node_mut.rs +++ b/crates/pgls_query/src/node_mut.rs @@ -1,6 +1,6 @@ use protobuf::Node; -pgt_query_macros::node_mut_codegen!(); +pgls_query_macros::node_mut_codegen!(); impl NodeMut { pub fn deparse(&self) -> Result { diff --git a/crates/pgt_query/src/node_ref.rs b/crates/pgls_query/src/node_ref.rs similarity index 94% rename from crates/pgt_query/src/node_ref.rs rename to crates/pgls_query/src/node_ref.rs index 603913cb7..a1f396c7e 100644 --- a/crates/pgt_query/src/node_ref.rs +++ b/crates/pgls_query/src/node_ref.rs @@ -1,6 +1,6 @@ use protobuf::Node; -pgt_query_macros::node_ref_codegen!(); +pgls_query_macros::node_ref_codegen!(); impl<'a> NodeRef<'a> { pub fn deparse(&self) -> Result { diff --git a/crates/pgt_query/src/node_structs.rs b/crates/pgls_query/src/node_structs.rs similarity index 90% rename from crates/pgt_query/src/node_structs.rs rename to crates/pgls_query/src/node_structs.rs index 8b81c98e5..4ef4daf6f 100644 --- a/crates/pgt_query/src/node_structs.rs +++ b/crates/pgls_query/src/node_structs.rs @@ -1,6 +1,6 @@ use protobuf::Node; -pgt_query_macros::node_structs_codegen!(); +pgls_query_macros::node_structs_codegen!(); impl Node { pub fn deparse(&self) -> Result { diff --git a/crates/pgt_query/src/normalize.rs b/crates/pgls_query/src/normalize.rs similarity index 98% rename from crates/pgt_query/src/normalize.rs rename to crates/pgls_query/src/normalize.rs index 71ff683c7..d9cd3795b 100644 --- a/crates/pgt_query/src/normalize.rs +++ b/crates/pgls_query/src/normalize.rs @@ -8,7 +8,7 @@ use crate::error::*; /// # Example /// /// ```rust -/// let result = pgt_query::normalize("SELECT * FROM contacts WHERE name='Paul'"); +/// let result = pgls_query::normalize("SELECT * FROM contacts WHERE name='Paul'"); /// assert!(result.is_ok()); /// let result = result.unwrap(); /// assert_eq!(result, "SELECT * FROM contacts WHERE name=$1"); diff --git a/crates/pgt_query/src/parse.rs b/crates/pgls_query/src/parse.rs similarity index 99% rename from crates/pgt_query/src/parse.rs rename to crates/pgls_query/src/parse.rs index 5853dfbc2..d7bd5f230 100644 --- a/crates/pgt_query/src/parse.rs +++ b/crates/pgls_query/src/parse.rs @@ -12,7 +12,7 @@ use prost::Message; /// # Example /// /// ```rust -/// use pgt_query::parse; +/// use pgls_query::parse; /// /// let result = parse("SELECT * FROM contacts"); /// assert!(result.is_ok()); diff --git a/crates/pgt_query/src/plpgsql.rs b/crates/pgls_query/src/plpgsql.rs similarity index 96% rename from crates/pgt_query/src/plpgsql.rs rename to crates/pgls_query/src/plpgsql.rs index fbaa9694b..9aa66e903 100644 --- a/crates/pgt_query/src/plpgsql.rs +++ b/crates/pgls_query/src/plpgsql.rs @@ -9,7 +9,7 @@ use crate::error::*; /// # Example /// /// ```rust -/// let result = pgt_query::parse_plpgsql(" +/// let result = pgls_query::parse_plpgsql(" /// CREATE OR REPLACE FUNCTION cs_fmt_browser_version(v_name varchar, v_version varchar) /// RETURNS varchar AS $$ /// BEGIN diff --git a/crates/pgt_query/src/protobuf.rs b/crates/pgls_query/src/protobuf.rs similarity index 100% rename from crates/pgt_query/src/protobuf.rs rename to crates/pgls_query/src/protobuf.rs diff --git a/crates/pgt_query/src/scan.rs b/crates/pgls_query/src/scan.rs similarity index 93% rename from crates/pgt_query/src/scan.rs rename to crates/pgls_query/src/scan.rs index b12061e7f..b21ee32cb 100644 --- a/crates/pgt_query/src/scan.rs +++ b/crates/pgls_query/src/scan.rs @@ -11,7 +11,7 @@ use prost::Message; /// # Example /// /// ```rust -/// let result = pgt_query::scan("SELECT * FROM contacts"); +/// let result = pgls_query::scan("SELECT * FROM contacts"); /// assert!(result.is_ok()); /// ``` pub fn scan(sql: &str) -> Result { diff --git a/crates/pgt_query/src/split.rs b/crates/pgls_query/src/split.rs similarity index 92% rename from crates/pgt_query/src/split.rs rename to crates/pgls_query/src/split.rs index abb95eb87..29cc7b3eb 100644 --- a/crates/pgt_query/src/split.rs +++ b/crates/pgls_query/src/split.rs @@ -9,7 +9,7 @@ use crate::error::*; /// /// ```rust /// let query = r#"select /*;*/ 1; select "2;", (select 3);"#; -/// let statements = pgt_query::split_with_parser(query).unwrap(); +/// let statements = pgls_query::split_with_parser(query).unwrap(); /// assert_eq!(statements, vec!["select /*;*/ 1", r#" select "2;", (select 3)"#]); /// ``` /// @@ -17,9 +17,9 @@ use crate::error::*; /// /// ```rust /// let query = "select 1; this statement is not sql; select 2;"; -/// let result = pgt_query::split_with_parser(query); +/// let result = pgls_query::split_with_parser(query); /// let err = r#"syntax error at or near "this""#; -/// assert_eq!(result, Err(pgt_query::Error::Split(err.to_string()))); +/// assert_eq!(result, Err(pgls_query::Error::Split(err.to_string()))); /// ``` pub fn split_with_parser(query: &str) -> Result> { let input = CString::new(query)?; @@ -49,7 +49,7 @@ pub fn split_with_parser(query: &str) -> Result> { /// invalid tokens will be skipped /// ```rust /// let query = r#"select /*;*/ 1; asdf; select "2;", (select 3); asdf"#; -/// let statements = pgt_query::split_with_scanner(query).unwrap(); +/// let statements = pgls_query::split_with_scanner(query).unwrap(); /// assert_eq!(statements, vec![ /// "select /*;*/ 1", /// // skipped " asdf" since it was an invalid token diff --git a/crates/pgt_query/vendor/libpg_query b/crates/pgls_query/vendor/libpg_query similarity index 100% rename from crates/pgt_query/vendor/libpg_query rename to crates/pgls_query/vendor/libpg_query diff --git a/crates/pgt_query_ext/Cargo.toml b/crates/pgls_query_ext/Cargo.toml similarity index 68% rename from crates/pgt_query_ext/Cargo.toml rename to crates/pgls_query_ext/Cargo.toml index 9b4bfa1d3..9db990936 100644 --- a/crates/pgt_query_ext/Cargo.toml +++ b/crates/pgls_query_ext/Cargo.toml @@ -6,15 +6,15 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_query_ext" +name = "pgls_query_ext" repository.workspace = true version = "0.0.0" [dependencies] -pgt_diagnostics.workspace = true -pgt_query.workspace = true -pgt_text_size.workspace = true +pgls_diagnostics.workspace = true +pgls_query.workspace = true +pgls_text_size.workspace = true [lib] doctest = false diff --git a/crates/pgt_query_ext/src/diagnostics.rs b/crates/pgls_query_ext/src/diagnostics.rs similarity index 83% rename from crates/pgt_query_ext/src/diagnostics.rs rename to crates/pgls_query_ext/src/diagnostics.rs index 4b5d92e9e..c10e93cef 100644 --- a/crates/pgt_query_ext/src/diagnostics.rs +++ b/crates/pgls_query_ext/src/diagnostics.rs @@ -1,5 +1,5 @@ -use pgt_diagnostics::{Diagnostic, MessageAndDescription}; -use pgt_text_size::TextRange; +use pgls_diagnostics::{Diagnostic, MessageAndDescription}; +use pgls_text_size::TextRange; /// A specialized diagnostic for the libpg_query parser. /// @@ -30,8 +30,8 @@ impl SyntaxDiagnostic { } } -impl From for SyntaxDiagnostic { - fn from(err: pgt_query::Error) -> Self { +impl From for SyntaxDiagnostic { + fn from(err: pgls_query::Error) -> Self { SyntaxDiagnostic { span: None, message: MessageAndDescription::from(err.to_string()), diff --git a/crates/pgt_query_ext/src/lib.rs b/crates/pgls_query_ext/src/lib.rs similarity index 100% rename from crates/pgt_query_ext/src/lib.rs rename to crates/pgls_query_ext/src/lib.rs diff --git a/crates/pgt_query_ext/src/utils.rs b/crates/pgls_query_ext/src/utils.rs similarity index 79% rename from crates/pgt_query_ext/src/utils.rs rename to crates/pgls_query_ext/src/utils.rs index 6dedebea1..abe047764 100644 --- a/crates/pgt_query_ext/src/utils.rs +++ b/crates/pgls_query_ext/src/utils.rs @@ -1,6 +1,6 @@ /// Helper function to find a specific option value from function options pub fn find_option_value( - create_fn: &pgt_query::protobuf::CreateFunctionStmt, + create_fn: &pgls_query::protobuf::CreateFunctionStmt, option_name: &str, ) -> Option { create_fn @@ -8,18 +8,18 @@ pub fn find_option_value( .iter() .filter_map(|opt_wrapper| opt_wrapper.node.as_ref()) .find_map(|opt| { - if let pgt_query::NodeEnum::DefElem(def_elem) = opt { + if let pgls_query::NodeEnum::DefElem(def_elem) = opt { if def_elem.defname == option_name { def_elem .arg .iter() .filter_map(|arg_wrapper| arg_wrapper.node.as_ref()) .find_map(|arg| { - if let pgt_query::NodeEnum::String(s) = arg { + if let pgls_query::NodeEnum::String(s) = arg { Some(s.sval.clone()) - } else if let pgt_query::NodeEnum::List(l) = arg { + } else if let pgls_query::NodeEnum::List(l) = arg { l.items.iter().find_map(|item_wrapper| { - if let Some(pgt_query::NodeEnum::String(s)) = + if let Some(pgls_query::NodeEnum::String(s)) = item_wrapper.node.as_ref() { Some(s.sval.clone()) @@ -40,11 +40,11 @@ pub fn find_option_value( }) } -pub fn parse_name(nodes: &[pgt_query::protobuf::Node]) -> Option<(Option, String)> { +pub fn parse_name(nodes: &[pgls_query::protobuf::Node]) -> Option<(Option, String)> { let names = nodes .iter() .map(|n| match &n.node { - Some(pgt_query::NodeEnum::String(s)) => Some(s.sval.clone()), + Some(pgls_query::NodeEnum::String(s)) => Some(s.sval.clone()), _ => None, }) .collect::>(); @@ -79,9 +79,9 @@ mod tests { " .trim(); - let ast = pgt_query::parse(input).unwrap().into_root().unwrap(); + let ast = pgls_query::parse(input).unwrap().into_root().unwrap(); let create_fn = match &ast { - pgt_query::NodeEnum::CreateFunctionStmt(stmt) => stmt, + pgls_query::NodeEnum::CreateFunctionStmt(stmt) => stmt, _ => panic!("Expected CreateFunctionStmt"), }; diff --git a/crates/pgt_query_macros/Cargo.toml b/crates/pgls_query_macros/Cargo.toml similarity index 92% rename from crates/pgt_query_macros/Cargo.toml rename to crates/pgls_query_macros/Cargo.toml index 0fcc52cf6..6a14d81a2 100644 --- a/crates/pgt_query_macros/Cargo.toml +++ b/crates/pgls_query_macros/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_query_macros" +name = "pgls_query_macros" repository.workspace = true version = "0.0.0" diff --git a/crates/pgt_query_macros/build.rs b/crates/pgls_query_macros/build.rs similarity index 100% rename from crates/pgt_query_macros/build.rs rename to crates/pgls_query_macros/build.rs diff --git a/crates/pgt_query_macros/src/iter_mut.rs b/crates/pgls_query_macros/src/iter_mut.rs similarity index 100% rename from crates/pgt_query_macros/src/iter_mut.rs rename to crates/pgls_query_macros/src/iter_mut.rs diff --git a/crates/pgt_query_macros/src/iter_ref.rs b/crates/pgls_query_macros/src/iter_ref.rs similarity index 100% rename from crates/pgt_query_macros/src/iter_ref.rs rename to crates/pgls_query_macros/src/iter_ref.rs diff --git a/crates/pgt_query_macros/src/lib.rs b/crates/pgls_query_macros/src/lib.rs similarity index 100% rename from crates/pgt_query_macros/src/lib.rs rename to crates/pgls_query_macros/src/lib.rs diff --git a/crates/pgt_query_macros/src/node_enum.rs b/crates/pgls_query_macros/src/node_enum.rs similarity index 100% rename from crates/pgt_query_macros/src/node_enum.rs rename to crates/pgls_query_macros/src/node_enum.rs diff --git a/crates/pgt_query_macros/src/node_mut.rs b/crates/pgls_query_macros/src/node_mut.rs similarity index 100% rename from crates/pgt_query_macros/src/node_mut.rs rename to crates/pgls_query_macros/src/node_mut.rs diff --git a/crates/pgt_query_macros/src/node_ref.rs b/crates/pgls_query_macros/src/node_ref.rs similarity index 100% rename from crates/pgt_query_macros/src/node_ref.rs rename to crates/pgls_query_macros/src/node_ref.rs diff --git a/crates/pgt_query_macros/src/node_structs.rs b/crates/pgls_query_macros/src/node_structs.rs similarity index 100% rename from crates/pgt_query_macros/src/node_structs.rs rename to crates/pgls_query_macros/src/node_structs.rs diff --git a/crates/pgt_query_macros/src/proto_analyser.rs b/crates/pgls_query_macros/src/proto_analyser.rs similarity index 100% rename from crates/pgt_query_macros/src/proto_analyser.rs rename to crates/pgls_query_macros/src/proto_analyser.rs diff --git a/crates/pgt_query_macros/vendor/17-latest/pg_query.proto b/crates/pgls_query_macros/vendor/17-latest/pg_query.proto similarity index 100% rename from crates/pgt_query_macros/vendor/17-latest/pg_query.proto rename to crates/pgls_query_macros/vendor/17-latest/pg_query.proto diff --git a/crates/pgls_schema_cache/Cargo.toml b/crates/pgls_schema_cache/Cargo.toml new file mode 100644 index 000000000..c4566929d --- /dev/null +++ b/crates/pgls_schema_cache/Cargo.toml @@ -0,0 +1,30 @@ +[package] +authors.workspace = true +categories.workspace = true +description = "" +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +name = "pgls_schema_cache" +repository.workspace = true +version = "0.0.0" + + +[dependencies] +anyhow.workspace = true +async-std = { version = "1.12.0" } +futures-util = "0.3.31" +pgls_console.workspace = true +pgls_diagnostics.workspace = true +serde.workspace = true +serde_json.workspace = true +sqlx.workspace = true +strum = { workspace = true } +tokio.workspace = true + +[dev-dependencies] +pgls_test_utils.workspace = true + +[lib] +doctest = false diff --git a/crates/pgt_schema_cache/src/columns.rs b/crates/pgls_schema_cache/src/columns.rs similarity index 99% rename from crates/pgt_schema_cache/src/columns.rs rename to crates/pgls_schema_cache/src/columns.rs index b08b1f3da..809eb271f 100644 --- a/crates/pgt_schema_cache/src/columns.rs +++ b/crates/pgls_schema_cache/src/columns.rs @@ -89,7 +89,7 @@ mod tests { use crate::{SchemaCache, columns::ColumnClassKind}; - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn loads_columns(test_db: PgPool) { let setup = r#" create table public.users ( diff --git a/crates/pgt_schema_cache/src/extensions.rs b/crates/pgls_schema_cache/src/extensions.rs similarity index 100% rename from crates/pgt_schema_cache/src/extensions.rs rename to crates/pgls_schema_cache/src/extensions.rs diff --git a/crates/pgt_schema_cache/src/functions.rs b/crates/pgls_schema_cache/src/functions.rs similarity index 99% rename from crates/pgt_schema_cache/src/functions.rs rename to crates/pgls_schema_cache/src/functions.rs index 4afaa76dd..959d6cb8a 100644 --- a/crates/pgt_schema_cache/src/functions.rs +++ b/crates/pgls_schema_cache/src/functions.rs @@ -151,7 +151,7 @@ mod tests { use crate::{Behavior, SchemaCache, functions::ProcKind}; - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn loads(pool: PgPool) { let setup = r#" create table coos ( diff --git a/crates/pgt_schema_cache/src/lib.rs b/crates/pgls_schema_cache/src/lib.rs similarity index 100% rename from crates/pgt_schema_cache/src/lib.rs rename to crates/pgls_schema_cache/src/lib.rs diff --git a/crates/pgt_schema_cache/src/policies.rs b/crates/pgls_schema_cache/src/policies.rs similarity index 99% rename from crates/pgt_schema_cache/src/policies.rs rename to crates/pgls_schema_cache/src/policies.rs index 8e2ee4d70..6461b8b6a 100644 --- a/crates/pgt_schema_cache/src/policies.rs +++ b/crates/pgls_schema_cache/src/policies.rs @@ -85,7 +85,7 @@ mod tests { use crate::{SchemaCache, policies::PolicyCommand}; - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn loads_policies(test_db: PgPool) { let setup = r#" create table public.users ( diff --git a/crates/pgt_schema_cache/src/queries/columns.sql b/crates/pgls_schema_cache/src/queries/columns.sql similarity index 100% rename from crates/pgt_schema_cache/src/queries/columns.sql rename to crates/pgls_schema_cache/src/queries/columns.sql diff --git a/crates/pgt_schema_cache/src/queries/extensions.sql b/crates/pgls_schema_cache/src/queries/extensions.sql similarity index 100% rename from crates/pgt_schema_cache/src/queries/extensions.sql rename to crates/pgls_schema_cache/src/queries/extensions.sql diff --git a/crates/pgt_schema_cache/src/queries/functions.sql b/crates/pgls_schema_cache/src/queries/functions.sql similarity index 100% rename from crates/pgt_schema_cache/src/queries/functions.sql rename to crates/pgls_schema_cache/src/queries/functions.sql diff --git a/crates/pgt_schema_cache/src/queries/policies.sql b/crates/pgls_schema_cache/src/queries/policies.sql similarity index 100% rename from crates/pgt_schema_cache/src/queries/policies.sql rename to crates/pgls_schema_cache/src/queries/policies.sql diff --git a/crates/pgt_schema_cache/src/queries/roles.sql b/crates/pgls_schema_cache/src/queries/roles.sql similarity index 100% rename from crates/pgt_schema_cache/src/queries/roles.sql rename to crates/pgls_schema_cache/src/queries/roles.sql diff --git a/crates/pgt_schema_cache/src/queries/schemas.sql b/crates/pgls_schema_cache/src/queries/schemas.sql similarity index 100% rename from crates/pgt_schema_cache/src/queries/schemas.sql rename to crates/pgls_schema_cache/src/queries/schemas.sql diff --git a/crates/pgt_schema_cache/src/queries/tables.sql b/crates/pgls_schema_cache/src/queries/tables.sql similarity index 100% rename from crates/pgt_schema_cache/src/queries/tables.sql rename to crates/pgls_schema_cache/src/queries/tables.sql diff --git a/crates/pgt_schema_cache/src/queries/triggers.sql b/crates/pgls_schema_cache/src/queries/triggers.sql similarity index 100% rename from crates/pgt_schema_cache/src/queries/triggers.sql rename to crates/pgls_schema_cache/src/queries/triggers.sql diff --git a/crates/pgt_schema_cache/src/queries/types.sql b/crates/pgls_schema_cache/src/queries/types.sql similarity index 100% rename from crates/pgt_schema_cache/src/queries/types.sql rename to crates/pgls_schema_cache/src/queries/types.sql diff --git a/crates/pgt_schema_cache/src/queries/versions.sql b/crates/pgls_schema_cache/src/queries/versions.sql similarity index 100% rename from crates/pgt_schema_cache/src/queries/versions.sql rename to crates/pgls_schema_cache/src/queries/versions.sql diff --git a/crates/pgt_schema_cache/src/roles.rs b/crates/pgls_schema_cache/src/roles.rs similarity index 94% rename from crates/pgt_schema_cache/src/roles.rs rename to crates/pgls_schema_cache/src/roles.rs index 76bf0ff47..cb4d8b24d 100644 --- a/crates/pgt_schema_cache/src/roles.rs +++ b/crates/pgls_schema_cache/src/roles.rs @@ -31,7 +31,7 @@ mod tests { use crate::SchemaCache; - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn loads_roles(test_db: PgPool) { let cache = SchemaCache::load(&test_db) .await @@ -58,7 +58,7 @@ mod tests { assert!(!login_role.can_bypass_rls); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn loads_comments(test_db: PgPool) { let setup = r#" comment on role owner is 'test'; diff --git a/crates/pgt_schema_cache/src/schema_cache.rs b/crates/pgls_schema_cache/src/schema_cache.rs similarity index 98% rename from crates/pgt_schema_cache/src/schema_cache.rs rename to crates/pgls_schema_cache/src/schema_cache.rs index 227b49883..36e668c2d 100644 --- a/crates/pgt_schema_cache/src/schema_cache.rs +++ b/crates/pgls_schema_cache/src/schema_cache.rs @@ -169,7 +169,7 @@ mod tests { use crate::SchemaCache; - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn it_loads(test_db: PgPool) { SchemaCache::load(&test_db) .await diff --git a/crates/pgt_schema_cache/src/schemas.rs b/crates/pgls_schema_cache/src/schemas.rs similarity index 100% rename from crates/pgt_schema_cache/src/schemas.rs rename to crates/pgls_schema_cache/src/schemas.rs diff --git a/crates/pgt_schema_cache/src/tables.rs b/crates/pgls_schema_cache/src/tables.rs similarity index 96% rename from crates/pgt_schema_cache/src/tables.rs rename to crates/pgls_schema_cache/src/tables.rs index 16b86c54a..ce0c79f4c 100644 --- a/crates/pgt_schema_cache/src/tables.rs +++ b/crates/pgls_schema_cache/src/tables.rs @@ -83,7 +83,7 @@ mod tests { use crate::{SchemaCache, tables::TableKind}; - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn includes_views_in_query(test_db: PgPool) { let setup = r#" create table public.base_table ( @@ -114,7 +114,7 @@ mod tests { assert_eq!(view.schema, "public"); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn includes_materialized_views_in_query(test_db: PgPool) { let setup = r#" create table public.base_table ( diff --git a/crates/pgt_schema_cache/src/triggers.rs b/crates/pgls_schema_cache/src/triggers.rs similarity index 98% rename from crates/pgt_schema_cache/src/triggers.rs rename to crates/pgls_schema_cache/src/triggers.rs index d0a4788a0..0e731860e 100644 --- a/crates/pgt_schema_cache/src/triggers.rs +++ b/crates/pgls_schema_cache/src/triggers.rs @@ -137,7 +137,7 @@ mod tests { triggers::{TriggerAffected, TriggerEvent, TriggerTiming}, }; - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn loads_triggers(test_db: PgPool) { let setup = r#" create table public.users ( @@ -220,7 +220,7 @@ mod tests { assert_eq!(delete_trigger.proc_name, "log_user_insert"); } - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn loads_instead_and_truncate_triggers(test_db: PgPool) { let setup = r#" create table public.docs ( diff --git a/crates/pgt_schema_cache/src/types.rs b/crates/pgls_schema_cache/src/types.rs similarity index 100% rename from crates/pgt_schema_cache/src/types.rs rename to crates/pgls_schema_cache/src/types.rs diff --git a/crates/pgt_schema_cache/src/versions.rs b/crates/pgls_schema_cache/src/versions.rs similarity index 100% rename from crates/pgt_schema_cache/src/versions.rs rename to crates/pgls_schema_cache/src/versions.rs diff --git a/crates/pgt_statement_splitter/Cargo.toml b/crates/pgls_statement_splitter/Cargo.toml similarity index 63% rename from crates/pgt_statement_splitter/Cargo.toml rename to crates/pgls_statement_splitter/Cargo.toml index 45a42ebc6..2ff3c90e1 100644 --- a/crates/pgt_statement_splitter/Cargo.toml +++ b/crates/pgls_statement_splitter/Cargo.toml @@ -6,17 +6,17 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_statement_splitter" +name = "pgls_statement_splitter" repository.workspace = true version = "0.0.0" [dependencies] -pgt_diagnostics = { workspace = true } -pgt_lexer.workspace = true -pgt_query.workspace = true -pgt_text_size.workspace = true -regex.workspace = true +pgls_diagnostics = { workspace = true } +pgls_lexer.workspace = true +pgls_query.workspace = true +pgls_text_size.workspace = true +regex.workspace = true [dev-dependencies] criterion = "0.3" diff --git a/crates/pgt_statement_splitter/benches/splitter.rs b/crates/pgls_statement_splitter/benches/splitter.rs similarity index 98% rename from crates/pgt_statement_splitter/benches/splitter.rs rename to crates/pgls_statement_splitter/benches/splitter.rs index e7cdeeef6..99bf2ad5f 100644 --- a/crates/pgt_statement_splitter/benches/splitter.rs +++ b/crates/pgls_statement_splitter/benches/splitter.rs @@ -1,5 +1,5 @@ use criterion::{Criterion, black_box, criterion_group, criterion_main}; -use pgt_statement_splitter::split; +use pgls_statement_splitter::split; pub fn splitter_benchmark(c: &mut Criterion) { let large_statement = r#"with diff --git a/crates/pgt_statement_splitter/src/diagnostics.rs b/crates/pgls_statement_splitter/src/diagnostics.rs similarity index 90% rename from crates/pgt_statement_splitter/src/diagnostics.rs rename to crates/pgls_statement_splitter/src/diagnostics.rs index d543d4e51..c929ad3b6 100644 --- a/crates/pgt_statement_splitter/src/diagnostics.rs +++ b/crates/pgls_statement_splitter/src/diagnostics.rs @@ -1,6 +1,6 @@ -use pgt_diagnostics::{Diagnostic, MessageAndDescription}; -use pgt_lexer::{LexDiagnostic, Lexed}; -use pgt_text_size::TextRange; +use pgls_diagnostics::{Diagnostic, MessageAndDescription}; +use pgls_lexer::{LexDiagnostic, Lexed}; +use pgls_text_size::TextRange; use crate::splitter::SplitError; diff --git a/crates/pgt_statement_splitter/src/lib.rs b/crates/pgls_statement_splitter/src/lib.rs similarity index 99% rename from crates/pgt_statement_splitter/src/lib.rs rename to crates/pgls_statement_splitter/src/lib.rs index 6fb81c092..03875d2e6 100644 --- a/crates/pgt_statement_splitter/src/lib.rs +++ b/crates/pgls_statement_splitter/src/lib.rs @@ -5,8 +5,8 @@ pub mod diagnostics; mod splitter; use diagnostics::SplitDiagnostic; -use pgt_lexer::Lexer; -use pgt_text_size::TextRange; +use pgls_lexer::Lexer; +use pgls_text_size::TextRange; use splitter::{Splitter, source}; pub struct SplitResult { @@ -42,8 +42,8 @@ pub fn split(sql: &str) -> SplitResult { mod tests { use diagnostics::SplitDiagnostic; use ntest::timeout; - use pgt_lexer::SyntaxKind; - use pgt_text_size::TextRange; + use pgls_lexer::SyntaxKind; + use pgls_text_size::TextRange; use super::*; diff --git a/crates/pgt_statement_splitter/src/splitter.rs b/crates/pgls_statement_splitter/src/splitter.rs similarity index 98% rename from crates/pgt_statement_splitter/src/splitter.rs rename to crates/pgls_statement_splitter/src/splitter.rs index 9061999ea..842fffe2f 100644 --- a/crates/pgt_statement_splitter/src/splitter.rs +++ b/crates/pgls_statement_splitter/src/splitter.rs @@ -5,8 +5,8 @@ mod dml; pub use common::source; -use pgt_lexer::{Lexed, SyntaxKind}; -use pgt_text_size::TextRange; +use pgls_lexer::{Lexed, SyntaxKind}; +use pgls_text_size::TextRange; pub struct SplitResult { pub ranges: Vec, diff --git a/crates/pgt_statement_splitter/src/splitter/common.rs b/crates/pgls_statement_splitter/src/splitter/common.rs similarity index 99% rename from crates/pgt_statement_splitter/src/splitter/common.rs rename to crates/pgls_statement_splitter/src/splitter/common.rs index 54db04e8b..0c35bd0a9 100644 --- a/crates/pgt_statement_splitter/src/splitter/common.rs +++ b/crates/pgls_statement_splitter/src/splitter/common.rs @@ -1,5 +1,5 @@ use super::TRIVIA_TOKENS; -use pgt_lexer::SyntaxKind; +use pgls_lexer::SyntaxKind; use super::{ Splitter, diff --git a/crates/pgt_statement_splitter/src/splitter/data.rs b/crates/pgls_statement_splitter/src/splitter/data.rs similarity index 96% rename from crates/pgt_statement_splitter/src/splitter/data.rs rename to crates/pgls_statement_splitter/src/splitter/data.rs index 0827484be..0ae909658 100644 --- a/crates/pgt_statement_splitter/src/splitter/data.rs +++ b/crates/pgls_statement_splitter/src/splitter/data.rs @@ -1,4 +1,4 @@ -use pgt_lexer::SyntaxKind; +use pgls_lexer::SyntaxKind; // All tokens listed here must be explicitly handled in the `unknown` function to ensure that we do // not break in the middle of another statement that contains a statement start token. diff --git a/crates/pgt_statement_splitter/src/splitter/ddl.rs b/crates/pgls_statement_splitter/src/splitter/ddl.rs similarity index 91% rename from crates/pgt_statement_splitter/src/splitter/ddl.rs rename to crates/pgls_statement_splitter/src/splitter/ddl.rs index 449288aab..75c9b3f10 100644 --- a/crates/pgt_statement_splitter/src/splitter/ddl.rs +++ b/crates/pgls_statement_splitter/src/splitter/ddl.rs @@ -1,4 +1,4 @@ -use pgt_lexer::SyntaxKind; +use pgls_lexer::SyntaxKind; use super::{Splitter, common::unknown}; diff --git a/crates/pgt_statement_splitter/src/splitter/dml.rs b/crates/pgls_statement_splitter/src/splitter/dml.rs similarity index 97% rename from crates/pgt_statement_splitter/src/splitter/dml.rs rename to crates/pgls_statement_splitter/src/splitter/dml.rs index acfbebfc9..a35aeafbd 100644 --- a/crates/pgt_statement_splitter/src/splitter/dml.rs +++ b/crates/pgls_statement_splitter/src/splitter/dml.rs @@ -1,4 +1,4 @@ -use pgt_lexer::SyntaxKind; +use pgls_lexer::SyntaxKind; use super::{ Splitter, diff --git a/crates/pgt_statement_splitter/tests/data/grant_statements__4.sql b/crates/pgls_statement_splitter/tests/data/grant_statements__4.sql similarity index 100% rename from crates/pgt_statement_splitter/tests/data/grant_statements__4.sql rename to crates/pgls_statement_splitter/tests/data/grant_statements__4.sql diff --git a/crates/pgt_statement_splitter/tests/data/on_conflict_do_update__1.sql b/crates/pgls_statement_splitter/tests/data/on_conflict_do_update__1.sql similarity index 100% rename from crates/pgt_statement_splitter/tests/data/on_conflict_do_update__1.sql rename to crates/pgls_statement_splitter/tests/data/on_conflict_do_update__1.sql diff --git a/crates/pgt_statement_splitter/tests/data/simple_select__4.sql b/crates/pgls_statement_splitter/tests/data/simple_select__4.sql similarity index 100% rename from crates/pgt_statement_splitter/tests/data/simple_select__4.sql rename to crates/pgls_statement_splitter/tests/data/simple_select__4.sql diff --git a/crates/pgt_statement_splitter/tests/data/simple_union__4.sql b/crates/pgls_statement_splitter/tests/data/simple_union__4.sql similarity index 100% rename from crates/pgt_statement_splitter/tests/data/simple_union__4.sql rename to crates/pgls_statement_splitter/tests/data/simple_union__4.sql diff --git a/crates/pgt_statement_splitter/tests/data/with_comments__4.sql b/crates/pgls_statement_splitter/tests/data/with_comments__4.sql similarity index 100% rename from crates/pgt_statement_splitter/tests/data/with_comments__4.sql rename to crates/pgls_statement_splitter/tests/data/with_comments__4.sql diff --git a/crates/pgt_statement_splitter/tests/statement_splitter_tests.rs b/crates/pgls_statement_splitter/tests/statement_splitter_tests.rs similarity index 93% rename from crates/pgt_statement_splitter/tests/statement_splitter_tests.rs rename to crates/pgls_statement_splitter/tests/statement_splitter_tests.rs index a4cf32599..b459f7dea 100644 --- a/crates/pgt_statement_splitter/tests/statement_splitter_tests.rs +++ b/crates/pgls_statement_splitter/tests/statement_splitter_tests.rs @@ -22,7 +22,7 @@ fn test_statement_splitter() { let contents = fs::read_to_string(&path).unwrap(); - let split = pgt_statement_splitter::split(&contents); + let split = pgls_statement_splitter::split(&contents); assert_eq!( split.ranges.len(), diff --git a/crates/pgt_suppressions/Cargo.toml b/crates/pgls_suppressions/Cargo.toml similarity index 66% rename from crates/pgt_suppressions/Cargo.toml rename to crates/pgls_suppressions/Cargo.toml index ee723b3bf..bb92035f3 100644 --- a/crates/pgt_suppressions/Cargo.toml +++ b/crates/pgls_suppressions/Cargo.toml @@ -7,12 +7,12 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_suppressions" +name = "pgls_suppressions" repository.workspace = true version = "0.0.0" [dependencies] -pgt_analyse = { workspace = true } -pgt_diagnostics = { workspace = true } -pgt_text_size = { workspace = true } -tracing = { workspace = true } +pgls_analyse = { workspace = true } +pgls_diagnostics = { workspace = true } +pgls_text_size = { workspace = true } +tracing = { workspace = true } diff --git a/crates/pgt_suppressions/src/lib.rs b/crates/pgls_suppressions/src/lib.rs similarity index 97% rename from crates/pgt_suppressions/src/lib.rs rename to crates/pgls_suppressions/src/lib.rs index 2577ea412..efdf7a034 100644 --- a/crates/pgt_suppressions/src/lib.rs +++ b/crates/pgls_suppressions/src/lib.rs @@ -2,8 +2,8 @@ use std::collections::HashMap; pub mod parser; pub mod suppression; -use pgt_analyse::RuleFilter; -use pgt_diagnostics::{Diagnostic, MessageAndDescription}; +use pgls_analyse::RuleFilter; +use pgls_diagnostics::{Diagnostic, MessageAndDescription}; pub mod line_index; @@ -217,8 +217,8 @@ impl Suppressions { #[cfg(test)] mod tests { - use pgt_diagnostics::{Diagnostic, MessageAndDescription}; - use pgt_text_size::TextRange; + use pgls_diagnostics::{Diagnostic, MessageAndDescription}; + use pgls_text_size::TextRange; use crate::suppression::SuppressionDiagnostic; @@ -308,7 +308,7 @@ mod tests { let suppressions = super::Suppressions::from(doc); let disabled_diagnostics = suppressions.get_disabled_diagnostic_suppressions_as_errors(&[ - pgt_analyse::RuleFilter::Group("safety"), + pgls_analyse::RuleFilter::Group("safety"), ]); assert_eq!(disabled_diagnostics.len(), 1); diff --git a/crates/pgt_suppressions/src/line_index.rs b/crates/pgls_suppressions/src/line_index.rs similarity index 87% rename from crates/pgt_suppressions/src/line_index.rs rename to crates/pgls_suppressions/src/line_index.rs index 16af72dde..ca71e235d 100644 --- a/crates/pgt_suppressions/src/line_index.rs +++ b/crates/pgls_suppressions/src/line_index.rs @@ -1,8 +1,8 @@ -use pgt_text_size::TextSize; +use pgls_text_size::TextSize; #[derive(Debug, Default, Clone)] pub(crate) struct LineIndex { - line_offset: Vec, + line_offset: Vec, } impl LineIndex { @@ -23,7 +23,7 @@ impl LineIndex { Self { line_offset } } - pub fn offset_for_line(&self, idx: usize) -> Option<&pgt_text_size::TextSize> { + pub fn offset_for_line(&self, idx: usize) -> Option<&pgls_text_size::TextSize> { self.line_offset.get(idx) } diff --git a/crates/pgt_suppressions/src/parser.rs b/crates/pgls_suppressions/src/parser.rs similarity index 99% rename from crates/pgt_suppressions/src/parser.rs rename to crates/pgls_suppressions/src/parser.rs index 663e52fef..a6828f022 100644 --- a/crates/pgt_suppressions/src/parser.rs +++ b/crates/pgls_suppressions/src/parser.rs @@ -3,8 +3,8 @@ use std::{ str::Lines, }; -use pgt_diagnostics::MessageAndDescription; -use pgt_text_size::TextRange; +use pgls_diagnostics::MessageAndDescription; +use pgls_text_size::TextRange; use crate::{ Suppressions, diff --git a/crates/pgt_suppressions/src/suppression.rs b/crates/pgls_suppressions/src/suppression.rs similarity index 97% rename from crates/pgt_suppressions/src/suppression.rs rename to crates/pgls_suppressions/src/suppression.rs index 6ebaf25c8..76c8bd277 100644 --- a/crates/pgt_suppressions/src/suppression.rs +++ b/crates/pgls_suppressions/src/suppression.rs @@ -1,6 +1,6 @@ -use pgt_analyse::RuleFilter; -use pgt_diagnostics::{Category, Diagnostic, MessageAndDescription}; -use pgt_text_size::{TextRange, TextSize}; +use pgls_analyse::RuleFilter; +use pgls_diagnostics::{Category, Diagnostic, MessageAndDescription}; +use pgls_text_size::{TextRange, TextSize}; /// A specialized diagnostic for the typechecker. /// @@ -29,7 +29,7 @@ pub(crate) enum SuppressionKind { /// The format of a rule specifier string is `(/(/))`. /// /// `RuleSpecifier` can only be constructed from a `&str` that matches a valid -/// [pgt_diagnostics::Category]. +/// [pgls_diagnostics::Category]. pub(crate) enum RuleSpecifier { Category(String), Group(String, String), @@ -129,7 +129,7 @@ impl Suppression { let full_offset = *offset + TextSize::new(leading_whitespace_offset.try_into().unwrap()); let span = TextRange::new( full_offset, - pgt_text_size::TextSize::new(trimmed.len().try_into().unwrap()) + full_offset, + pgls_text_size::TextSize::new(trimmed.len().try_into().unwrap()) + full_offset, ); let (line, explanation) = match trimmed.split_once(':') { @@ -234,7 +234,7 @@ pub(crate) struct RangeSuppression { #[cfg(test)] mod tests { use super::*; - use pgt_text_size::{TextRange, TextSize}; + use pgls_text_size::{TextRange, TextSize}; #[test] fn test_suppression_from_line_rule() { @@ -424,7 +424,7 @@ mod tests { #[test] fn test_rule_specifier_is_disabled() { - use pgt_analyse::RuleFilter; + use pgls_analyse::RuleFilter; // Group filter disables all rules in that group let spec = RuleSpecifier::Rule( diff --git a/crates/pgt_test_macros/Cargo.toml b/crates/pgls_test_macros/Cargo.toml similarity index 92% rename from crates/pgt_test_macros/Cargo.toml rename to crates/pgls_test_macros/Cargo.toml index 7f1f8b1a5..9d4a7795a 100644 --- a/crates/pgt_test_macros/Cargo.toml +++ b/crates/pgls_test_macros/Cargo.toml @@ -7,7 +7,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_test_macros" +name = "pgls_test_macros" repository.workspace = true version = "0.0.0" diff --git a/crates/pgt_test_macros/README.md b/crates/pgls_test_macros/README.md similarity index 100% rename from crates/pgt_test_macros/README.md rename to crates/pgls_test_macros/README.md diff --git a/crates/pgt_test_macros/src/lib.rs b/crates/pgls_test_macros/src/lib.rs similarity index 100% rename from crates/pgt_test_macros/src/lib.rs rename to crates/pgls_test_macros/src/lib.rs diff --git a/crates/pgt_test_utils/Cargo.toml b/crates/pgls_test_utils/Cargo.toml similarity index 75% rename from crates/pgt_test_utils/Cargo.toml rename to crates/pgls_test_utils/Cargo.toml index eda5a823e..9df568140 100644 --- a/crates/pgt_test_utils/Cargo.toml +++ b/crates/pgls_test_utils/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_test_utils" +name = "pgls_test_utils" repository.workspace = true version = "0.0.0" @@ -21,6 +21,6 @@ clap = { version = "4.5.23", features = ["derive"] } dotenv = "0.15.0" uuid = { version = "1.11.0", features = ["v4"] } -pgt_treesitter_grammar.workspace = true -sqlx.workspace = true -tree-sitter.workspace = true +pgls_treesitter_grammar.workspace = true +sqlx.workspace = true +tree-sitter.workspace = true diff --git a/crates/pgt_test_utils/src/bin/tree_print.rs b/crates/pgls_test_utils/src/bin/tree_print.rs similarity index 94% rename from crates/pgt_test_utils/src/bin/tree_print.rs rename to crates/pgls_test_utils/src/bin/tree_print.rs index f9e9a2ba0..5a2ee1f53 100644 --- a/crates/pgt_test_utils/src/bin/tree_print.rs +++ b/crates/pgls_test_utils/src/bin/tree_print.rs @@ -18,7 +18,7 @@ fn main() { let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .expect("Setting Language failed."); let tree = parser diff --git a/crates/pgt_test_utils/src/lib.rs b/crates/pgls_test_utils/src/lib.rs similarity index 100% rename from crates/pgt_test_utils/src/lib.rs rename to crates/pgls_test_utils/src/lib.rs diff --git a/crates/pgt_test_utils/testdb_migrations/0001_setup-roles.sql b/crates/pgls_test_utils/testdb_migrations/0001_setup-roles.sql similarity index 100% rename from crates/pgt_test_utils/testdb_migrations/0001_setup-roles.sql rename to crates/pgls_test_utils/testdb_migrations/0001_setup-roles.sql diff --git a/crates/pgls_text_edit/Cargo.toml b/crates/pgls_text_edit/Cargo.toml new file mode 100644 index 000000000..00954f8cd --- /dev/null +++ b/crates/pgls_text_edit/Cargo.toml @@ -0,0 +1,27 @@ +[package] +authors.workspace = true +categories.workspace = true +description = "" +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +name = "pgls_text_edit" +repository.workspace = true +version = "0.0.0" + + +[dependencies] +pgls_text_size = { workspace = true } +schemars = { workspace = true, optional = true } +serde = { workspace = true, features = ["derive"], optional = true } +similar = { workspace = true, features = ["unicode"] } + +[features] +schema = ["dep:schemars", "pgls_text_size/schema"] +serde = ["dep:serde", "pgls_text_size/serde"] + +[dev-dependencies] + +[lib] +doctest = false diff --git a/crates/pgt_text_edit/src/lib.rs b/crates/pgls_text_edit/src/lib.rs similarity index 99% rename from crates/pgt_text_edit/src/lib.rs rename to crates/pgls_text_edit/src/lib.rs index ba7f3c846..f8a3a4e85 100644 --- a/crates/pgt_text_edit/src/lib.rs +++ b/crates/pgls_text_edit/src/lib.rs @@ -10,7 +10,7 @@ use std::{cmp::Ordering, num::NonZeroU32}; -use pgt_text_size::{TextRange, TextSize}; +use pgls_text_size::{TextRange, TextSize}; pub use similar::ChangeTag; use similar::{TextDiff, utils::TextDiffRemapper}; diff --git a/crates/pgt_text_size/Cargo.toml b/crates/pgls_text_size/Cargo.toml similarity index 94% rename from crates/pgt_text_size/Cargo.toml rename to crates/pgls_text_size/Cargo.toml index 8e897832a..366ff7062 100644 --- a/crates/pgt_text_size/Cargo.toml +++ b/crates/pgls_text_size/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_text_size" +name = "pgls_text_size" repository.workspace = true version = "0.0.0" diff --git a/crates/pgt_text_size/src/lib.rs b/crates/pgls_text_size/src/lib.rs similarity index 100% rename from crates/pgt_text_size/src/lib.rs rename to crates/pgls_text_size/src/lib.rs diff --git a/crates/pgt_text_size/src/range.rs b/crates/pgls_text_size/src/range.rs similarity index 96% rename from crates/pgt_text_size/src/range.rs rename to crates/pgls_text_size/src/range.rs index baab91e9f..339cc9510 100644 --- a/crates/pgt_text_size/src/range.rs +++ b/crates/pgls_text_size/src/range.rs @@ -34,7 +34,7 @@ impl TextRange { /// # Examples /// /// ```rust - /// # use pgt_text_size::*; + /// # use pgls_text_size::*; /// let start = TextSize::from(5); /// let end = TextSize::from(10); /// let range = TextRange::new(start, end); @@ -54,7 +54,7 @@ impl TextRange { /// # Examples /// /// ```rust - /// # use pgt_text_size::*; + /// # use pgls_text_size::*; /// let text = "0123456789"; /// /// let offset = TextSize::from(2); @@ -74,7 +74,7 @@ impl TextRange { /// # Examples /// /// ```rust - /// # use pgt_text_size::*; + /// # use pgls_text_size::*; /// let point: TextSize; /// # point = TextSize::from(3); /// let range = TextRange::empty(point); @@ -94,7 +94,7 @@ impl TextRange { /// # Examples /// /// ```rust - /// # use pgt_text_size::*; + /// # use pgls_text_size::*; /// let point: TextSize; /// # point = TextSize::from(12); /// let range = TextRange::up_to(point); @@ -152,7 +152,7 @@ impl TextRange { /// # Examples /// /// ```rust - /// # use pgt_text_size::*; + /// # use pgls_text_size::*; /// let (start, end): (TextSize, TextSize); /// # start = 10.into(); end = 20.into(); /// let range = TextRange::new(start, end); @@ -171,7 +171,7 @@ impl TextRange { /// # Examples /// /// ```rust - /// # use pgt_text_size::*; + /// # use pgls_text_size::*; /// let (start, end): (TextSize, TextSize); /// # start = 10.into(); end = 20.into(); /// let range = TextRange::new(start, end); @@ -188,7 +188,7 @@ impl TextRange { /// # Examples /// /// ```rust - /// # use pgt_text_size::*; + /// # use pgls_text_size::*; /// let larger = TextRange::new(0.into(), 20.into()); /// let smaller = TextRange::new(5.into(), 15.into()); /// assert!(larger.contains_range(smaller)); @@ -209,7 +209,7 @@ impl TextRange { /// # Examples /// /// ```rust - /// # use pgt_text_size::*; + /// # use pgls_text_size::*; /// assert_eq!( /// TextRange::intersect( /// TextRange::new(0.into(), 10.into()), @@ -233,7 +233,7 @@ impl TextRange { /// # Examples /// /// ```rust - /// # use pgt_text_size::*; + /// # use pgls_text_size::*; /// assert_eq!( /// TextRange::cover( /// TextRange::new(0.into(), 5.into()), @@ -254,7 +254,7 @@ impl TextRange { /// # Examples /// /// ```rust - /// # use pgt_text_size::*; + /// # use pgls_text_size::*; /// assert_eq!( /// TextRange::empty(0.into()).cover_offset(20.into()), /// TextRange::new(0.into(), 20.into()), @@ -286,7 +286,7 @@ impl TextRange { /// # Examples /// /// ```rust - /// # use pgt_text_size::*; + /// # use pgls_text_size::*; /// assert_eq!( /// TextRange::new(2.into(), 4.into()).checked_expand_end(16.into()).unwrap(), /// TextRange::new(2.into(), 20.into()), @@ -306,7 +306,7 @@ impl TextRange { /// # Examples /// /// ```rust - /// # use pgt_text_size::*; + /// # use pgls_text_size::*; /// assert_eq!( /// TextRange::new(2.into(), 12.into()).checked_expand_start(4.into()).unwrap(), /// TextRange::new(6.into(), 12.into()), @@ -358,7 +358,7 @@ impl TextRange { /// # Examples /// /// ``` - /// # use pgt_text_size::*; + /// # use pgls_text_size::*; /// # use std::cmp::Ordering; /// /// let a = TextRange::new(0.into(), 3.into()); diff --git a/crates/pgt_text_size/src/schemars_impls.rs b/crates/pgls_text_size/src/schemars_impls.rs similarity index 100% rename from crates/pgt_text_size/src/schemars_impls.rs rename to crates/pgls_text_size/src/schemars_impls.rs diff --git a/crates/pgt_text_size/src/serde_impls.rs b/crates/pgls_text_size/src/serde_impls.rs similarity index 100% rename from crates/pgt_text_size/src/serde_impls.rs rename to crates/pgls_text_size/src/serde_impls.rs diff --git a/crates/pgt_text_size/src/size.rs b/crates/pgls_text_size/src/size.rs similarity index 99% rename from crates/pgt_text_size/src/size.rs rename to crates/pgls_text_size/src/size.rs index 1082485e7..b83f7f623 100644 --- a/crates/pgt_text_size/src/size.rs +++ b/crates/pgls_text_size/src/size.rs @@ -52,7 +52,7 @@ impl TextSize { /// # Examples /// /// ```rust - /// # use pgt_text_size::*; + /// # use pgls_text_size::*; /// let char_size = TextSize::of('🦀'); /// assert_eq!(char_size, TextSize::from(4)); /// diff --git a/crates/pgt_text_size/src/traits.rs b/crates/pgls_text_size/src/traits.rs similarity index 100% rename from crates/pgt_text_size/src/traits.rs rename to crates/pgls_text_size/src/traits.rs diff --git a/crates/pgt_text_size/tests/auto_traits.rs b/crates/pgls_text_size/tests/auto_traits.rs similarity index 95% rename from crates/pgt_text_size/tests/auto_traits.rs rename to crates/pgls_text_size/tests/auto_traits.rs index b3a11a753..21aecf088 100644 --- a/crates/pgt_text_size/tests/auto_traits.rs +++ b/crates/pgls_text_size/tests/auto_traits.rs @@ -1,5 +1,5 @@ use { - pgt_text_size::*, + pgls_text_size::*, static_assertions::*, std::{ fmt::Debug, diff --git a/crates/pgt_text_size/tests/constructors.rs b/crates/pgls_text_size/tests/constructors.rs similarity index 93% rename from crates/pgt_text_size/tests/constructors.rs rename to crates/pgls_text_size/tests/constructors.rs index e2b66295f..2f65f8853 100644 --- a/crates/pgt_text_size/tests/constructors.rs +++ b/crates/pgls_text_size/tests/constructors.rs @@ -1,4 +1,4 @@ -use pgt_text_size::TextSize; +use pgls_text_size::TextSize; #[derive(Copy, Clone)] struct BadRope<'a>(&'a [&'a str]); diff --git a/crates/pgt_text_size/tests/indexing.rs b/crates/pgls_text_size/tests/indexing.rs similarity index 82% rename from crates/pgt_text_size/tests/indexing.rs rename to crates/pgls_text_size/tests/indexing.rs index 286884f47..5f28415d5 100644 --- a/crates/pgt_text_size/tests/indexing.rs +++ b/crates/pgls_text_size/tests/indexing.rs @@ -1,4 +1,4 @@ -use pgt_text_size::*; +use pgls_text_size::*; #[test] fn main() { diff --git a/crates/pgt_text_size/tests/main.rs b/crates/pgls_text_size/tests/main.rs similarity index 98% rename from crates/pgt_text_size/tests/main.rs rename to crates/pgls_text_size/tests/main.rs index 1f84ce0e1..aa6345d78 100644 --- a/crates/pgt_text_size/tests/main.rs +++ b/crates/pgls_text_size/tests/main.rs @@ -1,4 +1,4 @@ -use {pgt_text_size::*, std::ops}; +use {pgls_text_size::*, std::ops}; fn size(x: u32) -> TextSize { TextSize::from(x) diff --git a/crates/pgt_text_size/tests/serde.rs b/crates/pgls_text_size/tests/serde.rs similarity index 97% rename from crates/pgt_text_size/tests/serde.rs rename to crates/pgls_text_size/tests/serde.rs index 4eaf366d8..bcd64cfe3 100644 --- a/crates/pgt_text_size/tests/serde.rs +++ b/crates/pgls_text_size/tests/serde.rs @@ -1,4 +1,4 @@ -use {pgt_text_size::*, serde_test::*, std::ops}; +use {pgls_text_size::*, serde_test::*, std::ops}; fn size(x: u32) -> TextSize { TextSize::from(x) diff --git a/crates/pgt_tokenizer/Cargo.toml b/crates/pgls_tokenizer/Cargo.toml similarity index 89% rename from crates/pgt_tokenizer/Cargo.toml rename to crates/pgls_tokenizer/Cargo.toml index 9cd4bf5e8..c1beb51c3 100644 --- a/crates/pgt_tokenizer/Cargo.toml +++ b/crates/pgls_tokenizer/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_tokenizer" +name = "pgls_tokenizer" repository.workspace = true version = "0.0.0" diff --git a/crates/pgt_tokenizer/README.md b/crates/pgls_tokenizer/README.md similarity index 100% rename from crates/pgt_tokenizer/README.md rename to crates/pgls_tokenizer/README.md diff --git a/crates/pgt_tokenizer/src/cursor.rs b/crates/pgls_tokenizer/src/cursor.rs similarity index 100% rename from crates/pgt_tokenizer/src/cursor.rs rename to crates/pgls_tokenizer/src/cursor.rs diff --git a/crates/pgt_tokenizer/src/lib.rs b/crates/pgls_tokenizer/src/lib.rs similarity index 100% rename from crates/pgt_tokenizer/src/lib.rs rename to crates/pgls_tokenizer/src/lib.rs diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__bitstring.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__bitstring.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__bitstring.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__bitstring.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__block_comment.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__block_comment.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__block_comment.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__block_comment.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__block_comment_unterminated.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__block_comment_unterminated.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__block_comment_unterminated.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__block_comment_unterminated.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__dollar_quote_mismatch_tags_complex.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__dollar_quote_mismatch_tags_complex.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__dollar_quote_mismatch_tags_complex.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__dollar_quote_mismatch_tags_complex.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__dollar_quote_mismatch_tags_simple.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__dollar_quote_mismatch_tags_simple.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__dollar_quote_mismatch_tags_simple.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__dollar_quote_mismatch_tags_simple.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__dollar_quoting.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__dollar_quoting.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__dollar_quoting.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__dollar_quoting.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__dollar_strings_part2.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__dollar_strings_part2.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__dollar_strings_part2.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__dollar_strings_part2.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__graphile_named_param.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__graphile_named_param.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__graphile_named_param.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__graphile_named_param.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__lex_statement.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__lex_statement.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__lex_statement.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__lex_statement.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__line_comment.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__line_comment.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__line_comment.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__line_comment.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__line_comment_whitespace.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__line_comment_whitespace.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__line_comment_whitespace.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__line_comment_whitespace.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_at.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_at.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_at.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_at.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_colon_identifier.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_colon_identifier.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_colon_identifier.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_colon_identifier.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_colon_raw.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_colon_raw.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_colon_raw.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_colon_raw.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_colon_raw_vs_cast.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_colon_raw_vs_cast.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_colon_raw_vs_cast.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_colon_raw_vs_cast.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_colon_string.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_colon_string.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_colon_string.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_colon_string.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_dollar_raw.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_dollar_raw.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_dollar_raw.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__named_param_dollar_raw.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__numeric.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__numeric.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__numeric.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__numeric.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__numeric_non_decimal.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__numeric_non_decimal.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__numeric_non_decimal.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__numeric_non_decimal.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__numeric_with_seperators.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__numeric_with_seperators.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__numeric_with_seperators.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__numeric_with_seperators.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__params.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__params.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__params.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__params.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__quoted_ident.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__quoted_ident.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__quoted_ident.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__quoted_ident.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__quoted_ident_with_escape_quote.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__quoted_ident_with_escape_quote.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__quoted_ident_with_escape_quote.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__quoted_ident_with_escape_quote.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__select_with_period.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__select_with_period.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__select_with_period.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__select_with_period.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__string.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__string.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__string.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__string.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__string_unicode_escape.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__string_unicode_escape.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__string_unicode_escape.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__string_unicode_escape.snap diff --git a/crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__string_with_escapes.snap b/crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__string_with_escapes.snap similarity index 100% rename from crates/pgt_tokenizer/src/snapshots/pgt_tokenizer__tests__string_with_escapes.snap rename to crates/pgls_tokenizer/src/snapshots/pgt_tokenizer__tests__string_with_escapes.snap diff --git a/crates/pgt_tokenizer/src/token.rs b/crates/pgls_tokenizer/src/token.rs similarity index 100% rename from crates/pgt_tokenizer/src/token.rs rename to crates/pgls_tokenizer/src/token.rs diff --git a/crates/pgt_treesitter/Cargo.toml b/crates/pgls_treesitter/Cargo.toml similarity index 51% rename from crates/pgt_treesitter/Cargo.toml rename to crates/pgls_treesitter/Cargo.toml index 1a991f0cf..c262b7076 100644 --- a/crates/pgt_treesitter/Cargo.toml +++ b/crates/pgls_treesitter/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_treesitter" +name = "pgls_treesitter" repository.workspace = true version = "0.0.0" @@ -14,11 +14,11 @@ version = "0.0.0" doctest = false [dependencies] -clap = { version = "4.5.23", features = ["derive"] } -pgt_schema_cache.workspace = true -pgt_text_size.workspace = true -pgt_treesitter_grammar.workspace = true -tree-sitter.workspace = true +clap = { version = "4.5.23", features = ["derive"] } +pgls_schema_cache.workspace = true +pgls_text_size.workspace = true +pgls_treesitter_grammar.workspace = true +tree-sitter.workspace = true [dev-dependencies] -pgt_test_utils.workspace = true +pgls_test_utils.workspace = true diff --git a/crates/pgt_treesitter/src/context/base_parser.rs b/crates/pgls_treesitter/src/context/base_parser.rs similarity index 99% rename from crates/pgt_treesitter/src/context/base_parser.rs rename to crates/pgls_treesitter/src/context/base_parser.rs index 83b315828..be68def80 100644 --- a/crates/pgt_treesitter/src/context/base_parser.rs +++ b/crates/pgls_treesitter/src/context/base_parser.rs @@ -1,4 +1,4 @@ -use pgt_text_size::{TextRange, TextSize}; +use pgls_text_size::{TextRange, TextSize}; use std::iter::Peekable; pub(crate) struct TokenNavigator { diff --git a/crates/pgt_treesitter/src/context/grant_parser.rs b/crates/pgls_treesitter/src/context/grant_parser.rs similarity index 98% rename from crates/pgt_treesitter/src/context/grant_parser.rs rename to crates/pgls_treesitter/src/context/grant_parser.rs index c9aebc33b..428262044 100644 --- a/crates/pgt_treesitter/src/context/grant_parser.rs +++ b/crates/pgls_treesitter/src/context/grant_parser.rs @@ -1,4 +1,4 @@ -use pgt_text_size::{TextRange, TextSize}; +use pgls_text_size::{TextRange, TextSize}; use crate::context::base_parser::{ CompletionStatementParser, TokenNavigator, WordWithIndex, schema_and_table_name, @@ -182,14 +182,14 @@ impl GrantParser { #[cfg(test)] mod tests { - use pgt_text_size::{TextRange, TextSize}; + use pgls_text_size::{TextRange, TextSize}; use crate::{ context::base_parser::CompletionStatementParser, context::grant_parser::{GrantContext, GrantParser}, }; - use pgt_test_utils::QueryWithCursorPosition; + use pgls_test_utils::QueryWithCursorPosition; fn with_pos(query: String) -> (usize, String) { let mut pos: Option = None; diff --git a/crates/pgt_treesitter/src/context/mod.rs b/crates/pgls_treesitter/src/context/mod.rs similarity index 99% rename from crates/pgt_treesitter/src/context/mod.rs rename to crates/pgls_treesitter/src/context/mod.rs index 6c2e8bbd0..56f8a4f4b 100644 --- a/crates/pgt_treesitter/src/context/mod.rs +++ b/crates/pgls_treesitter/src/context/mod.rs @@ -8,7 +8,7 @@ mod policy_parser; mod revoke_parser; use crate::queries::{self, QueryResult, TreeSitterQueriesExecutor}; -use pgt_text_size::{TextRange, TextSize}; +use pgls_text_size::{TextRange, TextSize}; use crate::context::{ base_parser::CompletionStatementParser, @@ -206,7 +206,7 @@ impl<'a> TreesitterContext<'a> { }; // policy handling is important to Supabase, but they are a PostgreSQL specific extension, - // so the pgt_treesitter_grammar language does not support it. + // so the pgls_treesitter_grammar language does not support it. // We infer the context manually. if PolicyParser::looks_like_matching_stmt(params.text) { ctx.gather_policy_context(); @@ -913,14 +913,14 @@ impl<'a> TreesitterContext<'a> { mod tests { use crate::context::{TreeSitterContextParams, TreesitterContext, WrappingClause}; - use pgt_test_utils::QueryWithCursorPosition; + use pgls_test_utils::QueryWithCursorPosition; use super::NodeUnderCursor; fn get_tree(input: &str) -> tree_sitter::Tree { let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .expect("Couldn't set language"); parser.parse(input, None).expect("Unable to parse tree") diff --git a/crates/pgt_treesitter/src/context/policy_parser.rs b/crates/pgls_treesitter/src/context/policy_parser.rs similarity index 99% rename from crates/pgt_treesitter/src/context/policy_parser.rs rename to crates/pgls_treesitter/src/context/policy_parser.rs index 9aec872bc..7b9a20c90 100644 --- a/crates/pgt_treesitter/src/context/policy_parser.rs +++ b/crates/pgls_treesitter/src/context/policy_parser.rs @@ -1,4 +1,4 @@ -use pgt_text_size::{TextRange, TextSize}; +use pgls_text_size::{TextRange, TextSize}; use crate::context::base_parser::{ CompletionStatementParser, TokenNavigator, WordWithIndex, schema_and_table_name, @@ -214,14 +214,14 @@ impl PolicyParser { #[cfg(test)] mod tests { - use pgt_text_size::{TextRange, TextSize}; + use pgls_text_size::{TextRange, TextSize}; use crate::{ context::base_parser::CompletionStatementParser, context::policy_parser::{PolicyContext, PolicyStmtKind}, }; - use pgt_test_utils::QueryWithCursorPosition; + use pgls_test_utils::QueryWithCursorPosition; use super::PolicyParser; diff --git a/crates/pgt_treesitter/src/context/revoke_parser.rs b/crates/pgls_treesitter/src/context/revoke_parser.rs similarity index 98% rename from crates/pgt_treesitter/src/context/revoke_parser.rs rename to crates/pgls_treesitter/src/context/revoke_parser.rs index 4f5b09ec8..6b8cf5a5d 100644 --- a/crates/pgt_treesitter/src/context/revoke_parser.rs +++ b/crates/pgls_treesitter/src/context/revoke_parser.rs @@ -1,4 +1,4 @@ -use pgt_text_size::{TextRange, TextSize}; +use pgls_text_size::{TextRange, TextSize}; use crate::context::base_parser::{ CompletionStatementParser, TokenNavigator, WordWithIndex, schema_and_table_name, @@ -175,14 +175,14 @@ impl RevokeParser { #[cfg(test)] mod tests { - use pgt_text_size::{TextRange, TextSize}; + use pgls_text_size::{TextRange, TextSize}; use crate::{ context::base_parser::CompletionStatementParser, context::revoke_parser::{RevokeContext, RevokeParser}, }; - use pgt_test_utils::QueryWithCursorPosition; + use pgls_test_utils::QueryWithCursorPosition; fn with_pos(query: String) -> (usize, String) { let mut pos: Option = None; diff --git a/crates/pgt_treesitter/src/lib.rs b/crates/pgls_treesitter/src/lib.rs similarity index 100% rename from crates/pgt_treesitter/src/lib.rs rename to crates/pgls_treesitter/src/lib.rs diff --git a/crates/pgt_treesitter/src/queries/insert_columns.rs b/crates/pgls_treesitter/src/queries/insert_columns.rs similarity index 93% rename from crates/pgt_treesitter/src/queries/insert_columns.rs rename to crates/pgls_treesitter/src/queries/insert_columns.rs index e80718321..c35020695 100644 --- a/crates/pgt_treesitter/src/queries/insert_columns.rs +++ b/crates/pgls_treesitter/src/queries/insert_columns.rs @@ -17,7 +17,7 @@ static TS_QUERY: LazyLock = LazyLock::new(|| { ) ) "#; - tree_sitter::Query::new(&pgt_treesitter_grammar::LANGUAGE.into(), QUERY_STR) + tree_sitter::Query::new(&pgls_treesitter_grammar::LANGUAGE.into(), QUERY_STR) .expect("Invalid TS Query") }); @@ -84,7 +84,7 @@ mod tests { let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .unwrap(); let tree = parser.parse(sql, None).unwrap(); @@ -115,7 +115,7 @@ mod tests { let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .unwrap(); let tree = parser.parse(sql, None).unwrap(); @@ -140,7 +140,7 @@ mod tests { let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .unwrap(); let tree = parser.parse(sql, None).unwrap(); diff --git a/crates/pgt_treesitter/src/queries/mod.rs b/crates/pgls_treesitter/src/queries/mod.rs similarity index 97% rename from crates/pgt_treesitter/src/queries/mod.rs rename to crates/pgls_treesitter/src/queries/mod.rs index 1b94f5fba..291e0a63a 100644 --- a/crates/pgt_treesitter/src/queries/mod.rs +++ b/crates/pgls_treesitter/src/queries/mod.rs @@ -189,7 +189,7 @@ where let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .unwrap(); let tree = parser.parse(sql, None).unwrap(); @@ -257,7 +257,7 @@ where let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .unwrap(); let tree = parser.parse(sql, None).unwrap(); @@ -307,7 +307,7 @@ on sq1.id = pt.id; let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .unwrap(); let tree = parser.parse(sql, None).unwrap(); @@ -350,7 +350,7 @@ on sq1.id = pt.id; let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .unwrap(); let tree = parser.parse(sql, None).unwrap(); diff --git a/crates/pgt_treesitter/src/queries/parameters.rs b/crates/pgls_treesitter/src/queries/parameters.rs similarity index 96% rename from crates/pgt_treesitter/src/queries/parameters.rs rename to crates/pgls_treesitter/src/queries/parameters.rs index b64c73ae7..86cb24400 100644 --- a/crates/pgt_treesitter/src/queries/parameters.rs +++ b/crates/pgls_treesitter/src/queries/parameters.rs @@ -17,7 +17,7 @@ static TS_QUERY: LazyLock = LazyLock::new(|| { (parameter) @parameter ] "#; - tree_sitter::Query::new(&pgt_treesitter_grammar::LANGUAGE.into(), QUERY_STR) + tree_sitter::Query::new(&pgls_treesitter_grammar::LANGUAGE.into(), QUERY_STR) .expect("Invalid TS Query") }); diff --git a/crates/pgt_treesitter/src/queries/relations.rs b/crates/pgls_treesitter/src/queries/relations.rs similarity index 93% rename from crates/pgt_treesitter/src/queries/relations.rs rename to crates/pgls_treesitter/src/queries/relations.rs index 74a51dcbd..492232cbe 100644 --- a/crates/pgt_treesitter/src/queries/relations.rs +++ b/crates/pgls_treesitter/src/queries/relations.rs @@ -35,7 +35,7 @@ static TS_QUERY: LazyLock = LazyLock::new(|| { )+ ) "#; - tree_sitter::Query::new(&pgt_treesitter_grammar::LANGUAGE.into(), QUERY_STR) + tree_sitter::Query::new(&pgls_treesitter_grammar::LANGUAGE.into(), QUERY_STR) .expect("Invalid TS Query") }); @@ -125,7 +125,7 @@ mod tests { let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .unwrap(); let tree = parser.parse(sql, None).unwrap(); @@ -150,7 +150,7 @@ mod tests { let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .unwrap(); let tree = parser.parse(sql, None).unwrap(); @@ -175,7 +175,7 @@ mod tests { let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .unwrap(); let tree = parser.parse(sql, None).unwrap(); @@ -200,7 +200,7 @@ mod tests { let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .unwrap(); let tree = parser.parse(sql, None).unwrap(); @@ -225,7 +225,7 @@ mod tests { let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .unwrap(); let tree = parser.parse(sql, None).unwrap(); @@ -250,7 +250,7 @@ mod tests { let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .unwrap(); let tree = parser.parse(sql, None).unwrap(); @@ -275,7 +275,7 @@ mod tests { let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .unwrap(); let tree = parser.parse(sql, None).unwrap(); diff --git a/crates/pgt_treesitter/src/queries/select_columns.rs b/crates/pgls_treesitter/src/queries/select_columns.rs similarity index 95% rename from crates/pgt_treesitter/src/queries/select_columns.rs rename to crates/pgls_treesitter/src/queries/select_columns.rs index ea3eb9bd1..ca691d72a 100644 --- a/crates/pgt_treesitter/src/queries/select_columns.rs +++ b/crates/pgls_treesitter/src/queries/select_columns.rs @@ -18,7 +18,7 @@ static TS_QUERY: LazyLock = LazyLock::new(|| { ","? ) "#; - tree_sitter::Query::new(&pgt_treesitter_grammar::LANGUAGE.into(), QUERY_STR) + tree_sitter::Query::new(&pgls_treesitter_grammar::LANGUAGE.into(), QUERY_STR) .expect("Invalid TS Query") }); @@ -108,7 +108,7 @@ mod tests { let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .unwrap(); let tree = parser.parse(sql, None).unwrap(); @@ -149,7 +149,7 @@ from let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .unwrap(); let tree = parser.parse(sql, None).unwrap(); diff --git a/crates/pgt_treesitter/src/queries/table_aliases.rs b/crates/pgls_treesitter/src/queries/table_aliases.rs similarity index 97% rename from crates/pgt_treesitter/src/queries/table_aliases.rs rename to crates/pgls_treesitter/src/queries/table_aliases.rs index 9d771bf71..47b0e797d 100644 --- a/crates/pgt_treesitter/src/queries/table_aliases.rs +++ b/crates/pgls_treesitter/src/queries/table_aliases.rs @@ -18,7 +18,7 @@ static TS_QUERY: LazyLock = LazyLock::new(|| { (identifier) @alias ) "#; - tree_sitter::Query::new(&pgt_treesitter_grammar::LANGUAGE.into(), QUERY_STR) + tree_sitter::Query::new(&pgls_treesitter_grammar::LANGUAGE.into(), QUERY_STR) .expect("Invalid TS Query") }); diff --git a/crates/pgt_treesitter/src/queries/where_columns.rs b/crates/pgls_treesitter/src/queries/where_columns.rs similarity index 96% rename from crates/pgt_treesitter/src/queries/where_columns.rs rename to crates/pgls_treesitter/src/queries/where_columns.rs index 27b466eac..0596a53e9 100644 --- a/crates/pgt_treesitter/src/queries/where_columns.rs +++ b/crates/pgls_treesitter/src/queries/where_columns.rs @@ -20,7 +20,7 @@ static TS_QUERY: LazyLock = LazyLock::new(|| { ) ) "#; - tree_sitter::Query::new(&pgt_treesitter_grammar::LANGUAGE.into(), QUERY_STR) + tree_sitter::Query::new(&pgls_treesitter_grammar::LANGUAGE.into(), QUERY_STR) .expect("Invalid TS Query") }); diff --git a/crates/pgt_treesitter_grammar/.editorconfig b/crates/pgls_treesitter_grammar/.editorconfig similarity index 100% rename from crates/pgt_treesitter_grammar/.editorconfig rename to crates/pgls_treesitter_grammar/.editorconfig diff --git a/crates/pgt_treesitter_grammar/.gitattributes b/crates/pgls_treesitter_grammar/.gitattributes similarity index 100% rename from crates/pgt_treesitter_grammar/.gitattributes rename to crates/pgls_treesitter_grammar/.gitattributes diff --git a/crates/pgt_treesitter_grammar/.gitignore b/crates/pgls_treesitter_grammar/.gitignore similarity index 100% rename from crates/pgt_treesitter_grammar/.gitignore rename to crates/pgls_treesitter_grammar/.gitignore diff --git a/crates/pgt_treesitter_grammar/Cargo.toml b/crates/pgls_treesitter_grammar/Cargo.toml similarity index 93% rename from crates/pgt_treesitter_grammar/Cargo.toml rename to crates/pgls_treesitter_grammar/Cargo.toml index 614a071a3..3b4bf0e67 100644 --- a/crates/pgt_treesitter_grammar/Cargo.toml +++ b/crates/pgls_treesitter_grammar/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_treesitter_grammar" +name = "pgls_treesitter_grammar" repository.workspace = true version = "0.0.0" diff --git a/crates/pgt_treesitter_grammar/NOTICE b/crates/pgls_treesitter_grammar/NOTICE similarity index 100% rename from crates/pgt_treesitter_grammar/NOTICE rename to crates/pgls_treesitter_grammar/NOTICE diff --git a/crates/pgt_treesitter_grammar/build.rs b/crates/pgls_treesitter_grammar/build.rs similarity index 100% rename from crates/pgt_treesitter_grammar/build.rs rename to crates/pgls_treesitter_grammar/build.rs diff --git a/crates/pgt_treesitter_grammar/grammar.js b/crates/pgls_treesitter_grammar/grammar.js similarity index 100% rename from crates/pgt_treesitter_grammar/grammar.js rename to crates/pgls_treesitter_grammar/grammar.js diff --git a/crates/pgt_treesitter_grammar/package-lock.json b/crates/pgls_treesitter_grammar/package-lock.json similarity index 100% rename from crates/pgt_treesitter_grammar/package-lock.json rename to crates/pgls_treesitter_grammar/package-lock.json diff --git a/crates/pgt_treesitter_grammar/package.json b/crates/pgls_treesitter_grammar/package.json similarity index 100% rename from crates/pgt_treesitter_grammar/package.json rename to crates/pgls_treesitter_grammar/package.json diff --git a/crates/pgt_treesitter_grammar/src/grammar.json b/crates/pgls_treesitter_grammar/src/grammar.json similarity index 100% rename from crates/pgt_treesitter_grammar/src/grammar.json rename to crates/pgls_treesitter_grammar/src/grammar.json diff --git a/crates/pgt_treesitter_grammar/src/lib.rs b/crates/pgls_treesitter_grammar/src/lib.rs similarity index 97% rename from crates/pgt_treesitter_grammar/src/lib.rs rename to crates/pgls_treesitter_grammar/src/lib.rs index f7fa02f8b..f5670a077 100644 --- a/crates/pgt_treesitter_grammar/src/lib.rs +++ b/crates/pgls_treesitter_grammar/src/lib.rs @@ -7,7 +7,7 @@ //! let code = r#" //! "#; //! let mut parser = tree_sitter::Parser::new(); -//! let language = pgt_treesitter_grammar::LANGUAGE; +//! let language = pgls_treesitter_grammar::LANGUAGE; //! parser //! .set_language(&language.into()) //! .expect("Error loading Postgres Language Server parser"); diff --git a/crates/pgt_treesitter_grammar/src/node-types.json b/crates/pgls_treesitter_grammar/src/node-types.json similarity index 100% rename from crates/pgt_treesitter_grammar/src/node-types.json rename to crates/pgls_treesitter_grammar/src/node-types.json diff --git a/crates/pgt_treesitter_grammar/src/parser.c b/crates/pgls_treesitter_grammar/src/parser.c similarity index 100% rename from crates/pgt_treesitter_grammar/src/parser.c rename to crates/pgls_treesitter_grammar/src/parser.c diff --git a/crates/pgt_treesitter_grammar/src/scanner.c b/crates/pgls_treesitter_grammar/src/scanner.c similarity index 100% rename from crates/pgt_treesitter_grammar/src/scanner.c rename to crates/pgls_treesitter_grammar/src/scanner.c diff --git a/crates/pgt_treesitter_grammar/src/tree_sitter/alloc.h b/crates/pgls_treesitter_grammar/src/tree_sitter/alloc.h similarity index 100% rename from crates/pgt_treesitter_grammar/src/tree_sitter/alloc.h rename to crates/pgls_treesitter_grammar/src/tree_sitter/alloc.h diff --git a/crates/pgt_treesitter_grammar/src/tree_sitter/array.h b/crates/pgls_treesitter_grammar/src/tree_sitter/array.h similarity index 100% rename from crates/pgt_treesitter_grammar/src/tree_sitter/array.h rename to crates/pgls_treesitter_grammar/src/tree_sitter/array.h diff --git a/crates/pgt_treesitter_grammar/src/tree_sitter/parser.h b/crates/pgls_treesitter_grammar/src/tree_sitter/parser.h similarity index 100% rename from crates/pgt_treesitter_grammar/src/tree_sitter/parser.h rename to crates/pgls_treesitter_grammar/src/tree_sitter/parser.h diff --git a/crates/pgt_treesitter_grammar/tree-sitter.json b/crates/pgls_treesitter_grammar/tree-sitter.json similarity index 100% rename from crates/pgt_treesitter_grammar/tree-sitter.json rename to crates/pgls_treesitter_grammar/tree-sitter.json diff --git a/crates/pgt_type_resolver/Cargo.toml b/crates/pgls_type_resolver/Cargo.toml similarity index 74% rename from crates/pgt_type_resolver/Cargo.toml rename to crates/pgls_type_resolver/Cargo.toml index 9a190fdf4..7d1661410 100644 --- a/crates/pgt_type_resolver/Cargo.toml +++ b/crates/pgls_type_resolver/Cargo.toml @@ -6,14 +6,14 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_type_resolver" +name = "pgls_type_resolver" repository.workspace = true version = "0.0.0" [dependencies] -pgt_query.workspace = true -pgt_schema_cache.workspace = true +pgls_query.workspace = true +pgls_schema_cache.workspace = true [dev-dependencies] diff --git a/crates/pgt_type_resolver/src/functions.rs b/crates/pgls_type_resolver/src/functions.rs similarity index 92% rename from crates/pgt_type_resolver/src/functions.rs rename to crates/pgls_type_resolver/src/functions.rs index 208af30dd..0e1072e66 100644 --- a/crates/pgt_type_resolver/src/functions.rs +++ b/crates/pgls_type_resolver/src/functions.rs @@ -1,4 +1,4 @@ -use pgt_schema_cache::{Function, SchemaCache}; +use pgls_schema_cache::{Function, SchemaCache}; use crate::{ types::{PossibleType, resolve_type}, @@ -6,7 +6,7 @@ use crate::{ }; pub fn resolve_func_call<'b>( - node: &pgt_query::protobuf::FuncCall, + node: &pgls_query::protobuf::FuncCall, schema_cache: &'b SchemaCache, ) -> Option<&'b Function> { let (schema, name) = resolve_func_identifier(node); @@ -30,7 +30,7 @@ pub fn resolve_func_call<'b>( if fns.len() == 1 { Some(fns[0]) } else { None } } -fn resolve_func_identifier(node: &pgt_query::protobuf::FuncCall) -> (Option, String) { +fn resolve_func_identifier(node: &pgls_query::protobuf::FuncCall) -> (Option, String) { match node.funcname.as_slice() { [name] => (None, get_string_from_node(name)), [schema, name] => ( diff --git a/crates/pgt_type_resolver/src/lib.rs b/crates/pgls_type_resolver/src/lib.rs similarity index 100% rename from crates/pgt_type_resolver/src/lib.rs rename to crates/pgls_type_resolver/src/lib.rs diff --git a/crates/pgt_type_resolver/src/types.rs b/crates/pgls_type_resolver/src/types.rs similarity index 82% rename from crates/pgt_type_resolver/src/types.rs rename to crates/pgls_type_resolver/src/types.rs index 85e1d8d2d..2ba6f336e 100644 --- a/crates/pgt_type_resolver/src/types.rs +++ b/crates/pgls_type_resolver/src/types.rs @@ -1,13 +1,13 @@ -use pgt_schema_cache::SchemaCache; +use pgls_schema_cache::SchemaCache; pub(crate) enum PossibleType { Null, AnyOf(Vec), } -pub fn resolve_type(node: &pgt_query::NodeEnum, schema_cache: &SchemaCache) -> PossibleType { +pub fn resolve_type(node: &pgls_query::NodeEnum, schema_cache: &SchemaCache) -> PossibleType { match node { - pgt_query::NodeEnum::AConst(n) => { + pgls_query::NodeEnum::AConst(n) => { if n.isnull { PossibleType::Null } else { @@ -16,7 +16,7 @@ pub fn resolve_type(node: &pgt_query::NodeEnum, schema_cache: &SchemaCache) -> P .as_ref() .expect("expected non-nullable AConst to have a value") { - pgt_query::protobuf::a_const::Val::Ival(_) => { + pgls_query::protobuf::a_const::Val::Ival(_) => { let types: Vec = ["int2", "int4", "int8"] .iter() .map(|s| s.to_string()) @@ -33,7 +33,7 @@ pub fn resolve_type(node: &pgt_query::NodeEnum, schema_cache: &SchemaCache) -> P .collect(), ) } - pgt_query::protobuf::a_const::Val::Fval(_) => { + pgls_query::protobuf::a_const::Val::Fval(_) => { let types: Vec = ["float4", "float8"].iter().map(|s| s.to_string()).collect(); @@ -46,7 +46,7 @@ pub fn resolve_type(node: &pgt_query::NodeEnum, schema_cache: &SchemaCache) -> P .collect(), ) } - pgt_query::protobuf::a_const::Val::Boolval(_) => PossibleType::AnyOf( + pgls_query::protobuf::a_const::Val::Boolval(_) => PossibleType::AnyOf( schema_cache .types .iter() @@ -54,7 +54,7 @@ pub fn resolve_type(node: &pgt_query::NodeEnum, schema_cache: &SchemaCache) -> P .map(|t| t.id) .collect(), ), - pgt_query::protobuf::a_const::Val::Sval(v) => { + pgls_query::protobuf::a_const::Val::Sval(v) => { let types: Vec = ["text", "varchar"].iter().map(|s| s.to_string()).collect(); @@ -70,7 +70,7 @@ pub fn resolve_type(node: &pgt_query::NodeEnum, schema_cache: &SchemaCache) -> P .collect(), ) } - pgt_query::protobuf::a_const::Val::Bsval(_) => todo!(), + pgls_query::protobuf::a_const::Val::Bsval(_) => todo!(), } } } diff --git a/crates/pgls_type_resolver/src/util.rs b/crates/pgls_type_resolver/src/util.rs new file mode 100644 index 000000000..292954703 --- /dev/null +++ b/crates/pgls_type_resolver/src/util.rs @@ -0,0 +1,6 @@ +pub(crate) fn get_string_from_node(node: &pgls_query::protobuf::Node) -> String { + match &node.node { + Some(pgls_query::NodeEnum::String(s)) => s.sval.to_string(), + _ => "".to_string(), + } +} diff --git a/crates/pgls_typecheck/Cargo.toml b/crates/pgls_typecheck/Cargo.toml new file mode 100644 index 000000000..6570d5d33 --- /dev/null +++ b/crates/pgls_typecheck/Cargo.toml @@ -0,0 +1,33 @@ +[package] +authors.workspace = true +categories.workspace = true +description = "" +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +name = "pgls_typecheck" +repository.workspace = true +version = "0.0.0" + + +[dependencies] +globset = "0.4.16" +itertools = { version = "0.14.0" } +pgls_console.workspace = true +pgls_diagnostics.workspace = true +pgls_query.workspace = true +pgls_schema_cache.workspace = true +pgls_text_size.workspace = true +pgls_treesitter.workspace = true +pgls_treesitter_grammar.workspace = true +sqlx.workspace = true +tokio.workspace = true +tree-sitter.workspace = true + +[dev-dependencies] +insta.workspace = true +pgls_test_utils.workspace = true + +[lib] +doctest = false diff --git a/crates/pgt_typecheck/src/diagnostics.rs b/crates/pgls_typecheck/src/diagnostics.rs similarity index 97% rename from crates/pgt_typecheck/src/diagnostics.rs rename to crates/pgls_typecheck/src/diagnostics.rs index 2117adbed..6a439d6ce 100644 --- a/crates/pgt_typecheck/src/diagnostics.rs +++ b/crates/pgls_typecheck/src/diagnostics.rs @@ -1,8 +1,8 @@ use std::io; -use pgt_console::markup; -use pgt_diagnostics::{Advices, Diagnostic, LogCategory, MessageAndDescription, Severity, Visit}; -use pgt_text_size::TextRange; +use pgls_console::markup; +use pgls_diagnostics::{Advices, Diagnostic, LogCategory, MessageAndDescription, Severity, Visit}; +use pgls_text_size::TextRange; use sqlx::postgres::{PgDatabaseError, PgSeverity}; /// A specialized diagnostic for the typechecker. diff --git a/crates/pgt_typecheck/src/lib.rs b/crates/pgls_typecheck/src/lib.rs similarity index 89% rename from crates/pgt_typecheck/src/lib.rs rename to crates/pgls_typecheck/src/lib.rs index 854cdfadc..a7ad86371 100644 --- a/crates/pgt_typecheck/src/lib.rs +++ b/crates/pgls_typecheck/src/lib.rs @@ -5,7 +5,7 @@ pub use diagnostics::TypecheckDiagnostic; use diagnostics::create_type_error; use globset::Glob; use itertools::Itertools; -use pgt_schema_cache::SchemaCache; +use pgls_schema_cache::SchemaCache; use sqlx::postgres::PgDatabaseError; pub use sqlx::postgres::PgSeverity; use sqlx::{Executor, PgPool}; @@ -16,9 +16,9 @@ pub use typed_identifier::{IdentifierType, TypedIdentifier}; pub struct TypecheckParams<'a> { pub conn: &'a PgPool, pub sql: &'a str, - pub ast: &'a pgt_query::NodeEnum, + pub ast: &'a pgls_query::NodeEnum, pub tree: &'a tree_sitter::Tree, - pub schema_cache: &'a pgt_schema_cache::SchemaCache, + pub schema_cache: &'a pgls_schema_cache::SchemaCache, pub identifiers: Vec, /// Set of glob patterns that will be matched against the schemas in the database. /// Each matching schema will be added to the search_path for the typecheck. @@ -31,11 +31,11 @@ pub async fn check_sql( // Check if the AST is not a supported statement type if !matches!( params.ast, - pgt_query::NodeEnum::SelectStmt(_) - | pgt_query::NodeEnum::InsertStmt(_) - | pgt_query::NodeEnum::UpdateStmt(_) - | pgt_query::NodeEnum::DeleteStmt(_) - | pgt_query::NodeEnum::CommonTableExpr(_) + pgls_query::NodeEnum::SelectStmt(_) + | pgls_query::NodeEnum::InsertStmt(_) + | pgls_query::NodeEnum::UpdateStmt(_) + | pgls_query::NodeEnum::DeleteStmt(_) + | pgls_query::NodeEnum::CommonTableExpr(_) ) { return Ok(None); } diff --git a/crates/pgt_typecheck/src/typed_identifier.rs b/crates/pgls_typecheck/src/typed_identifier.rs similarity index 96% rename from crates/pgt_typecheck/src/typed_identifier.rs rename to crates/pgls_typecheck/src/typed_identifier.rs index 199c5950e..8df648852 100644 --- a/crates/pgt_typecheck/src/typed_identifier.rs +++ b/crates/pgls_typecheck/src/typed_identifier.rs @@ -1,5 +1,5 @@ -use pgt_schema_cache::PostgresType; -use pgt_treesitter::queries::{ParameterMatch, TreeSitterQueriesExecutor}; +use pgls_schema_cache::PostgresType; +use pgls_treesitter::queries::{ParameterMatch, TreeSitterQueriesExecutor}; /// A typed identifier is a parameter that has a type associated with it. /// It is used to replace parameters within the SQL string. @@ -24,7 +24,7 @@ pub struct IdentifierType { /// Applies the identifiers to the SQL string by replacing them with their default values. pub fn apply_identifiers<'a>( identifiers: Vec, - schema_cache: &'a pgt_schema_cache::SchemaCache, + schema_cache: &'a pgls_schema_cache::SchemaCache, cst: &'a tree_sitter::Tree, sql: &'a str, ) -> (String, bool) { @@ -200,7 +200,7 @@ fn resolve_type<'a>( identifier: &TypedIdentifier, position: usize, parts: &[&str], - schema_cache: &'a pgt_schema_cache::SchemaCache, + schema_cache: &'a pgls_schema_cache::SchemaCache, ) -> Option<&'a PostgresType> { if position < parts.len() - 1 { // Find the composite type @@ -233,7 +233,7 @@ fn resolve_type<'a>( mod tests { use sqlx::{Executor, PgPool}; - #[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] + #[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_apply_identifiers(test_db: PgPool) { let input = "select v_test + fn_name.custom_type.v_test2 + $3 + custom_type.v_test3 + fn_name.v_test2 + enum_type"; @@ -316,10 +316,10 @@ mod tests { let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .expect("Error loading sql language"); - let schema_cache = pgt_schema_cache::SchemaCache::load(&test_db) + let schema_cache = pgls_schema_cache::SchemaCache::load(&test_db) .await .expect("Failed to load Schema Cache"); diff --git a/crates/pgt_typecheck/tests/diagnostics.rs b/crates/pgls_typecheck/tests/diagnostics.rs similarity index 83% rename from crates/pgt_typecheck/tests/diagnostics.rs rename to crates/pgls_typecheck/tests/diagnostics.rs index 43a776656..e6d9b675c 100644 --- a/crates/pgt_typecheck/tests/diagnostics.rs +++ b/crates/pgls_typecheck/tests/diagnostics.rs @@ -1,9 +1,9 @@ -use pgt_console::{ +use pgls_console::{ fmt::{Formatter, HTML}, markup, }; -use pgt_diagnostics::PrintDiagnostic; -use pgt_typecheck::{TypecheckParams, check_sql}; +use pgls_diagnostics::PrintDiagnostic; +use pgls_typecheck::{TypecheckParams, check_sql}; use sqlx::{Executor, PgPool}; async fn test(name: &str, query: &str, setup: Option<&str>, test_db: &PgPool) { @@ -16,14 +16,14 @@ async fn test(name: &str, query: &str, setup: Option<&str>, test_db: &PgPool) { let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .expect("Error loading sql language"); - let schema_cache = pgt_schema_cache::SchemaCache::load(test_db) + let schema_cache = pgls_schema_cache::SchemaCache::load(test_db) .await .expect("Failed to load Schema Cache"); - let root = pgt_query::parse(query) + let root = pgls_query::parse(query) .unwrap() .into_root() .expect("Failed to parse query"); @@ -59,7 +59,7 @@ async fn test(name: &str, query: &str, setup: Option<&str>, test_db: &PgPool) { }); } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn invalid_column(pool: PgPool) { test( "invalid_column", diff --git a/crates/pgt_typecheck/tests/snapshots/invalid_column.snap b/crates/pgls_typecheck/tests/snapshots/invalid_column.snap similarity index 100% rename from crates/pgt_typecheck/tests/snapshots/invalid_column.snap rename to crates/pgls_typecheck/tests/snapshots/invalid_column.snap diff --git a/crates/pgls_workspace/Cargo.toml b/crates/pgls_workspace/Cargo.toml new file mode 100644 index 000000000..bed849d9e --- /dev/null +++ b/crates/pgls_workspace/Cargo.toml @@ -0,0 +1,76 @@ +[package] +authors.workspace = true +categories.workspace = true +description = "" +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +name = "pgls_workspace" +repository.workspace = true +version = "0.0.0" + + +[dependencies] +biome_deserialize = "0.6.0" +futures = "0.3.31" +globset = "0.4.16" +lru = "0.12" + +ignore = { workspace = true } +pgls_analyse = { workspace = true, features = ["serde"] } +pgls_analyser = { workspace = true } +pgls_completions = { workspace = true } +pgls_configuration = { workspace = true } +pgls_console = { workspace = true } +pgls_diagnostics = { workspace = true } +pgls_fs = { workspace = true, features = ["serde"] } +pgls_hover = { workspace = true } +pgls_lexer = { workspace = true } +pgls_plpgsql_check = { workspace = true } +pgls_query = { workspace = true } +pgls_query_ext = { workspace = true } +pgls_schema_cache = { workspace = true } +pgls_statement_splitter = { workspace = true } +pgls_suppressions = { workspace = true } +pgls_text_size.workspace = true +pgls_tokenizer = { workspace = true } +pgls_treesitter_grammar.workspace = true +pgls_typecheck = { workspace = true } +pgls_workspace_macros = { workspace = true } +regex = { workspace = true } +rustc-hash = { workspace = true } +schemars = { workspace = true, optional = true } +serde = { workspace = true, features = ["derive"] } +serde_json = { workspace = true, features = ["raw_value"] } +slotmap = { workspace = true, features = ["serde"] } +sqlx.workspace = true +strum = { workspace = true } +tokio = { workspace = true, features = ["rt", "rt-multi-thread"] } +tracing = { workspace = true, features = ["attributes", "log"] } +tree-sitter.workspace = true + +biome_js_factory = { workspace = true, optional = true } +biome_js_syntax = { workspace = true, optional = true } +biome_rowan = { workspace = true, optional = true } + +[features] +schema = [ + "dep:schemars", + "dep:biome_rowan", + "dep:biome_js_syntax", + "dep:biome_js_factory", + "pgls_configuration/schema", + "pgls_diagnostics/schema", + "pgls_fs/schema", + "pgls_analyse/schema", + "pgls_completions/schema", +] + +[dev-dependencies] +pgls_test_utils = { workspace = true } +sqlx = { workspace = true } +tempfile = "3.15.0" + +[lib] +doctest = false diff --git a/crates/pgt_workspace/src/configuration.rs b/crates/pgls_workspace/src/configuration.rs similarity index 95% rename from crates/pgt_workspace/src/configuration.rs rename to crates/pgls_workspace/src/configuration.rs index 87e77b0ca..4a5a6fd46 100644 --- a/crates/pgt_workspace/src/configuration.rs +++ b/crates/pgls_workspace/src/configuration.rs @@ -6,13 +6,13 @@ use std::{ }; use biome_deserialize::Merge; -use pgt_analyse::AnalyserRules; -use pgt_configuration::{ +use pgls_analyse::AnalyserRules; +use pgls_configuration::{ ConfigurationDiagnostic, ConfigurationPathHint, ConfigurationPayload, PartialConfiguration, VERSION, diagnostics::CantLoadExtendFile, push_to_analyser_rules, }; -use pgt_console::markup; -use pgt_fs::{AutoSearchResult, ConfigName, FileSystem, OpenOptions}; +use pgls_console::markup; +use pgls_fs::{AutoSearchResult, ConfigName, FileSystem, OpenOptions}; use crate::{DynRef, WorkspaceError, settings::Settings}; @@ -130,7 +130,7 @@ fn load_config( ConfigurationPathHint::None => file_system.working_directory().unwrap_or_default(), }; - // We first search for `postgrestools.jsonc` files + // We first search for `postgres-language-server.jsonc` files if let Some(auto_search_result) = file_system.auto_search( &configuration_directory, ConfigName::file_names().as_slice(), @@ -186,9 +186,12 @@ pub fn create_config( configuration.schema = node_schema_path.to_str().map(String::from); } else if VERSION == "0.0.0" { // VERSION is 0.0.0 if it has not been explicitly set (e.g local dev, as fallback) - configuration.schema = Some("https://pgtools.dev/latest/schema.json".to_string()); + configuration.schema = + Some("https://pg-language-server.com/latest/schema.json".to_string()); } else { - configuration.schema = Some(format!("https://pgtools.dev/{VERSION}/schema.json")); + configuration.schema = Some(format!( + "https://pg-language-server.com/{VERSION}/schema.json" + )); } let contents = serde_json::to_string_pretty(&configuration) @@ -205,7 +208,7 @@ pub fn create_config( pub fn to_analyser_rules(settings: &Settings) -> AnalyserRules { let mut analyser_rules = AnalyserRules::default(); if let Some(rules) = settings.linter.rules.as_ref() { - push_to_analyser_rules(rules, pgt_analyser::METADATA.deref(), &mut analyser_rules); + push_to_analyser_rules(rules, pgls_analyser::METADATA.deref(), &mut analyser_rules); } analyser_rules } @@ -377,7 +380,7 @@ impl PartialConfigurationExt for PartialConfiguration { err.to_string(), ) .with_verbose_advice(markup! { - "Postgres Tools tried to load the configuration file \""{ + "Postgres Language Server tried to load the configuration file \""{ extend_configuration_file_path.display().to_string() }"\" in \"extends\" using \""{ external_resolution_base_path.display().to_string() @@ -520,20 +523,23 @@ mod tests { #[test] fn test_normalize_path_windows_drive() { if cfg!(windows) { - let path = Path::new(r"z:\workspace\test_one\..\postgrestools.jsonc"); + let path = Path::new(r"z:\workspace\test_one\..\postgres-language-server.jsonc"); let normalized = normalize_path(path); assert_eq!( normalized, - PathBuf::from(r"z:\workspace\postgrestools.jsonc") + PathBuf::from(r"z:\workspace\postgres-language-server.jsonc") ); } } #[test] fn test_normalize_path_relative() { - let path = Path::new("workspace/test_one/../postgrestools.jsonc"); + let path = Path::new("workspace/test_one/../postgres-language-server.jsonc"); let normalized = normalize_path(path); - assert_eq!(normalized, PathBuf::from("workspace/postgrestools.jsonc")); + assert_eq!( + normalized, + PathBuf::from("workspace/postgres-language-server.jsonc") + ); } #[test] diff --git a/crates/pgt_workspace/src/diagnostics.rs b/crates/pgls_workspace/src/diagnostics.rs similarity index 96% rename from crates/pgt_workspace/src/diagnostics.rs rename to crates/pgls_workspace/src/diagnostics.rs index 5020cc62e..0729b8c5a 100644 --- a/crates/pgt_workspace/src/diagnostics.rs +++ b/crates/pgls_workspace/src/diagnostics.rs @@ -1,11 +1,11 @@ -use pgt_configuration::ConfigurationDiagnostic; -use pgt_configuration::diagnostics::CantLoadExtendFile; -use pgt_console::fmt::Bytes; -use pgt_console::markup; -use pgt_diagnostics::{ +use pgls_configuration::ConfigurationDiagnostic; +use pgls_configuration::diagnostics::CantLoadExtendFile; +use pgls_console::fmt::Bytes; +use pgls_console::markup; +use pgls_diagnostics::{ Advices, Category, Diagnostic, DiagnosticTags, LogCategory, Severity, Visit, category, }; -use pgt_fs::FileSystemDiagnostic; +use pgls_fs::FileSystemDiagnostic; use serde::{Deserialize, Serialize}; use std::error::Error; use std::fmt; @@ -148,7 +148,7 @@ impl Diagnostic for TransportError { } } - fn message(&self, fmt: &mut pgt_console::fmt::Formatter<'_>) -> std::io::Result<()> { + fn message(&self, fmt: &mut pgls_console::fmt::Formatter<'_>) -> std::io::Result<()> { match self { TransportError::SerdeError(err) => write!(fmt, "serialization error: {err}"), TransportError::ChannelClosed => fmt.write_str( @@ -333,7 +333,7 @@ impl Diagnostic for FileTooLarge { Some(category!("internalError/fs")) } - fn message(&self, fmt: &mut pgt_console::fmt::Formatter<'_>) -> std::io::Result<()> { + fn message(&self, fmt: &mut pgls_console::fmt::Formatter<'_>) -> std::io::Result<()> { fmt.write_markup( markup!{ "Size of "{self.path}" is "{Bytes(self.size)}" which exceeds configured maximum of "{Bytes(self.limit)}" for this project. diff --git a/crates/pgt_workspace/src/dome.rs b/crates/pgls_workspace/src/dome.rs similarity index 74% rename from crates/pgt_workspace/src/dome.rs rename to crates/pgls_workspace/src/dome.rs index 8fa89c8b6..b0cfcb5b0 100644 --- a/crates/pgt_workspace/src/dome.rs +++ b/crates/pgls_workspace/src/dome.rs @@ -1,4 +1,4 @@ -use pgt_fs::PgTPath; +use pgls_fs::PgLSPath; use std::collections::BTreeSet; use std::collections::btree_set::Iter; use std::iter::{FusedIterator, Peekable}; @@ -7,16 +7,16 @@ use std::iter::{FusedIterator, Peekable}; /// specific paths like configuration files, manifests and more. #[derive(Debug, Default)] pub struct Dome { - paths: BTreeSet, + paths: BTreeSet, } impl Dome { - pub fn with_path(mut self, path: impl Into) -> Self { + pub fn with_path(mut self, path: impl Into) -> Self { self.paths.insert(path.into()); self } - pub fn new(paths: BTreeSet) -> Self { + pub fn new(paths: BTreeSet) -> Self { Self { paths } } @@ -26,17 +26,17 @@ impl Dome { } } - pub fn to_paths(self) -> BTreeSet { + pub fn to_paths(self) -> BTreeSet { self.paths } } pub struct DomeIterator<'a> { - iter: Peekable>, + iter: Peekable>, } impl<'a> DomeIterator<'a> { - pub fn next_config(&mut self) -> Option<&'a PgTPath> { + pub fn next_config(&mut self) -> Option<&'a PgLSPath> { if let Some(path) = self.iter.peek() { if path.is_config() { self.iter.next() @@ -48,7 +48,7 @@ impl<'a> DomeIterator<'a> { } } - pub fn next_ignore(&mut self) -> Option<&'a PgTPath> { + pub fn next_ignore(&mut self) -> Option<&'a PgLSPath> { if let Some(path) = self.iter.peek() { if path.is_ignore() { self.iter.next() @@ -62,7 +62,7 @@ impl<'a> DomeIterator<'a> { } impl<'a> Iterator for DomeIterator<'a> { - type Item = &'a PgTPath; + type Item = &'a PgLSPath; fn next(&mut self) -> Option { self.iter.next() diff --git a/crates/pgt_workspace/src/features/code_actions.rs b/crates/pgls_workspace/src/features/code_actions.rs similarity index 93% rename from crates/pgt_workspace/src/features/code_actions.rs rename to crates/pgls_workspace/src/features/code_actions.rs index cd1706d30..55a3d0ca0 100644 --- a/crates/pgt_workspace/src/features/code_actions.rs +++ b/crates/pgls_workspace/src/features/code_actions.rs @@ -1,12 +1,12 @@ use crate::workspace::StatementId; -use pgt_configuration::RuleSelector; -use pgt_fs::PgTPath; -use pgt_text_size::TextSize; +use pgls_configuration::RuleSelector; +use pgls_fs::PgLSPath; +use pgls_text_size::TextSize; #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] pub struct CodeActionsParams { - pub path: PgTPath, + pub path: PgLSPath, pub cursor_position: TextSize, pub only: Vec, pub skip: Vec, @@ -54,7 +54,7 @@ pub enum CommandActionCategory { #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] pub struct ExecuteStatementParams { pub statement_id: StatementId, - pub path: PgTPath, + pub path: PgLSPath, } #[derive(Debug, serde::Serialize, serde::Deserialize, Default, PartialEq, Eq)] diff --git a/crates/pgt_workspace/src/features/completions.rs b/crates/pgls_workspace/src/features/completions.rs similarity index 96% rename from crates/pgt_workspace/src/features/completions.rs rename to crates/pgls_workspace/src/features/completions.rs index 5944f14cf..773803589 100644 --- a/crates/pgt_workspace/src/features/completions.rs +++ b/crates/pgls_workspace/src/features/completions.rs @@ -1,8 +1,8 @@ use std::sync::Arc; -use pgt_completions::CompletionItem; -use pgt_fs::PgTPath; -use pgt_text_size::{TextRange, TextSize}; +use pgls_completions::CompletionItem; +use pgls_fs::PgLSPath; +use pgls_text_size::{TextRange, TextSize}; use crate::workspace::{Document, GetCompletionsFilter, StatementId, WithCSTMapper}; @@ -10,7 +10,7 @@ use crate::workspace::{Document, GetCompletionsFilter, StatementId, WithCSTMappe #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] pub struct GetCompletionsParams { /// The File for which a completion is requested. - pub path: PgTPath, + pub path: PgLSPath, /// The Cursor position in the file for which a completion is requested. pub position: TextSize, } @@ -76,13 +76,13 @@ pub(crate) fn get_statement_for_completions( #[cfg(test)] mod tests { - use pgt_text_size::TextSize; + use pgls_text_size::TextSize; use crate::workspace::Document; use super::get_statement_for_completions; - use pgt_test_utils::QueryWithCursorPosition; + use pgls_test_utils::QueryWithCursorPosition; fn get_doc_and_pos(sql: &str) -> (Document, TextSize) { let pos = sql diff --git a/crates/pgt_workspace/src/features/diagnostics.rs b/crates/pgls_workspace/src/features/diagnostics.rs similarity index 73% rename from crates/pgt_workspace/src/features/diagnostics.rs rename to crates/pgls_workspace/src/features/diagnostics.rs index a697641ed..ed6eca6da 100644 --- a/crates/pgt_workspace/src/features/diagnostics.rs +++ b/crates/pgls_workspace/src/features/diagnostics.rs @@ -1,11 +1,11 @@ -use pgt_analyse::RuleCategories; -use pgt_configuration::RuleSelector; -use pgt_fs::PgTPath; +use pgls_analyse::RuleCategories; +use pgls_configuration::RuleSelector; +use pgls_fs::PgLSPath; #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] pub struct PullDiagnosticsParams { - pub path: PgTPath, + pub path: PgLSPath, pub categories: RuleCategories, pub max_diagnostics: u64, pub only: Vec, @@ -15,7 +15,7 @@ pub struct PullDiagnosticsParams { #[derive(Debug, serde::Serialize, serde::Deserialize, Default)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] pub struct PullDiagnosticsResult { - pub diagnostics: Vec, + pub diagnostics: Vec, pub errors: usize, pub skipped_diagnostics: u64, } diff --git a/crates/pgt_workspace/src/features/mod.rs b/crates/pgls_workspace/src/features/mod.rs similarity index 100% rename from crates/pgt_workspace/src/features/mod.rs rename to crates/pgls_workspace/src/features/mod.rs diff --git a/crates/pgt_workspace/src/features/on_hover.rs b/crates/pgls_workspace/src/features/on_hover.rs similarity index 89% rename from crates/pgt_workspace/src/features/on_hover.rs rename to crates/pgls_workspace/src/features/on_hover.rs index 3e3fcd49e..6779a15b9 100644 --- a/crates/pgt_workspace/src/features/on_hover.rs +++ b/crates/pgls_workspace/src/features/on_hover.rs @@ -1,10 +1,10 @@ -use pgt_fs::PgTPath; -use pgt_text_size::TextSize; +use pgls_fs::PgLSPath; +use pgls_text_size::TextSize; #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] pub struct OnHoverParams { - pub path: PgTPath, + pub path: PgLSPath, pub position: TextSize, } diff --git a/crates/pgt_workspace/src/lib.rs b/crates/pgls_workspace/src/lib.rs similarity index 97% rename from crates/pgt_workspace/src/lib.rs rename to crates/pgls_workspace/src/lib.rs index df8b0ba7b..025bacab8 100644 --- a/crates/pgt_workspace/src/lib.rs +++ b/crates/pgls_workspace/src/lib.rs @@ -1,7 +1,7 @@ use std::ops::{Deref, DerefMut}; -use pgt_console::Console; -use pgt_fs::{FileSystem, OsFileSystem}; +use pgls_console::Console; +use pgls_fs::{FileSystem, OsFileSystem}; pub mod configuration; pub mod diagnostics; diff --git a/crates/pgt_workspace/src/matcher/LICENCE-APACHE b/crates/pgls_workspace/src/matcher/LICENCE-APACHE similarity index 100% rename from crates/pgt_workspace/src/matcher/LICENCE-APACHE rename to crates/pgls_workspace/src/matcher/LICENCE-APACHE diff --git a/crates/pgt_workspace/src/matcher/LICENSE-MIT b/crates/pgls_workspace/src/matcher/LICENSE-MIT similarity index 100% rename from crates/pgt_workspace/src/matcher/LICENSE-MIT rename to crates/pgls_workspace/src/matcher/LICENSE-MIT diff --git a/crates/pgt_workspace/src/matcher/mod.rs b/crates/pgls_workspace/src/matcher/mod.rs similarity index 97% rename from crates/pgt_workspace/src/matcher/mod.rs rename to crates/pgls_workspace/src/matcher/mod.rs index 1afc41664..6dbfe11ee 100644 --- a/crates/pgt_workspace/src/matcher/mod.rs +++ b/crates/pgls_workspace/src/matcher/mod.rs @@ -1,8 +1,8 @@ pub mod pattern; pub use pattern::{MatchOptions, Pattern, PatternError}; -use pgt_console::markup; -use pgt_diagnostics::Diagnostic; +use pgls_console::markup; +use pgls_diagnostics::Diagnostic; use std::collections::HashMap; use std::path::{Path, PathBuf}; use std::sync::RwLock; @@ -128,7 +128,7 @@ impl Diagnostic for PatternError { write!(fmt, "{}", self.msg) } - fn message(&self, fmt: &mut pgt_console::fmt::Formatter<'_>) -> std::io::Result<()> { + fn message(&self, fmt: &mut pgls_console::fmt::Formatter<'_>) -> std::io::Result<()> { fmt.write_markup(markup!({ self.msg })) } } diff --git a/crates/pgt_workspace/src/matcher/pattern.rs b/crates/pgls_workspace/src/matcher/pattern.rs similarity index 100% rename from crates/pgt_workspace/src/matcher/pattern.rs rename to crates/pgls_workspace/src/matcher/pattern.rs diff --git a/crates/pgt_workspace/src/settings.rs b/crates/pgls_workspace/src/settings.rs similarity index 96% rename from crates/pgt_workspace/src/settings.rs rename to crates/pgls_workspace/src/settings.rs index 46543980e..9bfcdee3d 100644 --- a/crates/pgt_workspace/src/settings.rs +++ b/crates/pgls_workspace/src/settings.rs @@ -1,6 +1,6 @@ use biome_deserialize::StringSet; use globset::Glob; -use pgt_diagnostics::Category; +use pgls_diagnostics::Category; use std::{ borrow::Cow, num::NonZeroU64, @@ -11,7 +11,7 @@ use std::{ use tracing::trace; use ignore::gitignore::{Gitignore, GitignoreBuilder}; -use pgt_configuration::{ +use pgls_configuration::{ ConfigurationDiagnostic, LinterConfiguration, PartialConfiguration, TypecheckConfiguration, database::PartialDatabaseConfiguration, diagnostics::InvalidIgnorePattern, @@ -19,7 +19,7 @@ use pgt_configuration::{ migrations::{MigrationsConfiguration, PartialMigrationsConfiguration}, plpgsql_check::PlPgSqlCheckConfiguration, }; -use pgt_fs::PgTPath; +use pgls_fs::PgLSPath; use crate::{ WorkspaceError, @@ -31,7 +31,7 @@ use crate::{ /// The information tracked for each project pub struct ProjectData { /// The root path of the project. This path should be **absolute**. - path: PgTPath, + path: PgLSPath, /// The settings of the project, usually inferred from the configuration file e.g. `biome.json`. settings: Settings, } @@ -50,7 +50,7 @@ impl WorkspaceSettings { self.current_project } - pub fn get_current_project_path(&self) -> Option<&PgTPath> { + pub fn get_current_project_path(&self) -> Option<&PgLSPath> { trace!("Current key {:?}", self.current_project); self.data .get(self.current_project) @@ -92,7 +92,7 @@ impl WorkspaceSettings { /// Insert a new project using its folder. Use [WorkspaceSettings::get_current_settings_mut] to retrieve /// a mutable reference to its [Settings] and manipulate them. pub fn insert_project(&mut self, workspace_path: impl Into) -> ProjectKey { - let path = PgTPath::new(workspace_path.into()); + let path = PgLSPath::new(workspace_path.into()); trace!("Insert workspace folder: {:?}", path); self.data.insert(ProjectData { path, @@ -123,7 +123,7 @@ impl WorkspaceSettings { /// Checks if the current path belongs to a registered project. /// /// If there's a match, and the match **isn't** the current project, it returns the new key. - pub fn path_belongs_to_current_workspace(&self, path: &PgTPath) -> Option { + pub fn path_belongs_to_current_workspace(&self, path: &PgLSPath) -> Option { if self.data.is_empty() { return None; } @@ -170,7 +170,7 @@ impl<'a> WorkspaceSettingsHandle<'a> { self.inner.get_current_settings() } - pub(crate) fn path(&self) -> Option<&PgTPath> { + pub(crate) fn path(&self) -> Option<&PgLSPath> { self.inner.get_current_project_path() } } @@ -280,7 +280,7 @@ impl Settings { } /// Returns linter rules. - pub fn as_linter_rules(&self) -> Option> { + pub fn as_linter_rules(&self) -> Option> { self.linter.rules.as_ref().map(Cow::Borrowed) } @@ -292,7 +292,7 @@ impl Settings { pub fn get_severity_from_rule_code( &self, code: &Category, - ) -> Option { + ) -> Option { self.linter .rules .as_ref() @@ -412,7 +412,7 @@ pub struct LinterSettings { pub enabled: bool, /// List of rules - pub rules: Option, + pub rules: Option, /// List of ignored paths/files to match pub ignored_files: Matcher, @@ -425,7 +425,7 @@ impl Default for LinterSettings { fn default() -> Self { Self { enabled: true, - rules: Some(pgt_configuration::analyser::linter::Rules::default()), + rules: Some(pgls_configuration::analyser::linter::Rules::default()), ignored_files: Matcher::empty(), included_files: Matcher::empty(), } @@ -598,7 +598,7 @@ impl Default for FilesSettings { #[cfg(test)] mod tests { use biome_deserialize::StringSet; - use pgt_configuration::database::PartialDatabaseConfiguration; + use pgls_configuration::database::PartialDatabaseConfiguration; use super::DatabaseSettings; diff --git a/crates/pgt_workspace/src/workspace.rs b/crates/pgls_workspace/src/workspace.rs similarity index 97% rename from crates/pgt_workspace/src/workspace.rs rename to crates/pgls_workspace/src/workspace.rs index 0747c081a..cb4afe5ff 100644 --- a/crates/pgt_workspace/src/workspace.rs +++ b/crates/pgls_workspace/src/workspace.rs @@ -1,9 +1,9 @@ use std::{panic::RefUnwindSafe, path::PathBuf, sync::Arc}; pub use self::client::{TransportRequest, WorkspaceClient, WorkspaceTransport}; -use pgt_analyse::RuleCategories; -use pgt_configuration::{PartialConfiguration, RuleSelector}; -use pgt_fs::PgTPath; +use pgls_analyse::RuleCategories; +use pgls_configuration::{PartialConfiguration, RuleSelector}; +use pgls_fs::PgLSPath; #[cfg(feature = "schema")] use schemars::{JsonSchema, SchemaGenerator, schema::Schema}; use serde::{Deserialize, Serialize}; @@ -30,7 +30,7 @@ pub(crate) use server::document::*; #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] pub struct OpenFileParams { - pub path: PgTPath, + pub path: PgLSPath, pub content: String, pub version: i32, } @@ -38,13 +38,13 @@ pub struct OpenFileParams { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] pub struct CloseFileParams { - pub path: PgTPath, + pub path: PgLSPath, } #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] pub struct ChangeFileParams { - pub path: PgTPath, + pub path: PgLSPath, pub version: i32, pub content: String, } @@ -52,7 +52,7 @@ pub struct ChangeFileParams { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] pub struct IsPathIgnoredParams { - pub pgt_path: PgTPath, + pub pgt_path: PgLSPath, } #[derive(Debug, serde::Serialize, serde::Deserialize)] @@ -67,7 +67,7 @@ pub struct UpdateSettingsParams { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] pub struct GetFileContentParams { - pub path: PgTPath, + pub path: PgLSPath, } #[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)] @@ -93,7 +93,7 @@ pub struct RegisterProjectFolderParams { #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase")] pub struct UnregisterProjectFolderParams { - pub path: PgTPath, + pub path: PgLSPath, } pub trait Workspace: Send + Sync + RefUnwindSafe { @@ -183,7 +183,7 @@ where /// automatically on drop pub struct FileGuard<'app, W: Workspace + ?Sized> { workspace: &'app W, - path: PgTPath, + path: PgLSPath, } impl<'app, W: Workspace + ?Sized> FileGuard<'app, W> { diff --git a/crates/pgt_workspace/src/workspace/client.rs b/crates/pgls_workspace/src/workspace/client.rs similarity index 98% rename from crates/pgt_workspace/src/workspace/client.rs rename to crates/pgls_workspace/src/workspace/client.rs index 05e964f6a..70f7c20a3 100644 --- a/crates/pgt_workspace/src/workspace/client.rs +++ b/crates/pgls_workspace/src/workspace/client.rs @@ -60,7 +60,7 @@ where "capabilities": {}, "clientInfo": { "name": env!("CARGO_PKG_NAME"), - "version": pgt_configuration::VERSION + "version": pgls_configuration::VERSION }, }), )?; diff --git a/crates/pgt_workspace/src/workspace/server.rs b/crates/pgls_workspace/src/workspace/server.rs similarity index 96% rename from crates/pgt_workspace/src/workspace/server.rs rename to crates/pgls_workspace/src/workspace/server.rs index b13a34422..88350d56e 100644 --- a/crates/pgt_workspace/src/workspace/server.rs +++ b/crates/pgls_workspace/src/workspace/server.rs @@ -15,14 +15,14 @@ use document::{ }; use futures::{StreamExt, stream}; use pg_query::convert_to_positional_params; -use pgt_analyse::{AnalyserOptions, AnalysisFilter}; -use pgt_analyser::{Analyser, AnalyserConfig, AnalyserParams}; -use pgt_diagnostics::{ +use pgls_analyse::{AnalyserOptions, AnalysisFilter}; +use pgls_analyser::{Analyser, AnalyserConfig, AnalyserParams}; +use pgls_diagnostics::{ Diagnostic, DiagnosticExt, Error, Severity, serde::Diagnostic as SDiagnostic, }; -use pgt_fs::{ConfigName, PgTPath}; -use pgt_typecheck::{IdentifierType, TypecheckParams, TypedIdentifier}; -use pgt_workspace_macros::ignored_path; +use pgls_fs::{ConfigName, PgLSPath}; +use pgls_typecheck::{IdentifierType, TypecheckParams, TypedIdentifier}; +use pgls_workspace_macros::ignored_path; use schema_cache_manager::SchemaCacheManager; use sqlx::{Executor, PgPool}; use tracing::{debug, info}; @@ -71,7 +71,7 @@ pub(super) struct WorkspaceServer { /// Stores the schema cache for this workspace schema_cache: SchemaCacheManager, - documents: RwLock>, + documents: RwLock>, connection: ConnectionManager, } @@ -122,7 +122,7 @@ impl WorkspaceServer { } /// Retrieves the current project path - fn get_current_project_path(&self) -> Option { + fn get_current_project_path(&self) -> Option { self.workspaces().path().cloned() } @@ -136,7 +136,7 @@ impl WorkspaceServer { /// Checks whether the current path belongs to the current project. /// /// If there's a match, and the match **isn't** the current project, it returns the new key. - fn path_belongs_to_current_workspace(&self, path: &PgTPath) -> Option { + fn path_belongs_to_current_workspace(&self, path: &PgLSPath) -> Option { let workspaces = self.workspaces(); workspaces.as_ref().path_belongs_to_current_workspace(path) } @@ -476,7 +476,7 @@ impl Workspace for WorkspaceServer { // Type checking if typecheck_enabled { let typecheck_result = - pgt_typecheck::check_sql(TypecheckParams { + pgls_typecheck::check_sql(TypecheckParams { conn: &pool, sql: convert_to_positional_params(id.content()) .as_str(), @@ -520,8 +520,8 @@ impl Workspace for WorkspaceServer { // plpgsql_check if plpgsql_check_enabled { let plpgsql_check_results = - pgt_plpgsql_check::check_plpgsql( - pgt_plpgsql_check::PlPgSqlCheckParams { + pgls_plpgsql_check::check_plpgsql( + pgls_plpgsql_check::PlPgSqlCheckParams { conn: &pool, sql: id.content(), ast: &ast, @@ -543,7 +543,7 @@ impl Workspace for WorkspaceServer { } } - Ok::, sqlx::Error>(diagnostics) + Ok::, sqlx::Error>(diagnostics) } }) .buffer_unordered(10) @@ -658,7 +658,7 @@ impl Workspace for WorkspaceServer { .chain(unused_suppression_errors.iter()) .cloned() .map(Error::from) - .collect::>(); + .collect::>(); diagnostics.retain(|d| !suppressions.is_suppressed(d)); diagnostics.extend(suppression_errors.into_iter().map(SDiagnostic::new)); @@ -707,7 +707,7 @@ impl Workspace for WorkspaceServer { Some((id, range, cst)) => { let position = params.position - range.start(); - let items = pgt_completions::complete(pgt_completions::CompletionParams { + let items = pgls_completions::complete(pgls_completions::CompletionParams { position, schema: schema_cache.as_ref(), tree: &cst, @@ -749,7 +749,7 @@ impl Workspace for WorkspaceServer { Some((stmt_id, range, ts_tree, maybe_ast)) => { let position_in_stmt = params.position - range.start(); - let markdown_blocks = pgt_hover::on_hover(pgt_hover::OnHoverParams { + let markdown_blocks = pgls_hover::on_hover(pgls_hover::OnHoverParams { ts_tree: &ts_tree, schema_cache: &schema_cache, ast: maybe_ast.as_ref(), diff --git a/crates/pgt_workspace/src/workspace/server.tests.rs b/crates/pgls_workspace/src/workspace/server.tests.rs similarity index 94% rename from crates/pgt_workspace/src/workspace/server.tests.rs rename to crates/pgls_workspace/src/workspace/server.tests.rs index 04c467116..7c274251d 100644 --- a/crates/pgt_workspace/src/workspace/server.tests.rs +++ b/crates/pgls_workspace/src/workspace/server.tests.rs @@ -1,17 +1,17 @@ use std::sync::Arc; use biome_deserialize::{Merge, StringSet}; -use pgt_analyse::RuleCategories; -use pgt_configuration::{ +use pgls_analyse::RuleCategories; +use pgls_configuration::{ PartialConfiguration, PartialTypecheckConfiguration, database::PartialDatabaseConfiguration, files::PartialFilesConfiguration, }; #[cfg(not(target_os = "windows"))] -use pgt_configuration::plpgsql_check::PartialPlPgSqlCheckConfiguration; -use pgt_diagnostics::Diagnostic; -use pgt_fs::PgTPath; -use pgt_text_size::TextRange; +use pgls_configuration::plpgsql_check::PartialPlPgSqlCheckConfiguration; +use pgls_diagnostics::Diagnostic; +use pgls_fs::PgLSPath; +use pgls_text_size::TextRange; use sqlx::{Executor, PgPool}; use crate::{ @@ -43,7 +43,7 @@ fn get_test_workspace( Ok(workspace) } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_diagnostics(test_db: PgPool) { let mut conf = PartialConfiguration::init(); conf.merge_with(PartialConfiguration { @@ -62,7 +62,7 @@ async fn test_diagnostics(test_db: PgPool) { let workspace = get_test_workspace(Some(conf)).expect("Unable to create test workspace"); - let path = PgTPath::new("test.sql"); + let path = PgLSPath::new("test.sql"); let content = r#" create table users ( id serial primary key, @@ -108,7 +108,7 @@ async fn test_diagnostics(test_db: PgPool) { ); } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_syntax_error(test_db: PgPool) { let mut conf = PartialConfiguration::init(); conf.merge_with(PartialConfiguration { @@ -127,7 +127,7 @@ async fn test_syntax_error(test_db: PgPool) { let workspace = get_test_workspace(Some(conf)).expect("Unable to create test workspace"); - let path = PgTPath::new("test.sql"); + let path = PgLSPath::new("test.sql"); let content = r#" seect 1; "#; @@ -176,7 +176,7 @@ async fn correctly_ignores_files() { let workspace = get_test_workspace(Some(conf)).expect("Unable to create test workspace"); - let path = PgTPath::new("test.sql"); + let path = PgLSPath::new("test.sql"); let content = r#" seect 1; "#; @@ -212,7 +212,7 @@ async fn correctly_ignores_files() { } #[cfg(all(test, not(target_os = "windows")))] -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_dedupe_diagnostics(test_db: PgPool) { let mut conf = PartialConfiguration::init(); conf.merge_with(PartialConfiguration { @@ -231,7 +231,7 @@ async fn test_dedupe_diagnostics(test_db: PgPool) { let workspace = get_test_workspace(Some(conf)).expect("Unable to create test workspace"); - let path = PgTPath::new("test.sql"); + let path = PgLSPath::new("test.sql"); let setup_sql = "CREATE EXTENSION IF NOT EXISTS plpgsql_check;"; test_db.execute(setup_sql).await.expect("setup sql failed"); @@ -282,13 +282,13 @@ async fn test_dedupe_diagnostics(test_db: PgPool) { ); } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_plpgsql_assign_composite_types(test_db: PgPool) { let conf = PartialConfiguration::init(); let workspace = get_test_workspace(Some(conf)).expect("Unable to create test workspace"); - let path = PgTPath::new("test.sql"); + let path = PgLSPath::new("test.sql"); let setup_sql = r" create table if not exists _fetch_cycle_continuation_data ( @@ -335,7 +335,7 @@ async fn test_plpgsql_assign_composite_types(test_db: PgPool) { assert_eq!(diagnostics.len(), 0, "Expected no diagnostic"); } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_positional_params(test_db: PgPool) { let mut conf = PartialConfiguration::init(); conf.merge_with(PartialConfiguration { @@ -354,7 +354,7 @@ async fn test_positional_params(test_db: PgPool) { let workspace = get_test_workspace(Some(conf)).expect("Unable to create test workspace"); - let path = PgTPath::new("test.sql"); + let path = PgLSPath::new("test.sql"); let setup_sql = r" create table users ( @@ -390,7 +390,7 @@ async fn test_positional_params(test_db: PgPool) { } #[cfg(all(test, not(target_os = "windows")))] -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_disable_plpgsql_check(test_db: PgPool) { let mut conf = PartialConfiguration::init(); conf.merge_with(PartialConfiguration { @@ -409,7 +409,7 @@ async fn test_disable_plpgsql_check(test_db: PgPool) { let workspace = get_test_workspace(Some(conf)).expect("Unable to create test workspace"); - let path = PgTPath::new("test.sql"); + let path = PgLSPath::new("test.sql"); let setup_sql = "CREATE EXTENSION IF NOT EXISTS plpgsql_check;"; test_db.execute(setup_sql).await.expect("setup sql failed"); @@ -489,7 +489,7 @@ async fn test_disable_plpgsql_check(test_db: PgPool) { ); } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_disable_typecheck(test_db: PgPool) { let mut conf = PartialConfiguration::init(); conf.merge_with(PartialConfiguration { @@ -508,7 +508,7 @@ async fn test_disable_typecheck(test_db: PgPool) { let workspace = get_test_workspace(Some(conf)).expect("Unable to create test workspace"); - let path = PgTPath::new("test.sql"); + let path = PgLSPath::new("test.sql"); let setup_sql = r" create table users ( @@ -582,13 +582,13 @@ async fn test_disable_typecheck(test_db: PgPool) { ); } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_named_params(_test_db: PgPool) { let conf = PartialConfiguration::init(); let workspace = get_test_workspace(Some(conf)).expect("Unable to create test workspace"); - let path = PgTPath::new("test.sql"); + let path = PgLSPath::new("test.sql"); let content = r#" SELECT @@ -629,7 +629,7 @@ FOR NO KEY UPDATE; ); } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_cstyle_comments(test_db: PgPool) { let mut conf = PartialConfiguration::init(); conf.merge_with(PartialConfiguration { @@ -648,7 +648,7 @@ async fn test_cstyle_comments(test_db: PgPool) { let workspace = get_test_workspace(Some(conf)).expect("Unable to create test workspace"); - let path = PgTPath::new("test.sql"); + let path = PgLSPath::new("test.sql"); let content = r#" /* @@ -683,7 +683,7 @@ async fn test_cstyle_comments(test_db: PgPool) { assert_eq!(diagnostics.len(), 0, "Expected no diagnostic"); } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")] async fn test_search_path_configuration(test_db: PgPool) { // Setup test schemas and functions let setup_sql = r#" @@ -695,7 +695,7 @@ async fn test_search_path_configuration(test_db: PgPool) { "#; test_db.execute(setup_sql).await.expect("setup sql failed"); - let path_glob = PgTPath::new("test_glob.sql"); + let path_glob = PgLSPath::new("test_glob.sql"); let file_content = r#" select get_user_id(); -- on private schema "#; diff --git a/crates/pgt_workspace/src/workspace/server/analyser.rs b/crates/pgls_workspace/src/workspace/server/analyser.rs similarity index 92% rename from crates/pgt_workspace/src/workspace/server/analyser.rs rename to crates/pgls_workspace/src/workspace/server/analyser.rs index 86e3d0763..5d6b5adf4 100644 --- a/crates/pgt_workspace/src/workspace/server/analyser.rs +++ b/crates/pgls_workspace/src/workspace/server/analyser.rs @@ -1,5 +1,5 @@ -use pgt_analyse::{GroupCategory, RegistryVisitor, Rule, RuleCategory, RuleFilter, RuleGroup}; -use pgt_configuration::RuleSelector; +use pgls_analyse::{GroupCategory, RegistryVisitor, Rule, RuleCategory, RuleFilter, RuleGroup}; +use pgls_configuration::RuleSelector; use rustc_hash::FxHashSet; use crate::settings::Settings; @@ -31,7 +31,7 @@ impl<'a, 'b> AnalyserVisitorBuilder<'a, 'b> { let mut disabled_rules = vec![]; let mut enabled_rules = vec![]; if let Some(mut lint) = self.lint { - pgt_analyser::visit_registry(&mut lint); + pgls_analyser::visit_registry(&mut lint); let (linter_enabled_rules, linter_disabled_rules) = lint.finish(); enabled_rules.extend(linter_enabled_rules); disabled_rules.extend(linter_disabled_rules); @@ -140,8 +140,8 @@ impl RegistryVisitor for LintVisitor<'_, '_> { #[cfg(test)] mod tests { - use pgt_analyse::RuleFilter; - use pgt_configuration::{RuleConfiguration, Rules, analyser::Safety}; + use pgls_analyse::RuleFilter; + use pgls_configuration::{RuleConfiguration, Rules, analyser::Safety}; use crate::{ settings::{LinterSettings, Settings}, @@ -155,7 +155,7 @@ mod tests { rules: Some(Rules { safety: Some(Safety { ban_drop_column: Some(RuleConfiguration::Plain( - pgt_configuration::RulePlainConfiguration::Off, + pgls_configuration::RulePlainConfiguration::Off, )), ..Default::default() }), diff --git a/crates/pgt_workspace/src/workspace/server/annotation.rs b/crates/pgls_workspace/src/workspace/server/annotation.rs similarity index 97% rename from crates/pgt_workspace/src/workspace/server/annotation.rs rename to crates/pgls_workspace/src/workspace/server/annotation.rs index 0ff6cc0a0..7275bc0dd 100644 --- a/crates/pgt_workspace/src/workspace/server/annotation.rs +++ b/crates/pgls_workspace/src/workspace/server/annotation.rs @@ -2,7 +2,7 @@ use std::num::NonZeroUsize; use std::sync::{Arc, Mutex}; use lru::LruCache; -use pgt_lexer::SyntaxKind; +use pgls_lexer::SyntaxKind; use super::statement_identifier::StatementId; @@ -47,7 +47,7 @@ impl AnnotationStore { return existing.clone(); } - let lexed = pgt_lexer::lex(content); + let lexed = pgls_lexer::lex(content); let ends_with_semicolon = (0..lexed.len()) // Iterate through tokens in reverse to find the last non-whitespace token diff --git a/crates/pgt_workspace/src/workspace/server/async_helper.rs b/crates/pgls_workspace/src/workspace/server/async_helper.rs similarity index 100% rename from crates/pgt_workspace/src/workspace/server/async_helper.rs rename to crates/pgls_workspace/src/workspace/server/async_helper.rs diff --git a/crates/pgt_workspace/src/workspace/server/connection_key.rs b/crates/pgls_workspace/src/workspace/server/connection_key.rs similarity index 100% rename from crates/pgt_workspace/src/workspace/server/connection_key.rs rename to crates/pgls_workspace/src/workspace/server/connection_key.rs diff --git a/crates/pgt_workspace/src/workspace/server/connection_manager.rs b/crates/pgls_workspace/src/workspace/server/connection_manager.rs similarity index 100% rename from crates/pgt_workspace/src/workspace/server/connection_manager.rs rename to crates/pgls_workspace/src/workspace/server/connection_manager.rs diff --git a/crates/pgt_workspace/src/workspace/server/document.rs b/crates/pgls_workspace/src/workspace/server/document.rs similarity index 97% rename from crates/pgt_workspace/src/workspace/server/document.rs rename to crates/pgls_workspace/src/workspace/server/document.rs index 9a496dc1a..d96dcf556 100644 --- a/crates/pgt_workspace/src/workspace/server/document.rs +++ b/crates/pgls_workspace/src/workspace/server/document.rs @@ -1,10 +1,10 @@ use std::sync::Arc; -use pgt_analyser::AnalysableStatement; -use pgt_diagnostics::{Diagnostic, DiagnosticExt, serde::Diagnostic as SDiagnostic}; -use pgt_query_ext::diagnostics::SyntaxDiagnostic; -use pgt_suppressions::Suppressions; -use pgt_text_size::{TextRange, TextSize}; +use pgls_analyser::AnalysableStatement; +use pgls_diagnostics::{Diagnostic, DiagnosticExt, serde::Diagnostic as SDiagnostic}; +use pgls_query_ext::diagnostics::SyntaxDiagnostic; +use pgls_suppressions::Suppressions; +use pgls_text_size::{TextRange, TextSize}; use super::{ annotation::AnnotationStore, @@ -191,7 +191,7 @@ impl<'a> StatementMapper<'a> for DefaultMapper { pub struct ExecuteStatementMapper; impl<'a> StatementMapper<'a> for ExecuteStatementMapper { - type Output = (StatementId, TextRange, String, Option); + type Output = (StatementId, TextRange, String, Option); fn map(&self, parser: &'a Document, id: StatementId, range: TextRange) -> Self::Output { let ast_result = parser.ast_db.get_or_cache_ast(&id); @@ -209,7 +209,7 @@ impl<'a> StatementMapper<'a> for TypecheckDiagnosticsMapper { type Output = ( StatementId, TextRange, - Option, + Option, Arc, Option, ); @@ -279,7 +279,7 @@ impl<'a> StatementMapper<'a> for WithCSTandASTMapper { StatementId, TextRange, Arc, - Option, + Option, ); fn map(&self, parser: &'a Document, id: StatementId, range: TextRange) -> Self::Output { @@ -367,7 +367,7 @@ pub(crate) fn split_with_diagnostics( offset: Option, ) -> (Vec, Vec) { let o = offset.unwrap_or_else(|| 0.into()); - let result = pgt_statement_splitter::split(content); + let result = pgls_statement_splitter::split(content); ( result.ranges, diff --git a/crates/pgt_workspace/src/workspace/server/migration.rs b/crates/pgls_workspace/src/workspace/server/migration.rs similarity index 100% rename from crates/pgt_workspace/src/workspace/server/migration.rs rename to crates/pgls_workspace/src/workspace/server/migration.rs diff --git a/crates/pgt_workspace/src/workspace/server/pg_query.rs b/crates/pgls_workspace/src/workspace/server/pg_query.rs similarity index 87% rename from crates/pgt_workspace/src/workspace/server/pg_query.rs rename to crates/pgls_workspace/src/workspace/server/pg_query.rs index a198ae3f7..179dec1b1 100644 --- a/crates/pgt_workspace/src/workspace/server/pg_query.rs +++ b/crates/pgls_workspace/src/workspace/server/pg_query.rs @@ -3,9 +3,9 @@ use std::num::NonZeroUsize; use std::sync::{Arc, LazyLock, Mutex}; use lru::LruCache; -use pgt_lexer::lex; -use pgt_query_ext::diagnostics::*; -use pgt_text_size::TextRange; +use pgls_lexer::lex; +use pgls_query_ext::diagnostics::*; +use pgls_text_size::TextRange; use regex::Regex; use super::statement_identifier::StatementId; @@ -13,7 +13,7 @@ use super::statement_identifier::StatementId; const DEFAULT_CACHE_SIZE: usize = 1000; pub struct PgQueryStore { - ast_db: Mutex>>>, + ast_db: Mutex>>>, plpgsql_db: Mutex>>, } @@ -32,7 +32,7 @@ impl PgQueryStore { pub fn get_or_cache_ast( &self, statement: &StatementId, - ) -> Arc> { + ) -> Arc> { let mut cache = self.ast_db.lock().unwrap(); if let Some(existing) = cache.get(statement) { @@ -40,7 +40,7 @@ impl PgQueryStore { } let r = Arc::new( - pgt_query::parse(&convert_to_positional_params(statement.content())) + pgls_query::parse(&convert_to_positional_params(statement.content())) .map_err(SyntaxDiagnostic::from) .and_then(|ast| { ast.into_root().ok_or_else(|| { @@ -59,11 +59,11 @@ impl PgQueryStore { let ast = self.get_or_cache_ast(statement); let create_fn = match ast.as_ref() { - Ok(pgt_query::NodeEnum::CreateFunctionStmt(node)) => node, + Ok(pgls_query::NodeEnum::CreateFunctionStmt(node)) => node, _ => return None, }; - let language = pgt_query_ext::utils::find_option_value(create_fn, "language")?; + let language = pgls_query_ext::utils::find_option_value(create_fn, "language")?; if language != "plpgsql" { return None; @@ -75,18 +75,18 @@ impl PgQueryStore { return Some(existing.clone()); } - let sql_body = pgt_query_ext::utils::find_option_value(create_fn, "as")?; + let sql_body = pgls_query_ext::utils::find_option_value(create_fn, "as")?; let start = statement.content().find(&sql_body)?; let end = start + sql_body.len(); let range = TextRange::new(start.try_into().unwrap(), end.try_into().unwrap()); - let r = pgt_query::parse_plpgsql(statement.content()) + let r = pgls_query::parse_plpgsql(statement.content()) .or_else(|e| match &e { // ignore `is not a known variable` for composite types because libpg_query reports a false positive. // https://github.com/pganalyze/libpg_query/issues/159 - pgt_query::Error::Parse(err) if is_composite_type_error(err) => Ok(()), + pgls_query::Error::Parse(err) if is_composite_type_error(err) => Ok(()), _ => Err(e), }) .map_err(|e| SyntaxDiagnostic::new(e.to_string(), Some(range))); @@ -106,23 +106,23 @@ fn is_composite_type_error(err: &str) -> bool { // Keywords that, when preceding a named parameter, indicate that the parameter should be treated // as an identifier rather than a positional parameter. -const IDENTIFIER_CONTEXT: [pgt_lexer::SyntaxKind; 15] = [ - pgt_lexer::SyntaxKind::TO_KW, - pgt_lexer::SyntaxKind::FROM_KW, - pgt_lexer::SyntaxKind::SCHEMA_KW, - pgt_lexer::SyntaxKind::TABLE_KW, - pgt_lexer::SyntaxKind::INDEX_KW, - pgt_lexer::SyntaxKind::CONSTRAINT_KW, - pgt_lexer::SyntaxKind::OWNER_KW, - pgt_lexer::SyntaxKind::ROLE_KW, - pgt_lexer::SyntaxKind::USER_KW, - pgt_lexer::SyntaxKind::DATABASE_KW, - pgt_lexer::SyntaxKind::TYPE_KW, - pgt_lexer::SyntaxKind::CAST_KW, - pgt_lexer::SyntaxKind::ALTER_KW, - pgt_lexer::SyntaxKind::DROP_KW, +const IDENTIFIER_CONTEXT: [pgls_lexer::SyntaxKind; 15] = [ + pgls_lexer::SyntaxKind::TO_KW, + pgls_lexer::SyntaxKind::FROM_KW, + pgls_lexer::SyntaxKind::SCHEMA_KW, + pgls_lexer::SyntaxKind::TABLE_KW, + pgls_lexer::SyntaxKind::INDEX_KW, + pgls_lexer::SyntaxKind::CONSTRAINT_KW, + pgls_lexer::SyntaxKind::OWNER_KW, + pgls_lexer::SyntaxKind::ROLE_KW, + pgls_lexer::SyntaxKind::USER_KW, + pgls_lexer::SyntaxKind::DATABASE_KW, + pgls_lexer::SyntaxKind::TYPE_KW, + pgls_lexer::SyntaxKind::CAST_KW, + pgls_lexer::SyntaxKind::ALTER_KW, + pgls_lexer::SyntaxKind::DROP_KW, // for schema.table style identifiers - pgt_lexer::SyntaxKind::DOT, + pgls_lexer::SyntaxKind::DOT, ]; /// Converts named parameters in a SQL query string to positional parameters. @@ -140,13 +140,13 @@ pub fn convert_to_positional_params(text: &str) -> String { let lexed = lex(text); for (token_idx, kind) in lexed.tokens().enumerate() { - if kind == pgt_lexer::SyntaxKind::EOF { + if kind == pgls_lexer::SyntaxKind::EOF { break; } let token_text = lexed.text(token_idx); - if matches!(kind, pgt_lexer::SyntaxKind::NAMED_PARAM) { + if matches!(kind, pgls_lexer::SyntaxKind::NAMED_PARAM) { let idx = match param_mapping.get(token_text) { Some(&index) => index, None => { diff --git a/crates/pgt_workspace/src/workspace/server/schema_cache_manager.rs b/crates/pgls_workspace/src/workspace/server/schema_cache_manager.rs similarity index 97% rename from crates/pgt_workspace/src/workspace/server/schema_cache_manager.rs rename to crates/pgls_workspace/src/workspace/server/schema_cache_manager.rs index 007ebb782..a487b1eaa 100644 --- a/crates/pgt_workspace/src/workspace/server/schema_cache_manager.rs +++ b/crates/pgls_workspace/src/workspace/server/schema_cache_manager.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use std::sync::{Arc, RwLock}; -use pgt_schema_cache::SchemaCache; +use pgls_schema_cache::SchemaCache; use sqlx::PgPool; use crate::WorkspaceError; diff --git a/crates/pgt_workspace/src/workspace/server/sql_function.rs b/crates/pgls_workspace/src/workspace/server/sql_function.rs similarity index 78% rename from crates/pgt_workspace/src/workspace/server/sql_function.rs rename to crates/pgls_workspace/src/workspace/server/sql_function.rs index 4a1463b71..cebcf29af 100644 --- a/crates/pgt_workspace/src/workspace/server/sql_function.rs +++ b/crates/pgls_workspace/src/workspace/server/sql_function.rs @@ -1,4 +1,4 @@ -use pgt_text_size::TextRange; +use pgls_text_size::TextRange; #[derive(Debug, Clone)] pub struct ArgType { @@ -28,30 +28,30 @@ pub struct SQLFunctionBody { } /// Extracts the function signature from a SQL function definition -pub fn get_sql_fn_signature(ast: &pgt_query::NodeEnum) -> Option { +pub fn get_sql_fn_signature(ast: &pgls_query::NodeEnum) -> Option { let create_fn = match ast { - pgt_query::NodeEnum::CreateFunctionStmt(cf) => cf, + pgls_query::NodeEnum::CreateFunctionStmt(cf) => cf, _ => return None, }; // Extract language from function options - let language = pgt_query_ext::utils::find_option_value(create_fn, "language")?; + let language = pgls_query_ext::utils::find_option_value(create_fn, "language")?; // Only process SQL functions if language != "sql" { return None; } - let fn_name = pgt_query_ext::utils::parse_name(&create_fn.funcname)?; + let fn_name = pgls_query_ext::utils::parse_name(&create_fn.funcname)?; // we return None if anything is not expected let mut fn_args = Vec::new(); for arg in &create_fn.parameters { - if let Some(pgt_query::NodeEnum::FunctionParameter(node)) = &arg.node { + if let Some(pgls_query::NodeEnum::FunctionParameter(node)) = &arg.node { let arg_name = (!node.name.is_empty()).then_some(node.name.clone()); let arg_type = node.arg_type.as_ref()?; - let type_name = pgt_query_ext::utils::parse_name(&arg_type.names)?; + let type_name = pgls_query_ext::utils::parse_name(&arg_type.names)?; fn_args.push(SQLFunctionArg { name: arg_name, type_: ArgType { @@ -77,14 +77,14 @@ pub fn get_sql_fn_signature(ast: &pgt_query::NodeEnum) -> Option Option { +pub fn get_sql_fn_body(ast: &pgls_query::NodeEnum, content: &str) -> Option { let create_fn = match ast { - pgt_query::NodeEnum::CreateFunctionStmt(cf) => cf, + pgls_query::NodeEnum::CreateFunctionStmt(cf) => cf, _ => return None, }; // Extract language from function options - let language = pgt_query_ext::utils::find_option_value(create_fn, "language")?; + let language = pgls_query_ext::utils::find_option_value(create_fn, "language")?; // Only process SQL functions if language != "sql" { @@ -92,7 +92,7 @@ pub fn get_sql_fn_body(ast: &pgt_query::NodeEnum, content: &str) -> Option TreeSitterStore { let mut parser = tree_sitter::Parser::new(); parser - .set_language(&pgt_treesitter_grammar::LANGUAGE.into()) + .set_language(&pgls_treesitter_grammar::LANGUAGE.into()) .expect("Error loading sql language"); TreeSitterStore { diff --git a/crates/pgt_workspace/src/workspace_types.rs b/crates/pgls_workspace/src/workspace_types.rs similarity index 100% rename from crates/pgt_workspace/src/workspace_types.rs rename to crates/pgls_workspace/src/workspace_types.rs diff --git a/crates/pgt_workspace_macros/Cargo.toml b/crates/pgls_workspace_macros/Cargo.toml similarity index 90% rename from crates/pgt_workspace_macros/Cargo.toml rename to crates/pgls_workspace_macros/Cargo.toml index c192db04b..3a9239db1 100644 --- a/crates/pgt_workspace_macros/Cargo.toml +++ b/crates/pgls_workspace_macros/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pgt_workspace_macros" +name = "pgls_workspace_macros" repository.workspace = true version = "0.0.0" diff --git a/crates/pgt_workspace_macros/src/lib.rs b/crates/pgls_workspace_macros/src/lib.rs similarity index 98% rename from crates/pgt_workspace_macros/src/lib.rs rename to crates/pgls_workspace_macros/src/lib.rs index d46f484da..2f77cd154 100644 --- a/crates/pgt_workspace_macros/src/lib.rs +++ b/crates/pgls_workspace_macros/src/lib.rs @@ -31,7 +31,7 @@ impl syn::parse::Parse for IgnoredPath { /// is ignored by the user's settings. /// /// This will work for any function where &self is in scope and that returns `Result`, `Result<(), E>`, or `T`, where `T: Default`. -/// `path` needs to point at a `&PgTPath`. +/// `path` needs to point at a `&PgLSPath`. /// /// ### Usage /// diff --git a/crates/pgt_analyser/Cargo.toml b/crates/pgt_analyser/Cargo.toml deleted file mode 100644 index b00c9939c..000000000 --- a/crates/pgt_analyser/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ - -[package] -authors.workspace = true -categories.workspace = true -description = "" -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -license.workspace = true -name = "pgt_analyser" -repository.workspace = true -version = "0.0.0" - -[dependencies] -pgt_analyse = { workspace = true } -pgt_console = { workspace = true } -pgt_diagnostics = { workspace = true } -pgt_query = { workspace = true } -pgt_query_ext = { workspace = true } -pgt_schema_cache = { workspace = true } -pgt_text_size = { workspace = true } -serde = { workspace = true } - -[dev-dependencies] -insta = { version = "1.42.1" } -pgt_diagnostics = { workspace = true } -pgt_statement_splitter = { workspace = true } -pgt_test_macros = { workspace = true } -termcolor = { workspace = true } diff --git a/crates/pgt_analyser/src/lint.rs b/crates/pgt_analyser/src/lint.rs deleted file mode 100644 index cbc13c9d7..000000000 --- a/crates/pgt_analyser/src/lint.rs +++ /dev/null @@ -1,4 +0,0 @@ -//! Generated file, do not edit by hand, see `xtask/codegen` - -pub mod safety; -::pgt_analyse::declare_category! { pub Lint { kind : Lint , groups : [self :: safety :: Safety ,] } } diff --git a/crates/pgt_completions/Cargo.toml b/crates/pgt_completions/Cargo.toml deleted file mode 100644 index c20b7d897..000000000 --- a/crates/pgt_completions/Cargo.toml +++ /dev/null @@ -1,45 +0,0 @@ -[package] -authors.workspace = true -categories.workspace = true -description = "" -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -license.workspace = true -name = "pgt_completions" -repository.workspace = true -version = "0.0.0" - - -[dependencies] -async-std = "1.12.0" - -pgt_schema_cache.workspace = true -pgt_text_size.workspace = true -pgt_treesitter.workspace = true - -fuzzy-matcher = "0.3.7" -pgt_treesitter_grammar.workspace = true -schemars = { workspace = true, optional = true } -serde = { workspace = true, features = ["derive"] } -serde_json = { workspace = true } -tracing = { workspace = true } -tree-sitter.workspace = true - -sqlx.workspace = true - -tokio = { version = "1.41.1", features = ["full"] } - -[dev-dependencies] -criterion = "0.5.1" -pgt_test_utils.workspace = true - -[lib] -doctest = false - -[features] -schema = ["dep:schemars"] - -[[bench]] -harness = false -name = "sanitization" diff --git a/crates/pgt_completions/src/relevance.rs b/crates/pgt_completions/src/relevance.rs deleted file mode 100644 index 1d39d9bb4..000000000 --- a/crates/pgt_completions/src/relevance.rs +++ /dev/null @@ -1,12 +0,0 @@ -pub(crate) mod filtering; -pub(crate) mod scoring; - -#[derive(Debug, Clone)] -pub(crate) enum CompletionRelevanceData<'a> { - Table(&'a pgt_schema_cache::Table), - Function(&'a pgt_schema_cache::Function), - Column(&'a pgt_schema_cache::Column), - Schema(&'a pgt_schema_cache::Schema), - Policy(&'a pgt_schema_cache::Policy), - Role(&'a pgt_schema_cache::Role), -} diff --git a/crates/pgt_diagnostics/Cargo.toml b/crates/pgt_diagnostics/Cargo.toml deleted file mode 100644 index 06c6f8dcd..000000000 --- a/crates/pgt_diagnostics/Cargo.toml +++ /dev/null @@ -1,36 +0,0 @@ -[package] -authors.workspace = true -categories.workspace = true -description = "" -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -license.workspace = true -name = "pgt_diagnostics" -repository.workspace = true -version = "0.0.0" - - -[dependencies] -backtrace = "0.3.74" -bpaf = { workspace = true } -enumflags2 = { workspace = true } -oxc_resolver = { workspace = true } -pgt_console = { workspace = true, features = ["serde"] } -pgt_diagnostics_categories = { workspace = true, features = ["serde"] } -pgt_diagnostics_macros = { workspace = true } -pgt_text_edit = { workspace = true, features = ["serde"] } -pgt_text_size.workspace = true -schemars = { workspace = true, optional = true } -serde = { workspace = true, features = ["derive"] } -serde_json = { workspace = true } -termcolor = { workspace = true } -unicode-width = { workspace = true } - -[features] -schema = ["dep:schemars", "pgt_text_edit/schema", "pgt_diagnostics_categories/schema", "pgt_console/schema"] - -[dev-dependencies] - -[lib] -doctest = false diff --git a/crates/pgt_diagnostics_categories/src/categories.rs b/crates/pgt_diagnostics_categories/src/categories.rs deleted file mode 100644 index 416416ef9..000000000 --- a/crates/pgt_diagnostics_categories/src/categories.rs +++ /dev/null @@ -1,67 +0,0 @@ -// This file contains the list of all diagnostic categories for the pg -// toolchain -// -// The `define_categories` macro is preprocessed in the build script for the -// crate in order to generate the static registry. The body of the macro -// consists of a list of key-value pairs defining the categories that have an -// associated hyperlink, then a list of string literals defining the remaining -// categories without a link. - -// PLEASE, DON'T EDIT THIS FILE BY HAND. -// Use `just new-lintrule` to create a new rule. -// lint rules are lexicographically sorted and -// must be between `define_categories! {\n` and `\n ;\n`. - -define_categories! { - "lint/safety/addingFieldWithDefault": "https://pgtools.dev/latest/rules/adding-field-with-default", - "lint/safety/addingForeignKeyConstraint": "https://pgtools.dev/latest/rules/adding-foreign-key-constraint", - "lint/safety/addingNotNullField": "https://pgtools.dev/latest/rules/adding-not-null-field", - "lint/safety/addingPrimaryKeyConstraint": "https://pgtools.dev/latest/rules/adding-primary-key-constraint", - "lint/safety/addingRequiredField": "https://pgtools.dev/latest/rules/adding-required-field", - "lint/safety/banCharField": "https://pgtools.dev/latest/rules/ban-char-field", - "lint/safety/banConcurrentIndexCreationInTransaction": "https://pgtools.dev/latest/rules/ban-concurrent-index-creation-in-transaction", - "lint/safety/banDropColumn": "https://pgtools.dev/latest/rules/ban-drop-column", - "lint/safety/banDropDatabase": "https://pgtools.dev/latest/rules/ban-drop-database", - "lint/safety/banDropNotNull": "https://pgtools.dev/latest/rules/ban-drop-not-null", - "lint/safety/banDropTable": "https://pgtools.dev/latest/rules/ban-drop-table", - "lint/safety/banTruncateCascade": "https://pgtools.dev/latest/rules/ban-truncate-cascade", - "lint/safety/changingColumnType": "https://pgtools.dev/latest/rules/changing-column-type", - "lint/safety/constraintMissingNotValid": "https://pgtools.dev/latest/rules/constraint-missing-not-valid", - "lint/safety/disallowUniqueConstraint": "https://pgtools.dev/latest/rules/disallow-unique-constraint", - "lint/safety/preferBigInt": "https://pgtools.dev/latest/rules/prefer-big-int", - "lint/safety/preferBigintOverInt": "https://pgtools.dev/latest/rules/prefer-bigint-over-int", - "lint/safety/preferBigintOverSmallint": "https://pgtools.dev/latest/rules/prefer-bigint-over-smallint", - "lint/safety/preferIdentity": "https://pgtools.dev/latest/rules/prefer-identity", - "lint/safety/preferJsonb": "https://pgtools.dev/latest/rules/prefer-jsonb", - "lint/safety/preferRobustStmts": "https://pgtools.dev/latest/rules/prefer-robust-stmts", - "lint/safety/preferTextField": "https://pgtools.dev/latest/rules/prefer-text-field", - "lint/safety/preferTimestamptz": "https://pgtools.dev/latest/rules/prefer-timestamptz", - "lint/safety/renamingColumn": "https://pgtools.dev/latest/rules/renaming-column", - "lint/safety/renamingTable": "https://pgtools.dev/latest/rules/renaming-table", - "lint/safety/requireConcurrentIndexCreation": "https://pgtools.dev/latest/rules/require-concurrent-index-creation", - "lint/safety/requireConcurrentIndexDeletion": "https://pgtools.dev/latest/rules/require-concurrent-index-deletion", - "lint/safety/transactionNesting": "https://pgtools.dev/latest/rules/transaction-nesting", - // end lint rules - ; - // General categories - "stdin", - "check", - "configuration", - "database/connection", - "internalError/io", - "internalError/runtime", - "internalError/fs", - "flags/invalid", - "project", - "typecheck", - "plpgsql_check", - "internalError/panic", - "syntax", - "dummy", - - // Lint groups start - "lint", - "lint/performance", - "lint/safety", - // Lint groups end -} diff --git a/crates/pgt_fs/Cargo.toml b/crates/pgt_fs/Cargo.toml deleted file mode 100644 index 40478934c..000000000 --- a/crates/pgt_fs/Cargo.toml +++ /dev/null @@ -1,33 +0,0 @@ -[package] -authors.workspace = true -categories.workspace = true -description = "" -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -license.workspace = true -name = "pgt_fs" -repository.workspace = true -version = "0.0.0" - - -[dependencies] -crossbeam = { workspace = true } -directories = "5.0.1" -enumflags2 = { workspace = true } -oxc_resolver = { workspace = true } -parking_lot = { version = "0.12.3", features = ["arc_lock"] } -pgt_diagnostics = { workspace = true } -rayon = { workspace = true } -rustc-hash = { workspace = true } -schemars = { workspace = true, optional = true } -serde = { workspace = true, optional = true } -smallvec = { workspace = true } -tracing = { workspace = true } - -[features] -schema = ["dep:schemars", "pgt_diagnostics/schema"] -serde = ["dep:serde"] - -[lib] -doctest = false diff --git a/crates/pgt_hover/Cargo.toml b/crates/pgt_hover/Cargo.toml deleted file mode 100644 index ca328fa00..000000000 --- a/crates/pgt_hover/Cargo.toml +++ /dev/null @@ -1,37 +0,0 @@ -[package] -authors.workspace = true -categories.workspace = true -description = "" -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -license.workspace = true -name = "pgt_hover" -repository.workspace = true -version = "0.0.0" - - -[dependencies] -humansize = { version = "2.1.3" } -pgt_query.workspace = true -pgt_schema_cache.workspace = true -pgt_text_size.workspace = true -pgt_treesitter.workspace = true -pgt_treesitter_grammar.workspace = true -schemars = { workspace = true, optional = true } -serde = { workspace = true, features = ["derive"] } -serde_json = { workspace = true } -sqlx.workspace = true -tokio = { version = "1.41.1", features = ["full"] } -tracing = { workspace = true } -tree-sitter.workspace = true - -[dev-dependencies] -insta = { version = "1.42.1" } -pgt_test_utils.workspace = true - -[lib] -doctest = false - -[features] -schema = ["dep:schemars"] diff --git a/crates/pgt_lexer/src/codegen/syntax_kind.rs b/crates/pgt_lexer/src/codegen/syntax_kind.rs deleted file mode 100644 index f50398ec2..000000000 --- a/crates/pgt_lexer/src/codegen/syntax_kind.rs +++ /dev/null @@ -1 +0,0 @@ -pgt_lexer_codegen::syntax_kind_codegen!(); diff --git a/crates/pgt_lsp/Cargo.toml b/crates/pgt_lsp/Cargo.toml deleted file mode 100644 index f2aca70a9..000000000 --- a/crates/pgt_lsp/Cargo.toml +++ /dev/null @@ -1,43 +0,0 @@ -[package] -authors.workspace = true -categories.workspace = true -description = "" -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -license.workspace = true -name = "pgt_lsp" -repository.workspace = true -version = "0.0.0" - - -[dependencies] -anyhow = { workspace = true } -biome_deserialize = { workspace = true } -futures = "0.3.31" -pgt_analyse = { workspace = true } -pgt_completions = { workspace = true } -pgt_configuration = { workspace = true } -pgt_console = { workspace = true } -pgt_diagnostics = { workspace = true } -pgt_fs = { workspace = true } -pgt_text_edit = { workspace = true } -pgt_text_size.workspace = true -pgt_workspace = { workspace = true } -rustc-hash = { workspace = true } -serde = { workspace = true, features = ["derive"] } -serde_json = { workspace = true } -strum = { workspace = true } -tokio = { workspace = true, features = ["rt", "io-std"] } -tower-lsp = { version = "0.20.0" } -tracing = { workspace = true, features = ["attributes"] } - -[dev-dependencies] -pgt_test_utils = { workspace = true } -sqlx = { workspace = true } -test-log = { workspace = true } -tokio = { workspace = true, features = ["macros"] } -tower = { version = "0.4.13", features = ["timeout"] } - -[lib] -doctest = false diff --git a/crates/pgt_plpgsql_check/Cargo.toml b/crates/pgt_plpgsql_check/Cargo.toml deleted file mode 100644 index 75d1a52b3..000000000 --- a/crates/pgt_plpgsql_check/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -[package] -authors.workspace = true -categories.workspace = true -description = "" -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -license.workspace = true -name = "pgt_plpgsql_check" -repository.workspace = true -version = "0.0.0" - - -[dependencies] -pgt_console = { workspace = true } -pgt_diagnostics = { workspace = true } -pgt_query = { workspace = true } -pgt_query_ext = { workspace = true } -pgt_schema_cache = { workspace = true } -pgt_text_size = { workspace = true } -regex = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true } -sqlx = { workspace = true } -tree-sitter = { workspace = true } - -[dev-dependencies] -pgt_test_utils = { workspace = true } - -[lib] diff --git a/crates/pgt_query/src/iter_mut.rs b/crates/pgt_query/src/iter_mut.rs deleted file mode 100644 index fe5e88068..000000000 --- a/crates/pgt_query/src/iter_mut.rs +++ /dev/null @@ -1 +0,0 @@ -pgt_query_macros::iter_mut_codegen!(); diff --git a/crates/pgt_query/src/iter_ref.rs b/crates/pgt_query/src/iter_ref.rs deleted file mode 100644 index 6ac4f220a..000000000 --- a/crates/pgt_query/src/iter_ref.rs +++ /dev/null @@ -1 +0,0 @@ -pgt_query_macros::iter_ref_codegen!(); diff --git a/crates/pgt_schema_cache/Cargo.toml b/crates/pgt_schema_cache/Cargo.toml deleted file mode 100644 index c5fadb3e2..000000000 --- a/crates/pgt_schema_cache/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -[package] -authors.workspace = true -categories.workspace = true -description = "" -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -license.workspace = true -name = "pgt_schema_cache" -repository.workspace = true -version = "0.0.0" - - -[dependencies] -anyhow.workspace = true -async-std = { version = "1.12.0" } -futures-util = "0.3.31" -pgt_console.workspace = true -pgt_diagnostics.workspace = true -serde.workspace = true -serde_json.workspace = true -sqlx.workspace = true -strum = { workspace = true } -tokio.workspace = true - -[dev-dependencies] -pgt_test_utils.workspace = true - -[lib] -doctest = false diff --git a/crates/pgt_text_edit/Cargo.toml b/crates/pgt_text_edit/Cargo.toml deleted file mode 100644 index e0dc83a64..000000000 --- a/crates/pgt_text_edit/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] -authors.workspace = true -categories.workspace = true -description = "" -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -license.workspace = true -name = "pgt_text_edit" -repository.workspace = true -version = "0.0.0" - - -[dependencies] -pgt_text_size = { workspace = true } -schemars = { workspace = true, optional = true } -serde = { workspace = true, features = ["derive"], optional = true } -similar = { workspace = true, features = ["unicode"] } - -[features] -schema = ["dep:schemars", "pgt_text_size/schema"] -serde = ["dep:serde", "pgt_text_size/serde"] - -[dev-dependencies] - -[lib] -doctest = false diff --git a/crates/pgt_type_resolver/src/util.rs b/crates/pgt_type_resolver/src/util.rs deleted file mode 100644 index d31d1fa8f..000000000 --- a/crates/pgt_type_resolver/src/util.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub(crate) fn get_string_from_node(node: &pgt_query::protobuf::Node) -> String { - match &node.node { - Some(pgt_query::NodeEnum::String(s)) => s.sval.to_string(), - _ => "".to_string(), - } -} diff --git a/crates/pgt_typecheck/Cargo.toml b/crates/pgt_typecheck/Cargo.toml deleted file mode 100644 index 9c0db5d91..000000000 --- a/crates/pgt_typecheck/Cargo.toml +++ /dev/null @@ -1,33 +0,0 @@ -[package] -authors.workspace = true -categories.workspace = true -description = "" -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -license.workspace = true -name = "pgt_typecheck" -repository.workspace = true -version = "0.0.0" - - -[dependencies] -globset = "0.4.16" -itertools = { version = "0.14.0" } -pgt_console.workspace = true -pgt_diagnostics.workspace = true -pgt_query.workspace = true -pgt_schema_cache.workspace = true -pgt_text_size.workspace = true -pgt_treesitter.workspace = true -pgt_treesitter_grammar.workspace = true -sqlx.workspace = true -tokio.workspace = true -tree-sitter.workspace = true - -[dev-dependencies] -insta.workspace = true -pgt_test_utils.workspace = true - -[lib] -doctest = false diff --git a/crates/pgt_workspace/Cargo.toml b/crates/pgt_workspace/Cargo.toml deleted file mode 100644 index 19e1d3fe3..000000000 --- a/crates/pgt_workspace/Cargo.toml +++ /dev/null @@ -1,76 +0,0 @@ -[package] -authors.workspace = true -categories.workspace = true -description = "" -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -license.workspace = true -name = "pgt_workspace" -repository.workspace = true -version = "0.0.0" - - -[dependencies] -biome_deserialize = "0.6.0" -futures = "0.3.31" -globset = "0.4.16" -lru = "0.12" - -ignore = { workspace = true } -pgt_analyse = { workspace = true, features = ["serde"] } -pgt_analyser = { workspace = true } -pgt_completions = { workspace = true } -pgt_configuration = { workspace = true } -pgt_console = { workspace = true } -pgt_diagnostics = { workspace = true } -pgt_fs = { workspace = true, features = ["serde"] } -pgt_hover = { workspace = true } -pgt_lexer = { workspace = true } -pgt_plpgsql_check = { workspace = true } -pgt_query = { workspace = true } -pgt_query_ext = { workspace = true } -pgt_schema_cache = { workspace = true } -pgt_statement_splitter = { workspace = true } -pgt_suppressions = { workspace = true } -pgt_text_size.workspace = true -pgt_tokenizer = { workspace = true } -pgt_treesitter_grammar.workspace = true -pgt_typecheck = { workspace = true } -pgt_workspace_macros = { workspace = true } -regex = { workspace = true } -rustc-hash = { workspace = true } -schemars = { workspace = true, optional = true } -serde = { workspace = true, features = ["derive"] } -serde_json = { workspace = true, features = ["raw_value"] } -slotmap = { workspace = true, features = ["serde"] } -sqlx.workspace = true -strum = { workspace = true } -tokio = { workspace = true, features = ["rt", "rt-multi-thread"] } -tracing = { workspace = true, features = ["attributes", "log"] } -tree-sitter.workspace = true - -biome_js_factory = { workspace = true, optional = true } -biome_js_syntax = { workspace = true, optional = true } -biome_rowan = { workspace = true, optional = true } - -[features] -schema = [ - "dep:schemars", - "dep:biome_rowan", - "dep:biome_js_syntax", - "dep:biome_js_factory", - "pgt_configuration/schema", - "pgt_diagnostics/schema", - "pgt_fs/schema", - "pgt_analyse/schema", - "pgt_completions/schema", -] - -[dev-dependencies] -pgt_test_utils = { workspace = true } -sqlx = { workspace = true } -tempfile = "3.15.0" - -[lib] -doctest = false diff --git a/docs/codegen/Cargo.toml b/docs/codegen/Cargo.toml index bf650ac9b..3a7d6c022 100644 --- a/docs/codegen/Cargo.toml +++ b/docs/codegen/Cargo.toml @@ -20,16 +20,16 @@ serde = { workspace = true } serde_json = { workspace = true } pulldown-cmark = "0.12.2" -pgt_configuration = { workspace = true, features = ["schema"] } -pgt_flags = { workspace = true } -pgt_cli = { workspace = true } -pgt_analyse = { workspace = true } -pgt_analyser = { workspace = true } -pgt_diagnostics = { workspace = true } -pgt_query = { workspace = true } -pgt_query_ext = { workspace = true } -pgt_workspace = { workspace = true } -pgt_statement_splitter = { workspace = true } -pgt_console = { workspace = true } +pgls_configuration = { workspace = true, features = ["schema"] } +pgls_flags = { workspace = true } +pgls_cli = { workspace = true } +pgls_analyse = { workspace = true } +pgls_analyser = { workspace = true } +pgls_diagnostics = { workspace = true } +pgls_query = { workspace = true } +pgls_query_ext = { workspace = true } +pgls_workspace = { workspace = true } +pgls_statement_splitter = { workspace = true } +pgls_console = { workspace = true } biome_string_case = { workspace = true } diff --git a/docs/codegen/src/cli_doc.rs b/docs/codegen/src/cli_doc.rs index b6c4a75b8..d84892c4c 100644 --- a/docs/codegen/src/cli_doc.rs +++ b/docs/codegen/src/cli_doc.rs @@ -1,4 +1,4 @@ -use pgt_cli::pgt_command; +use pgls_cli::pgt_command; use std::{fs, path::Path}; use crate::utils; @@ -8,11 +8,8 @@ pub fn generate_cli_doc(docs_dir: &Path) -> anyhow::Result<()> { let content = fs::read_to_string(&file_path)?; - let new_content = utils::replace_section( - &content, - "CLI_REF", - &pgt_command().render_markdown("postgrestools"), - ); + let new_content = + utils::replace_section(&content, "CLI_REF", &pgt_command().render_markdown("pgls")); fs::write(file_path, &new_content)?; diff --git a/docs/codegen/src/default_configuration.rs b/docs/codegen/src/default_configuration.rs index 7b7eadfd4..256640dd4 100644 --- a/docs/codegen/src/default_configuration.rs +++ b/docs/codegen/src/default_configuration.rs @@ -2,7 +2,7 @@ use std::{fs, path::Path}; use crate::utils::replace_section; -use pgt_configuration::PartialConfiguration; +use pgls_configuration::PartialConfiguration; pub fn generate_default_configuration(docs_dir: &Path) -> anyhow::Result<()> { let index_path = docs_dir.join("getting_started.md"); diff --git a/docs/codegen/src/env_variables.rs b/docs/codegen/src/env_variables.rs index fd21ed1b5..ec747b8fd 100644 --- a/docs/codegen/src/env_variables.rs +++ b/docs/codegen/src/env_variables.rs @@ -10,7 +10,7 @@ pub fn generate_env_variables(docs_dir: &Path) -> Result<()> { let mut content = vec![]; - let env = pgt_flags::pgt_env(); + let env = pgls_flags::pgt_env(); writeln!(content, "\n",)?; diff --git a/docs/codegen/src/rules_docs.rs b/docs/codegen/src/rules_docs.rs index 3624dfb86..33283d1a5 100644 --- a/docs/codegen/src/rules_docs.rs +++ b/docs/codegen/src/rules_docs.rs @@ -1,11 +1,11 @@ use anyhow::{Result, bail}; use biome_string_case::Case; -use pgt_analyse::{AnalyserOptions, AnalysisFilter, RuleFilter, RuleMetadata}; -use pgt_analyser::{AnalysableStatement, Analyser, AnalyserConfig}; -use pgt_console::StdDisplay; -use pgt_diagnostics::{Diagnostic, DiagnosticExt, PrintDiagnostic}; -use pgt_query_ext::diagnostics::SyntaxDiagnostic; -use pgt_workspace::settings::Settings; +use pgls_analyse::{AnalyserOptions, AnalysisFilter, RuleFilter, RuleMetadata}; +use pgls_analyser::{AnalysableStatement, Analyser, AnalyserConfig}; +use pgls_console::StdDisplay; +use pgls_diagnostics::{Diagnostic, DiagnosticExt, PrintDiagnostic}; +use pgls_query_ext::diagnostics::SyntaxDiagnostic; +use pgls_workspace::settings::Settings; use pulldown_cmark::{CodeBlockKind, Event, LinkType, Parser, Tag, TagEnd}; use std::{ fmt::Write as _, @@ -28,7 +28,7 @@ pub fn generate_rules_docs(docs_dir: &Path) -> anyhow::Result<()> { fs::create_dir_all(&rules_dir)?; let mut visitor = crate::utils::LintRulesVisitor::default(); - pgt_analyser::visit_registry(&mut visitor); + pgls_analyser::visit_registry(&mut visitor); let crate::utils::LintRulesVisitor { groups } = visitor; @@ -419,7 +419,7 @@ fn print_diagnostics( ) -> Result<()> { let file_path = format!("code-block.{}", test.tag); - let mut write_diagnostic = |_: &str, diag: pgt_diagnostics::Error| -> Result<()> { + let mut write_diagnostic = |_: &str, diag: pgls_diagnostics::Error| -> Result<()> { let printer = PrintDiagnostic::simple(&diag); writeln!(content, "{}", StdDisplay(printer)).unwrap(); @@ -442,19 +442,19 @@ fn print_diagnostics( }); // split and parse each statement - let stmts = pgt_statement_splitter::split(code); + let stmts = pgls_statement_splitter::split(code); for stmt_range in stmts.ranges { - match pgt_query::parse(&code[stmt_range]) { + match pgls_query::parse(&code[stmt_range]) { Ok(ast) => { if let Some(root) = ast.into_root() { - for rule_diag in analyser.run(pgt_analyser::AnalyserParams { + for rule_diag in analyser.run(pgls_analyser::AnalyserParams { schema_cache: None, stmts: vec![AnalysableStatement { range: stmt_range, root, }], }) { - let diag = pgt_diagnostics::serde::Diagnostic::new(rule_diag); + let diag = pgls_diagnostics::serde::Diagnostic::new(rule_diag); let category = diag.category().expect("linter diagnostic has no code"); let severity = settings.get_severity_from_rule_code(category).expect( diff --git a/docs/codegen/src/rules_index.rs b/docs/codegen/src/rules_index.rs index 443c5c031..41a65baf5 100644 --- a/docs/codegen/src/rules_index.rs +++ b/docs/codegen/src/rules_index.rs @@ -1,7 +1,7 @@ use biome_string_case::Case; -use pgt_analyse::RuleMetadata; -use pgt_console::fmt::{Formatter, HTML}; -use pgt_console::{Markup, markup}; +use pgls_analyse::RuleMetadata; +use pgls_console::fmt::{Formatter, HTML}; +use pgls_console::{Markup, markup}; use pulldown_cmark::{Event, Parser, Tag, TagEnd}; use std::{ collections::BTreeMap, @@ -20,7 +20,7 @@ pub fn generate_rules_index(docs_dir: &Path) -> anyhow::Result<()> { let index_file = docs_dir.join("reference/rules.md"); let mut visitor = crate::utils::LintRulesVisitor::default(); - pgt_analyser::visit_registry(&mut visitor); + pgls_analyser::visit_registry(&mut visitor); let crate::utils::LintRulesVisitor { groups } = visitor; diff --git a/docs/codegen/src/rules_sources.rs b/docs/codegen/src/rules_sources.rs index ddbadec8e..a25430d5b 100644 --- a/docs/codegen/src/rules_sources.rs +++ b/docs/codegen/src/rules_sources.rs @@ -1,6 +1,6 @@ use anyhow::Result; use biome_string_case::Case; -use pgt_analyse::RuleMetadata; +use pgls_analyse::RuleMetadata; use std::cmp::Ordering; use std::collections::{BTreeMap, BTreeSet}; use std::fs; @@ -31,7 +31,7 @@ pub fn generate_rule_sources(docs_dir: &Path) -> anyhow::Result<()> { let rule_sources_file = docs_dir.join("reference/rule_sources.md"); let mut visitor = crate::utils::LintRulesVisitor::default(); - pgt_analyser::visit_registry(&mut visitor); + pgls_analyser::visit_registry(&mut visitor); let crate::utils::LintRulesVisitor { groups } = visitor; diff --git a/docs/codegen/src/schema.rs b/docs/codegen/src/schema.rs index 3e430517d..747b3ba27 100644 --- a/docs/codegen/src/schema.rs +++ b/docs/codegen/src/schema.rs @@ -1,4 +1,4 @@ -use pgt_configuration::PartialConfiguration; +use pgls_configuration::PartialConfiguration; use schemars::{ schema::{RootSchema, Schema, SchemaObject}, schema_for, diff --git a/docs/codegen/src/utils.rs b/docs/codegen/src/utils.rs index 5e28d2c13..d7980b5e5 100644 --- a/docs/codegen/src/utils.rs +++ b/docs/codegen/src/utils.rs @@ -1,4 +1,4 @@ -use pgt_analyse::{GroupCategory, RegistryVisitor, Rule, RuleCategory, RuleGroup, RuleMetadata}; +use pgls_analyse::{GroupCategory, RegistryVisitor, Rule, RuleCategory, RuleGroup, RuleMetadata}; use regex::Regex; use std::collections::BTreeMap; diff --git a/docs/configuration.md b/docs/configuration.md index 9661d2a87..6f1424274 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -2,7 +2,7 @@ This guide will help you to understand how to configure the Postgres Language Server. It explains the structure of the configuration file and how the configuration is resolved. -The Postgres Language Server allows you to customize its behavior using CLI options or a configuration file named `postgrestools.jsonc`. We recommend that you create a configuration file for each project. This ensures that each team member has the same configuration in the CLI and in any editor that allows Biome integration. Many of the options available in a configuration file are also available in the CLI. +The Postgres Language Server allows you to customize its behavior using CLI options or a configuration file named `postgres-language-server.jsonc`. We recommend that you create a configuration file for each project. This ensures that each team member has the same configuration in the CLI and in any editor that allows Biome integration. Many of the options available in a configuration file are also available in the CLI. ## Configuration file structure @@ -10,7 +10,7 @@ A configuration file is usually placed in your project’s root folder. It is or ```json { - "$schema": "https://pgtools.dev/latest/schema.json", + "$schema": "https://pg-language-server.com/latest/schema.json", "linter": { "enabled": true, "rules": { @@ -32,7 +32,7 @@ Some tools that the Postgres Language Server provides are implemented as mere in ```json { - "$schema": "https://pgtools.dev/latest/schema.json", + "$schema": "https://pg-language-server.com/latest/schema.json", "db": { "host": "127.0.0.1", "port": 5432, @@ -54,7 +54,7 @@ You can control the files/folders to process using different strategies, either The first way to control which files and folders are processed is to list them in the CLI. In the following command, we only check `file1.sql` and all the files in the `src` folder, because folders are recursively traversed. ```shell -postgrestools check file1.js src/ +pgls check file1.js src/ ``` ### Control files via configuration diff --git a/docs/features/linting.md b/docs/features/linting.md index 814ce558e..794b3c798 100644 --- a/docs/features/linting.md +++ b/docs/features/linting.md @@ -10,7 +10,7 @@ See the [Rules Reference](../reference/rules.md) for the complete list of availa ## Configuration -Configure linting behavior in your `postgrestools.jsonc`: +Configure linting behavior in your `postgres-language-server.jsonc`: ```json { @@ -54,13 +54,13 @@ The linter can also be used via the CLI for CI integration: ```bash # Lint specific files -postgrestools check migrations/ +pgls check migrations/ # With specific rules -postgrestools check migrations/ --only safety/banDropColumn +pgls check migrations/ --only safety/banDropColumn # Skip certain rules -postgrestools check migrations/ --skip safety/banDropTable +pgls check migrations/ --skip safety/banDropTable ``` See the [CLI Reference](../reference/cli.md) for more options, and check the guide on [linting migrations]('../guides/checking_migrations.md'). diff --git a/docs/getting_started.md b/docs/getting_started.md index 8cbe655bd..4f093003c 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -4,19 +4,19 @@ The Postgres Language Server can be installed as a development dependency of you ## Configuration -We recommend creating a `postgrestools.jsonc` configuration file for each project. This eliminates repetitive CLI options and ensures that consistent configuration in your editor. Some options are only available from a configuration file. This step is optional though: if you are happy with the defaults, you don’t need a configuration file. To create the `postgrestools.jsonc` file, run the `init` command in the root folder of your project: +We recommend creating a `postgres-language-server.jsonc` configuration file for each project. This eliminates repetitive CLI options and ensures that consistent configuration in your editor. Some options are only available from a configuration file. This step is optional though: if you are happy with the defaults, you don’t need a configuration file. To create the `postgres-language-server.jsonc` file, run the `init` command in the root folder of your project: ```sh -postgrestools init +pgls init ``` -You’ll now have a `postgrestools.jsonc` file in your directory: +You’ll now have a `postgres-language-server.jsonc` file in your directory: [//]: # "BEGIN DEFAULT_CONFIGURATION" ```json { - "$schema": "https://pgtools.dev/latest/schema.json", + "$schema": "https://pg-language-server.com/latest/schema.json", "vcs": { "enabled": false, "clientKind": "git", @@ -47,7 +47,7 @@ You’ll now have a `postgrestools.jsonc` file in your directory: Make sure to edit the database connection settings to connect to your local development database. To see all options, run `postgrestools --help`. -You can use your current `postgrestools` version instead of "latest" in the `$schema` URL, e.g. `https://pgtools.dev/0.8.1/schema.json`. +You can use your current `pgls` version instead of "latest" in the `$schema` URL, e.g. `https://pg-language-server.com/0.8.1/schema.json`. ## Usage @@ -59,13 +59,13 @@ The CLI exposes a `check` command that will run all checks on the given files or ```sh # check a specific file -postgrestools check myfile.sql +pgls check myfile.sql # check a directory -postgrestools check supabase/migrations +pgls check supabase/migrations ``` -Run `postgrestools --help` for all options. The CLI options take precedence over what is loaded from `postgrestools.jsonc`. +Run `postgrestools --help` for all options. The CLI options take precedence over what is loaded from `postgres-language-server.jsonc`. ### Editor Integrations @@ -78,7 +78,7 @@ The Postgres Language Server is available as an extension in your favorite edito ### Continuous Integration -Run `postgrestools check` in your CI pipeline to lint your schema changes and enforce code quality across your team. We provide a [GitHub Action](https://github.com/supabase-community/postgrestools-cli-action) to setup the Postgres Language Server in your runner. +Run `pgls check` in your CI pipeline to lint your schema changes and enforce code quality across your team. We provide a [GitHub Action](https://github.com/supabase-community/postgrestools-cli-action) to setup the Postgres Language Server in your runner. See the [Continuous Integration](/guides/continuous_integration) guide for an example. diff --git a/docs/guides/checking_migrations.md b/docs/guides/checking_migrations.md index 6f552f6ed..c044af0ae 100644 --- a/docs/guides/checking_migrations.md +++ b/docs/guides/checking_migrations.md @@ -5,10 +5,10 @@ Postgres Language Tools comes with a `check` command that can be integrated into To run it, simply point at your migrations directory. ```sh -postgrestools check supabase/migrations +pgls check supabase/migrations ``` -When you are setting it up in an existing project, you might want to ignore all migrations that are already applied. To do so, add `migrationsDir` and `after` to your `postgrestools.jsonc` file +When you are setting it up in an existing project, you might want to ignore all migrations that are already applied. To do so, add `migrationsDir` and `after` to your `postgres-language-server.jsonc` file ```json @@ -23,10 +23,10 @@ When you are setting it up in an existing project, you might want to ignore all Alternatively, pass them directly. ``` -postgrestools check supabase/migrations --migrations-dir="supabase/migrations" --after=1740868021 +pgls check supabase/migrations --migrations-dir="supabase/migrations" --after=1740868021 ``` This will only check migrations after the specified timestamp. -For pre-commit hooks and when working locally, use `--staged` to only lint files that have been staged. In CI environments, you most likely want to use `--changed` to only lint files that have been changed compared to your `vcs.default_branch` configuration. If `default_branch` is not set in your `postgrestools.jsonc`, use `--since=REF` to specify the base branch to compare against. +For pre-commit hooks and when working locally, use `--staged` to only lint files that have been staged. In CI environments, you most likely want to use `--changed` to only lint files that have been changed compared to your `vcs.default_branch` configuration. If `default_branch` is not set in your `postgres-language-server.jsonc`, use `--since=REF` to specify the base branch to compare against. diff --git a/docs/guides/configure_database.md b/docs/guides/configure_database.md index ae4d6d0c2..41d5262d3 100644 --- a/docs/guides/configure_database.md +++ b/docs/guides/configure_database.md @@ -13,7 +13,7 @@ The language server requires a database connection for schema-dependent features ## Configuration -Configure database connection details in your `postgrestools.jsonc` file: +Configure database connection details in your `postgres-language-server.jsonc` file: ```json { @@ -79,7 +79,7 @@ If you prefer to work without a database connection, you can disable all databas Or use the command line flag: ```bash -postgrestools check sql/ --disable-db +pgls check sql/ --disable-db ``` When disabled, you'll still get: diff --git a/docs/guides/continuous_integration.md b/docs/guides/continuous_integration.md index 44ac4c2d3..2663d2ee7 100644 --- a/docs/guides/continuous_integration.md +++ b/docs/guides/continuous_integration.md @@ -15,7 +15,7 @@ jobs: - uses: supabase-community/pglt-cli-action@main with: version: latest - - run: postgrestools check --skip-db sql/ + - run: pgls check --skip-db sql/ ``` You likely want to setup Postgres to enable more advanced checks: @@ -38,7 +38,7 @@ jobs: - uses: supabase-community/pglt-cli-action@main with: version: latest - - run: postgrestools check sql/ + - run: pgls check sql/ ``` A common use-case is to check your migration files. Check out [the dedicated guide](./checking_migrations.md) for details. diff --git a/docs/guides/ide_setup.md b/docs/guides/ide_setup.md index b97c6c249..8a12381e3 100644 --- a/docs/guides/ide_setup.md +++ b/docs/guides/ide_setup.md @@ -46,7 +46,7 @@ postgrestools start Then, every command needs to add the `--use-server` options, e.g.: ```shell -postgrestools check --use-server --stdin-file-path=dummy.sql +pgls check --use-server --stdin-file-path=dummy.sql ``` diff --git a/docs/guides/vcs_integration.md b/docs/guides/vcs_integration.md index e22e83676..e1019b250 100644 --- a/docs/guides/vcs_integration.md +++ b/docs/guides/vcs_integration.md @@ -50,13 +50,13 @@ First, you have to update your configuration file with the default branch via th Add the `--changed` option to your command to process only those files that your VCS acknowledged as “changed”. The language server will determine the changed files from the branch `main` and your current revision: ```shell -postgrestools check --changed +pgls check --changed ``` Alternatively, you can use the option `--since` to specify an arbitrary branch. This option takes precedence over the option `vcs.defaultBranch`. For example, you might want to check your changes against the `next` branch: ```shell -postgrestools check --changed --since=next +pgls check --changed --since=next ``` ## Process only staged files @@ -64,6 +64,6 @@ postgrestools check --changed --since=next Before committing your changes, you may want to check the files that have been added to the index, also known as staged files. Add the `--staged` option to process only those files: ```shell -postgrestools check --staged +pgls check --staged ``` diff --git a/docs/reference/cli.md b/docs/reference/cli.md index 81db5e1e5..57f71a7f2 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -4,20 +4,20 @@ # Command summary -- [`postgrestools`↴](#postgrestools) -- [`postgrestools version`↴](#postgrestools-version) -- [`postgrestools check`↴](#postgrestools-check) +- [`pgls`↴](#postgrestools) +- [`pgls version`↴](#postgrestools-version) +- [`pgls check`↴](#postgrestools-check) - [`postgrestools start`↴](#postgrestools-start) - [`postgrestools stop`↴](#postgrestools-stop) -- [`postgrestools init`↴](#postgrestools-init) +- [`pgls init`↴](#postgrestools-init) - [`postgrestools lsp-proxy`↴](#postgrestools-lsp-proxy) -- [`postgrestools clean`↴](#postgrestools-clean) +- [`pgls clean`↴](#postgrestools-clean) ## postgrestools -PostgresTools official CLI. Use it to check the health of your project or run it to check single files. +Postgres Language Server official CLI. Use it to check the health of your project or run it to check single files. -**Usage**: **`postgrestools`** _`COMMAND ...`_ +**Usage**: **`pgls`** _`COMMAND ...`_ **Available options:** @@ -43,11 +43,11 @@ PostgresTools official CLI. Use it to check the health of your project or run it - **`clean`** — Cleans the logs emitted by the daemon. -## postgrestools version +## pgls version Shows the version information and quit. -**Usage**: **`postgrestools`** **`version`** +**Usage**: **`pgls`** **`version`** **Global options applied to all commands** @@ -60,7 +60,7 @@ Shows the version information and quit. - **` --verbose`** — Print additional diagnostics, and some diagnostics show more information. Also, print out what files were processed and which ones were modified. - **` --config-path`**=_`PATH`_ — - Set the file path to the configuration file, or the directory path to find `postgrestools.jsonc`. If used, it disables the default configuration file resolution. + Set the file path to the configuration file, or the directory path to find `postgres-language-server.jsonc`. If used, it disables the default configuration file resolution. - **` --max-diagnostics`**=_`>`_ — Cap the amount of diagnostics displayed. When `none` is provided, the limit is lifted. [default: 20] @@ -69,7 +69,7 @@ Shows the version information and quit. - **` --no-errors-on-unmatched`** — Silence errors that would be emitted in case no files were processed during the execution of the command. - **` --error-on-warnings`** — - Tell Postgres Tools to exit with an error code if some diagnostics emit warnings. + Tell Postgres Language Server to exit with an error code if some diagnostics emit warnings. - **` --reporter`**=_``_ — Allows to change how diagnostics and summary are reported. - **` --log-level`**=_``_ — @@ -83,7 +83,7 @@ Shows the version information and quit. How the log should look like. [default: pretty] - **` --diagnostic-level`**=_``_ — - The level of diagnostics to show. In order, from the lowest to the most important: info, warn, error. Passing `--diagnostic-level=error` will cause Postgres Tools to print only diagnostics that contain only errors. + The level of diagnostics to show. In order, from the lowest to the most important: info, warn, error. Passing `--diagnostic-level=error` will cause Postgres Language Server to print only diagnostics that contain only errors. [default: info] **Available options:** @@ -91,11 +91,11 @@ Shows the version information and quit. - **`-h`**, **`--help`** — Prints help information -## postgrestools check +## pgls check Runs everything to the requested files. -**Usage**: **`postgrestools`** **`check`** \[**`--staged`**\] \[**`--changed`**\] \[**`--since`**=_`REF`_\] \[_`PATH`_\]... +**Usage**: **`pgls`** **`check`** \[**`--staged`**\] \[**`--changed`**\] \[**`--since`**=_`REF`_\] \[_`PATH`_\]... **The configuration that is contained inside the configuration file.** @@ -106,7 +106,7 @@ Runs everything to the requested files. - **` --vcs-use-ignore-file`**=_``_ — Whether we should use the VCS ignore file. When [true], we will ignore the files specified in the ignore file. - **` --vcs-root`**=_`PATH`_ — - The folder where we should check for VCS files. By default, we will use the same folder where `postgrestools.jsonc` was found. + The folder where we should check for VCS files. By default, we will use the same folder where `postgres-language-server.jsonc` was found. If we can't find the configuration, it will attempt to use the current working directory. If no current working directory can't be found, we won't use the VCS integration, and a diagnostic will be emitted @@ -143,7 +143,7 @@ Runs everything to the requested files. - **` --verbose`** — Print additional diagnostics, and some diagnostics show more information. Also, print out what files were processed and which ones were modified. - **` --config-path`**=_`PATH`_ — - Set the file path to the configuration file, or the directory path to find `postgrestools.jsonc`. If used, it disables the default configuration file resolution. + Set the file path to the configuration file, or the directory path to find `postgres-language-server.jsonc`. If used, it disables the default configuration file resolution. - **` --max-diagnostics`**=_`>`_ — Cap the amount of diagnostics displayed. When `none` is provided, the limit is lifted. [default: 20] @@ -152,7 +152,7 @@ Runs everything to the requested files. - **` --no-errors-on-unmatched`** — Silence errors that would be emitted in case no files were processed during the execution of the command. - **` --error-on-warnings`** — - Tell Postgres Tools to exit with an error code if some diagnostics emit warnings. + Tell Postgres Language Server to exit with an error code if some diagnostics emit warnings. - **` --reporter`**=_``_ — Allows to change how diagnostics and summary are reported. - **` --log-level`**=_``_ — @@ -166,7 +166,7 @@ Runs everything to the requested files. How the log should look like. [default: pretty] - **` --diagnostic-level`**=_``_ — - The level of diagnostics to show. In order, from the lowest to the most important: info, warn, error. Passing `--diagnostic-level=error` will cause Postgres Tools to print only diagnostics that contain only errors. + The level of diagnostics to show. In order, from the lowest to the most important: info, warn, error. Passing `--diagnostic-level=error` will cause Postgres Language Server to print only diagnostics that contain only errors. [default: info] **Available positional items:** @@ -188,7 +188,7 @@ Runs everything to the requested files. - **` --changed`** — When set to true, only the files that have been changed compared to your `defaultBranch` configuration will be linted. This option should be used in CI environments. - **` --since`**=_`REF`_ — - Use this to specify the base branch to compare against when you're using the --changed flag and the `defaultBranch` is not set in your `postgrestools.jsonc` + Use this to specify the base branch to compare against when you're using the --changed flag and the `defaultBranch` is not set in your `postgres-language-server.jsonc` - **`-h`**, **`--help`** — Prints help information @@ -196,7 +196,7 @@ Runs everything to the requested files. Starts the daemon server process. -**Usage**: **`postgrestools`** **`start`** \[**`--config-path`**=_`PATH`_\] +**Usage**: **`pgls`** **`start`** \[**`--config-path`**=_`PATH`_\] **Available options:** @@ -208,7 +208,7 @@ Starts the daemon server process. Allows to change the folder where logs are stored. Uses environment variable **`PGT_LOG_PATH`** - **` --config-path`**=_`PATH`_ — - Allows to set a custom file path to the configuration file, or a custom directory path to find `postgrestools.jsonc` + Allows to set a custom file path to the configuration file, or a custom directory path to find `postgres-language-server.jsonc` Uses environment variable **`PGT_LOG_PREFIX_NAME`** - **`-h`**, **`--help`** — Prints help information @@ -217,18 +217,18 @@ Starts the daemon server process. Stops the daemon server process. -**Usage**: **`postgrestools`** **`stop`** +**Usage**: **`pgls`** **`stop`** **Available options:** - **`-h`**, **`--help`** — Prints help information -## postgrestools init +## pgls init Bootstraps a new project. Creates a configuration file with some defaults. -**Usage**: **`postgrestools`** **`init`** +**Usage**: **`pgls`** **`init`** **Available options:** @@ -239,7 +239,7 @@ Bootstraps a new project. Creates a configuration file with some defaults. Acts as a server for the Language Server Protocol over stdin/stdout. -**Usage**: **`postgrestools`** **`lsp-proxy`** \[**`--config-path`**=_`PATH`_\] +**Usage**: **`pgls`** **`lsp-proxy`** \[**`--config-path`**=_`PATH`_\] **Available options:** @@ -251,16 +251,16 @@ Acts as a server for the Language Server Protocol over stdin/stdout. Allows to change the folder where logs are stored. Uses environment variable **`PGT_LOG_PATH`** - **` --config-path`**=_`PATH`_ — - Allows to set a custom file path to the configuration file, or a custom directory path to find `postgrestools.jsonc` + Allows to set a custom file path to the configuration file, or a custom directory path to find `postgres-language-server.jsonc` Uses environment variable **`PGT_CONFIG_PATH`** - **`-h`**, **`--help`** — Prints help information -## postgrestools clean +## pgls clean Cleans the logs emitted by the daemon. -**Usage**: **`postgrestools`** **`clean`** +**Usage**: **`pgls`** **`clean`** **Available options:** diff --git a/docs/schema.json b/docs/schema.json index 2d40cf9ed..f4ef1e0cf 100644 --- a/docs/schema.json +++ b/docs/schema.json @@ -333,7 +333,7 @@ ] }, "recommended": { - "description": "It enables the lint rules recommended by Postgres Tools. `true` by default.", + "description": "It enables the lint rules recommended by Postgres Language Server. `true` by default.", "type": [ "boolean", "null" @@ -754,7 +754,7 @@ ] }, "root": { - "description": "The folder where we should check for VCS files. By default, we will use the same folder where `postgrestools.jsonc` was found.\n\nIf we can't find the configuration, it will attempt to use the current working directory. If no current working directory can't be found, we won't use the VCS integration, and a diagnostic will be emitted", + "description": "The folder where we should check for VCS files. By default, we will use the same folder where `postgres-language-server.jsonc` was found.\n\nIf we can't find the configuration, it will attempt to use the current working directory. If no current working directory can't be found, we won't use the VCS integration, and a diagnostic will be emitted", "type": [ "string", "null" diff --git a/mkdocs.yml b/mkdocs.yml index 489a1aff0..99966100d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,5 +1,5 @@ site_name: Postgres Language Server -site_url: https://pgtools.dev +site_url: https://pg-language-server.com site_description: A collection of language tools and a Language Server Protocol (LSP) implementation for Postgres, focusing on developer experience and reliable SQL tooling. repo_name: supabase-community/postgres-language-server diff --git a/packages/@postgrestools/backend-jsonrpc/package.json b/packages/@pgls/backend-jsonrpc/package.json similarity index 63% rename from packages/@postgrestools/backend-jsonrpc/package.json rename to packages/@pgls/backend-jsonrpc/package.json index d8e0db2cc..5d8a08986 100644 --- a/packages/@postgrestools/backend-jsonrpc/package.json +++ b/packages/@pgls/backend-jsonrpc/package.json @@ -1,5 +1,5 @@ { - "name": "@postgrestools/backend-jsonrpc", + "name": "@pgls/backend-jsonrpc", "version": "", "main": "dist/index.js", "scripts": { @@ -11,7 +11,7 @@ "repository": { "type": "git", "url": "git+https://github.com/supabase-community/postgres-language-server.git", - "directory": "packages/@postgrestools/backend-jsonrpc" + "directory": "packages/@pgls/backend-jsonrpc" }, "author": "Supabase Community", "bugs": "ttps://github.com/supabase-community/postgres-language-server/issues", @@ -22,11 +22,11 @@ "provenance": true }, "optionalDependencies": { - "@postgrestools/cli-win32-x64": "", - "@postgrestools/cli-win32-arm64": "", - "@postgrestools/cli-darwin-x64": "", - "@postgrestools/cli-darwin-arm64": "", - "@postgrestools/cli-linux-x64": "", - "@postgrestools/cli-linux-arm64": "" + "@pgls/cli-win32-x64": "", + "@pgls/cli-win32-arm64": "", + "@pgls/cli-darwin-x64": "", + "@pgls/cli-darwin-arm64": "", + "@pgls/cli-linux-x64": "", + "@pgls/cli-linux-arm64": "" } } diff --git a/packages/@postgrestools/backend-jsonrpc/src/command.ts b/packages/@pgls/backend-jsonrpc/src/command.ts similarity index 100% rename from packages/@postgrestools/backend-jsonrpc/src/command.ts rename to packages/@pgls/backend-jsonrpc/src/command.ts diff --git a/packages/@postgrestools/backend-jsonrpc/src/index.ts b/packages/@pgls/backend-jsonrpc/src/index.ts similarity index 100% rename from packages/@postgrestools/backend-jsonrpc/src/index.ts rename to packages/@pgls/backend-jsonrpc/src/index.ts diff --git a/packages/@postgrestools/backend-jsonrpc/src/socket.ts b/packages/@pgls/backend-jsonrpc/src/socket.ts similarity index 100% rename from packages/@postgrestools/backend-jsonrpc/src/socket.ts rename to packages/@pgls/backend-jsonrpc/src/socket.ts diff --git a/packages/@postgrestools/backend-jsonrpc/src/transport.ts b/packages/@pgls/backend-jsonrpc/src/transport.ts similarity index 100% rename from packages/@postgrestools/backend-jsonrpc/src/transport.ts rename to packages/@pgls/backend-jsonrpc/src/transport.ts diff --git a/packages/@postgrestools/backend-jsonrpc/src/workspace.ts b/packages/@pgls/backend-jsonrpc/src/workspace.ts similarity index 97% rename from packages/@postgrestools/backend-jsonrpc/src/workspace.ts rename to packages/@pgls/backend-jsonrpc/src/workspace.ts index 51a4f5663..1218576d2 100644 --- a/packages/@postgrestools/backend-jsonrpc/src/workspace.ts +++ b/packages/@pgls/backend-jsonrpc/src/workspace.ts @@ -1,11 +1,11 @@ // Generated file, do not edit by hand, see `xtask/codegen` import type { Transport } from "./transport"; export interface IsPathIgnoredParams { - pgt_path: PgTPath; + pgt_path: PgLSPath; } -export interface PgTPath { +export interface PgLSPath { /** - * Determines the kind of the file inside Postgres Tools. Some files are considered as configuration files, others as manifest files, and others as files to handle + * Determines the kind of the file inside Postgres Language Server. Some files are considered as configuration files, others as manifest files, and others as files to handle */ kind: FileKind; path: string; @@ -25,13 +25,13 @@ export interface RegisterProjectFolderParams { } export type ProjectKey = string; export interface GetFileContentParams { - path: PgTPath; + path: PgLSPath; } export interface PullDiagnosticsParams { categories: RuleCategories; max_diagnostics: number; only: RuleCode[]; - path: PgTPath; + path: PgLSPath; skip: RuleCode[]; } export type RuleCategories = RuleCategory[]; @@ -203,7 +203,7 @@ export interface GetCompletionsParams { /** * The File for which a completion is requested. */ - path: PgTPath; + path: PgLSPath; /** * The Cursor position in the file for which a completion is requested. */ @@ -409,7 +409,7 @@ export interface PartialVcsConfiguration { */ enabled?: boolean; /** - * The folder where we should check for VCS files. By default, we will use the same folder where `postgrestools.jsonc` was found. + * The folder where we should check for VCS files. By default, we will use the same folder where `postgres-language-server.jsonc` was found. If we can't find the configuration, it will attempt to use the current working directory. If no current working directory can't be found, we won't use the VCS integration, and a diagnostic will be emitted */ @@ -425,7 +425,7 @@ export interface Rules { */ all?: boolean; /** - * It enables the lint rules recommended by Postgres Tools. `true` by default. + * It enables the lint rules recommended by Postgres Language Server. `true` by default. */ recommended?: boolean; safety?: Safety; @@ -572,16 +572,16 @@ export interface RuleWithOptions_for_Null { } export interface OpenFileParams { content: string; - path: PgTPath; + path: PgLSPath; version: number; } export interface ChangeFileParams { content: string; - path: PgTPath; + path: PgLSPath; version: number; } export interface CloseFileParams { - path: PgTPath; + path: PgLSPath; } export type Configuration = PartialConfiguration; export interface Workspace { diff --git a/packages/@postgrestools/backend-jsonrpc/tests/transport.test.mjs b/packages/@pgls/backend-jsonrpc/tests/transport.test.mjs similarity index 100% rename from packages/@postgrestools/backend-jsonrpc/tests/transport.test.mjs rename to packages/@pgls/backend-jsonrpc/tests/transport.test.mjs diff --git a/packages/@postgrestools/backend-jsonrpc/tests/workspace.test.mjs b/packages/@pgls/backend-jsonrpc/tests/workspace.test.mjs similarity index 100% rename from packages/@postgrestools/backend-jsonrpc/tests/workspace.test.mjs rename to packages/@pgls/backend-jsonrpc/tests/workspace.test.mjs diff --git a/packages/@postgrestools/postgrestools/bin/postgrestools b/packages/@pgls/cli/bin/pgls similarity index 100% rename from packages/@postgrestools/postgrestools/bin/postgrestools rename to packages/@pgls/cli/bin/pgls diff --git a/packages/@postgrestools/postgrestools/package.json b/packages/@pgls/cli/package.json similarity index 56% rename from packages/@postgrestools/postgrestools/package.json rename to packages/@pgls/cli/package.json index a172d65f3..3cfbd9743 100644 --- a/packages/@postgrestools/postgrestools/package.json +++ b/packages/@pgls/cli/package.json @@ -1,13 +1,13 @@ { - "name": "@postgrestools/postgrestools", + "name": "@pgls/cli", "version": "", "bin": { - "postgrestools": "bin/postgrestools" + "pgls": "bin/pgls" }, "repository": { "type": "git", "url": "git+https://github.com/supabase-community/postgres-language-server.git", - "directory": "packages/@postgrestools/postgrestools" + "directory": "packages/@pgls/cli" }, "author": "Supabase Community", "contributors": [ @@ -23,7 +23,7 @@ "license": "MIT or Apache-2.0", "description": "A collection of language tools and a Language Server Protocol (LSP) implementation for Postgres, focusing on developer experience and reliable SQL tooling.", "files": [ - "bin/postgrestools", + "bin/pgls", "schema.json" ], "engines": { @@ -33,12 +33,12 @@ "provenance": true }, "optionalDependencies": { - "@postgrestools/cli-x86_64-windows-msvc": "", - "@postgrestools/cli-aarch64-windows-msvc": "", - "@postgrestools/cli-x86_64-apple-darwin": "", - "@postgrestools/cli-aarch64-apple-darwin": "", - "@postgrestools/cli-x86_64-linux-gnu": "", - "@postgrestools/cli-aarch64-linux-gnu": "", - "@postgrestools/cli-x86_64-linux-musl": "" + "@pgls/cli-x86_64-windows-msvc": "", + "@pgls/cli-aarch64-windows-msvc": "", + "@pgls/cli-x86_64-apple-darwin": "", + "@pgls/cli-aarch64-apple-darwin": "", + "@pgls/cli-x86_64-linux-gnu": "", + "@pgls/cli-aarch64-linux-gnu": "", + "@pgls/cli-x86_64-linux-musl": "" } } diff --git a/packages/@postgrestools/postgrestools/scripts/generate-packages.mjs b/packages/@pgls/cli/scripts/generate-packages.mjs similarity index 100% rename from packages/@postgrestools/postgrestools/scripts/generate-packages.mjs rename to packages/@pgls/cli/scripts/generate-packages.mjs diff --git a/pyproject.toml b/pyproject.toml index 41317471b..a678b9fe9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [project] -name = "postgrestools" +name = "pgls" version = "0.1.0" description = "A collection of language tools and a Language Server Protocol (LSP) implementation for Postgres, focusing on developer experience and reliable SQL tooling." readme = "README.md" diff --git a/xtask/codegen/Cargo.toml b/xtask/codegen/Cargo.toml index 758a3212d..71e075aa9 100644 --- a/xtask/codegen/Cargo.toml +++ b/xtask/codegen/Cargo.toml @@ -12,10 +12,10 @@ biome_js_syntax = { workspace = true } biome_rowan = { workspace = true } biome_string_case = { workspace = true } bpaf = { workspace = true, features = ["derive"] } -pgt_analyse = { workspace = true } -pgt_analyser = { workspace = true } -pgt_diagnostics = { workspace = true } -pgt_workspace = { workspace = true, features = ["schema"] } +pgls_analyse = { workspace = true } +pgls_analyser = { workspace = true } +pgls_diagnostics = { workspace = true } +pgls_workspace = { workspace = true, features = ["schema"] } proc-macro2 = { workspace = true, features = ["span-locations"] } pulldown-cmark = { version = "0.12.2" } quote = "1.0.36" diff --git a/xtask/codegen/src/generate_analyser.rs b/xtask/codegen/src/generate_analyser.rs index 398e6f3a4..105ca7a82 100644 --- a/xtask/codegen/src/generate_analyser.rs +++ b/xtask/codegen/src/generate_analyser.rs @@ -13,7 +13,7 @@ pub fn generate_analyser() -> Result<()> { } fn generate_linter() -> Result<()> { - let base_path = project_root().join("crates/pgt_analyser/src"); + let base_path = project_root().join("crates/pgls_analyser/src"); let mut analysers = BTreeMap::new(); generate_category("lint", &mut analysers, &base_path)?; @@ -39,7 +39,7 @@ fn generate_options(base_path: &Path) -> Result<()> { let rule_module_name = format_ident!("{}", rule_filename); let rule_name = format_ident!("{}", rule_name); rules_options.insert(rule_filename.to_string(), quote! { - pub type #rule_name = <#category_name::#group_name::#rule_module_name::#rule_name as pgt_analyse::Rule>::Options; + pub type #rule_name = <#category_name::#group_name::#rule_module_name::#rule_name as pgls_analyse::Rule>::Options; }); } } @@ -120,7 +120,7 @@ fn generate_category( let (modules, paths): (Vec<_>, Vec<_>) = groups.into_values().unzip(); let tokens = xtask::reformat(quote! { #( #modules )* - ::pgt_analyse::declare_category! { + ::pgls_analyse::declare_category! { pub #category_name { kind: #kind, groups: [ @@ -173,7 +173,7 @@ fn generate_group(category: &'static str, group: &str, base_path: &Path) -> Resu let (import_macro, use_macro) = match category { "lint" => ( quote!( - use pgt_analyse::declare_lint_group; + use pgls_analyse::declare_lint_group; ), quote!(declare_lint_group), ), @@ -200,12 +200,12 @@ fn generate_group(category: &'static str, group: &str, base_path: &Path) -> Resu } fn update_linter_registry_builder(rules: BTreeMap<&'static str, TokenStream>) -> Result<()> { - let path = project_root().join("crates/pgt_analyser/src/registry.rs"); + let path = project_root().join("crates/pgls_analyser/src/registry.rs"); let categories = rules.into_values(); let tokens = xtask::reformat(quote! { - use pgt_analyse::RegistryVisitor; + use pgls_analyse::RegistryVisitor; pub fn visit_registry(registry: &mut V) { #( #categories )* diff --git a/xtask/codegen/src/generate_bindings.rs b/xtask/codegen/src/generate_bindings.rs index 4b66fd004..e8e635580 100644 --- a/xtask/codegen/src/generate_bindings.rs +++ b/xtask/codegen/src/generate_bindings.rs @@ -10,7 +10,7 @@ use biome_js_syntax::{ }; use biome_rowan::AstNode; use biome_string_case::Case; -use pgt_workspace::workspace_types::{generate_type, methods, ModuleQueue}; +use pgls_workspace::workspace_types::{generate_type, methods, ModuleQueue}; use xtask::{project_root, Mode, Result}; pub fn generate_bindings(mode: Mode) -> Result<()> { diff --git a/xtask/codegen/src/generate_configuration.rs b/xtask/codegen/src/generate_configuration.rs index 661f44b51..0ec8bb795 100644 --- a/xtask/codegen/src/generate_configuration.rs +++ b/xtask/codegen/src/generate_configuration.rs @@ -1,7 +1,7 @@ use crate::{to_capitalized, update}; use biome_string_case::Case; -use pgt_analyse::{GroupCategory, RegistryVisitor, Rule, RuleCategory, RuleGroup, RuleMetadata}; -use pgt_diagnostics::Severity; +use pgls_analyse::{GroupCategory, RegistryVisitor, Rule, RuleCategory, RuleGroup, RuleMetadata}; +use pgls_diagnostics::Severity; use proc_macro2::{Ident, Literal, Span, TokenStream}; use pulldown_cmark::{Event, Parser, Tag, TagEnd}; use quote::quote; @@ -33,11 +33,11 @@ impl RegistryVisitor for LintRulesVisitor { } pub fn generate_rules_configuration(mode: Mode) -> Result<()> { - let linter_config_root = project_root().join("crates/pgt_configuration/src/analyser/linter"); - let push_rules_directory = project_root().join("crates/pgt_configuration/src/generated"); + let linter_config_root = project_root().join("crates/pgls_configuration/src/analyser/linter"); + let push_rules_directory = project_root().join("crates/pgls_configuration/src/generated"); let mut lint_visitor = LintRulesVisitor::default(); - pgt_analyser::visit_registry(&mut lint_visitor); + pgls_analyser::visit_registry(&mut lint_visitor); generate_for_groups( lint_visitor.groups, @@ -111,8 +111,8 @@ fn generate_for_groups( let severity_fn = if kind == RuleCategory::Action { quote! { - /// Given a category coming from [Diagnostic](pgt_diagnostics::Diagnostic), this function returns - /// the [Severity](pgt_diagnostics::Severity) associated to the rule, if the configuration changed it. + /// Given a category coming from [Diagnostic](pgls_diagnostics::Diagnostic), this function returns + /// the [Severity](pgls_diagnostics::Severity) associated to the rule, if the configuration changed it. /// If the severity is off or not set, then the function returns the default severity of the rule: /// [Severity::Error] for recommended rules and [Severity::Warning] for other rules. /// @@ -142,8 +142,8 @@ fn generate_for_groups( } else { quote! { - /// Given a category coming from [Diagnostic](pgt_diagnostics::Diagnostic), this function returns - /// the [Severity](pgt_diagnostics::Severity) associated to the rule, if the configuration changed it. + /// Given a category coming from [Diagnostic](pgls_diagnostics::Diagnostic), this function returns + /// the [Severity](pgls_diagnostics::Severity) associated to the rule, if the configuration changed it. /// If the severity is off or not set, then the function returns the default severity of the rule, /// which is configured at the rule definition. /// The function can return `None` if the rule is not properly configured. @@ -178,12 +178,12 @@ fn generate_for_groups( let use_rule_configuration = if kind == RuleCategory::Action { quote! { use crate::analyser::{RuleAssistConfiguration, RuleAssistPlainConfiguration}; - use pgt_analyse::{RuleFilter, options::RuleOptions}; + use pgls_analyse::{RuleFilter, options::RuleOptions}; } } else { quote! { use crate::analyser::{RuleConfiguration, RulePlainConfiguration}; - use pgt_analyse::{RuleFilter, options::RuleOptions}; + use pgls_analyse::{RuleFilter, options::RuleOptions}; } }; @@ -191,7 +191,7 @@ fn generate_for_groups( quote! { #use_rule_configuration use biome_deserialize_macros::Merge; - use pgt_diagnostics::{Category, Severity}; + use pgls_diagnostics::{Category, Severity}; use rustc_hash::FxHashSet; use serde::{Deserialize, Serialize}; #[cfg(feature = "schema")] @@ -231,7 +231,7 @@ fn generate_for_groups( } impl Actions { - /// Checks if the code coming from [pgt_diagnostics::Diagnostic] corresponds to a rule. + /// Checks if the code coming from [pgls_diagnostics::Diagnostic] corresponds to a rule. /// Usually the code is built like {group}/{rule_name} pub fn has_rule( group: RuleGroup, @@ -278,7 +278,7 @@ fn generate_for_groups( quote! { #use_rule_configuration use biome_deserialize_macros::Merge; - use pgt_diagnostics::{Category, Severity}; + use pgls_diagnostics::{Category, Severity}; use rustc_hash::FxHashSet; use serde::{Deserialize, Serialize}; #[cfg(feature = "schema")] @@ -326,7 +326,7 @@ fn generate_for_groups( } impl Rules { - /// Checks if the code coming from [pgt_diagnostics::Diagnostic] corresponds to a rule. + /// Checks if the code coming from [pgls_diagnostics::Diagnostic] corresponds to a rule. /// Usually the code is built like {group}/{rule_name} pub fn has_rule( group: RuleGroup, @@ -399,7 +399,7 @@ fn generate_for_groups( RuleCategory::Lint => { quote! { use crate::analyser::linter::*; - use pgt_analyse::{AnalyserRules, MetadataRegistry}; + use pgls_analyse::{AnalyserRules, MetadataRegistry}; pub fn push_to_analyser_rules( rules: &Rules, @@ -423,7 +423,7 @@ fn generate_for_groups( RuleCategory::Action => { quote! { use crate::analyser::assists::*; - use pgt_analyse::{AnalyserRules, MetadataRegistry}; + use pgls_analyse::{AnalyserRules, MetadataRegistry}; pub fn push_to_analyser_assists( rules: &Actions, @@ -549,7 +549,7 @@ fn generate_group_struct( #rule }); let rule_option_type = quote! { - pgt_analyser::options::#rule_name + pgls_analyser::options::#rule_name }; let rule_option = quote! { Option<#rule_config_type<#rule_option_type>> }; schema_lines_rules.push(quote! { diff --git a/xtask/codegen/src/generate_new_analyser_rule.rs b/xtask/codegen/src/generate_new_analyser_rule.rs index 514886a71..87de47fbb 100644 --- a/xtask/codegen/src/generate_new_analyser_rule.rs +++ b/xtask/codegen/src/generate_new_analyser_rule.rs @@ -1,6 +1,6 @@ use biome_string_case::Case; use bpaf::Bpaf; -use pgt_diagnostics::Severity; +use pgls_diagnostics::Severity; use std::str::FromStr; use xtask::project_root; @@ -40,12 +40,12 @@ fn generate_rule_template( }; format!( - r#"use pgt_analyse::{{ + r#"use pgls_analyse::{{ AnalysedFileContext, context::RuleContext, {macro_name}, Rule, RuleDiagnostic, }}; -use pgt_console::markup; -use pgt_diagnostics::Severity; -use pgt_schema_cache::SchemaCache; +use pgls_console::markup; +use pgls_diagnostics::Severity; +use pgls_schema_cache::SchemaCache; {macro_name}! {{ /// Succinct description of the rule. @@ -98,7 +98,7 @@ pub fn generate_new_analyser_rule( severity: Severity, ) { let rule_name_camel = Case::Camel.convert(rule_name); - let crate_folder = project_root().join("crates/pgt_analyser"); + let crate_folder = project_root().join("crates/pgls_analyser"); let rule_folder = match &category { Category::Lint => crate_folder.join(format!("src/lint/{group}")), }; @@ -120,7 +120,7 @@ pub fn generate_new_analyser_rule( ); std::fs::write(file_name.clone(), code).unwrap_or_else(|_| panic!("To write {}", &file_name)); - let categories_path = "crates/pgt_diagnostics_categories/src/categories.rs"; + let categories_path = "crates/pgls_diagnostics_categories/src/categories.rs"; let mut categories = std::fs::read_to_string(categories_path).unwrap(); if !categories.contains(&rule_name_camel) { @@ -128,7 +128,7 @@ pub fn generate_new_analyser_rule( // We sort rules to reduce conflicts between contributions made in parallel. let rule_line = match category { Category::Lint => format!( - r#" "lint/{group}/{rule_name_camel}": "https://pgtools.dev/latest/rules/{kebab_case_rule}","# + r#" "lint/{group}/{rule_name_camel}": "https://pg-language-server.com/latest/rules/{kebab_case_rule}","# ), }; let lint_start = match category { diff --git a/xtask/codegen/src/lib.rs b/xtask/codegen/src/lib.rs index dc6f81a08..d095cce9a 100644 --- a/xtask/codegen/src/lib.rs +++ b/xtask/codegen/src/lib.rs @@ -13,7 +13,7 @@ pub use self::generate_crate::generate_crate; pub use self::generate_new_analyser_rule::generate_new_analyser_rule; use bpaf::Bpaf; use generate_new_analyser_rule::Category; -use pgt_diagnostics::Severity; +use pgls_diagnostics::Severity; use std::path::Path; use xtask::{glue::fs2, Mode, Result}; diff --git a/xtask/rules_check/Cargo.toml b/xtask/rules_check/Cargo.toml index abd02a05b..b20578641 100644 --- a/xtask/rules_check/Cargo.toml +++ b/xtask/rules_check/Cargo.toml @@ -6,13 +6,13 @@ publish = false version = "0.0.0" [dependencies] -anyhow = { workspace = true } -pgt_analyse = { workspace = true } -pgt_analyser = { workspace = true } -pgt_console = { workspace = true } -pgt_diagnostics = { workspace = true } -pgt_query = { workspace = true } -pgt_query_ext = { workspace = true } -pgt_statement_splitter = { workspace = true } -pgt_workspace = { workspace = true } -pulldown-cmark = "0.12.2" +anyhow = { workspace = true } +pgls_analyse = { workspace = true } +pgls_analyser = { workspace = true } +pgls_console = { workspace = true } +pgls_diagnostics = { workspace = true } +pgls_query = { workspace = true } +pgls_query_ext = { workspace = true } +pgls_statement_splitter = { workspace = true } +pgls_workspace = { workspace = true } +pulldown-cmark = "0.12.2" diff --git a/xtask/rules_check/src/lib.rs b/xtask/rules_check/src/lib.rs index dfdd24ba5..3276e1a00 100644 --- a/xtask/rules_check/src/lib.rs +++ b/xtask/rules_check/src/lib.rs @@ -3,15 +3,15 @@ use std::str::FromStr; use std::{fmt::Write, slice}; use anyhow::bail; -use pgt_analyse::{ +use pgls_analyse::{ AnalyserOptions, AnalysisFilter, GroupCategory, RegistryVisitor, Rule, RuleCategory, RuleFilter, RuleGroup, RuleMetadata, }; -use pgt_analyser::{AnalysableStatement, Analyser, AnalyserConfig}; -use pgt_console::{markup, Console}; -use pgt_diagnostics::{Diagnostic, DiagnosticExt, PrintDiagnostic}; -use pgt_query_ext::diagnostics::SyntaxDiagnostic; -use pgt_workspace::settings::Settings; +use pgls_analyser::{AnalysableStatement, Analyser, AnalyserConfig}; +use pgls_console::{markup, Console}; +use pgls_diagnostics::{Diagnostic, DiagnosticExt, PrintDiagnostic}; +use pgls_query_ext::diagnostics::SyntaxDiagnostic; +use pgls_workspace::settings::Settings; use pulldown_cmark::{CodeBlockKind, Event, Parser, Tag, TagEnd}; pub fn check_rules() -> anyhow::Result<()> { @@ -48,7 +48,7 @@ pub fn check_rules() -> anyhow::Result<()> { } let mut visitor = LintRulesVisitor::default(); - pgt_analyser::visit_registry(&mut visitor); + pgls_analyser::visit_registry(&mut visitor); let LintRulesVisitor { groups } = visitor; @@ -74,16 +74,16 @@ fn assert_lint( let mut diagnostic_count = 0; let mut all_diagnostics = vec![]; let mut has_error = false; - let mut write_diagnostic = |code: &str, diag: pgt_diagnostics::Error| { + let mut write_diagnostic = |code: &str, diag: pgls_diagnostics::Error| { all_diagnostics.push(diag); // Fail the test if the analysis returns more diagnostics than expected if test.expect_diagnostic { // Print all diagnostics to help the user if all_diagnostics.len() > 1 { - let mut console = pgt_console::EnvConsole::default(); + let mut console = pgls_console::EnvConsole::default(); for diag in all_diagnostics.iter() { console.println( - pgt_console::LogLevel::Error, + pgls_console::LogLevel::Error, markup! { {PrintDiagnostic::verbose(diag)} }, @@ -94,10 +94,10 @@ fn assert_lint( } } else { // Print all diagnostics to help the user - let mut console = pgt_console::EnvConsole::default(); + let mut console = pgls_console::EnvConsole::default(); for diag in all_diagnostics.iter() { console.println( - pgt_console::LogLevel::Error, + pgls_console::LogLevel::Error, markup! { {PrintDiagnostic::verbose(diag)} }, @@ -126,19 +126,19 @@ fn assert_lint( filter, }); - let result = pgt_statement_splitter::split(code); + let result = pgls_statement_splitter::split(code); for stmt_range in result.ranges { - match pgt_query::parse(&code[stmt_range]) { + match pgls_query::parse(&code[stmt_range]) { Ok(ast) => { if let Some(root) = ast.into_root() { - for rule_diag in analyser.run(pgt_analyser::AnalyserParams { + for rule_diag in analyser.run(pgls_analyser::AnalyserParams { schema_cache: None, stmts: vec![AnalysableStatement { range: stmt_range, root, }], }) { - let diag = pgt_diagnostics::serde::Diagnostic::new(rule_diag); + let diag = pgls_diagnostics::serde::Diagnostic::new(rule_diag); let category = diag.category().expect("linter diagnostic has no code"); let severity = settings.get_severity_from_rule_code(category).expect( @@ -164,10 +164,10 @@ fn assert_lint( } if !result.errors.is_empty() { // Print all diagnostics to help the user - let mut console = pgt_console::EnvConsole::default(); + let mut console = pgls_console::EnvConsole::default(); for err in result.errors { console.println( - pgt_console::LogLevel::Error, + pgls_console::LogLevel::Error, markup! { {PrintDiagnostic::verbose(&err)} }, diff --git a/xtask/src/install.rs b/xtask/src/install.rs index faaf5c56f..fe3ea8ca6 100644 --- a/xtask/src/install.rs +++ b/xtask/src/install.rs @@ -137,7 +137,7 @@ fn install_client(sh: &Shell, client_opt: ClientOpt) -> anyhow::Result<()> { } fn install_server(sh: &Shell) -> anyhow::Result<()> { - let cmd = cmd!(sh, "cargo install --path crates/pgt_cli --locked --force"); + let cmd = cmd!(sh, "cargo install --path crates/pgls_cli --locked --force"); cmd.run()?; Ok(()) } From 8f485be2f2c39b66134fa9af0c05ac07e98371a3 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 24 Sep 2025 08:06:35 +0200 Subject: [PATCH 2/8] fix: git submodule --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 4df59c035..5bef02654 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ -[submodule "crates/pgt_query/vendor/libpg_query"] - path = crates/pgt_query/vendor/libpg_query +[submodule "crates/pgls_query/vendor/libpg_query"] + path = crates/pgls_query/vendor/libpg_query url = https://github.com/pganalyze/libpg_query.git branch = 17-latest From 394cba61de6920dd7653cfb5b47269f9d5800877 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 24 Sep 2025 08:26:14 +0200 Subject: [PATCH 3/8] chore: update GitHub Actions for renamed packages and binaries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Updated release.yml to use pgls_cli instead of pgt_cli and pgls binary name - Changed environment variable from PGT_VERSION to PGLS_VERSION - Updated artifact names from postgrestools_* to pgls_* - Fixed package paths from @postgrestools/* to @pgls/* in workflows - Updated root package.json to use @pgls namespace - Removed obsolete @postgrestools test files from merge 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/publish.reusable.yml | 6 +- .github/workflows/pull_request.yml | 8 +-- .github/workflows/release.yml | 16 ++--- package.json | 6 +- .../postgrestools/test/bin.test.js | 62 ------------------- .../postgrestools/test/test.sql | 1 - 6 files changed, 18 insertions(+), 81 deletions(-) delete mode 100644 packages/@postgrestools/postgrestools/test/bin.test.js delete mode 100644 packages/@postgrestools/postgrestools/test/test.sql diff --git a/.github/workflows/publish.reusable.yml b/.github/workflows/publish.reusable.yml index 3ebf9216d..6cc728280 100644 --- a/.github/workflows/publish.reusable.yml +++ b/.github/workflows/publish.reusable.yml @@ -35,7 +35,7 @@ jobs: - name: Generate Packages id: generate-packages - run: node packages/@postgrestools/postgrestools/scripts/generate-packages.mjs + run: node packages/@pgls/cli/scripts/generate-packages.mjs env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} RELEASE_TAG: ${{ inputs.release-tag }} @@ -44,7 +44,7 @@ jobs: - name: Publish npm packages as nightly if: inputs.is-prerelease == 'true' run: | - for package in packages/@postgrestools/*; do + for package in packages/@pgls/*; do npm publish "$package" --tag nightly --access public --provenance done env: @@ -53,7 +53,7 @@ jobs: - name: Publish npm packages as latest if: inputs.is-prerelease != 'true' run: | - for package in packages/@postgrestools/*; do + for package in packages/@pgls/*; do version="${{ inputs.release-tag }}" npm_package_name=$(jq -r ".name" "$package/package.json") diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 8d0ca84a1..3ccf2ee3c 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -196,19 +196,19 @@ jobs: with: cache-base: main - name: Build main binary - run: cargo build -p pgt_cli --release + run: cargo build -p pgls_cli --release - name: Setup Bun uses: oven-sh/setup-bun@v2 - name: Install JS dependencies run: bun install - name: Build backend-jsonrpc - working-directory: packages/@postgrestools/backend-jsonrpc + working-directory: packages/@pgls/backend-jsonrpc run: bun run build - name: Run backend-jsonrpc test - working-directory: packages/@postgrestools/backend-jsonrpc + working-directory: packages/@pgls/backend-jsonrpc run: bun run test - name: Run cli test - working-directory: packages/@postgrestools/postgrestools + working-directory: packages/@pgls/cli run: bun run test codegen: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7ccc53055..54d2c0191 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -84,24 +84,24 @@ jobs: DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres - name: 🛠️ Run Build - run: cargo build -p pgt_cli --release --target ${{ matrix.config.target }} + run: cargo build -p pgls_cli --release --target ${{ matrix.config.target }} env: # Strip all debug symbols from the resulting binaries RUSTFLAGS: "-C strip=symbols -C codegen-units=1" # Inline the version in the CLI binary - PGT_VERSION: ${{ needs.extract_version.outputs.version }} + PGLS_VERSION: ${{ needs.extract_version.outputs.version }} # windows is a special snowflake too, it saves binaries as .exe - name: 👦 Name the Binary if: matrix.config.os == 'windows-2022' run: | mkdir dist - cp target/${{ matrix.config.target }}/release/postgrestools.exe ./dist/postgrestools_${{ matrix.config.target }} + cp target/${{ matrix.config.target }}/release/pgls.exe ./dist/pgls_${{ matrix.config.target }} - name: 👦 Name the Binary if: matrix.config.os != 'windows-2022' run: | mkdir dist - cp target/${{ matrix.config.target }}/release/postgrestools ./dist/postgrestools_${{ matrix.config.target }} + cp target/${{ matrix.config.target }}/release/pgls ./dist/pgls_${{ matrix.config.target }} # It is not possible to return the artifacts from the matrix jobs individually: Matrix outputs overwrite each other. # A common workaround is to upload and download the resulting artifacts. @@ -109,8 +109,8 @@ jobs: id: upload-artifacts uses: actions/upload-artifact@v4 with: - name: postgrestools_${{ matrix.config.target }} - path: ./dist/postgrestools_* + name: pgls_${{ matrix.config.target }} + path: ./dist/pgls_* # The default compression level is 6; this took the binary down from 350 to 330MB. # It is recommended to use a lower level for binaries, since the compressed result is not much smaller, # and the higher levels of compression take much longer. @@ -147,7 +147,7 @@ jobs: id: download with: merge-multiple: true - pattern: postgrestools_* + pattern: pgls_* - name: 📂 Create Release uses: softprops/action-gh-release@v2 @@ -159,7 +159,7 @@ jobs: body: ${{ steps.create_changelog.outputs.content }} tag_name: ${{ steps.create_changelog.outputs.version }} files: | - postgrestools_* + pgls_* docs/schema.json fail_on_unmatched_files: true draft: true diff --git a/package.json b/package.json index bf9303007..bd74ee9fa 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@postgrestools/monorepo", + "name": "@pgls/monorepo", "version": "0.0.0", "private": true, "devDependencies": { @@ -10,8 +10,8 @@ "typescript": "^5" }, "workspaces": [ - "packages/@postgrestools/postgrestools", - "packages/@postgrestools/backend-jsonrpc" + "packages/@pgls/cli", + "packages/@pgls/backend-jsonrpc" ], "keywords": [], "author": "Supabase Community", diff --git a/packages/@postgrestools/postgrestools/test/bin.test.js b/packages/@postgrestools/postgrestools/test/bin.test.js deleted file mode 100644 index 9b85042e5..000000000 --- a/packages/@postgrestools/postgrestools/test/bin.test.js +++ /dev/null @@ -1,62 +0,0 @@ -import { describe, it, expect } from "bun:test"; -import { spawn } from "child_process"; -import { join, dirname } from "path"; -import { fileURLToPath } from "url"; - -const __dirname = dirname(fileURLToPath(import.meta.url)); -const binPath = join(__dirname, "../bin/postgrestools"); -const testSqlPath = join(__dirname, "test.sql"); - -describe("postgrestools bin", () => { - - it("should check a SQL file successfully", async () => { - const result = await new Promise((resolve) => { - const proc = spawn("node", [binPath, "check", testSqlPath], { - env: { ...process.env }, - }); - - let stdout = ""; - let stderr = ""; - - proc.stdout.on("data", (data) => { - stdout += data.toString(); - }); - - proc.stderr.on("data", (data) => { - stderr += data.toString(); - }); - - proc.on("close", (code) => { - resolve({ code, stdout, stderr }); - }); - }); - - expect(result.code).toBe(0); - expect(result.stderr).toBe(""); - }); - - it("should fail when file doesn't exist", async () => { - const result = await new Promise((resolve) => { - const proc = spawn("node", [binPath, "check", "nonexistent.sql"], { - env: { ...process.env }, - }); - - let stdout = ""; - let stderr = ""; - - proc.stdout.on("data", (data) => { - stdout += data.toString(); - }); - - proc.stderr.on("data", (data) => { - stderr += data.toString(); - }); - - proc.on("close", (code) => { - resolve({ code, stdout, stderr }); - }); - }); - - expect(result.code).not.toBe(0); - }); -}); diff --git a/packages/@postgrestools/postgrestools/test/test.sql b/packages/@postgrestools/postgrestools/test/test.sql deleted file mode 100644 index 9e13a3eff..000000000 --- a/packages/@postgrestools/postgrestools/test/test.sql +++ /dev/null @@ -1 +0,0 @@ -select 1; \ No newline at end of file From 642eaf8de96a1173dcc55d9253125bd734d9095b Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 24 Sep 2025 08:35:59 +0200 Subject: [PATCH 4/8] fix: update console macro test snapshots for renamed crate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated stderr files in pgls_console tests to use pgls_console::markup\! instead of pgt_console::markup\! after the crate rename. This fixes the failing trybuild tests on macOS that were comparing expected vs actual macro error messages. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../tests/markup/open_element_unfinished_1.stderr | 4 ++-- .../tests/markup/open_element_unfinished_2.stderr | 4 ++-- .../tests/markup/open_element_unfinished_3.stderr | 4 ++-- .../tests/markup/open_element_unfinished_4.stderr | 4 ++-- .../tests/markup/open_element_unfinished_5.stderr | 4 ++-- .../tests/markup/open_element_unfinished_6.stderr | 4 ++-- .../tests/markup/open_element_unfinished_7.stderr | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/pgls_console/tests/markup/open_element_unfinished_1.stderr b/crates/pgls_console/tests/markup/open_element_unfinished_1.stderr index 923a0330c..8d0b6ca1a 100644 --- a/crates/pgls_console/tests/markup/open_element_unfinished_1.stderr +++ b/crates/pgls_console/tests/markup/open_element_unfinished_1.stderr @@ -1,9 +1,9 @@ error: unexpected end of input --> tests/markup/open_element_unfinished_1.rs:2:5 | -2 | / pgt_console::markup! { +2 | / pgls_console::markup! { 3 | | < 4 | | } | |_____^ | - = note: this error originates in the macro `pgt_console::markup` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `pgls_console::markup` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/crates/pgls_console/tests/markup/open_element_unfinished_2.stderr b/crates/pgls_console/tests/markup/open_element_unfinished_2.stderr index 463fe1822..1fa631d87 100644 --- a/crates/pgls_console/tests/markup/open_element_unfinished_2.stderr +++ b/crates/pgls_console/tests/markup/open_element_unfinished_2.stderr @@ -1,9 +1,9 @@ error: unexpected end of input --> tests/markup/open_element_unfinished_2.rs:2:5 | -2 | / pgt_console::markup! { +2 | / pgls_console::markup! { 3 | | tests/markup/open_element_unfinished_3.rs:2:5 | -2 | / pgt_console::markup! { +2 | / pgls_console::markup! { 3 | | tests/markup/open_element_unfinished_4.rs:2:5 | -2 | / pgt_console::markup! { +2 | / pgls_console::markup! { 3 | | tests/markup/open_element_unfinished_5.rs:2:5 | -2 | / pgt_console::markup! { +2 | / pgls_console::markup! { 3 | | tests/markup/open_element_unfinished_6.rs:2:5 | -2 | / pgt_console::markup! { +2 | / pgls_console::markup! { 3 | | tests/markup/open_element_unfinished_7.rs:2:5 | -2 | / pgt_console::markup! { +2 | / pgls_console::markup! { 3 | | Date: Wed, 24 Sep 2025 08:38:19 +0200 Subject: [PATCH 5/8] chore: update codegen artifacts after rename MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Updated SQL query cache files (.sqlx) for new schema - Regenerated docs/schema.json - Generated workspace bindings (needs path update) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- ...f2472fa8afc0b24bf02ee1bfdfdbf111acfc8.json | 15 +- docs/schema.json | 2 +- .../backend-jsonrpc/src/workspace.ts | 636 ++++++++++++++++++ 3 files changed, 651 insertions(+), 2 deletions(-) create mode 100644 packages/@postgrestools/backend-jsonrpc/src/workspace.ts diff --git a/.sqlx/query-aced4382cedbfc359bb1c1ab71cf2472fa8afc0b24bf02ee1bfdfdbf111acfc8.json b/.sqlx/query-aced4382cedbfc359bb1c1ab71cf2472fa8afc0b24bf02ee1bfdfdbf111acfc8.json index a32c84237..398f0ee20 100644 --- a/.sqlx/query-aced4382cedbfc359bb1c1ab71cf2472fa8afc0b24bf02ee1bfdfdbf111acfc8.json +++ b/.sqlx/query-aced4382cedbfc359bb1c1ab71cf2472fa8afc0b24bf02ee1bfdfdbf111acfc8.json @@ -67,7 +67,20 @@ "parameters": { "Left": [] }, - "nullable": [null, false, false, false, false, false, null, null, null, null, null, null] + "nullable": [ + null, + false, + false, + false, + false, + false, + null, + null, + null, + null, + null, + null + ] }, "hash": "aced4382cedbfc359bb1c1ab71cf2472fa8afc0b24bf02ee1bfdfdbf111acfc8" } diff --git a/docs/schema.json b/docs/schema.json index f4ef1e0cf..55f1abbfb 100644 --- a/docs/schema.json +++ b/docs/schema.json @@ -333,7 +333,7 @@ ] }, "recommended": { - "description": "It enables the lint rules recommended by Postgres Language Server. `true` by default.", + "description": "It enables the lint rules recommended by Postgres Tools. `true` by default.", "type": [ "boolean", "null" diff --git a/packages/@postgrestools/backend-jsonrpc/src/workspace.ts b/packages/@postgrestools/backend-jsonrpc/src/workspace.ts new file mode 100644 index 000000000..e49a7097b --- /dev/null +++ b/packages/@postgrestools/backend-jsonrpc/src/workspace.ts @@ -0,0 +1,636 @@ +// Generated file, do not edit by hand, see `xtask/codegen` +import type { Transport } from "./transport"; +export interface IsPathIgnoredParams { + pgt_path: PgLSPath; +} +export interface PgLSPath { + /** + * Determines the kind of the file inside Postgres Language Server. Some files are considered as configuration files, others as manifest files, and others as files to handle + */ + kind: FileKind; + path: string; + /** + * Whether this path (usually a file) was fixed as a result of a format/lint/check command with the `--write` filag. + */ + was_written: boolean; +} +export type FileKind = FileKind2[]; +/** + * The priority of the file + */ +export type FileKind2 = "Config" | "Ignore" | "Inspectable" | "Handleable"; +export interface RegisterProjectFolderParams { + path?: string; + setAsCurrentWorkspace: boolean; +} +export type ProjectKey = string; +export interface GetFileContentParams { + path: PgLSPath; +} +export interface PullDiagnosticsParams { + categories: RuleCategories; + max_diagnostics: number; + only: RuleCode[]; + path: PgLSPath; + skip: RuleCode[]; +} +export type RuleCategories = RuleCategory[]; +export type RuleCode = string; +export type RuleCategory = "Lint" | "Action" | "Transformation"; +export interface PullDiagnosticsResult { + diagnostics: Diagnostic[]; + errors: number; + skipped_diagnostics: number; +} +/** + * Serializable representation for a [Diagnostic](super::Diagnostic). + */ +export interface Diagnostic { + advices: Advices; + category?: Category; + description: string; + location: Location; + message: MarkupBuf; + severity: Severity; + source?: Diagnostic; + tags: DiagnosticTags; + verboseAdvices: Advices; +} +/** + * Implementation of [Visitor] collecting serializable [Advice] into a vector. + */ +export interface Advices { + advices: Advice[]; +} +export type Category = + | "lint/safety/addingFieldWithDefault" + | "lint/safety/addingForeignKeyConstraint" + | "lint/safety/addingNotNullField" + | "lint/safety/addingPrimaryKeyConstraint" + | "lint/safety/addingRequiredField" + | "lint/safety/banCharField" + | "lint/safety/banConcurrentIndexCreationInTransaction" + | "lint/safety/banDropColumn" + | "lint/safety/banDropDatabase" + | "lint/safety/banDropNotNull" + | "lint/safety/banDropTable" + | "lint/safety/banTruncateCascade" + | "lint/safety/changingColumnType" + | "lint/safety/constraintMissingNotValid" + | "lint/safety/disallowUniqueConstraint" + | "lint/safety/preferBigInt" + | "lint/safety/preferBigintOverInt" + | "lint/safety/preferBigintOverSmallint" + | "lint/safety/preferIdentity" + | "lint/safety/preferJsonb" + | "lint/safety/preferRobustStmts" + | "lint/safety/preferTextField" + | "lint/safety/preferTimestamptz" + | "lint/safety/renamingColumn" + | "lint/safety/renamingTable" + | "lint/safety/requireConcurrentIndexCreation" + | "lint/safety/requireConcurrentIndexDeletion" + | "lint/safety/transactionNesting" + | "stdin" + | "check" + | "configuration" + | "database/connection" + | "internalError/io" + | "internalError/runtime" + | "internalError/fs" + | "flags/invalid" + | "project" + | "typecheck" + | "plpgsql_check" + | "internalError/panic" + | "syntax" + | "dummy" + | "lint" + | "lint/performance" + | "lint/safety"; +export interface Location { + path?: Resource_for_String; + sourceCode?: string; + span?: TextRange; +} +export type MarkupBuf = MarkupNodeBuf[]; +/** + * The severity to associate to a diagnostic. + */ +export type Severity = "hint" | "information" | "warning" | "error" | "fatal"; +export type DiagnosticTags = DiagnosticTag[]; +/** + * Serializable representation of a [Diagnostic](super::Diagnostic) advice + +See the [Visitor] trait for additional documentation on all the supported advice types. + */ +export type Advice = + | { log: [LogCategory, MarkupBuf] } + | { list: MarkupBuf[] } + | { frame: Location } + | { diff: TextEdit } + | { backtrace: [MarkupBuf, Backtrace] } + | { command: string } + | { group: [MarkupBuf, Advices] }; +/** + * Represents the resource a diagnostic is associated with. + */ +export type Resource_for_String = "argv" | "memory" | { file: string }; +export type TextRange = [TextSize, TextSize]; +export interface MarkupNodeBuf { + content: string; + elements: MarkupElement[]; +} +/** + * Internal enum used to automatically generate bit offsets for [DiagnosticTags] and help with the implementation of `serde` and `schemars` for tags. + */ +export type DiagnosticTag = + | "fixable" + | "internal" + | "unnecessaryCode" + | "deprecatedCode" + | "verbose"; +/** + * The category for a log advice, defines how the message should be presented to the user. + */ +export type LogCategory = "none" | "info" | "warn" | "error"; +export interface TextEdit { + dictionary: string; + ops: CompressedOp[]; +} +export type Backtrace = BacktraceFrame[]; +export type TextSize = number; +/** + * Enumeration of all the supported markup elements + */ +export type MarkupElement = + | "Emphasis" + | "Dim" + | "Italic" + | "Underline" + | "Error" + | "Success" + | "Warn" + | "Info" + | "Debug" + | "Trace" + | "Inverse" + | { Hyperlink: { href: string } }; +export type CompressedOp = + | { diffOp: DiffOp } + | { equalLines: { line_count: number } }; +/** + * Serializable representation of a backtrace frame. + */ +export interface BacktraceFrame { + ip: number; + symbols: BacktraceSymbol[]; +} +export type DiffOp = + | { equal: { range: TextRange } } + | { insert: { range: TextRange } } + | { delete: { range: TextRange } }; +/** + * Serializable representation of a backtrace frame symbol. + */ +export interface BacktraceSymbol { + colno?: number; + filename?: string; + lineno?: number; + name?: string; +} +export interface GetCompletionsParams { + /** + * The File for which a completion is requested. + */ + path: PgLSPath; + /** + * The Cursor position in the file for which a completion is requested. + */ + position: TextSize; +} +export interface CompletionsResult { + items: CompletionItem[]; +} +export interface CompletionItem { + completion_text?: CompletionText; + description: string; + detail?: string; + kind: CompletionItemKind; + label: string; + preselected: boolean; + /** + * String used for sorting by LSP clients. + */ + sort_text: string; +} +/** + * The text that the editor should fill in. If `None`, the `label` should be used. Tables, for example, might have different completion_texts: + +label: "users", description: "Schema: auth", completion_text: "auth.users". + */ +export interface CompletionText { + is_snippet: boolean; + /** + * A `range` is required because some editors replace the current token, others naively insert the text. Having a range where start == end makes it an insertion. + */ + range: TextRange; + text: string; +} +export type CompletionItemKind = + | "table" + | "function" + | "column" + | "schema" + | "policy" + | "role"; +export interface UpdateSettingsParams { + configuration: PartialConfiguration; + gitignore_matches: string[]; + vcs_base_path?: string; + workspace_directory?: string; +} +/** + * The configuration that is contained inside the configuration file. + */ +export interface PartialConfiguration { + /** + * A field for the [JSON schema](https://json-schema.org/) specification + */ + $schema?: string; + /** + * The configuration of the database connection + */ + db?: PartialDatabaseConfiguration; + /** + * A list of paths to other JSON files, used to extends the current configuration. + */ + extends?: StringSet; + /** + * The configuration of the filesystem + */ + files?: PartialFilesConfiguration; + /** + * The configuration for the linter + */ + linter?: PartialLinterConfiguration; + /** + * Configure migrations + */ + migrations?: PartialMigrationsConfiguration; + /** + * The configuration for type checking + */ + plpgsqlCheck?: PartialPlPgSqlCheckConfiguration; + /** + * The configuration for type checking + */ + typecheck?: PartialTypecheckConfiguration; + /** + * The configuration of the VCS integration + */ + vcs?: PartialVcsConfiguration; +} +/** + * The configuration of the database connection. + */ +export interface PartialDatabaseConfiguration { + allowStatementExecutionsAgainst?: StringSet; + /** + * The connection timeout in seconds. + */ + connTimeoutSecs?: number; + /** + * The name of the database. + */ + database?: string; + /** + * The host of the database. Required if you want database-related features. All else falls back to sensible defaults. + */ + host?: string; + /** + * The password to connect to the database. + */ + password?: string; + /** + * The port of the database. + */ + port?: number; + /** + * The username to connect to the database. + */ + username?: string; +} +export type StringSet = string[]; +/** + * The configuration of the filesystem + */ +export interface PartialFilesConfiguration { + /** + * A list of Unix shell style patterns. Will ignore files/folders that will match these patterns. + */ + ignore?: StringSet; + /** + * A list of Unix shell style patterns. Will handle only those files/folders that will match these patterns. + */ + include?: StringSet; + /** + * The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reasons. Defaults to 1 MiB + */ + maxSize?: number; +} +export interface PartialLinterConfiguration { + /** + * if `false`, it disables the feature and the linter won't be executed. `true` by default + */ + enabled?: boolean; + /** + * A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns. + */ + ignore?: StringSet; + /** + * A list of Unix shell style patterns. The formatter will include files/folders that will match these patterns. + */ + include?: StringSet; + /** + * List of rules + */ + rules?: Rules; +} +/** + * The configuration of the filesystem + */ +export interface PartialMigrationsConfiguration { + /** + * Ignore any migrations before this timestamp + */ + after?: number; + /** + * The directory where the migration files are stored + */ + migrationsDir?: string; +} +/** + * The configuration for type checking. + */ +export interface PartialPlPgSqlCheckConfiguration { + /** + * if `false`, it disables the feature and pglpgsql_check won't be executed. `true` by default + */ + enabled?: boolean; +} +/** + * The configuration for type checking. + */ +export interface PartialTypecheckConfiguration { + /** + * if `false`, it disables the feature and the typechecker won't be executed. `true` by default + */ + enabled?: boolean; + /** + * Default search path schemas for type checking. Can be a list of schema names or glob patterns like ["public", "app_*"]. If not specified, defaults to ["public"]. + */ + searchPath?: StringSet; +} +/** + * Set of properties to integrate with a VCS software. + */ +export interface PartialVcsConfiguration { + /** + * The kind of client. + */ + clientKind?: VcsClientKind; + /** + * The main branch of the project + */ + defaultBranch?: string; + /** + * Whether we should integrate itself with the VCS client + */ + enabled?: boolean; + /** + * The folder where we should check for VCS files. By default, we will use the same folder where `postgres-language-server.jsonc` was found. + +If we can't find the configuration, it will attempt to use the current working directory. If no current working directory can't be found, we won't use the VCS integration, and a diagnostic will be emitted + */ + root?: string; + /** + * Whether we should use the VCS ignore file. When [true], we will ignore the files specified in the ignore file. + */ + useIgnoreFile?: boolean; +} +export interface Rules { + /** + * It enables ALL rules. The rules that belong to `nursery` won't be enabled. + */ + all?: boolean; + /** + * It enables the lint rules recommended by Postgres Tools. `true` by default. + */ + recommended?: boolean; + safety?: Safety; +} +export type VcsClientKind = "git"; +/** + * A list of rules that belong to this group + */ +export interface Safety { + /** + * Adding a column with a DEFAULT value may lead to a table rewrite while holding an ACCESS EXCLUSIVE lock. + */ + addingFieldWithDefault?: RuleConfiguration_for_Null; + /** + * Adding a foreign key constraint requires a table scan and a SHARE ROW EXCLUSIVE lock on both tables, which blocks writes. + */ + addingForeignKeyConstraint?: RuleConfiguration_for_Null; + /** + * Setting a column NOT NULL blocks reads while the table is scanned. + */ + addingNotNullField?: RuleConfiguration_for_Null; + /** + * Adding a primary key constraint results in locks and table rewrites. + */ + addingPrimaryKeyConstraint?: RuleConfiguration_for_Null; + /** + * Adding a new column that is NOT NULL and has no default value to an existing table effectively makes it required. + */ + addingRequiredField?: RuleConfiguration_for_Null; + /** + * It enables ALL rules for this group. + */ + all?: boolean; + /** + * Using CHAR(n) or CHARACTER(n) types is discouraged. + */ + banCharField?: RuleConfiguration_for_Null; + /** + * Concurrent index creation is not allowed within a transaction. + */ + banConcurrentIndexCreationInTransaction?: RuleConfiguration_for_Null; + /** + * Dropping a column may break existing clients. + */ + banDropColumn?: RuleConfiguration_for_Null; + /** + * Dropping a database may break existing clients (and everything else, really). + */ + banDropDatabase?: RuleConfiguration_for_Null; + /** + * Dropping a NOT NULL constraint may break existing clients. + */ + banDropNotNull?: RuleConfiguration_for_Null; + /** + * Dropping a table may break existing clients. + */ + banDropTable?: RuleConfiguration_for_Null; + /** + * Using TRUNCATE's CASCADE option will truncate any tables that are also foreign-keyed to the specified tables. + */ + banTruncateCascade?: RuleConfiguration_for_Null; + /** + * Changing a column type may break existing clients. + */ + changingColumnType?: RuleConfiguration_for_Null; + /** + * Adding constraints without NOT VALID blocks all reads and writes. + */ + constraintMissingNotValid?: RuleConfiguration_for_Null; + /** + * Disallow adding a UNIQUE constraint without using an existing index. + */ + disallowUniqueConstraint?: RuleConfiguration_for_Null; + /** + * Prefer BIGINT over smaller integer types. + */ + preferBigInt?: RuleConfiguration_for_Null; + /** + * Prefer BIGINT over INT/INTEGER types. + */ + preferBigintOverInt?: RuleConfiguration_for_Null; + /** + * Prefer BIGINT over SMALLINT types. + */ + preferBigintOverSmallint?: RuleConfiguration_for_Null; + /** + * Prefer using IDENTITY columns over serial columns. + */ + preferIdentity?: RuleConfiguration_for_Null; + /** + * Prefer JSONB over JSON types. + */ + preferJsonb?: RuleConfiguration_for_Null; + /** + * Prefer statements with guards for robustness in migrations. + */ + preferRobustStmts?: RuleConfiguration_for_Null; + /** + * Prefer using TEXT over VARCHAR(n) types. + */ + preferTextField?: RuleConfiguration_for_Null; + /** + * Prefer TIMESTAMPTZ over TIMESTAMP types. + */ + preferTimestamptz?: RuleConfiguration_for_Null; + /** + * It enables the recommended rules for this group + */ + recommended?: boolean; + /** + * Renaming columns may break existing queries and application code. + */ + renamingColumn?: RuleConfiguration_for_Null; + /** + * Renaming tables may break existing queries and application code. + */ + renamingTable?: RuleConfiguration_for_Null; + /** + * Creating indexes non-concurrently can lock the table for writes. + */ + requireConcurrentIndexCreation?: RuleConfiguration_for_Null; + /** + * Dropping indexes non-concurrently can lock the table for reads. + */ + requireConcurrentIndexDeletion?: RuleConfiguration_for_Null; + /** + * Detects problematic transaction nesting that could lead to unexpected behavior. + */ + transactionNesting?: RuleConfiguration_for_Null; +} +export type RuleConfiguration_for_Null = + | RulePlainConfiguration + | RuleWithOptions_for_Null; +export type RulePlainConfiguration = "warn" | "error" | "info" | "off"; +export interface RuleWithOptions_for_Null { + /** + * The severity of the emitted diagnostics by the rule + */ + level: RulePlainConfiguration; + /** + * Rule's options + */ + options: null; +} +export interface OpenFileParams { + content: string; + path: PgLSPath; + version: number; +} +export interface ChangeFileParams { + content: string; + path: PgLSPath; + version: number; +} +export interface CloseFileParams { + path: PgLSPath; +} +export type Configuration = PartialConfiguration; +export interface Workspace { + isPathIgnored(params: IsPathIgnoredParams): Promise; + registerProjectFolder( + params: RegisterProjectFolderParams, + ): Promise; + getFileContent(params: GetFileContentParams): Promise; + pullDiagnostics( + params: PullDiagnosticsParams, + ): Promise; + getCompletions(params: GetCompletionsParams): Promise; + updateSettings(params: UpdateSettingsParams): Promise; + openFile(params: OpenFileParams): Promise; + changeFile(params: ChangeFileParams): Promise; + closeFile(params: CloseFileParams): Promise; + destroy(): void; +} +export function createWorkspace(transport: Transport): Workspace { + return { + isPathIgnored(params) { + return transport.request("pgt/is_path_ignored", params); + }, + registerProjectFolder(params) { + return transport.request("pgt/register_project_folder", params); + }, + getFileContent(params) { + return transport.request("pgt/get_file_content", params); + }, + pullDiagnostics(params) { + return transport.request("pgt/pull_diagnostics", params); + }, + getCompletions(params) { + return transport.request("pgt/get_completions", params); + }, + updateSettings(params) { + return transport.request("pgt/update_settings", params); + }, + openFile(params) { + return transport.request("pgt/open_file", params); + }, + changeFile(params) { + return transport.request("pgt/change_file", params); + }, + closeFile(params) { + return transport.request("pgt/close_file", params); + }, + destroy() { + transport.destroy(); + }, + }; +} From 59cd8507f09735e133db9006d3577eba0a68d5d1 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 24 Sep 2025 08:39:02 +0200 Subject: [PATCH 6/8] fix: update codegen to generate files in correct package paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed xtask_codegen to generate workspace.ts in the correct location: packages/@pgls/backend-jsonrpc/src/workspace.ts instead of packages/@postgrestools/backend-jsonrpc/src/workspace.ts 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../@pgls/backend-jsonrpc/src/workspace.ts | 2 +- .../backend-jsonrpc/src/workspace.ts | 636 ------------------ xtask/codegen/src/generate_bindings.rs | 2 +- 3 files changed, 2 insertions(+), 638 deletions(-) delete mode 100644 packages/@postgrestools/backend-jsonrpc/src/workspace.ts diff --git a/packages/@pgls/backend-jsonrpc/src/workspace.ts b/packages/@pgls/backend-jsonrpc/src/workspace.ts index 1218576d2..e49a7097b 100644 --- a/packages/@pgls/backend-jsonrpc/src/workspace.ts +++ b/packages/@pgls/backend-jsonrpc/src/workspace.ts @@ -425,7 +425,7 @@ export interface Rules { */ all?: boolean; /** - * It enables the lint rules recommended by Postgres Language Server. `true` by default. + * It enables the lint rules recommended by Postgres Tools. `true` by default. */ recommended?: boolean; safety?: Safety; diff --git a/packages/@postgrestools/backend-jsonrpc/src/workspace.ts b/packages/@postgrestools/backend-jsonrpc/src/workspace.ts deleted file mode 100644 index e49a7097b..000000000 --- a/packages/@postgrestools/backend-jsonrpc/src/workspace.ts +++ /dev/null @@ -1,636 +0,0 @@ -// Generated file, do not edit by hand, see `xtask/codegen` -import type { Transport } from "./transport"; -export interface IsPathIgnoredParams { - pgt_path: PgLSPath; -} -export interface PgLSPath { - /** - * Determines the kind of the file inside Postgres Language Server. Some files are considered as configuration files, others as manifest files, and others as files to handle - */ - kind: FileKind; - path: string; - /** - * Whether this path (usually a file) was fixed as a result of a format/lint/check command with the `--write` filag. - */ - was_written: boolean; -} -export type FileKind = FileKind2[]; -/** - * The priority of the file - */ -export type FileKind2 = "Config" | "Ignore" | "Inspectable" | "Handleable"; -export interface RegisterProjectFolderParams { - path?: string; - setAsCurrentWorkspace: boolean; -} -export type ProjectKey = string; -export interface GetFileContentParams { - path: PgLSPath; -} -export interface PullDiagnosticsParams { - categories: RuleCategories; - max_diagnostics: number; - only: RuleCode[]; - path: PgLSPath; - skip: RuleCode[]; -} -export type RuleCategories = RuleCategory[]; -export type RuleCode = string; -export type RuleCategory = "Lint" | "Action" | "Transformation"; -export interface PullDiagnosticsResult { - diagnostics: Diagnostic[]; - errors: number; - skipped_diagnostics: number; -} -/** - * Serializable representation for a [Diagnostic](super::Diagnostic). - */ -export interface Diagnostic { - advices: Advices; - category?: Category; - description: string; - location: Location; - message: MarkupBuf; - severity: Severity; - source?: Diagnostic; - tags: DiagnosticTags; - verboseAdvices: Advices; -} -/** - * Implementation of [Visitor] collecting serializable [Advice] into a vector. - */ -export interface Advices { - advices: Advice[]; -} -export type Category = - | "lint/safety/addingFieldWithDefault" - | "lint/safety/addingForeignKeyConstraint" - | "lint/safety/addingNotNullField" - | "lint/safety/addingPrimaryKeyConstraint" - | "lint/safety/addingRequiredField" - | "lint/safety/banCharField" - | "lint/safety/banConcurrentIndexCreationInTransaction" - | "lint/safety/banDropColumn" - | "lint/safety/banDropDatabase" - | "lint/safety/banDropNotNull" - | "lint/safety/banDropTable" - | "lint/safety/banTruncateCascade" - | "lint/safety/changingColumnType" - | "lint/safety/constraintMissingNotValid" - | "lint/safety/disallowUniqueConstraint" - | "lint/safety/preferBigInt" - | "lint/safety/preferBigintOverInt" - | "lint/safety/preferBigintOverSmallint" - | "lint/safety/preferIdentity" - | "lint/safety/preferJsonb" - | "lint/safety/preferRobustStmts" - | "lint/safety/preferTextField" - | "lint/safety/preferTimestamptz" - | "lint/safety/renamingColumn" - | "lint/safety/renamingTable" - | "lint/safety/requireConcurrentIndexCreation" - | "lint/safety/requireConcurrentIndexDeletion" - | "lint/safety/transactionNesting" - | "stdin" - | "check" - | "configuration" - | "database/connection" - | "internalError/io" - | "internalError/runtime" - | "internalError/fs" - | "flags/invalid" - | "project" - | "typecheck" - | "plpgsql_check" - | "internalError/panic" - | "syntax" - | "dummy" - | "lint" - | "lint/performance" - | "lint/safety"; -export interface Location { - path?: Resource_for_String; - sourceCode?: string; - span?: TextRange; -} -export type MarkupBuf = MarkupNodeBuf[]; -/** - * The severity to associate to a diagnostic. - */ -export type Severity = "hint" | "information" | "warning" | "error" | "fatal"; -export type DiagnosticTags = DiagnosticTag[]; -/** - * Serializable representation of a [Diagnostic](super::Diagnostic) advice - -See the [Visitor] trait for additional documentation on all the supported advice types. - */ -export type Advice = - | { log: [LogCategory, MarkupBuf] } - | { list: MarkupBuf[] } - | { frame: Location } - | { diff: TextEdit } - | { backtrace: [MarkupBuf, Backtrace] } - | { command: string } - | { group: [MarkupBuf, Advices] }; -/** - * Represents the resource a diagnostic is associated with. - */ -export type Resource_for_String = "argv" | "memory" | { file: string }; -export type TextRange = [TextSize, TextSize]; -export interface MarkupNodeBuf { - content: string; - elements: MarkupElement[]; -} -/** - * Internal enum used to automatically generate bit offsets for [DiagnosticTags] and help with the implementation of `serde` and `schemars` for tags. - */ -export type DiagnosticTag = - | "fixable" - | "internal" - | "unnecessaryCode" - | "deprecatedCode" - | "verbose"; -/** - * The category for a log advice, defines how the message should be presented to the user. - */ -export type LogCategory = "none" | "info" | "warn" | "error"; -export interface TextEdit { - dictionary: string; - ops: CompressedOp[]; -} -export type Backtrace = BacktraceFrame[]; -export type TextSize = number; -/** - * Enumeration of all the supported markup elements - */ -export type MarkupElement = - | "Emphasis" - | "Dim" - | "Italic" - | "Underline" - | "Error" - | "Success" - | "Warn" - | "Info" - | "Debug" - | "Trace" - | "Inverse" - | { Hyperlink: { href: string } }; -export type CompressedOp = - | { diffOp: DiffOp } - | { equalLines: { line_count: number } }; -/** - * Serializable representation of a backtrace frame. - */ -export interface BacktraceFrame { - ip: number; - symbols: BacktraceSymbol[]; -} -export type DiffOp = - | { equal: { range: TextRange } } - | { insert: { range: TextRange } } - | { delete: { range: TextRange } }; -/** - * Serializable representation of a backtrace frame symbol. - */ -export interface BacktraceSymbol { - colno?: number; - filename?: string; - lineno?: number; - name?: string; -} -export interface GetCompletionsParams { - /** - * The File for which a completion is requested. - */ - path: PgLSPath; - /** - * The Cursor position in the file for which a completion is requested. - */ - position: TextSize; -} -export interface CompletionsResult { - items: CompletionItem[]; -} -export interface CompletionItem { - completion_text?: CompletionText; - description: string; - detail?: string; - kind: CompletionItemKind; - label: string; - preselected: boolean; - /** - * String used for sorting by LSP clients. - */ - sort_text: string; -} -/** - * The text that the editor should fill in. If `None`, the `label` should be used. Tables, for example, might have different completion_texts: - -label: "users", description: "Schema: auth", completion_text: "auth.users". - */ -export interface CompletionText { - is_snippet: boolean; - /** - * A `range` is required because some editors replace the current token, others naively insert the text. Having a range where start == end makes it an insertion. - */ - range: TextRange; - text: string; -} -export type CompletionItemKind = - | "table" - | "function" - | "column" - | "schema" - | "policy" - | "role"; -export interface UpdateSettingsParams { - configuration: PartialConfiguration; - gitignore_matches: string[]; - vcs_base_path?: string; - workspace_directory?: string; -} -/** - * The configuration that is contained inside the configuration file. - */ -export interface PartialConfiguration { - /** - * A field for the [JSON schema](https://json-schema.org/) specification - */ - $schema?: string; - /** - * The configuration of the database connection - */ - db?: PartialDatabaseConfiguration; - /** - * A list of paths to other JSON files, used to extends the current configuration. - */ - extends?: StringSet; - /** - * The configuration of the filesystem - */ - files?: PartialFilesConfiguration; - /** - * The configuration for the linter - */ - linter?: PartialLinterConfiguration; - /** - * Configure migrations - */ - migrations?: PartialMigrationsConfiguration; - /** - * The configuration for type checking - */ - plpgsqlCheck?: PartialPlPgSqlCheckConfiguration; - /** - * The configuration for type checking - */ - typecheck?: PartialTypecheckConfiguration; - /** - * The configuration of the VCS integration - */ - vcs?: PartialVcsConfiguration; -} -/** - * The configuration of the database connection. - */ -export interface PartialDatabaseConfiguration { - allowStatementExecutionsAgainst?: StringSet; - /** - * The connection timeout in seconds. - */ - connTimeoutSecs?: number; - /** - * The name of the database. - */ - database?: string; - /** - * The host of the database. Required if you want database-related features. All else falls back to sensible defaults. - */ - host?: string; - /** - * The password to connect to the database. - */ - password?: string; - /** - * The port of the database. - */ - port?: number; - /** - * The username to connect to the database. - */ - username?: string; -} -export type StringSet = string[]; -/** - * The configuration of the filesystem - */ -export interface PartialFilesConfiguration { - /** - * A list of Unix shell style patterns. Will ignore files/folders that will match these patterns. - */ - ignore?: StringSet; - /** - * A list of Unix shell style patterns. Will handle only those files/folders that will match these patterns. - */ - include?: StringSet; - /** - * The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reasons. Defaults to 1 MiB - */ - maxSize?: number; -} -export interface PartialLinterConfiguration { - /** - * if `false`, it disables the feature and the linter won't be executed. `true` by default - */ - enabled?: boolean; - /** - * A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns. - */ - ignore?: StringSet; - /** - * A list of Unix shell style patterns. The formatter will include files/folders that will match these patterns. - */ - include?: StringSet; - /** - * List of rules - */ - rules?: Rules; -} -/** - * The configuration of the filesystem - */ -export interface PartialMigrationsConfiguration { - /** - * Ignore any migrations before this timestamp - */ - after?: number; - /** - * The directory where the migration files are stored - */ - migrationsDir?: string; -} -/** - * The configuration for type checking. - */ -export interface PartialPlPgSqlCheckConfiguration { - /** - * if `false`, it disables the feature and pglpgsql_check won't be executed. `true` by default - */ - enabled?: boolean; -} -/** - * The configuration for type checking. - */ -export interface PartialTypecheckConfiguration { - /** - * if `false`, it disables the feature and the typechecker won't be executed. `true` by default - */ - enabled?: boolean; - /** - * Default search path schemas for type checking. Can be a list of schema names or glob patterns like ["public", "app_*"]. If not specified, defaults to ["public"]. - */ - searchPath?: StringSet; -} -/** - * Set of properties to integrate with a VCS software. - */ -export interface PartialVcsConfiguration { - /** - * The kind of client. - */ - clientKind?: VcsClientKind; - /** - * The main branch of the project - */ - defaultBranch?: string; - /** - * Whether we should integrate itself with the VCS client - */ - enabled?: boolean; - /** - * The folder where we should check for VCS files. By default, we will use the same folder where `postgres-language-server.jsonc` was found. - -If we can't find the configuration, it will attempt to use the current working directory. If no current working directory can't be found, we won't use the VCS integration, and a diagnostic will be emitted - */ - root?: string; - /** - * Whether we should use the VCS ignore file. When [true], we will ignore the files specified in the ignore file. - */ - useIgnoreFile?: boolean; -} -export interface Rules { - /** - * It enables ALL rules. The rules that belong to `nursery` won't be enabled. - */ - all?: boolean; - /** - * It enables the lint rules recommended by Postgres Tools. `true` by default. - */ - recommended?: boolean; - safety?: Safety; -} -export type VcsClientKind = "git"; -/** - * A list of rules that belong to this group - */ -export interface Safety { - /** - * Adding a column with a DEFAULT value may lead to a table rewrite while holding an ACCESS EXCLUSIVE lock. - */ - addingFieldWithDefault?: RuleConfiguration_for_Null; - /** - * Adding a foreign key constraint requires a table scan and a SHARE ROW EXCLUSIVE lock on both tables, which blocks writes. - */ - addingForeignKeyConstraint?: RuleConfiguration_for_Null; - /** - * Setting a column NOT NULL blocks reads while the table is scanned. - */ - addingNotNullField?: RuleConfiguration_for_Null; - /** - * Adding a primary key constraint results in locks and table rewrites. - */ - addingPrimaryKeyConstraint?: RuleConfiguration_for_Null; - /** - * Adding a new column that is NOT NULL and has no default value to an existing table effectively makes it required. - */ - addingRequiredField?: RuleConfiguration_for_Null; - /** - * It enables ALL rules for this group. - */ - all?: boolean; - /** - * Using CHAR(n) or CHARACTER(n) types is discouraged. - */ - banCharField?: RuleConfiguration_for_Null; - /** - * Concurrent index creation is not allowed within a transaction. - */ - banConcurrentIndexCreationInTransaction?: RuleConfiguration_for_Null; - /** - * Dropping a column may break existing clients. - */ - banDropColumn?: RuleConfiguration_for_Null; - /** - * Dropping a database may break existing clients (and everything else, really). - */ - banDropDatabase?: RuleConfiguration_for_Null; - /** - * Dropping a NOT NULL constraint may break existing clients. - */ - banDropNotNull?: RuleConfiguration_for_Null; - /** - * Dropping a table may break existing clients. - */ - banDropTable?: RuleConfiguration_for_Null; - /** - * Using TRUNCATE's CASCADE option will truncate any tables that are also foreign-keyed to the specified tables. - */ - banTruncateCascade?: RuleConfiguration_for_Null; - /** - * Changing a column type may break existing clients. - */ - changingColumnType?: RuleConfiguration_for_Null; - /** - * Adding constraints without NOT VALID blocks all reads and writes. - */ - constraintMissingNotValid?: RuleConfiguration_for_Null; - /** - * Disallow adding a UNIQUE constraint without using an existing index. - */ - disallowUniqueConstraint?: RuleConfiguration_for_Null; - /** - * Prefer BIGINT over smaller integer types. - */ - preferBigInt?: RuleConfiguration_for_Null; - /** - * Prefer BIGINT over INT/INTEGER types. - */ - preferBigintOverInt?: RuleConfiguration_for_Null; - /** - * Prefer BIGINT over SMALLINT types. - */ - preferBigintOverSmallint?: RuleConfiguration_for_Null; - /** - * Prefer using IDENTITY columns over serial columns. - */ - preferIdentity?: RuleConfiguration_for_Null; - /** - * Prefer JSONB over JSON types. - */ - preferJsonb?: RuleConfiguration_for_Null; - /** - * Prefer statements with guards for robustness in migrations. - */ - preferRobustStmts?: RuleConfiguration_for_Null; - /** - * Prefer using TEXT over VARCHAR(n) types. - */ - preferTextField?: RuleConfiguration_for_Null; - /** - * Prefer TIMESTAMPTZ over TIMESTAMP types. - */ - preferTimestamptz?: RuleConfiguration_for_Null; - /** - * It enables the recommended rules for this group - */ - recommended?: boolean; - /** - * Renaming columns may break existing queries and application code. - */ - renamingColumn?: RuleConfiguration_for_Null; - /** - * Renaming tables may break existing queries and application code. - */ - renamingTable?: RuleConfiguration_for_Null; - /** - * Creating indexes non-concurrently can lock the table for writes. - */ - requireConcurrentIndexCreation?: RuleConfiguration_for_Null; - /** - * Dropping indexes non-concurrently can lock the table for reads. - */ - requireConcurrentIndexDeletion?: RuleConfiguration_for_Null; - /** - * Detects problematic transaction nesting that could lead to unexpected behavior. - */ - transactionNesting?: RuleConfiguration_for_Null; -} -export type RuleConfiguration_for_Null = - | RulePlainConfiguration - | RuleWithOptions_for_Null; -export type RulePlainConfiguration = "warn" | "error" | "info" | "off"; -export interface RuleWithOptions_for_Null { - /** - * The severity of the emitted diagnostics by the rule - */ - level: RulePlainConfiguration; - /** - * Rule's options - */ - options: null; -} -export interface OpenFileParams { - content: string; - path: PgLSPath; - version: number; -} -export interface ChangeFileParams { - content: string; - path: PgLSPath; - version: number; -} -export interface CloseFileParams { - path: PgLSPath; -} -export type Configuration = PartialConfiguration; -export interface Workspace { - isPathIgnored(params: IsPathIgnoredParams): Promise; - registerProjectFolder( - params: RegisterProjectFolderParams, - ): Promise; - getFileContent(params: GetFileContentParams): Promise; - pullDiagnostics( - params: PullDiagnosticsParams, - ): Promise; - getCompletions(params: GetCompletionsParams): Promise; - updateSettings(params: UpdateSettingsParams): Promise; - openFile(params: OpenFileParams): Promise; - changeFile(params: ChangeFileParams): Promise; - closeFile(params: CloseFileParams): Promise; - destroy(): void; -} -export function createWorkspace(transport: Transport): Workspace { - return { - isPathIgnored(params) { - return transport.request("pgt/is_path_ignored", params); - }, - registerProjectFolder(params) { - return transport.request("pgt/register_project_folder", params); - }, - getFileContent(params) { - return transport.request("pgt/get_file_content", params); - }, - pullDiagnostics(params) { - return transport.request("pgt/pull_diagnostics", params); - }, - getCompletions(params) { - return transport.request("pgt/get_completions", params); - }, - updateSettings(params) { - return transport.request("pgt/update_settings", params); - }, - openFile(params) { - return transport.request("pgt/open_file", params); - }, - changeFile(params) { - return transport.request("pgt/change_file", params); - }, - closeFile(params) { - return transport.request("pgt/close_file", params); - }, - destroy() { - transport.destroy(); - }, - }; -} diff --git a/xtask/codegen/src/generate_bindings.rs b/xtask/codegen/src/generate_bindings.rs index e8e635580..95c34eb42 100644 --- a/xtask/codegen/src/generate_bindings.rs +++ b/xtask/codegen/src/generate_bindings.rs @@ -15,7 +15,7 @@ use xtask::{project_root, Mode, Result}; pub fn generate_bindings(mode: Mode) -> Result<()> { let bindings_path = - project_root().join("packages/@postgrestools/backend-jsonrpc/src/workspace.ts"); + project_root().join("packages/@pgls/backend-jsonrpc/src/workspace.ts"); let methods = methods(); let mut declarations = Vec::new(); From d14b44b6c37017c12152a544aefbe67710e2b2fc Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 24 Sep 2025 08:41:01 +0200 Subject: [PATCH 7/8] style: format generate_bindings.rs after path update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Applied rustfmt formatting to the codegen file after updating the package path. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- xtask/codegen/src/generate_bindings.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xtask/codegen/src/generate_bindings.rs b/xtask/codegen/src/generate_bindings.rs index 95c34eb42..7f898c2dd 100644 --- a/xtask/codegen/src/generate_bindings.rs +++ b/xtask/codegen/src/generate_bindings.rs @@ -14,8 +14,7 @@ use pgls_workspace::workspace_types::{generate_type, methods, ModuleQueue}; use xtask::{project_root, Mode, Result}; pub fn generate_bindings(mode: Mode) -> Result<()> { - let bindings_path = - project_root().join("packages/@pgls/backend-jsonrpc/src/workspace.ts"); + let bindings_path = project_root().join("packages/@pgls/backend-jsonrpc/src/workspace.ts"); let methods = methods(); let mut declarations = Vec::new(); From 0efae21031dc525ede8902199c488280bcd1c854 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 24 Sep 2025 08:55:27 +0200 Subject: [PATCH 8/8] fix: regenerate tokenizer test snapshots after crate rename MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All pgls_tokenizer test snapshots were regenerated to reflect the new crate naming after the rename from pgt_* to pgls_*. The snapshot files now correctly reference the renamed crate and all 28 tests are passing. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../pgls_tokenizer__tests__bitstring.snap | 16 ++++++++++ .../pgls_tokenizer__tests__block_comment.snap | 9 ++++++ ...er__tests__block_comment_unterminated.snap | 9 ++++++ ...s__dollar_quote_mismatch_tags_complex.snap | 11 +++++++ ...ts__dollar_quote_mismatch_tags_simple.snap | 11 +++++++ ...pgls_tokenizer__tests__dollar_quoting.snap | 15 ++++++++++ ...okenizer__tests__dollar_strings_part2.snap | 12 ++++++++ ...okenizer__tests__graphile_named_param.snap | 27 +++++++++++++++++ .../pgls_tokenizer__tests__lex_statement.snap | 11 +++++++ .../pgls_tokenizer__tests__line_comment.snap | 10 +++++++ ...nizer__tests__line_comment_whitespace.snap | 16 ++++++++++ ...pgls_tokenizer__tests__named_param_at.snap | 23 ++++++++++++++ ...__tests__named_param_colon_identifier.snap | 23 ++++++++++++++ ...kenizer__tests__named_param_colon_raw.snap | 23 ++++++++++++++ ..._tests__named_param_colon_raw_vs_cast.snap | 25 ++++++++++++++++ ...izer__tests__named_param_colon_string.snap | 23 ++++++++++++++ ...enizer__tests__named_param_dollar_raw.snap | 23 ++++++++++++++ .../pgls_tokenizer__tests__numeric.snap | 30 +++++++++++++++++++ ...tokenizer__tests__numeric_non_decimal.snap | 20 +++++++++++++ ...nizer__tests__numeric_with_seperators.snap | 18 +++++++++++ .../pgls_tokenizer__tests__params.snap | 27 +++++++++++++++++ .../pgls_tokenizer__tests__quoted_ident.snap | 12 ++++++++ ...tests__quoted_ident_with_escape_quote.snap | 10 +++++++ ..._tokenizer__tests__select_with_period.snap | 15 ++++++++++ .../pgls_tokenizer__tests__string.snap | 26 ++++++++++++++++ ...kenizer__tests__string_unicode_escape.snap | 20 +++++++++++++ ...tokenizer__tests__string_with_escapes.snap | 20 +++++++++++++ 27 files changed, 485 insertions(+) create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__bitstring.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__block_comment.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__block_comment_unterminated.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__dollar_quote_mismatch_tags_complex.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__dollar_quote_mismatch_tags_simple.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__dollar_quoting.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__dollar_strings_part2.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__graphile_named_param.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__lex_statement.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__line_comment.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__line_comment_whitespace.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_at.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_colon_identifier.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_colon_raw.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_colon_raw_vs_cast.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_colon_string.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_dollar_raw.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__numeric.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__numeric_non_decimal.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__numeric_with_seperators.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__params.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__quoted_ident.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__quoted_ident_with_escape_quote.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__select_with_period.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__string.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__string_unicode_escape.snap create mode 100644 crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__string_with_escapes.snap diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__bitstring.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__bitstring.snap new file mode 100644 index 000000000..22ca160d9 --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__bitstring.snap @@ -0,0 +1,16 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: "lex(r#\"\nB'1001'\nb'1001'\nX'1FF'\nx'1FF'\n\"#)" +snapshot_kind: text +--- +[ + "\n" @ LineEnding { count: 1 }, + "B'1001'" @ Literal { kind: BitStr { terminated: true } }, + "\n" @ LineEnding { count: 1 }, + "b'1001'" @ Literal { kind: BitStr { terminated: true } }, + "\n" @ LineEnding { count: 1 }, + "X'1FF'" @ Literal { kind: ByteStr { terminated: true } }, + "\n" @ LineEnding { count: 1 }, + "x'1FF'" @ Literal { kind: ByteStr { terminated: true } }, + "\n" @ LineEnding { count: 1 }, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__block_comment.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__block_comment.snap new file mode 100644 index 000000000..0fc5b7950 --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__block_comment.snap @@ -0,0 +1,9 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: result +snapshot_kind: text +--- +[ + "\n" @ LineEnding { count: 1 }, + "/*\n * foo\n * bar\n*/" @ BlockComment { terminated: true }, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__block_comment_unterminated.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__block_comment_unterminated.snap new file mode 100644 index 000000000..9b1a75bb6 --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__block_comment_unterminated.snap @@ -0,0 +1,9 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: result +snapshot_kind: text +--- +[ + "\n" @ LineEnding { count: 1 }, + "/*\n * foo\n * bar\n /*\n*/" @ BlockComment { terminated: false }, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__dollar_quote_mismatch_tags_complex.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__dollar_quote_mismatch_tags_complex.snap new file mode 100644 index 000000000..aa12a0606 --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__dollar_quote_mismatch_tags_complex.snap @@ -0,0 +1,11 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: "lex(r#\"\n-- with dollar inside but mismatched tags\n$foo$hello$world$bar$\n\"#)" +snapshot_kind: text +--- +[ + "\n" @ LineEnding { count: 1 }, + "-- with dollar inside but mismatched tags" @ LineComment, + "\n" @ LineEnding { count: 1 }, + "$foo$hello$world$bar$\n" @ Literal { kind: DollarQuotedString { terminated: false } }, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__dollar_quote_mismatch_tags_simple.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__dollar_quote_mismatch_tags_simple.snap new file mode 100644 index 000000000..34deb223e --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__dollar_quote_mismatch_tags_simple.snap @@ -0,0 +1,11 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: "lex(r#\"\n-- dollar quoting with mismatched tags\n$foo$hello world$bar$\n\"#)" +snapshot_kind: text +--- +[ + "\n" @ LineEnding { count: 1 }, + "-- dollar quoting with mismatched tags" @ LineComment, + "\n" @ LineEnding { count: 1 }, + "$foo$hello world$bar$\n" @ Literal { kind: DollarQuotedString { terminated: false } }, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__dollar_quoting.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__dollar_quoting.snap new file mode 100644 index 000000000..a7ecdc1bd --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__dollar_quoting.snap @@ -0,0 +1,15 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: "lex(r#\"\n$$Dianne's horse$$\n$SomeTag$Dianne's horse$SomeTag$\n\n-- with dollar inside and matching tags\n$foo$hello$world$bar$\n\"#)" +snapshot_kind: text +--- +[ + "\n" @ LineEnding { count: 1 }, + "$$Dianne's horse$$" @ Literal { kind: DollarQuotedString { terminated: true } }, + "\n" @ LineEnding { count: 1 }, + "$SomeTag$Dianne's horse$SomeTag$" @ Literal { kind: DollarQuotedString { terminated: true } }, + "\n\n" @ LineEnding { count: 2 }, + "-- with dollar inside and matching tags" @ LineComment, + "\n" @ LineEnding { count: 1 }, + "$foo$hello$world$bar$\n" @ Literal { kind: DollarQuotedString { terminated: false } }, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__dollar_strings_part2.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__dollar_strings_part2.snap new file mode 100644 index 000000000..cd9739c83 --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__dollar_strings_part2.snap @@ -0,0 +1,12 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: "lex(r#\"\nDO $doblock$\nend\n$doblock$;\"#)" +snapshot_kind: text +--- +[ + "\n" @ LineEnding { count: 1 }, + "DO" @ Ident, + " " @ Space, + "$doblock$\nend\n$doblock$" @ Literal { kind: DollarQuotedString { terminated: true } }, + ";" @ Semi, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__graphile_named_param.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__graphile_named_param.snap new file mode 100644 index 000000000..f0c477ed8 --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__graphile_named_param.snap @@ -0,0 +1,27 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: result +snapshot_kind: text +--- +[ + "grant" @ Ident, + " " @ Space, + "usage" @ Ident, + " " @ Space, + "on" @ Ident, + " " @ Space, + "schema" @ Ident, + " " @ Space, + "public" @ Ident, + "," @ Comma, + " " @ Space, + "app_public" @ Ident, + "," @ Comma, + " " @ Space, + "app_hidden" @ Ident, + " " @ Space, + "to" @ Ident, + " " @ Space, + ":DATABASE_VISITOR" @ NamedParam { kind: ColonRaw }, + ";" @ Semi, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__lex_statement.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__lex_statement.snap new file mode 100644 index 000000000..bff78a56b --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__lex_statement.snap @@ -0,0 +1,11 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: result +snapshot_kind: text +--- +[ + "select" @ Ident, + " " @ Space, + "1" @ Literal { kind: Int { base: Decimal, empty_int: false } }, + ";" @ Semi, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__line_comment.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__line_comment.snap new file mode 100644 index 000000000..8b0db6276 --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__line_comment.snap @@ -0,0 +1,10 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: result +snapshot_kind: text +--- +[ + "\n" @ LineEnding { count: 1 }, + "-- foooooooooooo bar buzz" @ LineComment, + "\n" @ LineEnding { count: 1 }, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__line_comment_whitespace.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__line_comment_whitespace.snap new file mode 100644 index 000000000..ae812fdf4 --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__line_comment_whitespace.snap @@ -0,0 +1,16 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: "lex(r#\"\nselect 'Hello' -- This is a comment\n' World';\"#)" +snapshot_kind: text +--- +[ + "\n" @ LineEnding { count: 1 }, + "select" @ Ident, + " " @ Space, + "'Hello'" @ Literal { kind: Str { terminated: true } }, + " " @ Space, + "-- This is a comment" @ LineComment, + "\n" @ LineEnding { count: 1 }, + "' World'" @ Literal { kind: Str { terminated: true } }, + ";" @ Semi, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_at.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_at.snap new file mode 100644 index 000000000..10f3193eb --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_at.snap @@ -0,0 +1,23 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: result +snapshot_kind: text +--- +[ + "select" @ Ident, + " " @ Space, + "1" @ Literal { kind: Int { base: Decimal, empty_int: false } }, + " " @ Space, + "from" @ Ident, + " " @ Space, + "c" @ Ident, + " " @ Space, + "where" @ Ident, + " " @ Space, + "id" @ Ident, + " " @ Space, + "=" @ Eq, + " " @ Space, + "@id" @ NamedParam { kind: AtPrefix }, + ";" @ Semi, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_colon_identifier.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_colon_identifier.snap new file mode 100644 index 000000000..293dd9cda --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_colon_identifier.snap @@ -0,0 +1,23 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: result +snapshot_kind: text +--- +[ + "select" @ Ident, + " " @ Space, + "1" @ Literal { kind: Int { base: Decimal, empty_int: false } }, + " " @ Space, + "from" @ Ident, + " " @ Space, + "c" @ Ident, + " " @ Space, + "where" @ Ident, + " " @ Space, + "id" @ Ident, + " " @ Space, + "=" @ Eq, + " " @ Space, + ":\"id\"" @ NamedParam { kind: ColonIdentifier { terminated: true } }, + ";" @ Semi, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_colon_raw.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_colon_raw.snap new file mode 100644 index 000000000..ba5c9a844 --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_colon_raw.snap @@ -0,0 +1,23 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: result +snapshot_kind: text +--- +[ + "select" @ Ident, + " " @ Space, + "1" @ Literal { kind: Int { base: Decimal, empty_int: false } }, + " " @ Space, + "from" @ Ident, + " " @ Space, + "c" @ Ident, + " " @ Space, + "where" @ Ident, + " " @ Space, + "id" @ Ident, + " " @ Space, + "=" @ Eq, + " " @ Space, + ":id" @ NamedParam { kind: ColonRaw }, + ";" @ Semi, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_colon_raw_vs_cast.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_colon_raw_vs_cast.snap new file mode 100644 index 000000000..9be148b63 --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_colon_raw_vs_cast.snap @@ -0,0 +1,25 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: result +snapshot_kind: text +--- +[ + "select" @ Ident, + " " @ Space, + "1" @ Literal { kind: Int { base: Decimal, empty_int: false } }, + " " @ Space, + "from" @ Ident, + " " @ Space, + "c" @ Ident, + " " @ Space, + "where" @ Ident, + " " @ Space, + "id" @ Ident, + "::" @ DoubleColon, + "test" @ Ident, + " " @ Space, + "=" @ Eq, + " " @ Space, + ":id" @ NamedParam { kind: ColonRaw }, + ";" @ Semi, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_colon_string.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_colon_string.snap new file mode 100644 index 000000000..b38b6dbcb --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_colon_string.snap @@ -0,0 +1,23 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: result +snapshot_kind: text +--- +[ + "select" @ Ident, + " " @ Space, + "1" @ Literal { kind: Int { base: Decimal, empty_int: false } }, + " " @ Space, + "from" @ Ident, + " " @ Space, + "c" @ Ident, + " " @ Space, + "where" @ Ident, + " " @ Space, + "id" @ Ident, + " " @ Space, + "=" @ Eq, + " " @ Space, + ":'id'" @ NamedParam { kind: ColonString { terminated: true } }, + ";" @ Semi, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_dollar_raw.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_dollar_raw.snap new file mode 100644 index 000000000..cf479ab5c --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__named_param_dollar_raw.snap @@ -0,0 +1,23 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: result +snapshot_kind: text +--- +[ + "select" @ Ident, + " " @ Space, + "1" @ Literal { kind: Int { base: Decimal, empty_int: false } }, + " " @ Space, + "from" @ Ident, + " " @ Space, + "c" @ Ident, + " " @ Space, + "where" @ Ident, + " " @ Space, + "id" @ Ident, + " " @ Space, + "=" @ Eq, + " " @ Space, + "$id" @ NamedParam { kind: DollarRaw }, + ";" @ Semi, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__numeric.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__numeric.snap new file mode 100644 index 000000000..4231febd5 --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__numeric.snap @@ -0,0 +1,30 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: "lex(r#\"\n42\n3.5\n4.\n.001\n.123e10\n5e2\n1.925e-3\n1e-10\n1e+10\n1e10\n4664.E+5\n\"#)" +snapshot_kind: text +--- +[ + "\n" @ LineEnding { count: 1 }, + "42" @ Literal { kind: Int { base: Decimal, empty_int: false } }, + "\n" @ LineEnding { count: 1 }, + "3.5" @ Literal { kind: Float { base: Decimal, empty_exponent: false } }, + "\n" @ LineEnding { count: 1 }, + "4." @ Literal { kind: Float { base: Decimal, empty_exponent: false } }, + "\n" @ LineEnding { count: 1 }, + ".001" @ Literal { kind: Int { base: Decimal, empty_int: false } }, + "\n" @ LineEnding { count: 1 }, + ".123e10" @ Literal { kind: Float { base: Decimal, empty_exponent: false } }, + "\n" @ LineEnding { count: 1 }, + "5e2" @ Literal { kind: Float { base: Decimal, empty_exponent: false } }, + "\n" @ LineEnding { count: 1 }, + "1.925e-3" @ Literal { kind: Float { base: Decimal, empty_exponent: false } }, + "\n" @ LineEnding { count: 1 }, + "1e-10" @ Literal { kind: Float { base: Decimal, empty_exponent: false } }, + "\n" @ LineEnding { count: 1 }, + "1e+10" @ Literal { kind: Float { base: Decimal, empty_exponent: false } }, + "\n" @ LineEnding { count: 1 }, + "1e10" @ Literal { kind: Float { base: Decimal, empty_exponent: false } }, + "\n" @ LineEnding { count: 1 }, + "4664.E+5" @ Literal { kind: Float { base: Decimal, empty_exponent: false } }, + "\n" @ LineEnding { count: 1 }, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__numeric_non_decimal.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__numeric_non_decimal.snap new file mode 100644 index 000000000..5e026370a --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__numeric_non_decimal.snap @@ -0,0 +1,20 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: "lex(r#\"\n0b100101\n0B10011001\n0o273\n0O755\n0x42f\n0XFFFF\n\"#)" +snapshot_kind: text +--- +[ + "\n" @ LineEnding { count: 1 }, + "0b100101" @ Literal { kind: Int { base: Binary, empty_int: false } }, + "\n" @ LineEnding { count: 1 }, + "0B10011001" @ Literal { kind: Int { base: Binary, empty_int: false } }, + "\n" @ LineEnding { count: 1 }, + "0o273" @ Literal { kind: Int { base: Octal, empty_int: false } }, + "\n" @ LineEnding { count: 1 }, + "0O755" @ Literal { kind: Int { base: Octal, empty_int: false } }, + "\n" @ LineEnding { count: 1 }, + "0x42f" @ Literal { kind: Int { base: Hexadecimal, empty_int: false } }, + "\n" @ LineEnding { count: 1 }, + "0XFFFF" @ Literal { kind: Int { base: Hexadecimal, empty_int: false } }, + "\n" @ LineEnding { count: 1 }, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__numeric_with_seperators.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__numeric_with_seperators.snap new file mode 100644 index 000000000..482158f01 --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__numeric_with_seperators.snap @@ -0,0 +1,18 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: "lex(r#\"\n1_500_000_000\n0b10001000_00000000\n0o_1_755\n0xFFFF_FFFF\n1.618_034\n\"#)" +snapshot_kind: text +--- +[ + "\n" @ LineEnding { count: 1 }, + "1_500_000_000" @ Literal { kind: Int { base: Decimal, empty_int: false } }, + "\n" @ LineEnding { count: 1 }, + "0b10001000_00000000" @ Literal { kind: Int { base: Binary, empty_int: false } }, + "\n" @ LineEnding { count: 1 }, + "0o_1_755" @ Literal { kind: Int { base: Octal, empty_int: false } }, + "\n" @ LineEnding { count: 1 }, + "0xFFFF_FFFF" @ Literal { kind: Int { base: Hexadecimal, empty_int: false } }, + "\n" @ LineEnding { count: 1 }, + "1.618_034" @ Literal { kind: Float { base: Decimal, empty_exponent: false } }, + "\n" @ LineEnding { count: 1 }, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__params.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__params.snap new file mode 100644 index 000000000..d82687662 --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__params.snap @@ -0,0 +1,27 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: "lex(r#\"\nselect $1 + $2;\n\nselect $1123123123123;\n\nselect $;\n\"#)" +snapshot_kind: text +--- +[ + "\n" @ LineEnding { count: 1 }, + "select" @ Ident, + " " @ Space, + "$1" @ PositionalParam, + " " @ Space, + "+" @ Plus, + " " @ Space, + "$2" @ PositionalParam, + ";" @ Semi, + "\n\n" @ LineEnding { count: 2 }, + "select" @ Ident, + " " @ Space, + "$1123123123123" @ PositionalParam, + ";" @ Semi, + "\n\n" @ LineEnding { count: 2 }, + "select" @ Ident, + " " @ Space, + "$" @ PositionalParam, + ";" @ Semi, + "\n" @ LineEnding { count: 1 }, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__quoted_ident.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__quoted_ident.snap new file mode 100644 index 000000000..8afe6e99c --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__quoted_ident.snap @@ -0,0 +1,12 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: "lex(r#\"\n\"hello &1 -world\";\n\n\n\"hello-world\n\"#)" +snapshot_kind: text +--- +[ + "\n" @ LineEnding { count: 1 }, + "\"hello &1 -world\"" @ QuotedIdent { terminated: true }, + ";" @ Semi, + "\n\n\n" @ LineEnding { count: 3 }, + "\"hello-world\n" @ QuotedIdent { terminated: false }, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__quoted_ident_with_escape_quote.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__quoted_ident_with_escape_quote.snap new file mode 100644 index 000000000..36302719d --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__quoted_ident_with_escape_quote.snap @@ -0,0 +1,10 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: "lex(r#\"\n\"foo \"\" bar\"\n\"#)" +snapshot_kind: text +--- +[ + "\n" @ LineEnding { count: 1 }, + "\"foo \"\" bar\"" @ QuotedIdent { terminated: true }, + "\n" @ LineEnding { count: 1 }, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__select_with_period.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__select_with_period.snap new file mode 100644 index 000000000..467863e35 --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__select_with_period.snap @@ -0,0 +1,15 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: "lex(r#\"\nselect public.users;\n\"#)" +snapshot_kind: text +--- +[ + "\n" @ LineEnding { count: 1 }, + "select" @ Ident, + " " @ Space, + "public" @ Ident, + "." @ Dot, + "users" @ Ident, + ";" @ Semi, + "\n" @ LineEnding { count: 1 }, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__string.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__string.snap new file mode 100644 index 000000000..925652851 --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__string.snap @@ -0,0 +1,26 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: "lex(r#\"\n'Dianne''s horse'\n\nselect 'foo ''\nbar';\n\nselect 'foooo'\n 'bar';\n\n\n'foo \\\\ \\n \\tbar'\n\n'forgot to close the string\n\"#)" +snapshot_kind: text +--- +[ + "\n" @ LineEnding { count: 1 }, + "'Dianne''s horse'" @ Literal { kind: Str { terminated: true } }, + "\n\n" @ LineEnding { count: 2 }, + "select" @ Ident, + " " @ Space, + "'foo ''\nbar'" @ Literal { kind: Str { terminated: true } }, + ";" @ Semi, + "\n\n" @ LineEnding { count: 2 }, + "select" @ Ident, + " " @ Space, + "'foooo'" @ Literal { kind: Str { terminated: true } }, + "\n" @ LineEnding { count: 1 }, + " " @ Space, + "'bar'" @ Literal { kind: Str { terminated: true } }, + ";" @ Semi, + "\n\n\n" @ LineEnding { count: 3 }, + "'foo \\\\ \\n \\tbar'" @ Literal { kind: Str { terminated: true } }, + "\n\n" @ LineEnding { count: 2 }, + "'forgot to close the string\n" @ Literal { kind: Str { terminated: false } }, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__string_unicode_escape.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__string_unicode_escape.snap new file mode 100644 index 000000000..e17c62511 --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__string_unicode_escape.snap @@ -0,0 +1,20 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: "lex(r#\"\nU&\"d\\0061t\\+000061\"\n\nU&\"\\0441\\043B\\043E\\043D\"\n\nu&'\\0441\\043B'\n\nU&\"d!0061t!+000061\" UESCAPE '!'\n\"#)" +snapshot_kind: text +--- +[ + "\n" @ LineEnding { count: 1 }, + "U&\"d\\0061t\\+000061\"" @ QuotedIdent { terminated: true }, + "\n\n" @ LineEnding { count: 2 }, + "U&\"\\0441\\043B\\043E\\043D\"" @ QuotedIdent { terminated: true }, + "\n\n" @ LineEnding { count: 2 }, + "u&'\\0441\\043B'" @ Literal { kind: UnicodeEscStr { terminated: true } }, + "\n\n" @ LineEnding { count: 2 }, + "U&\"d!0061t!+000061\"" @ QuotedIdent { terminated: true }, + " " @ Space, + "UESCAPE" @ Ident, + " " @ Space, + "'!'" @ Literal { kind: Str { terminated: true } }, + "\n" @ LineEnding { count: 1 }, +] diff --git a/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__string_with_escapes.snap b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__string_with_escapes.snap new file mode 100644 index 000000000..d2cb5b3d2 --- /dev/null +++ b/crates/pgls_tokenizer/src/snapshots/pgls_tokenizer__tests__string_with_escapes.snap @@ -0,0 +1,20 @@ +--- +source: crates/pgls_tokenizer/src/lib.rs +expression: "lex(r#\"\nE'foo'\n\ne'bar'\n\ne'\\b\\f\\n\\r\\t'\n\ne'\\0\\11\\777'\n\ne'\\x0\\x11\\xFF'\n\ne'\\uAAAA \\UFFFFFFFF'\n\n\"#)" +snapshot_kind: text +--- +[ + "\n" @ LineEnding { count: 1 }, + "E'foo'" @ Literal { kind: EscStr { terminated: true } }, + "\n\n" @ LineEnding { count: 2 }, + "e'bar'" @ Literal { kind: EscStr { terminated: true } }, + "\n\n" @ LineEnding { count: 2 }, + "e'\\b\\f\\n\\r\\t'" @ Literal { kind: EscStr { terminated: true } }, + "\n\n" @ LineEnding { count: 2 }, + "e'\\0\\11\\777'" @ Literal { kind: EscStr { terminated: true } }, + "\n\n" @ LineEnding { count: 2 }, + "e'\\x0\\x11\\xFF'" @ Literal { kind: EscStr { terminated: true } }, + "\n\n" @ LineEnding { count: 2 }, + "e'\\uAAAA \\UFFFFFFFF'" @ Literal { kind: EscStr { terminated: true } }, + "\n\n" @ LineEnding { count: 2 }, +]