Skip to content

Commit

Permalink
feat: Add ParseFilesConfig.resolveParseFiles to handle the include/ex…
Browse files Browse the repository at this point in the history
…clude config
  • Loading branch information
littleGnAl committed Dec 13, 2023
1 parent d84cff0 commit f43e2bf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
7 changes: 5 additions & 2 deletions cxx-parser/__tests__/unit_test/cxx_parser_configs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import fs from 'fs';
import os from 'os';
import path from 'path';

import { CXXParserConfigs } from '../../src/cxx_parser_configs';
import {
CXXParserConfigs,
ParseFilesConfig,
} from '../../src/cxx_parser_configs';

describe('CXXParserConfigs', () => {
let tmpDir: string = '';
Expand Down Expand Up @@ -72,7 +75,7 @@ describe('ParseFilesConfig', () => {
args as unknown as CXXParserConfigs
);

let finalParseFiles = config.parseFiles.resolveParseFiles();
let finalParseFiles = ParseFilesConfig.resolveParseFiles(config.parseFiles);

expect(finalParseFiles.length).toBe(1);
expect(finalParseFiles[0]).toEqual(path1); // file1.h
Expand Down
6 changes: 4 additions & 2 deletions cxx-parser/src/cxx_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import path from 'path';
import { ParseResult, TerraContext } from '@agoraio-extensions/terra-core';

import { ClangASTStructConstructorParser } from './constructor_initializer_parser';
import { CXXParserConfigs } from './cxx_parser_configs';
import { CXXParserConfigs, ParseFilesConfig } from './cxx_parser_configs';
import { CXXFile, CXXTYPE, cast } from './cxx_terra_node';

export function generateChecksum(files: string[]) {
Expand Down Expand Up @@ -117,7 +117,9 @@ export function CXXParser(
): ParseResult | undefined {
let cxxParserConfigs = CXXParserConfigs.resolve(terraContext.configDir, args);

let parseFiles = cxxParserConfigs.parseFiles.resolveParseFiles();
let parseFiles = ParseFilesConfig.resolveParseFiles(
cxxParserConfigs.parseFiles
);
let jsonContent = dumpCXXAstJson(
terraContext,
cxxParserConfigs.includeHeaderDirs,
Expand Down
6 changes: 3 additions & 3 deletions cxx-parser/src/cxx_parser_configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ export class ParseFilesConfig {
*
* @returns An array of strings representing the files to be parsed.
*/
resolveParseFiles(): string[] {
return this.include.filter((it) => {
return !this.exclude.includes(it);
static resolveParseFiles(config: ParseFilesConfig): string[] {
return config.include.filter((it) => {
return !config.exclude.includes(it);
});
}
}
Expand Down

0 comments on commit f43e2bf

Please sign in to comment.