/[eiffelstudio]/branches/eth/eve/Src/framework/code_analysis/ca_code_analyzer.e
ViewVC logotype

Annotation of /branches/eth/eve/Src/framework/code_analysis/ca_code_analyzer.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 93168 - (hide annotations)
Thu Oct 24 19:43:13 2013 UTC (6 years ago) by zurfluhs
File size: 3358 byte(s)
Code Analysis: initial commit for code analysis project. Library 'code_analysis' added.
1 zurfluhs 93168 note
2     description: "Summary description for {CA_CODE_ANALYZER}."
3     author: "Stefan Zurfluh"
4     date: "$Date$"
5     revision: "$Revision$"
6    
7     class
8     CA_CODE_ANALYZER
9    
10     inherit {NONE}
11     SHARED_EIFFEL_PROJECT
12    
13     create
14     make
15    
16     feature {NONE} -- Initialization
17    
18     make
19     -- Initialization for `Current'.
20     do
21     create settings
22     create rules.make
23     -- Adding example rules
24     rules.extend (create {CA_SELF_ASSIGNMENT_RULE}.make)
25     rules.extend (create {CA_UNUSED_ARGUMENT_RULE}.make)
26     end
27    
28     feature
29    
30     analyze_system
31     local
32     l_groups: LIST [CONF_GROUP]
33     l_cluster: CLUSTER_I
34     do
35     create rules_checker.make
36     across rules as l_rules loop
37     if l_rules.item.is_enabled then -- important: only add enabled rules
38     rules_checker.add_rule_checker (l_rules.item.rule_checker)
39     end
40     end
41    
42     from
43     l_groups := eiffel_universe.groups
44     l_groups.start
45     until
46     l_groups.after
47     loop
48     l_cluster ?= l_groups.item_for_iteration
49     -- Only load top-level clusters, as they are loaded recursively afterwards
50     if l_cluster /= Void and then l_cluster.parent_cluster = Void then
51     analyze_cluster (l_cluster)
52     end
53     l_groups.forth
54     end
55    
56     analysis_successful := rules_checker.last_run_successful
57     if analysis_successful then
58     rule_violations := rules_checker.last_result
59     end
60     ensure
61     violation_list_exists: analysis_successful implies rule_violations /= Void
62     end
63    
64     analyze_cluster (a_cluster: CLUSTER_I)
65     local
66     l_conf_class: CONF_CLASS
67     l_class_i: CLASS_I
68     do
69     from
70     a_cluster.classes.start
71     until
72     a_cluster.classes.after
73     loop
74     l_conf_class := a_cluster.classes.item_for_iteration
75     l_class_i := eiffel_universe.class_named (l_conf_class.name, a_cluster)
76     analyze_class_if_compiled (l_class_i)
77     a_cluster.classes.forth
78     end
79     if a_cluster.sub_clusters /= Void then
80     from
81     a_cluster.sub_clusters.start
82     until
83     a_cluster.sub_clusters.after
84     loop
85     analyze_cluster (a_cluster.sub_clusters.item_for_iteration)
86     a_cluster.sub_clusters.forth
87     end
88     end
89     end
90    
91     analyze_classes (classes: LINKED_LIST[CLASS_AS])
92     do
93    
94     ensure
95     violation_list_exists: analysis_successful implies rule_violations /= Void
96     end
97    
98     analyze_class (a_class_to_analyze: CLASS_AS)
99     do
100     create rules_checker.make
101     across rules as l_rules loop
102     if l_rules.item.is_enabled then -- important: only add enabled rules
103     rules_checker.add_rule_checker (l_rules.item.rule_checker)
104     end
105     end
106    
107     rules_checker.run_on_class (a_class_to_analyze)
108     analysis_successful := rules_checker.last_run_successful
109     if analysis_successful then
110     rule_violations := rules_checker.last_result
111     end
112     ensure
113     violation_list_exists: analysis_successful implies rule_violations /= Void
114     end
115    
116     feature
117    
118     analysis_successful: BOOLEAN
119    
120     rules: LINKED_LIST[CA_RULE]
121    
122     rule_violations: detachable LINKED_LIST[CA_RULE_VIOLATION]
123    
124     feature {NONE} -- Implementation
125    
126     settings: CA_SETTINGS
127    
128     analyze_class_if_compiled (a_class: CLASS_I)
129     local
130     l_class_c: CLASS_C
131     do
132     if a_class.is_compiled then
133     l_class_c := a_class.compiled_class
134     check l_class_c /= Void end
135     print ("Analyzing class " + a_class.name + "...%N")
136     rules_checker.run_on_class (l_class_c.ast)
137     else
138     print ("Class " + a_class.name + " not compiled (skipped).%N")
139     end
140     end
141    
142     rules_checker: CA_ALL_RULES_CHECKER
143    
144     end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date ID Revision

  ViewVC Help
Powered by ViewVC 1.1.23