-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.rs
More file actions
133 lines (124 loc) · 4.51 KB
/
Copy pathfunction.rs
File metadata and controls
133 lines (124 loc) · 4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
use crate::analyser::core::{AnalysableFunction, Analyser};
use crate::diagnostics::diagnose::Diagnose;
use crate::diagnostics::kinds::DiagnosticKind;
impl Analyser {
pub fn analyse_runtime_function(&mut self, af: &AnalysableFunction) {
let name = af.function.runtime_name.clone();
let function = &af.function;
let original = af.original_definition.clone();
for linked in function.linked_data_type_identifiers.clone() {
if !self.data_type_identifier_exists(linked.as_str(), None) {
self.reporter.add(Diagnose::new(
name.clone(),
original.clone(),
DiagnosticKind::UndefinedDataTypeIdentifier {
identifier: linked.clone(),
},
));
}
}
if function.display_icon.is_empty() {
self.reporter.add(Diagnose::new(
name.clone(),
original.clone(),
DiagnosticKind::NullField {
field_name: "displayIcon".into(),
},
))
}
if function.alias.is_empty() {
self.reporter.add(Diagnose::new(
name.clone(),
original.clone(),
DiagnosticKind::MissingTranslation {
translation_field: "alias".into(),
},
));
}
if function.display_message.is_empty() {
self.reporter.add(Diagnose::new(
name.clone(),
original.clone(),
DiagnosticKind::MissingTranslation {
translation_field: "displayMessage".into(),
},
));
}
if function.name.is_empty() {
self.reporter.add(Diagnose::new(
name.clone(),
original.clone(),
DiagnosticKind::UndefinedTranslation {
translation_field: "name".into(),
},
));
}
if function.description.is_empty() {
self.reporter.add(Diagnose::new(
name.clone(),
original.clone(),
DiagnosticKind::UndefinedTranslation {
translation_field: "description".into(),
},
));
}
if function.documentation.is_empty() {
self.reporter.add(Diagnose::new(
name.clone(),
original.clone(),
DiagnosticKind::UndefinedTranslation {
translation_field: "documentation".into(),
},
));
}
if function.signature.is_empty() {
self.reporter.add(Diagnose::new(
name.clone(),
original.clone(),
DiagnosticKind::NullField {
field_name: "signature".into(),
},
));
}
let mut param_names: Vec<String> = vec![];
for parameter in &function.runtime_parameter_definitions {
if parameter.name.is_empty() {
self.reporter.add(Diagnose::new(
name.clone(),
original.clone(),
DiagnosticKind::UndefinedTranslation {
translation_field: "name".into(),
},
));
}
if parameter.description.is_empty() {
self.reporter.add(Diagnose::new(
name.clone(),
original.clone(),
DiagnosticKind::UndefinedTranslation {
translation_field: "description".into(),
},
));
}
if parameter.documentation.is_empty() {
self.reporter.add(Diagnose::new(
name.clone(),
original.clone(),
DiagnosticKind::UndefinedTranslation {
translation_field: "documentation".into(),
},
));
}
if param_names.contains(¶meter.runtime_name) {
self.reporter.add(Diagnose::new(
name.clone(),
original.clone(),
DiagnosticKind::DuplicateRuntimeParameterIdentifier {
identifier: parameter.runtime_name.clone(),
},
));
}
param_names.push(parameter.runtime_name.clone());
}
}
}