From e24aa835d9ee951d53c6c135c2ab970dc56a6d8e Mon Sep 17 00:00:00 2001 From: Mariana Azevedo Date: Sat, 14 Jul 2018 13:59:16 -0300 Subject: [PATCH] Updating project's configs. Correcting possible arrayindexoutofboundsexception point. --- META-INF/MANIFEST.MF | 1 + .../astvisitors/CouplingBetweenObjectsVisitor.java | 10 ++++++---- .../javamodel/LackCohesionMethodsJavaModel.java | 1 + src/com/o3smeasures/structures/Measure.java | 2 +- src/com/o3smeasures/util/JavaParser.java | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF index ef68a61..a6aac7a 100644 --- a/META-INF/MANIFEST.MF +++ b/META-INF/MANIFEST.MF @@ -38,3 +38,4 @@ Bundle-ClassPath: lib/jcommon-1.0.16.jar, lib/commons-csv-1.0.jar, lib/jsefa-1.0.0.RELEASE.jar, lib/log4j-1.2.17.jar +Automatic-Module-Name: O3SMeasures diff --git a/src/com/o3smeasures/astvisitors/CouplingBetweenObjectsVisitor.java b/src/com/o3smeasures/astvisitors/CouplingBetweenObjectsVisitor.java index d33b9b4..7eb26ce 100644 --- a/src/com/o3smeasures/astvisitors/CouplingBetweenObjectsVisitor.java +++ b/src/com/o3smeasures/astvisitors/CouplingBetweenObjectsVisitor.java @@ -63,10 +63,12 @@ public boolean visit(CompilationUnit node) { private void calculateClazzUsed(CompilationUnit unit){ Object typeDeclaration = unit.types().stream().filter(type -> type instanceof TypeDeclaration).collect(Collectors.toList()); - MethodDeclaration [] methods = ((List) typeDeclaration).get(0).getMethods(); - for (MethodDeclaration method: methods){ - Block firstMethodBody = method.getBody(); - Optional.ofNullable(firstMethodBody).ifPresent(m -> checkMethodStatements(method, firstMethodBody)); + if(!((List) typeDeclaration).isEmpty()){ + MethodDeclaration [] methods = ((List) typeDeclaration).get(0).getMethods(); + for (MethodDeclaration method: methods){ + Block firstMethodBody = method.getBody(); + Optional.ofNullable(firstMethodBody).ifPresent(m -> checkMethodStatements(method, firstMethodBody)); + } } } diff --git a/src/com/o3smeasures/javamodel/LackCohesionMethodsJavaModel.java b/src/com/o3smeasures/javamodel/LackCohesionMethodsJavaModel.java index eba7347..6386deb 100644 --- a/src/com/o3smeasures/javamodel/LackCohesionMethodsJavaModel.java +++ b/src/com/o3smeasures/javamodel/LackCohesionMethodsJavaModel.java @@ -151,6 +151,7 @@ public void addMethod(String method, Set methodSet) { * @since 13/07/2014 * @param methods */ + @SuppressWarnings("deprecation") private void checkMethodsWithSharedAttributes(IMethod[] methods){ IScanner scanner = null; diff --git a/src/com/o3smeasures/structures/Measure.java b/src/com/o3smeasures/structures/Measure.java index 266c8d0..0ce40f9 100644 --- a/src/com/o3smeasures/structures/Measure.java +++ b/src/com/o3smeasures/structures/Measure.java @@ -34,7 +34,7 @@ public enum Granularity { public Measure(){ applicableGranularities = new ArrayList<>(4); - parser = ASTParser.newParser(AST.JLS9); + parser = ASTParser.newParser(AST.JLS10); parser.setKind(ASTParser.K_COMPILATION_UNIT); parser.setResolveBindings(true); } diff --git a/src/com/o3smeasures/util/JavaParser.java b/src/com/o3smeasures/util/JavaParser.java index 0822ce3..bd203ca 100644 --- a/src/com/o3smeasures/util/JavaParser.java +++ b/src/com/o3smeasures/util/JavaParser.java @@ -69,7 +69,7 @@ public static CompilationUnit parseAST(FileInputStream fileInputStream){ ASTSession.getInstance().reset(); if (cacheParser) { - astParser = ASTParser.newParser(AST.JLS9); + astParser = ASTParser.newParser(AST.JLS10); astParser.setKind(ASTParser.K_COMPILATION_UNIT); astParser.setResolveBindings(true); char[] source = getFileContent(fileInputStream);