Skip to content

Commit 5095a40

Browse files
committed
fix: apply copilot suggestions from review
1 parent a5fa208 commit 5095a40

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

packages/igniteui-mcp/igniteui-doc-mcp/src/lib/api-doc-loader.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,15 @@ export class ApiDocLoader {
7878
const llmsFile = join(versionDir, 'llms-full.txt');
7979
if (!existsSync(llmsFile)) continue;
8080

81-
const content = readFileSync(llmsFile, 'utf-8');
81+
let content: string;
82+
try {
83+
content = readFileSync(llmsFile, 'utf-8');
84+
} catch (err) {
85+
throw new ApiDocsInitializationError(
86+
`Failed to read ${llmsFile}: ${err instanceof Error ? err.message : String(err)}`,
87+
{ cause: err }
88+
);
89+
}
8290

8391
// Split on "### [ComponentName](url)" headings
8492
// Each chunk starts with the heading line and contains the member list
@@ -136,11 +144,11 @@ export class ApiDocLoader {
136144
const heading = chunk.split('\n')[0];
137145
if (/enum/i.test(heading)) return 'enum';
138146
if (platform === 'blazor') {
139-
if (/^### \[Igb\w+EventArgs\]/m.test(chunk)) return 'interface';
140-
if (/^### \[Igb\w+Options\]/m.test(chunk)) return 'interface';
147+
if (/^### \[Igb\w+EventArgs\]/.test(heading)) return 'interface';
148+
if (/^### \[Igb\w+Options\]/.test(heading)) return 'interface';
141149
}
142150
if (platform === 'webcomponents') {
143-
if (/^### \[Igc\w+EventArgs\]/m.test(chunk)) return 'interface';
151+
if (/^### \[Igc\w+EventArgs\]/.test(heading)) return 'interface';
144152
if (/interface/i.test(heading)) return 'interface';
145153
}
146154
if (platform === 'react') {
@@ -149,7 +157,7 @@ export class ApiDocLoader {
149157
if (platform === 'angular') {
150158
// Angular interfaces conventionally start with I + uppercase (e.g., IGridState, IScrollStrategy)
151159
// while class names starting with Igx have a lowercase g (e.g., IgxGridComponent)
152-
if (/^### \[I[A-Z]/.test(chunk)) return 'interface';
160+
if (/^### \[I[A-Z]/.test(heading)) return 'interface';
153161
}
154162
return 'class';
155163
}

0 commit comments

Comments
 (0)