|
13 | 13 |
|
14 | 14 | package com.ibm.northstar; |
15 | 15 |
|
| 16 | +import com.ibm.northstar.entities.AbstractGraphEdge; |
| 17 | +import com.ibm.northstar.entities.CallEdge; |
| 18 | +import com.ibm.northstar.entities.Callable; |
| 19 | +import com.ibm.northstar.entities.SystemDepEdge; |
16 | 20 | import com.ibm.northstar.utils.AnalysisUtils; |
17 | 21 | import com.ibm.northstar.utils.Log; |
18 | | -import com.ibm.northstar.entities.*; |
19 | 22 | import com.ibm.northstar.utils.ScopeUtils; |
20 | 23 | import com.ibm.wala.cast.ir.ssa.AstIRFactory; |
21 | | -import com.ibm.wala.cast.java.client.impl.ZeroCFABuilderFactory; |
22 | 24 | import com.ibm.wala.cast.java.translator.jdt.ecj.ECJClassLoaderFactory; |
23 | 25 | import com.ibm.wala.classLoader.CallSiteReference; |
| 26 | +import com.ibm.wala.classLoader.IClass; |
| 27 | +import com.ibm.wala.classLoader.IMethod; |
24 | 28 | import com.ibm.wala.ipa.callgraph.*; |
25 | 29 | import com.ibm.wala.ipa.callgraph.AnalysisOptions.ReflectionOptions; |
26 | 30 | import com.ibm.wala.ipa.callgraph.impl.Util; |
|
51 | 55 | import java.util.function.Supplier; |
52 | 56 |
|
53 | 57 | import static com.ibm.northstar.CodeAnalyzer.gson; |
54 | | -import static com.ibm.northstar.utils.AnalysisUtils.getCallableFromSymbolTable; |
55 | | -import static com.ibm.northstar.utils.AnalysisUtils.createAndPutNewCallableInSymbolTable; |
| 58 | +import static com.ibm.northstar.utils.AnalysisUtils.*; |
56 | 59 |
|
57 | 60 | /** |
58 | 61 | * The type Sdg 2 json. |
@@ -223,6 +226,18 @@ public static String construct( |
223 | 226 | IAnalysisCacheView cache = new AnalysisCacheImpl(AstIRFactory.makeDefaultFactory(), |
224 | 227 | options.getSSAOptions()); |
225 | 228 |
|
| 229 | + // set cyclomatic complexity for callables in the symbol table |
| 230 | + int numClasses = cha.getNumberOfClasses(); |
| 231 | + for (Iterator<IClass> classIter = cha.iterator(); classIter.hasNext(); ) { |
| 232 | + IClass cls = classIter.next(); |
| 233 | + for (IMethod method: cls.getAllMethods()) { |
| 234 | + Callable callable = getCallableFromSymbolTable(method).getRight(); |
| 235 | + if (callable != null) { |
| 236 | + callable.setCyclomaticComplexity(getCyclomaticComplexity(cache.getIR(method))); |
| 237 | + } |
| 238 | + } |
| 239 | + } |
| 240 | + |
226 | 241 | // Build call graph |
227 | 242 | Log.info("Building call graph."); |
228 | 243 |
|
|
0 commit comments