From ff4b53b9b728b7af1535771ef4c8f65d4a3c25b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Mon, 5 Feb 2024 11:20:10 +0100 Subject: [PATCH] fix some "no AST change" when there are syntax errors (#299) --- src/main/java/gumtree/spoon/AstComparator.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/gumtree/spoon/AstComparator.java b/src/main/java/gumtree/spoon/AstComparator.java index 04eadcb1..bb726e1b 100644 --- a/src/main/java/gumtree/spoon/AstComparator.java +++ b/src/main/java/gumtree/spoon/AstComparator.java @@ -57,7 +57,13 @@ protected Factory createFactory() { * compares two java files */ public Diff compare(File f1, File f2) throws Exception { - return this.compare(getCtType(f1), getCtType(f2)); + CtType ctType1 = getCtType(f1); + CtType ctType2 = getCtType(f2); + if (ctType1 == null || ctType2 == null) { + return null; + } else { + return compare(ctType1, ctType2); + } } /**