Package: VdmFunctionCompletionExtractor

VdmFunctionCompletionExtractor

nameinstructionbranchcomplexitylinemethod
VdmFunctionCompletionExtractor()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
explicitFunctionNameExtractor(AExplicitFunctionDefinition)
M: 48 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
explicitFunctionParameterNameExtractor(AExplicitFunctionDefinition)
M: 29 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
implicitFunctionNameExtractor(AImplicitFunctionDefinition)
M: 48 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
implicitFunctionParameterNameExtractor(AImplicitFunctionDefinition)
M: 28 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 5 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.LinkedList;
5: import java.util.List;
6:
7: import org.eclipse.jface.text.IRegion;
8: import org.eclipse.jface.text.ITextSelection;
9: import org.eclipse.jface.text.ITextViewer;
10: import org.eclipse.jface.text.Region;
11: import org.eclipse.jface.text.contentassist.ICompletionProposal;
12: import org.eclipse.jface.text.templates.Template;
13: import org.eclipse.jface.text.templates.TemplateContext;
14: import org.overture.ast.definitions.AExplicitFunctionDefinition;
15: import org.overture.ast.definitions.AExplicitOperationDefinition;
16: import org.overture.ast.definitions.AImplicitFunctionDefinition;
17: import org.overture.ast.definitions.AImplicitOperationDefinition;
18: import org.overture.ast.node.INode;
19: import org.overture.ast.patterns.APatternListTypePair;
20: import org.overture.ast.patterns.PPattern;
21:
22: public class VdmFunctionCompletionExtractor{
23:         
24:         private static VdmCompletionHelper VdmHelper = new VdmCompletionHelper();
25:         
26:         public String[] implicitFunctionNameExtractor(AImplicitFunctionDefinition node){
27:
28:         String functionName[] = new String[2];
29:         String[] SplitName = (node.getName().toString()).split("\\(");
30:         functionName[0] = SplitName[0];
31:         
32:•         if(functionName[0] != null && !functionName[0].isEmpty()){
33:                 functionName[1] = functionName[0] + "("; //ReplacemestString
34:         }
35:         List<String> parameterNameList = null;
36:
37:         parameterNameList = implicitFunctionParameterNameExtractor(node);
38:                 
39:         return VdmHelper.templatePatternGenerator(parameterNameList,functionName);
40:         
41: }
42:         
43:         public String[] explicitFunctionNameExtractor(AExplicitFunctionDefinition node){
44:         String functionName[] = new String[2];
45:         String[] SplitName = (node.getName().toString()).split("\\(");
46:         functionName[0] = SplitName[0];
47:         
48:•         if(functionName[0] != null && !functionName[0].isEmpty()){
49:                 functionName[1] = functionName[0] + "("; //ReplacemestString
50:         }
51:         List<String> parameterNameList = null;
52:
53:         parameterNameList = explicitFunctionParameterNameExtractor(node);
54:                 
55:         return VdmHelper.templatePatternGenerator(parameterNameList,functionName);
56: }
57:         
58:         public List<String> explicitFunctionParameterNameExtractor(AExplicitFunctionDefinition node) {
59:
60:         List<String> parameterNameList = new ArrayList<String>();
61:         LinkedList<List<PPattern>> strList = node.getParamPatternList();
62:         List<PPattern> paramList = strList.getFirst();
63:         
64:•         for (PPattern str : paramList) {
65:                 parameterNameList.add(str.toString());
66:                 }
67:
68:                 return parameterNameList;
69:         }
70:         
71:         public List<String> implicitFunctionParameterNameExtractor(AImplicitFunctionDefinition node) {
72:
73:         List<String> parameterNameList = new ArrayList<String>();
74:         LinkedList<APatternListTypePair> strList = node.getParamPatterns();
75:
76:•         for(int i = 0;i < strList.size(); i++){
77:                 parameterNameList.add(strList.get(i).getPatterns().getFirst().toString());
78:         }
79:                 return parameterNameList;
80:         }
81: }