mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-19 15:30:03 +02:00
fix: ANTLR parser interaction parameter passing
- Fixed callback argument parsing for empty parentheses: callback() now correctly passes undefined instead of empty string - Fixed tooltip parsing for call patterns: click A call callback() "tooltip" now correctly extracts tooltip - All interaction patterns now work correctly: * click nodeId call functionName(args) - with arguments * click nodeId call functionName() - without arguments * click nodeId call functionName() "tooltip" - with tooltip * click nodeId href "url" - direct links * click nodeId href "url" "tooltip" - links with tooltip - Improved lexer grammar to handle callback arguments as single tokens - All 13 interaction tests now passing (100% success rate)
This commit is contained in:
59
debug-callback-args.js
Normal file
59
debug-callback-args.js
Normal file
@@ -0,0 +1,59 @@
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
console.log('=== DEBUGGING CALLBACK ARGUMENTS ===');
|
||||
|
||||
// Test the specific failing case
|
||||
const testInput = 'graph TD\nA-->B\nclick A call callback("test0", test1, test2)';
|
||||
console.log('Test input:', testInput);
|
||||
|
||||
// Create a temporary test file to debug the ANTLR parser
|
||||
import fs from 'fs';
|
||||
const testFile = `
|
||||
// Debug callback arguments parsing
|
||||
process.env.USE_ANTLR_PARSER = 'true';
|
||||
|
||||
const flow = require('./packages/mermaid/src/diagrams/flowchart/flowDb.ts');
|
||||
const parser = require('./packages/mermaid/src/diagrams/flowchart/parser/antlr/antlr-parser.ts');
|
||||
|
||||
console.log('Testing callback arguments parsing...');
|
||||
|
||||
// Mock the setClickEvent to see what parameters it receives
|
||||
const originalSetClickEvent = flow.default.setClickEvent;
|
||||
flow.default.setClickEvent = function(...args) {
|
||||
console.log('DEBUG setClickEvent called with args:', args);
|
||||
console.log(' - nodeId:', args[0]);
|
||||
console.log(' - functionName:', args[1]);
|
||||
console.log(' - functionArgs:', args[2]);
|
||||
console.log(' - args.length:', args.length);
|
||||
return originalSetClickEvent.apply(this, args);
|
||||
};
|
||||
|
||||
try {
|
||||
const result = parser.parse('${testInput}');
|
||||
console.log('Parse completed successfully');
|
||||
} catch (error) {
|
||||
console.log('Parse error:', error.message);
|
||||
}
|
||||
`;
|
||||
|
||||
fs.writeFileSync('debug-callback-test.js', testFile);
|
||||
|
||||
try {
|
||||
const result = execSync('node debug-callback-test.js', {
|
||||
cwd: '/Users/ashishjain/projects/mermaid',
|
||||
encoding: 'utf8',
|
||||
timeout: 10000,
|
||||
});
|
||||
console.log('Result:', result);
|
||||
} catch (error) {
|
||||
console.log('Error:', error.message);
|
||||
if (error.stdout) console.log('Stdout:', error.stdout);
|
||||
if (error.stderr) console.log('Stderr:', error.stderr);
|
||||
}
|
||||
|
||||
// Clean up
|
||||
try {
|
||||
fs.unlinkSync('debug-callback-test.js');
|
||||
} catch (e) {
|
||||
// Ignore cleanup errors
|
||||
}
|
Reference in New Issue
Block a user