Skip to content

Commit

Permalink
feat: deprecated schema sematic settings attr
Browse files Browse the repository at this point in the history
  • Loading branch information
Peefy committed Nov 7, 2023
1 parent b24a298 commit 3111382
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 38 deletions.
17 changes: 0 additions & 17 deletions kclvm/sema/src/resolver/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,23 +568,6 @@ impl<'ctx> Resolver<'ctx> {
};
// Schema attributes
let mut attr_obj_map: IndexMap<String, SchemaAttr> = IndexMap::default();
let settings_dummy_pos = Position {
filename: self.ctx.filename.clone(),
line: pos.line,
column: pos.column,
};
attr_obj_map.insert(
kclvm_runtime::SCHEMA_SETTINGS_ATTR_NAME.to_string(),
SchemaAttr {
is_optional: true,
has_default: false,
default: None,
ty: Type::dict_ref(self.str_ty(), self.any_ty()),
range: (settings_dummy_pos.clone(), settings_dummy_pos),
doc: None,
decorators: vec![],
},
);
let parsed_doc = parse_doc_string(
&schema_stmt
.doc
Expand Down
30 changes: 14 additions & 16 deletions kclvm/tools/src/LSP/src/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,18 +533,16 @@ pub(crate) fn get_dot_completion(
// ```
kclvm_sema::ty::TypeKind::Schema(schema) => {
for (name, attr) in &schema.attrs {
if name != "__settings__" {
items.insert(KCLCompletionItem {
label: name.clone(),
detail: Some(format!(
"{}: {}",
name,
attr.ty.ty_str()
)),
documentation: attr.doc.clone(),
kind: Some(KCLCompletionItemKind::SchemaAttr),
});
}
items.insert(KCLCompletionItem {
label: name.clone(),
detail: Some(format!(
"{}: {}",
name,
attr.ty.ty_str()
)),
documentation: attr.doc.clone(),
kind: Some(KCLCompletionItemKind::SchemaAttr),
});
}
}

Expand Down Expand Up @@ -748,7 +746,7 @@ mod tests {
CompletionResponse::List(_) => panic!("test failed"),
};

expected_labels.extend(["__settings__", "name", "age"]);
expected_labels.extend(["name", "age"]);
assert_eq!(got_labels, expected_labels);
}

Expand Down Expand Up @@ -871,7 +869,7 @@ mod tests {
CompletionResponse::List(_) => panic!("test failed"),
};

let expected_labels: Vec<&str> = vec!["__settings__", "a"];
let expected_labels: Vec<&str> = vec!["a"];
assert_eq!(got_labels, expected_labels);
}

Expand Down Expand Up @@ -995,7 +993,7 @@ mod tests {
CompletionResponse::List(_) => panic!("test failed"),
};

let expected_labels: Vec<&str> = vec!["__settings__", "a"];
let expected_labels: Vec<&str> = vec!["a"];
assert_eq!(got_labels, expected_labels);
}

Expand Down Expand Up @@ -1163,7 +1161,7 @@ mod tests {
CompletionItem {
label: "Person(b){}".to_string(),
kind: Some(CompletionItemKind:: CLASS),
detail: Some("__main__\n\nschema Person[b: int](Base)\nAttributes:\n__settings__?: {str:any}\nc: int".to_string()),
detail: Some("__main__\n\nschema Person[b: int](Base)\nAttributes:\nc: int".to_string()),
documentation: Some(lsp_types::Documentation::String("".to_string())),
..Default::default()
}
Expand Down
4 changes: 2 additions & 2 deletions kclvm/tools/src/LSP/src/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ mod tests {
if let MarkedString::String(s) = vec[2].clone() {
assert_eq!(
s,
"Attributes:\n\n__settings__?: {str:any}\n\nname: str\n\nage: int"
"Attributes:\n\nname: str\n\nage: int"
);
}
}
Expand Down Expand Up @@ -227,7 +227,7 @@ mod tests {
if let MarkedString::String(s) = vec[2].clone() {
assert_eq!(
s,
"Attributes:\n\n__settings__?: {str:any}\n\nname: str\n\nage?: int"
"Attributes:\n\nname: str\n\nage?: int"
);
}
}
Expand Down
5 changes: 2 additions & 3 deletions kclvm/tools/src/LSP/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ fn hover_test() {
MarkedString::String("__main__\n\nschema Person".to_string()),
MarkedString::String("hover doc test".to_string()),
MarkedString::String(
"Attributes:\n\n__settings__?: {str:any}\n\nname: str\n\nage?: int".to_string()
"Attributes:\n\nname: str\n\nage?: int".to_string()
),
]),
range: None
Expand Down Expand Up @@ -1225,7 +1225,6 @@ fn konfig_completion_test_main() {
"kubevela_output",
"server_output",
"schedulingStrategy",
"__settings__",
"name",
"workloadType",
"renderType",
Expand Down Expand Up @@ -1310,7 +1309,7 @@ fn konfig_hover_test_main() {
let expect: Vec<MarkedString> = vec![
"base.pkg.kusion_models.kube.frontend\n\nschema Server",
"Server is abstaction of Deployment and StatefulSet.",
"Attributes:\n\n__settings__?: {str:any}\n\nname?: str\n\nworkloadType: str(Deployment) | str(StatefulSet)\n\nrenderType?: str(Server) | str(KubeVelaApplication)\n\nreplicas: int\n\nimage: str\n\nschedulingStrategy: SchedulingStrategy\n\nmainContainer: Main\n\nsidecarContainers?: [Sidecar]\n\ninitContainers?: [Sidecar]\n\nuseBuiltInLabels?: bool\n\nlabels?: {str:str}\n\nannotations?: {str:str}\n\nuseBuiltInSelector?: bool\n\nselector?: {str:str}\n\npodMetadata?: ObjectMeta\n\nvolumes?: [Volume]\n\nneedNamespace?: bool\n\nenableMonitoring?: bool\n\nconfigMaps?: [ConfigMap]\n\nsecrets?: [Secret]\n\nservices?: [Service]\n\ningresses?: [Ingress]\n\nserviceAccount?: ServiceAccount\n\nstorage?: ObjectStorage\n\ndatabase?: DataBase"
"Attributes:\n\nname?: str\n\nworkloadType: str(Deployment) | str(StatefulSet)\n\nrenderType?: str(Server) | str(KubeVelaApplication)\n\nreplicas: int\n\nimage: str\n\nschedulingStrategy: SchedulingStrategy\n\nmainContainer: Main\n\nsidecarContainers?: [Sidecar]\n\ninitContainers?: [Sidecar]\n\nuseBuiltInLabels?: bool\n\nlabels?: {str:str}\n\nannotations?: {str:str}\n\nuseBuiltInSelector?: bool\n\nselector?: {str:str}\n\npodMetadata?: ObjectMeta\n\nvolumes?: [Volume]\n\nneedNamespace?: bool\n\nenableMonitoring?: bool\n\nconfigMaps?: [ConfigMap]\n\nsecrets?: [Secret]\n\nservices?: [Service]\n\ningresses?: [Ingress]\n\nserviceAccount?: ServiceAccount\n\nstorage?: ObjectStorage\n\ndatabase?: DataBase"
]
.iter()
.map(|s| MarkedString::String(s.to_string()))
Expand Down

0 comments on commit 3111382

Please sign in to comment.