Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 118x 118x 124x 124x 53x 118x 53x 53x 53x 53x 53x 53x | /**
* ParameterExtractorUtils - Shared utilities for parameter extraction in C/C++.
*
* Contains common patterns for building parameter info from extracted values.
*/
/* eslint-disable @typescript-eslint/no-explicit-any */
import IExtractedParameter from "./IExtractedParameter";
class ParameterExtractorUtils {
/**
* Process a list of parameter declarations and collect parameter info.
*
* @param paramList The parameter list context (from either C or C++ grammar)
* @param extractInfo Function to extract parameter info from a single declaration
* @returns Array of extracted parameters
*/
static processParameterList(
paramList: any,
extractInfo: (paramDecl: any) => IExtractedParameter | null,
): IExtractedParameter[] {
const params: IExtractedParameter[] = [];
for (const paramDecl of paramList.parameterDeclaration?.() ?? []) {
const paramInfo = extractInfo(paramDecl);
if (paramInfo) {
params.push(paramInfo);
}
}
return params;
}
/**
* Build extracted parameter info from intermediate values.
*
* @param declarator The declarator context
* @param type The parameter's type, pointers included -- each grammar
* reads its own declarator for them
* @param isConst Whether the parameter is const
* @param isArray Whether the parameter is an array
* @param extractName Function to extract name from declarator
* @returns The extracted parameter info
*/
static buildParameterInfo(
declarator: any,
type: string,
isConst: boolean,
isArray: boolean,
extractName: (decl: any) => string | null,
): IExtractedParameter {
// Get parameter name (may be empty for abstract declarators)
let paramName = "";
Eif (declarator) {
const name = extractName(declarator);
Eif (name) {
paramName = name;
}
}
return {
name: paramName,
type,
isConst,
isArray,
};
}
}
export default ParameterExtractorUtils;
|