diff --git a/supporting_scripts/analysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/Config.java b/supporting_scripts/analysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/Config.java index d58d9e106414..8f80bb8fe3a7 100644 --- a/supporting_scripts/analysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/Config.java +++ b/supporting_scripts/analysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/Config.java @@ -2,8 +2,7 @@ import java.util.List; -public record Config(List excludedServerFiles, List excludedEndpointFiles, List excludedEndpoints, - List excludedRestCallFiles, List excludedRestCalls, - String endpointParsingResultPath, String restCallParsingResultPath, String endpointAnalysisResultPath, - String restCallAnalysisResultPath, String clientDirPath) { +public record Config(List excludedServerFiles, List excludedEndpointFiles, List excludedEndpoints, List excludedRestCallFiles, + List excludedRestCalls, String endpointParsingResultPath, String restCallParsingResultPath, String endpointAnalysisResultPath, String restCallAnalysisResultPath, + String clientDirPath) { } diff --git a/supporting_scripts/analysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/EndpointParser.java b/supporting_scripts/analysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/EndpointParser.java index 4c2a0d49c2ab..8feb264468ac 100644 --- a/supporting_scripts/analysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/EndpointParser.java +++ b/supporting_scripts/analysis-of-endpoint-connections/src/main/java/de/tum/cit/endpointanalysis/EndpointParser.java @@ -44,8 +44,8 @@ public static void main(String[] args) { String[] filesToParse = {}; try (Stream paths = Files.walk(absoluteDirectoryPath)) { - filesToParse = paths.filter(path -> Files.isRegularFile(path) && path.toString().endsWith(".java") && !CONFIG.excludedServerFiles().contains(path)) - .map(Path::toString).toArray(String[]::new); + filesToParse = paths.filter(path -> Files.isRegularFile(path) && path.toString().endsWith(".java") && !CONFIG.excludedServerFiles().contains(path)).map(Path::toString) + .toArray(String[]::new); } catch (IOException e) { log.error("Error reading files from directory: {}", absoluteDirectoryPath, e); diff --git a/supporting_scripts/analysis-of-endpoint-connections/src/main/typeScript/AnalysisOfEndpointConnectionsClient.ts b/supporting_scripts/analysis-of-endpoint-connections/src/main/typeScript/AnalysisOfEndpointConnectionsClient.ts index f80e04ee22df..205a60c628d7 100644 --- a/supporting_scripts/analysis-of-endpoint-connections/src/main/typeScript/AnalysisOfEndpointConnectionsClient.ts +++ b/supporting_scripts/analysis-of-endpoint-connections/src/main/typeScript/AnalysisOfEndpointConnectionsClient.ts @@ -71,7 +71,9 @@ function readConfigFile(filePath: string): Config | null { } } -const configFilePath = 'supporting_scripts/analysis-of-endpoint-connections/analysisOfEndpointConnections.config.yml'; +// const configFilePath = 'supporting_scripts/analysis-of-endpoint-connections/analysisOfEndpointConnections.config.yml'; +console.log(__dirname); +const configFilePath = '../../../analysisOfEndpointConnections.config.yml'; const config = readConfigFile(configFilePath); if (!config) { @@ -79,38 +81,46 @@ if (!config) { } -const tsFiles = collectTypeScriptFiles(config.clientDirPath); - -// create and store Syntax Tree for each file -const astMap = new Map; -tsFiles.forEach((filePath) => { - const ast = parseTypeScriptFile(filePath); - if (ast) { - astMap.set(filePath, ast); - } -}); - -// preprocess each file -Array.from(astMap.keys()).forEach((filePath: string) => { - const ast = astMap.get(filePath); - if (ast) { - const preProcessor = new Preprocessor(ast); - preProcessor.preprocessFile(); - } -}); - -// postprocess each file -Array.from(astMap.keys()).forEach((filePath) => { - const ast = astMap.get(filePath); - if (ast) { - const postProcessor = new Postprocessor(filePath, ast); - postProcessor.extractRestCallsFromProgram(); - } -}); +// const tsFiles = collectTypeScriptFiles(config.clientDirPath); +// +// // create and store Syntax Tree for each file +// const astMap = new Map; +// tsFiles.forEach((filePath) => { +// const ast = parseTypeScriptFile(filePath); +// if (ast) { +// astMap.set(filePath, ast); +// } +// }); +// +// // preprocess each file +// Array.from(astMap.keys()).forEach((filePath: string) => { +// const ast = astMap.get(filePath); +// if (ast) { +// const preProcessor = new Preprocessor(ast); +// preProcessor.preprocessFile(); +// } +// }); +// +// // postprocess each file +// Array.from(astMap.keys()).forEach((filePath) => { +// const ast = astMap.get(filePath); +// if (ast) { +// const postProcessor = new Postprocessor(filePath, ast); +// postProcessor.extractRestCallsFromProgram(); +// } +// }); + +let ast = parseTypeScriptFile('../../../../../src/main/webapp/app/exercises/shared/course-exercises/course-exercise.service.ts'); +if (ast) { + const preProcessor = new Preprocessor(ast); + preProcessor.preprocessFile(); + const postProcessor = new Postprocessor('../../../../../src/main/webapp/app/exercises/shared/course-exercises/course-exercise.service.ts', ast); +} try { - writeFileSync(`supporting_scripts/analysis-of-endpoint-connections/${config.restCallParsingResultPath}`, JSON.stringify(Postprocessor.filesWithRestCalls, null, 2)); + // writeFileSync(`supporting_scripts/analysis-of-endpoint-connections/${config.restCallParsingResultPath}`, JSON.stringify(Postprocessor.filesWithRestCalls, null, 2)); + writeFileSync(`${config.restCallParsingResultPath}`, JSON.stringify(Postprocessor.filesWithRestCalls, null, 2)); } catch (error) { console.error('Failed to write REST calls to file:', error); }