From 7e3fca2da98938923a62c0856c64297951310c3b Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Mon, 28 May 2018 16:18:33 +0200 Subject: [PATCH] =?UTF-8?q?Hotfix=20f=C3=BCr=20Typparsen=20Problem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../parser/SyntaxTreeGenerator/TypeGenerator.java | 14 ++++++++------ test/parser/PackageNameTest.jav | 9 +++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 test/parser/PackageNameTest.jav diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/TypeGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/TypeGenerator.java index 4bc08960..00a0f778 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/TypeGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/TypeGenerator.java @@ -22,18 +22,20 @@ import java.util.List; public class TypeGenerator { public static RefTypeOrTPHOrWildcardOrGeneric convert(Java8Parser.UnannClassOrInterfaceTypeContext unannClassOrInterfaceTypeContext, JavaClassRegistry reg, GenericsRegistry generics) { - String name; - if(unannClassOrInterfaceTypeContext.unannInterfaceType_lfno_unannClassOrInterfaceType() != null){ - name = unannClassOrInterfaceTypeContext.unannInterfaceType_lfno_unannClassOrInterfaceType().unannClassType_lfno_unannClassOrInterfaceType().Identifier().getText(); - } Java8Parser.TypeArgumentsContext arguments; if(unannClassOrInterfaceTypeContext.unannClassType_lfno_unannClassOrInterfaceType() != null){ - name = unannClassOrInterfaceTypeContext.unannClassType_lfno_unannClassOrInterfaceType().Identifier().getText(); arguments = unannClassOrInterfaceTypeContext.unannClassType_lfno_unannClassOrInterfaceType().typeArguments(); }else{// if(unannClassOrInterfaceTypeContext.unannInterfaceType_lfno_unannClassOrInterfaceType() != null){ - name = unannClassOrInterfaceTypeContext.unannInterfaceType_lfno_unannClassOrInterfaceType().unannClassType_lfno_unannClassOrInterfaceType().getText(); arguments = unannClassOrInterfaceTypeContext.unannInterfaceType_lfno_unannClassOrInterfaceType().unannClassType_lfno_unannClassOrInterfaceType().typeArguments(); } + /** + * Problem sind hier die verschachtelten Typen mit verschachtelten Typargumenten + * Beispiel: Typ.InnererTyp + */ + String name = unannClassOrInterfaceTypeContext.getText(); + if(name.contains("<")){ + name = name.split("<")[0]; //Der Typ ist alles vor den ersten Argumenten + } return convertTypeName(name, arguments, unannClassOrInterfaceTypeContext.getStart(), reg, generics); } diff --git a/test/parser/PackageNameTest.jav b/test/parser/PackageNameTest.jav new file mode 100644 index 00000000..53c889b7 --- /dev/null +++ b/test/parser/PackageNameTest.jav @@ -0,0 +1,9 @@ +import java.lang.Integer; +import java.lang.Comparable; + +class PackageNameTest{ +java.lang.Integer test(a){return a;} + +Comparable test2(a){return a;} + +} \ No newline at end of file