Skip to content

Commit 9ffbc5d

Browse files
committed
Add logic to annotate entrypoint methods in codeanalyzer output. This attempts to address the feature request #86
Signed-off-by: Rahul Krishna <[email protected]>
1 parent eb040d7 commit 9ffbc5d

28 files changed

+4028
-181
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ plugins {
1515
// Apply the application plugin to add support for building a CLI application in Java.
1616
id 'eclipse'
1717
id 'application'
18-
id 'org.graalvm.buildtools.native' version '0.9.28'
18+
id 'org.graalvm.buildtools.native' version '0.10.4'
1919
}
2020

2121
// Get the version from the property file first

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=2.0.2
1+
version=2.1.0-dev

src/main/java/com/ibm/cldk/SymbolTable.java

Lines changed: 311 additions & 176 deletions
Large diffs are not rendered by default.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.ibm.cldk.entities;
2+
3+
import com.ibm.cldk.utils.annotations.NotImplemented;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
import java.util.List;
8+
9+
@Data
10+
@NoArgsConstructor
11+
@AllArgsConstructor
12+
public class CRUDOperation {
13+
public enum OperationType {
14+
CREATE,
15+
READ,
16+
UPDATE,
17+
DELETE,
18+
UNKNOWN
19+
}
20+
21+
private OperationType operationType;
22+
private String targetTable;
23+
private int lineNumber;
24+
private int startPosition;
25+
private int endPosition;
26+
27+
@NotImplemented
28+
private String operationString;
29+
@NotImplemented
30+
private List<String> involvedFields;
31+
@NotImplemented
32+
private String condition;
33+
@NotImplemented
34+
private List<String> joinedTables;
35+
@NotImplemented
36+
private String technology;
37+
@NotImplemented
38+
private boolean isBatchOperation = false;
39+
}

src/main/java/com/ibm/cldk/entities/Callable.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import lombok.Data;
44

5+
import java.util.ArrayList;
56
import java.util.List;
67

78
@Data
@@ -25,4 +26,6 @@ public class Callable {
2526
private List<CallSite> callSites;
2627
private List<VariableDeclaration> variableDeclarations;
2728
private int cyclomaticComplexity;
29+
private boolean isEntryPoint = false;
30+
private List<CRUDOperation> crudOperations = null;
2831
}

src/main/java/com/ibm/cldk/entities/Type.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ public class Type {
2525
private Map<String, Callable> callableDeclarations;
2626
private List<Field> fieldDeclarations;
2727
private List<EnumConstant> enumConstants;
28+
private boolean isEntryPointClass = false;
2829
}

src/main/java/com/ibm/cldk/utils/BuildProject.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,18 @@ public static boolean downloadLibraryDependencies(String projectPath, String pro
234234
String[] mavenCommand = {MAVEN_CMD, "--no-transfer-progress", "-f", Paths.get(projectRoot, "pom.xml").toString(), "dependency:copy-dependencies", "-DoutputDirectory=" + libDownloadPath.toString()};
235235
return buildWithTool(mavenCommand);
236236
} else if (new File(projectRoot, "build.gradle").exists() || new File(projectRoot, "build.gradle.kts").exists()) {
237-
if (GRADLE_CMD == null || !commandExists(new File(GRADLE_CMD)).getKey()) {
238-
libDownloadPath = Paths.get(projectPath, "build", LIB_DEPS_DOWNLOAD_DIR).toAbsolutePath();
237+
libDownloadPath = Paths.get(projectPath, "build", LIB_DEPS_DOWNLOAD_DIR).toAbsolutePath();
239238
if (mkLibDepDirs(projectPath))
240239
Log.debug("Dependencies found/created in " + libDownloadPath);
241240
else
242241
throw new IllegalStateException("Error creating library dependency directory in " + libDownloadPath);
243242

243+
if (GRADLE_CMD == null || !commandExists(new File(GRADLE_CMD)).getKey()) {
244244
String msg = GRADLE_CMD == null ?
245245
"Could not find Gradle or valid Gradle Wrapper" :
246246
MessageFormat.format("Could not verify that {0} exists", GRADLE_CMD);
247247
Log.error(msg);
248-
throw new IllegalStateException("Unable to execute Maven command. " +
248+
throw new IllegalStateException("Unable to execute Gradle command. " +
249249
(GRADLE_CMD == null ?
250250
"Could not find Gradle or valid Gradle Wrapper" :
251251
"Attempt failed with message\n" + commandExists(new File(GRADLE_CMD)).getValue()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.ibm.cldk.utils.annotations;
2+
3+
import java.lang.annotation.*;
4+
5+
@Documented
6+
@Target({ElementType.METHOD, ElementType.FIELD})
7+
@Retention(RetentionPolicy.RUNTIME)
8+
public @interface NotImplemented {
9+
String value() default "";
10+
String since() default "";
11+
String ticketId() default "";
12+
}

0 commit comments

Comments
 (0)