Skip to content

Commit

Permalink
Merge pull request prisma#2565 from prisma/prisma-fmt/is-incomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhoule authored Jan 7, 2022
2 parents b23e167 + 7e1768b commit ba817f5
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 39 deletions.
22 changes: 11 additions & 11 deletions prisma-fmt/src/text_document_completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ pub(crate) fn completion(schema: &str, params: CompletionParams) -> CompletionLi
)
});

let mut items = Vec::new();
let mut list = CompletionList {
is_incomplete: false,
items: Vec::new(),
};

push_ast_completions(&mut items, connector, referential_integrity, &schema_ast, position);
push_ast_completions(&mut list, connector, referential_integrity, &schema_ast, position);

CompletionList {
is_incomplete: items.is_empty(),
items,
}
list
}

/// The LSP position is expressed as a (line, col) tuple, but our pest-based parser works with byte
Expand Down Expand Up @@ -93,7 +93,7 @@ fn position_to_offset(position: &Position, document: &str) -> Option<usize> {
// - referential actions (onDelete and onUpdate arguments)
// - default arguments on scalar fields (based on connector capabilities for the `map: ...` argument).
fn push_ast_completions(
items: &mut Vec<CompletionItem>,
completion_list: &mut CompletionList,
connector: &'static dyn Connector,
referential_integrity: ReferentialIntegrity,
ast: &ast::SchemaAst,
Expand All @@ -105,7 +105,7 @@ fn push_ast_completions(
ast::ModelPosition::Field(_, ast::FieldPosition::Attribute("default", _, None)),
) => {
if connector.has_capability(datamodel::datamodel_connector::ConnectorCapability::NamedDefaultValues) {
items.push(CompletionItem {
completion_list.items.push(CompletionItem {
label: "map: ".to_owned(),
kind: Some(CompletionItemKind::PROPERTY),
..Default::default()
Expand All @@ -117,11 +117,11 @@ fn push_ast_completions(
ast::ModelPosition::Field(_, ast::FieldPosition::Attribute("relation", _, Some(attr_name))),
) if attr_name == "onDelete" || attr_name == "onUpdate" => {
for referential_action in connector.referential_actions(&referential_integrity).iter() {
items.push(CompletionItem {
completion_list.items.push(CompletionItem {
label: referential_action.as_str().to_owned(),
kind: Some(CompletionItemKind::ENUM),
detail: None, // what is the difference between detail and documentation?
documentation: Some(Documentation::String(referential_action.documentation().to_owned())),
// what is the difference between detail and documentation?
detail: Some(referential_action.documentation().to_owned()),
..Default::default()
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"isIncomplete": true,
"isIncomplete": false,
"items": []
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"isIncomplete": true,
"isIncomplete": false,
"items": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
{
"label": "Cascade",
"kind": 13,
"documentation": "Delete the child records when the parent record is deleted."
"detail": "Delete the child records when the parent record is deleted."
},
{
"label": "Restrict",
"kind": 13,
"documentation": "Prevent deleting a parent record as long as it is referenced."
"detail": "Prevent deleting a parent record as long as it is referenced."
},
{
"label": "NoAction",
"kind": 13,
"documentation": "Prevent deleting a parent record as long as it is referenced."
"detail": "Prevent deleting a parent record as long as it is referenced."
},
{
"label": "SetNull",
"kind": 13,
"documentation": "Set the referencing fields to NULL when the referenced record is deleted."
"detail": "Set the referencing fields to NULL when the referenced record is deleted."
},
{
"label": "SetDefault",
"kind": 13,
"documentation": "Set the referencing field's value to the default when the referenced record is deleted."
"detail": "Set the referencing field's value to the default when the referenced record is deleted."
}
]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"isIncomplete": true,
"isIncomplete": false,
"items": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
{
"label": "Cascade",
"kind": 13,
"documentation": "Delete the child records when the parent record is deleted."
"detail": "Delete the child records when the parent record is deleted."
},
{
"label": "NoAction",
"kind": 13,
"documentation": "Prevent deleting a parent record as long as it is referenced."
"detail": "Prevent deleting a parent record as long as it is referenced."
},
{
"label": "SetNull",
"kind": 13,
"documentation": "Set the referencing fields to NULL when the referenced record is deleted."
"detail": "Set the referencing fields to NULL when the referenced record is deleted."
},
{
"label": "SetDefault",
"kind": 13,
"documentation": "Set the referencing field's value to the default when the referenced record is deleted."
"detail": "Set the referencing field's value to the default when the referenced record is deleted."
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
{
"label": "Cascade",
"kind": 13,
"documentation": "Delete the child records when the parent record is deleted."
"detail": "Delete the child records when the parent record is deleted."
},
{
"label": "NoAction",
"kind": 13,
"documentation": "Prevent deleting a parent record as long as it is referenced."
"detail": "Prevent deleting a parent record as long as it is referenced."
},
{
"label": "SetNull",
"kind": 13,
"documentation": "Set the referencing fields to NULL when the referenced record is deleted."
"detail": "Set the referencing fields to NULL when the referenced record is deleted."
},
{
"label": "SetDefault",
"kind": 13,
"documentation": "Set the referencing field's value to the default when the referenced record is deleted."
"detail": "Set the referencing field's value to the default when the referenced record is deleted."
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
{
"label": "Cascade",
"kind": 13,
"documentation": "Delete the child records when the parent record is deleted."
"detail": "Delete the child records when the parent record is deleted."
},
{
"label": "NoAction",
"kind": 13,
"documentation": "Prevent deleting a parent record as long as it is referenced."
"detail": "Prevent deleting a parent record as long as it is referenced."
},
{
"label": "SetNull",
"kind": 13,
"documentation": "Set the referencing fields to NULL when the referenced record is deleted."
"detail": "Set the referencing fields to NULL when the referenced record is deleted."
},
{
"label": "SetDefault",
"kind": 13,
"documentation": "Set the referencing field's value to the default when the referenced record is deleted."
"detail": "Set the referencing field's value to the default when the referenced record is deleted."
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
{
"label": "Cascade",
"kind": 13,
"documentation": "Delete the child records when the parent record is deleted."
"detail": "Delete the child records when the parent record is deleted."
},
{
"label": "NoAction",
"kind": 13,
"documentation": "Prevent deleting a parent record as long as it is referenced."
"detail": "Prevent deleting a parent record as long as it is referenced."
},
{
"label": "SetNull",
"kind": 13,
"documentation": "Set the referencing fields to NULL when the referenced record is deleted."
"detail": "Set the referencing fields to NULL when the referenced record is deleted."
},
{
"label": "SetDefault",
"kind": 13,
"documentation": "Set the referencing field's value to the default when the referenced record is deleted."
"detail": "Set the referencing field's value to the default when the referenced record is deleted."
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
{
"label": "Cascade",
"kind": 13,
"documentation": "Delete the child records when the parent record is deleted."
"detail": "Delete the child records when the parent record is deleted."
},
{
"label": "NoAction",
"kind": 13,
"documentation": "Prevent deleting a parent record as long as it is referenced."
"detail": "Prevent deleting a parent record as long as it is referenced."
},
{
"label": "SetNull",
"kind": 13,
"documentation": "Set the referencing fields to NULL when the referenced record is deleted."
"detail": "Set the referencing fields to NULL when the referenced record is deleted."
},
{
"label": "SetDefault",
"kind": 13,
"documentation": "Set the referencing field's value to the default when the referenced record is deleted."
"detail": "Set the referencing field's value to the default when the referenced record is deleted."
}
]
}

0 comments on commit ba817f5

Please sign in to comment.