MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / csharpParameterType

Function csharpParameterType

src/resolution/override-parameters.ts:283–301  ·  view source on GitHub ↗

* A C# parameter's type: past its attributes and the modifiers that are no * part of it (`this`, `params`, `scoped`), keeping `ref`, `out` and `in`, * which are, and before its name and default value.

(param: string)

Source from the content-addressed store, hash-verified

281 * which are, and before its name and default value.
282 */
283function csharpParameterType(param: string): string | null {
284 let p = param.trim();
285 while (p.startsWith('[')) {
286 const close = closingBracket(p, 0);
287 if (close < 0) return null;
288 p = p.slice(close + 1).trim();
289 }
290 const assign = topLevelIndex(p, (i) => p[i] === '=' && !/[=!<>]/.test(p[i - 1] ?? '') && !/[=>]/.test(p[i + 1] ?? ''));
291 if (assign >= 0) p = p.slice(0, assign).trim();
292 const m = /^([\s\S]*?\S)\s+@?[A-Za-z_]\w*$/.exec(p);
293 if (!m) return null;
294 let type = m[1]!.trim();
295 const kept: string[] = [];
296 for (let mod = /^(this|params|scoped|ref|out|in|readonly)\s+/.exec(type); mod; mod = /^(this|params|scoped|ref|out|in|readonly)\s+/.exec(type)) {
297 if (mod[1] !== 'this' && mod[1] !== 'params' && mod[1] !== 'scoped') kept.push(mod[1]!);
298 type = type.slice(mod[0].length);
299 }
300 return type ? [...kept, type].join(' ') : null;
301}
302
303/**
304 * A parameter type as the languages compare it: qualifiers dropped

Callers 1

parameterTypeFunction · 0.85

Calls 5

closingBracketFunction · 0.85
topLevelIndexFunction · 0.85
pushMethod · 0.80
execMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected