Package: VdmCompletionExtractor$1

VdmCompletionExtractor$1

nameinstructionbranchcomplexitylinemethod
caseAExplicitFunctionDefinition(AExplicitFunctionDefinition)
M: 45 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
caseAExplicitOperationDefinition(AExplicitOperationDefinition)
M: 45 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
caseAImplicitFunctionDefinition(AImplicitFunctionDefinition)
M: 45 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
caseAImplicitOperationDefinition(AImplicitOperationDefinition)
M: 45 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
caseAInstanceVariableDefinition(AInstanceVariableDefinition)
M: 30 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
caseAVariableExp(AVariableExp)
M: 29 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
{...}
M: 21 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: package org.overture.ide.ui.templates;
2:
3: import java.util.ArrayList;
4: import java.util.Iterator;
5: import java.util.List;
6: import org.eclipse.jface.text.ITextViewer;
7: import org.eclipse.jface.text.contentassist.ICompletionProposal;
8: import org.eclipse.jface.text.templates.TemplateContext;
9: import org.overture.ast.analysis.AnalysisException;
10: import org.overture.ast.analysis.DepthFirstAnalysisAdaptor;
11: import org.overture.ast.definitions.AClassClassDefinition;
12: import org.overture.ast.definitions.AExplicitFunctionDefinition;
13: import org.overture.ast.definitions.AExplicitOperationDefinition;
14: import org.overture.ast.definitions.AImplicitFunctionDefinition;
15: import org.overture.ast.definitions.AImplicitOperationDefinition;
16: import org.overture.ast.definitions.AInstanceVariableDefinition;
17: import org.overture.ast.expressions.AVariableExp;
18: import org.overture.ast.node.INode;
19: import org.overture.ide.ui.VdmUIPlugin;
20: import org.overture.ide.ui.editor.core.VdmDocument;
21:
22: public final class VdmCompletionExtractor {
23:         
24:         private static VdmCompletionHelper VdmHelper = new VdmCompletionHelper();
25:         private static VdmFunctionCompletionExtractor VdmFunctionHelper = new VdmFunctionCompletionExtractor();
26:         private static VdmOperationCompletionExtractor VdmOperationHelper = new VdmOperationCompletionExtractor();
27:
28:         private ArrayList<String> basicTypes = new ArrayList<String>();
29:         private ArrayList<String> dynamicTemplateProposals = new ArrayList<String>();
30:         private ArrayList<String> dynamicProposals = new ArrayList<String>();
31:         
32:         public VdmCompletionExtractor(){
33:                 basicTypes.add("nat");
34:                 basicTypes.add("nat1");
35:                 basicTypes.add("bool");
36:                 basicTypes.add("int");
37:                 basicTypes.add("real");
38:                 basicTypes.add("char");
39:         }
40:         
41:         public void generateCompleteProposals(final VdmCompletionContext info,
42:                         VdmDocument document, final List<ICompletionProposal> proposals,
43:                         final int offset, List<INode> Ast, final TemplateContext context,final ITextViewer viewer)
44:         {
45:                 for (final INode element : Ast)
46:                 {
47:                         try
48:                         {
49:                                 element.apply(new DepthFirstAnalysisAdaptor()
50:                                 {
51:                                         
52:                                         @Override
53:                                         public void caseAInstanceVariableDefinition(AInstanceVariableDefinition node)
54: throws AnalysisException{
55:                                                 String name = node.getName().toString();
56:                                                 
57:•                                                if(!VdmHelper.checkForDuplicates(name,dynamicTemplateProposals)){
58:                                                         VdmHelper.createProposal(node,name,name,"Instance Variable",info,proposals,offset);
59:                                                         dynamicTemplateProposals.add(name);
60:                                                 }
61:                                         }
62:
63:                                         @Override
64:                                         public void caseAExplicitFunctionDefinition(AExplicitFunctionDefinition node)
65: throws AnalysisException{
66:                                                 String extractedName[] = VdmFunctionHelper.explicitFunctionNameExtractor(node);
67:                                                 
68:•                                                if(VdmHelper.nullOrEmptyCheck(extractedName[1]) && !VdmHelper.checkForDuplicates(extractedName[1],dynamicTemplateProposals)){
69:                                                         VdmHelper.dynamicTemplateCreator(extractedName,"Explicit Function",offset,context,proposals,info,viewer,node.getLocation().getEndOffset());
70:                                                         dynamicTemplateProposals.add(extractedName[1]);
71:                                                 }
72:                                         }
73:                                         
74:                                         @Override
75:                                         public void caseAImplicitFunctionDefinition(AImplicitFunctionDefinition node)
76: throws AnalysisException{
77:                                                 String extractedName[] = VdmFunctionHelper.implicitFunctionNameExtractor(node);
78:                                                 
79:•                                                if(VdmHelper.nullOrEmptyCheck(extractedName[1]) && !VdmHelper.checkForDuplicates(extractedName[1],dynamicTemplateProposals)){
80:                                                         VdmHelper.dynamicTemplateCreator(extractedName,"Implicit Function",offset,context,proposals,info,viewer,node.getLocation().getEndOffset());
81:                                                         dynamicTemplateProposals.add(extractedName[1]);
82:                                                 }        
83:                                         }
84:                                         
85:                                         @Override
86:                                         public void caseAExplicitOperationDefinition(AExplicitOperationDefinition node)
87: throws AnalysisException{
88:                                                 String extractedName[] = VdmOperationHelper.explicitOperationNameExtractor(node);
89:                                                 
90:•                                                if(VdmHelper.nullOrEmptyCheck(extractedName[1]) && !VdmHelper.checkForDuplicates(extractedName[1],dynamicTemplateProposals)){
91:                                                         VdmHelper.dynamicTemplateCreator(extractedName,"Explicit Operation",offset,context,proposals,info,viewer,node.getLocation().getEndOffset());
92:                                                         dynamicTemplateProposals.add(extractedName[1]);
93:                                                 }        
94:                                         }
95:                                         
96:                                         @Override
97:                                         public void caseAImplicitOperationDefinition(AImplicitOperationDefinition node)
98: throws AnalysisException{
99:                                                 String extractedName[] = VdmOperationHelper.implicitOperationNameExtractor(node);
100:                                                 
101:•                                                if(VdmHelper.nullOrEmptyCheck(extractedName[1]) && !VdmHelper.checkForDuplicates(extractedName[1],dynamicTemplateProposals)){
102:                                                         VdmHelper.dynamicTemplateCreator(extractedName,"Implicit Operation",offset,context,proposals,info,viewer,node.getLocation().getEndOffset());
103:                                                         dynamicTemplateProposals.add(extractedName[1]);
104:                                                 }        
105:                                         }
106:                                         
107:                                         @Override
108:                                         public void caseAVariableExp(AVariableExp node)
109:                          throws AnalysisException{
110:                                                 String name = node.toString();
111:                                                 
112:•                                                if(!VdmHelper.checkForDuplicates(name,dynamicTemplateProposals)){
113:                                                         VdmHelper.createProposal(node,name,name,"Variable Exp",info,proposals,offset);
114:                                                         dynamicTemplateProposals.add(name);
115:                                                 }
116:                                         }
117:                                 });
118:                         } catch (AnalysisException e)
119:                         {
120:                                 VdmUIPlugin.log("Completion error in " + getClass().getSimpleName()
121:                                                 + "faild during populateNameList", e);
122:                         }
123:                 }
124:                 basicTypeProposalFunction(info, proposals, offset);
125:                 dynamicTemplateProposals.clear();
126:                 dynamicProposals.clear();
127:         }
128:         
129:         private void basicTypeProposalFunction(final VdmCompletionContext info, final List<ICompletionProposal> proposals,
130:                         final int offset){
131:                 
132:                 Iterator<String> iter = basicTypes.iterator();
133:                 while(iter.hasNext()){
134:                         String item = iter.next();
135:                         VdmHelper.createProposal(null,item,item,"Basic Type",info,proposals,offset);                        
136:                 }
137:         }
138: }