Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion schema/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sourcemod-dev/schema",
"version": "0.1.18",
"version": "0.1.19",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
Expand Down
5 changes: 3 additions & 2 deletions schema/src/classes/symbol/type_def.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ export class TypeDefinition extends Declaration implements ITypeDefinition, Sear

/**
* @brief Parsed function signature
* @note Null if type is not a function signature, such as `typedef Address = int`
* @readonly
*/
readonly parsedSignature: ITypeSignature;
readonly parsedSignature: ITypeSignature | null;

readonly identifier: Identifier = Identifier.TypeDefinition;

Expand All @@ -28,7 +29,7 @@ export class TypeDefinition extends Declaration implements ITypeDefinition, Sear

const parents = [...options.parents, `${this.identifier}.${this.name}`];

if (options.l1Only !== true) {
if (options.l1Only !== true && this.parsedSignature !== null) {
for (const arg of this.parsedSignature.arguments) {
ret.push({
name: arg.type,
Expand Down
4 changes: 4 additions & 0 deletions schema/src/classes/symbol/type_set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export class TypeSet extends Declaration implements ITypeSet, Searchable {

if (options.l1Only !== true) {
for (const type of Object.values(this.types)) {
if (type.parsedSignature === null) {
continue;
}

for (const arg of type.parsedSignature.arguments) {
ret.push({
name: arg.name,
Expand Down
3 changes: 2 additions & 1 deletion schema/src/interfaces/symbol/type_def.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ export interface ITypeDefinition extends IDeclaration {

/**
* @brief Parsed function signature
* @note Null if type is not a function signature, such as `typedef Address = int`
* @readonly
*/
readonly parsedSignature: ITypeSignature;
readonly parsedSignature: ITypeSignature | null;
}

export interface ITypeSignature {
Expand Down
3 changes: 2 additions & 1 deletion schema/src/interfaces/symbol/type_set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ export interface IType extends IDocumentation {

/**
* @brief Parsed function signature
* @note Null if type is not a function signature, such as `typedef Address = int`
* @readonly
*/
readonly parsedSignature: ITypeSignature;
readonly parsedSignature: ITypeSignature | null;
}

export interface ITypeSet extends IDeclaration {
Expand Down
8 changes: 7 additions & 1 deletion schema/src/tests/search_index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const data = {
...decl('SQLQueryCallback'),
types: {
a: { ...decl(''), type: 'function void (Database db)', parsedSignature: sig('void', [['db', 'Database']]) },
b: { ...decl(''), type: 'int', parsedSignature: null },
},
},
},
Expand All @@ -100,6 +101,11 @@ const data = {
type: 'function Action (int client, const char[] command)',
parsedSignature: sig('Action', [['client', 'int'], ['command', 'const char[]']]),
},
Address: {
...decl('Address'),
type: 'int',
parsedSignature: null,
},
},
},
},
Expand All @@ -109,7 +115,7 @@ const needles = [
'', 'a', 'A', ' ', 'int', 'INT', 'void', 'char[]', 'const char[]', 'constchar[]', 'const char[]',
'ArrayList', 'arraylist', 'Array List', 'Array', 'GetClientName', 'getclientname', 'GetClient',
'ClientName', 'GetClinetName', 'NetFlow', 'netflow_in', 'MAX', 'max_name', 'userid', 'Player',
'Database', 'Action', 'Length', 'xyzzy', 'Q',
'Database', 'Action', 'Length', 'Address', 'xyzzy', 'Q',
];

// Score every entry, as search did before indexing
Expand Down
Loading