]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/assist/SCLContentProposal.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scl.ui / src / org / simantics / scl / ui / assist / SCLContentProposal.java
1 package org.simantics.scl.ui.assist;\r
2 \r
3 import org.eclipse.jface.fieldassist.IContentProposal;\r
4 import org.simantics.scl.compiler.common.names.Name;\r
5 import org.simantics.scl.compiler.elaboration.modules.SCLValue;\r
6 import org.simantics.scl.compiler.types.Type;\r
7 \r
8 public class SCLContentProposal implements IContentProposal {\r
9 \r
10     private final String content;\r
11     private final String name;\r
12     private final String module;\r
13     private final Type type;\r
14     private final String documentation;\r
15     \r
16     public SCLContentProposal(SCLValue value) {\r
17         Name n = value.getName();\r
18         this.name = n.name;\r
19         this.module = n.module;\r
20 //        this.content = name.substring(prefixLength-namespaceLength);\r
21         this.content = name;\r
22         this.type = value.getType();\r
23         this.documentation = value.getDocumentation();\r
24     }\r
25     \r
26     public SCLContentProposal(String name, String module, Type type) {\r
27         this.name = name;\r
28         this.module = module;\r
29 //        this.content = name.substring(prefixLength-namespaceLength);\r
30         this.content = name;\r
31         this.type = type;\r
32         this.documentation = null;\r
33     }\r
34     \r
35     @Override\r
36     public String getContent() {\r
37         return content;\r
38     }\r
39 \r
40     @Override\r
41     public int getCursorPosition() {\r
42         return content.length();\r
43     }\r
44 \r
45     @Override\r
46     public String getLabel() {\r
47         return name + " :: " + type + "  (" + module + ")";\r
48     }\r
49 \r
50     @Override\r
51     public String getDescription() {\r
52         return documentation;\r
53     }\r
54 \r
55 }\r