Skip to content

Commit 7ac1415

Browse files
authored
Merge branch 'cloudwego:main' into main
2 parents d7d507c + 3eb6ab0 commit 7ac1415

4 files changed

Lines changed: 23 additions & 14 deletions

File tree

lang/golang/parser/file.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,14 @@ func (p *GoParser) parseVar(ctx *fileContext, vspec *ast.ValueSpec, isConst bool
225225

226226
// newFunc allocate a function in the repo
227227
func (p *GoParser) newFunc(mod, pkg, name string) *Function {
228-
ret := &Function{Identity: NewIdentity(mod, pkg, name), Exported: isUpperCase(name[0])}
228+
var exported bool
229+
if ind := strings.LastIndexByte(name, '.'); ind != -1 && ind+1 < len(name) {
230+
exported = isUpperCase(name[ind+1])
231+
} else {
232+
exported = isUpperCase(name[0])
233+
}
234+
235+
ret := &Function{Identity: NewIdentity(mod, pkg, name), Exported: exported}
229236
return p.repo.SetFunction(ret.Identity, ret)
230237
}
231238

ts-parser/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"license": "ALv2",
2828
"dependencies": {
2929
"commander": "^11.0.0",
30+
"json-stream-stringify": "^3.1.6",
3031
"json5": "^2.2.3",
3132
"ts-morph": "^23.0.0"
3233
},
@@ -43,4 +44,4 @@
4344
"ts-node": "^10.9.0",
4445
"typescript": "^5.0.0"
4546
}
46-
}
47+
}

ts-parser/src/index.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/usr/bin/env node
22

33
import { Command } from 'commander';
4-
import * as path from 'path';
4+
import fs from 'fs';
5+
import path from 'path';
56
import { RepositoryParser } from './parser/RepositoryParser';
6-
import * as fs from 'fs';
7+
import { JsonStreamStringify } from 'json-stream-stringify';
78

89
const program = new Command();
910

@@ -43,22 +44,22 @@ program
4344

4445
// Output the repository JSON file
4546
const outputPath = path.resolve(options.output);
46-
const jsonOutput = options.pretty
47-
? JSON.stringify(repository, null, 2)
48-
: JSON.stringify(repository);
47+
const jsonStream = new JsonStreamStringify(repository, undefined, options.pretty ? 2 : undefined);
48+
const fileStream = fs.createWriteStream(outputPath);
49+
jsonStream.pipe(fileStream);
4950

50-
fs.writeFileSync(outputPath, jsonOutput);
51+
fileStream.on('finish', () => {
52+
console.log(`Repository has been parsed and saved to ${outputPath}`);
53+
});
5154

52-
console.log(`Successfully parsed repository`);
53-
console.log(`Output written to: ${outputPath}`);
54-
console.log(`Total modules: ${Object.keys(repository.Modules).length}`);
55-
console.log(`Total symbols in graph: ${Object.keys(repository.Graph).length}`);
55+
fileStream.on('error', (err) => {
56+
console.error('Error writing to file:', err);
57+
});
5658

5759
} catch (error) {
5860
console.error('Error parsing repository:', error);
5961
process.exit(1);
6062
}
6163
});
6264

63-
6465
program.parse();

ts-parser/src/utils/cluster-processor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export function processPackagesWithCluster(
149149
totalProcessed: results.length,
150150
errors: [...errors, new Error('Processing timeout')],
151151
});
152-
}, 15 * 60 * 1000); // 15 minutes
152+
}, 120 * 60 * 1000); // 120 minutes
153153
};
154154

155155
cluster.on('message', (worker: Worker, message: WorkerResult) => {

0 commit comments

Comments
 (0)