MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / resolve_remove_throws

Method resolve_remove_throws

src/code_actions/phpstan/remove_throws.rs:121–156  ·  view source on GitHub ↗

Resolve a "Remove @throws" code action by recomputing the workspace edit from the stored data.

(
        &self,
        data: &CodeActionData,
        content: &str,
    )

Source from the content-addressed store, hash-verified

119 /// Resolve a "Remove @throws" code action by recomputing the
120 /// workspace edit from the stored data.
121 pub(crate) fn resolve_remove_throws(
122 &self,
123 data: &CodeActionData,
124 content: &str,
125 ) -> Option<WorkspaceEdit> {
126 let uri = &data.uri;
127 let extra = &data.extra;
128 let message = extra.get("diagnostic_message")?.as_str()?;
129 let line = extra.get("diagnostic_line")?.as_u64()? as usize;
130 let code = extra.get("diagnostic_code")?.as_str()?;
131
132 let type_name = extract_throws_type(message, code)?;
133 let type_name_str = type_name.to_string();
134
135 let file_use_map: HashMap<String, String> = self.file_use_map(uri);
136 let file_namespace: Option<String> = self.first_file_namespace(uri);
137
138 let docblock = find_docblock_above_line(content, line)?;
139 let throws_edit = build_remove_throws_edit(
140 content,
141 &docblock,
142 &type_name_str,
143 &file_use_map,
144 &file_namespace,
145 )?;
146
147 let doc_uri: Url = data.uri.parse().ok()?;
148 let mut changes = HashMap::new();
149 changes.insert(doc_uri, vec![throws_edit]);
150
151 Some(WorkspaceEdit {
152 changes: Some(changes),
153 document_changes: None,
154 change_annotations: None,
155 })
156 }
157}
158
159// ── Helpers ─────────────────────────────────────────────────────────────────

Callers 1

resolve_code_actionMethod · 0.80

Calls 9

extract_throws_typeFunction · 0.85
build_remove_throws_editFunction · 0.85
as_strMethod · 0.80
file_use_mapMethod · 0.80
first_file_namespaceMethod · 0.80
find_docblock_above_lineFunction · 0.70
getMethod · 0.45
parseMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected