From b8d68809e15aa54d25791918f8ef5f1e16ca836b Mon Sep 17 00:00:00 2001 From: Sophie Atkins Date: Wed, 15 Mar 2023 18:47:02 +0100 Subject: [PATCH] rename push_completions -> datamodel_completions formatting --- prisma-fmt/src/text_document_completion.rs | 2 +- .../src/cockroach_datamodel_connector.rs | 2 +- psl/builtin-connectors/src/mssql_datamodel_connector.rs | 2 +- psl/builtin-connectors/src/postgres_datamodel_connector.rs | 3 ++- psl/psl-core/src/configuration/datasource.rs | 5 +++++ psl/psl-core/src/datamodel_connector.rs | 7 ++++++- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/prisma-fmt/src/text_document_completion.rs b/prisma-fmt/src/text_document_completion.rs index e403e78be7fa..4df8f3e91471 100644 --- a/prisma-fmt/src/text_document_completion.rs +++ b/prisma-fmt/src/text_document_completion.rs @@ -169,7 +169,7 @@ fn push_ast_completions(ctx: CompletionContext<'_>, completion_list: &mut Comple datasource::url_quotes_completion(completion_list); } - position => ctx.connector().push_completions(ctx.db, position, completion_list), + position => ctx.connector().datamodel_completions(ctx.db, position, completion_list), } } diff --git a/psl/builtin-connectors/src/cockroach_datamodel_connector.rs b/psl/builtin-connectors/src/cockroach_datamodel_connector.rs index 9ab8c4225a9c..c477a8574d01 100644 --- a/psl/builtin-connectors/src/cockroach_datamodel_connector.rs +++ b/psl/builtin-connectors/src/cockroach_datamodel_connector.rs @@ -266,7 +266,7 @@ impl Connector for CockroachDatamodelConnector { Ok(()) } - fn push_completions( + fn datamodel_completions( &self, _db: &ParserDatabase, position: SchemaPosition<'_>, diff --git a/psl/builtin-connectors/src/mssql_datamodel_connector.rs b/psl/builtin-connectors/src/mssql_datamodel_connector.rs index f9a01205c292..7c5042599821 100644 --- a/psl/builtin-connectors/src/mssql_datamodel_connector.rs +++ b/psl/builtin-connectors/src/mssql_datamodel_connector.rs @@ -279,7 +279,7 @@ impl Connector for MsSqlDatamodelConnector { Ok(()) } - fn push_completions( + fn datamodel_completions( &self, _db: &ParserDatabase, position: ast::SchemaPosition<'_>, diff --git a/psl/builtin-connectors/src/postgres_datamodel_connector.rs b/psl/builtin-connectors/src/postgres_datamodel_connector.rs index 631c54b919b8..07846d2bb30d 100644 --- a/psl/builtin-connectors/src/postgres_datamodel_connector.rs +++ b/psl/builtin-connectors/src/postgres_datamodel_connector.rs @@ -96,6 +96,7 @@ impl PostgresDatasourceProperties { span: ast::Span::empty(), }); } + // Validation for property existence pub fn extensions_defined(&self) -> bool { self.extensions.is_some() @@ -449,7 +450,7 @@ impl Connector for PostgresDatamodelConnector { Ok(()) } - fn push_completions( + fn datamodel_completions( &self, db: &ParserDatabase, position: ast::SchemaPosition<'_>, diff --git a/psl/psl-core/src/configuration/datasource.rs b/psl/psl-core/src/configuration/datasource.rs index 6198b3b48976..8bb97eae06c1 100644 --- a/psl/psl-core/src/configuration/datasource.rs +++ b/psl/psl-core/src/configuration/datasource.rs @@ -250,18 +250,23 @@ impl Datasource { pub fn provider_defined(&self) -> bool { !self.provider.is_empty() } + pub fn url_defined(&self) -> bool { self.url_span.end > self.url_span.start } + pub fn direct_url_defined(&self) -> bool { self.direct_url.is_some() } + pub fn shadow_url_defined(&self) -> bool { self.shadow_database_url.is_some() } + pub fn relation_mode_defined(&self) -> bool { self.relation_mode.is_some() } + pub fn schemas_defined(&self) -> bool { self.schemas_span.is_some() } diff --git a/psl/psl-core/src/datamodel_connector.rs b/psl/psl-core/src/datamodel_connector.rs index e7a66c7e6f4b..94888f143139 100644 --- a/psl/psl-core/src/datamodel_connector.rs +++ b/psl/psl-core/src/datamodel_connector.rs @@ -335,7 +335,12 @@ pub trait Connector: Send + Sync { fn validate_url(&self, url: &str) -> Result<(), String>; - fn push_completions(&self, _db: &ParserDatabase, _position: SchemaPosition<'_>, _completions: &mut CompletionList) { + fn datamodel_completions( + &self, + _db: &ParserDatabase, + _position: SchemaPosition<'_>, + _completions: &mut CompletionList, + ) { } fn datasource_completions(&self, _config: &Configuration, _completion_list: &mut CompletionList) {}