]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - 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
diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/assist/SCLContentProposal.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/assist/SCLContentProposal.java
new file mode 100644 (file)
index 0000000..f111780
--- /dev/null
@@ -0,0 +1,55 @@
+package org.simantics.scl.ui.assist;\r
+\r
+import org.eclipse.jface.fieldassist.IContentProposal;\r
+import org.simantics.scl.compiler.common.names.Name;\r
+import org.simantics.scl.compiler.elaboration.modules.SCLValue;\r
+import org.simantics.scl.compiler.types.Type;\r
+\r
+public class SCLContentProposal implements IContentProposal {\r
+\r
+    private final String content;\r
+    private final String name;\r
+    private final String module;\r
+    private final Type type;\r
+    private final String documentation;\r
+    \r
+    public SCLContentProposal(SCLValue value) {\r
+        Name n = value.getName();\r
+        this.name = n.name;\r
+        this.module = n.module;\r
+//        this.content = name.substring(prefixLength-namespaceLength);\r
+        this.content = name;\r
+        this.type = value.getType();\r
+        this.documentation = value.getDocumentation();\r
+    }\r
+    \r
+    public SCLContentProposal(String name, String module, Type type) {\r
+        this.name = name;\r
+        this.module = module;\r
+//        this.content = name.substring(prefixLength-namespaceLength);\r
+        this.content = name;\r
+        this.type = type;\r
+        this.documentation = null;\r
+    }\r
+    \r
+    @Override\r
+    public String getContent() {\r
+        return content;\r
+    }\r
+\r
+    @Override\r
+    public int getCursorPosition() {\r
+        return content.length();\r
+    }\r
+\r
+    @Override\r
+    public String getLabel() {\r
+        return name + " :: " + type + "  (" + module + ")";\r
+    }\r
+\r
+    @Override\r
+    public String getDescription() {\r
+        return documentation;\r
+    }\r
+\r
+}\r