Skip to content

Commit

Permalink
merge develop into this branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan-Thurner committed Sep 28, 2024
1 parent 5d701e5 commit bb7f8c6
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import java.util.List;

public record Config(List<String> excludedServerFiles, List<String> excludedEndpointFiles, List<String> excludedEndpoints,
List<String> excludedRestCallFiles, List<String> excludedRestCalls,
String endpointParsingResultPath, String restCallParsingResultPath, String endpointAnalysisResultPath,
String restCallAnalysisResultPath, String clientDirPath) {
public record Config(List<String> excludedServerFiles, List<String> excludedEndpointFiles, List<String> excludedEndpoints, List<String> excludedRestCallFiles,
List<String> excludedRestCalls, String endpointParsingResultPath, String restCallParsingResultPath, String endpointAnalysisResultPath, String restCallAnalysisResultPath,
String clientDirPath) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public static void main(String[] args) {

String[] filesToParse = {};
try (Stream<Path> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,46 +71,56 @@ 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) {
process.exit(1);
}


const tsFiles = collectTypeScriptFiles(config.clientDirPath);

// create and store Syntax Tree for each file
const astMap = new Map<string, TSESTree.Program>;
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<string, TSESTree.Program>;
// 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);
}

0 comments on commit bb7f8c6

Please sign in to comment.