]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor/completion/SCLCompletionAssistProcessor.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.scl.ui / src / org / simantics / scl / ui / editor / completion / SCLCompletionAssistProcessor.java
index 8d9a56b8555e390c6fc64754c7ef23ba00f70256..f779435ead4ae4a6f35d6dbdbe92f408641641cc 100644 (file)
@@ -1,79 +1,79 @@
-package org.simantics.scl.ui.editor.completion;\r
-\r
-import org.eclipse.jface.text.BadLocationException;\r
-import org.eclipse.jface.text.IDocument;\r
-import org.eclipse.jface.text.ITextSelection;\r
-import org.eclipse.jface.text.ITextViewer;\r
-import org.eclipse.jface.text.contentassist.ICompletionProposal;\r
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;\r
-import org.eclipse.jface.text.contentassist.IContextInformation;\r
-import org.eclipse.jface.text.contentassist.IContextInformationValidator;\r
-\r
-public class SCLCompletionAssistProcessor implements IContentAssistProcessor {\r
-    \r
-//    private String lastPrefix = null;\r
-    private String lastError = "";\r
-    private SCLTextEditorEnvironment sclTextEditorEnvironment;\r
-    \r
-    public SCLCompletionAssistProcessor(SCLTextEditorEnvironment sclTextEditorEnvironment) {\r
-        this.sclTextEditorEnvironment = sclTextEditorEnvironment;\r
-    }\r
-\r
-    @Override\r
-    public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int tmpOffset) {\r
-        ITextSelection selection= (ITextSelection) viewer.getSelectionProvider().getSelection();\r
-        // adjust offset to end of normalized selection\r
-        if (selection.getOffset() == tmpOffset)\r
-            tmpOffset = selection.getOffset() + selection.getLength();\r
-        final int offset = tmpOffset;\r
-        IDocument document = viewer.getDocument();\r
-        String tmpPrefix = "";\r
-        try {\r
-            tmpPrefix = getPrefix(document, offset);\r
-        } catch (BadLocationException e) {\r
-            e.printStackTrace();\r
-        }\r
-        sclTextEditorEnvironment.updateEnvironment(document);\r
-        return sclTextEditorEnvironment.getCompletionProposals(tmpPrefix, offset);\r
-    }\r
-    \r
-    private static String getPrefix(IDocument doc, int offset) throws BadLocationException {\r
-        int docLen = doc.getLength();\r
-        if (doc == null || offset > docLen || docLen == 0)\r
-            return "";\r
-\r
-        int length= 0;\r
-        while (--offset >= 0 && Character.isJavaIdentifierPart(doc.getChar(offset)) || doc.getChar(offset) == '.')\r
-            length++;\r
-\r
-        return doc.get(offset + 1, length);\r
-    }\r
-    \r
-    @Override\r
-    public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {\r
-        return null;\r
-    }\r
-\r
-    private static final char[] AUTO_ACTIVATION_CHARS = new char[] { '.', '(' };\r
-    \r
-    @Override\r
-    public char[] getCompletionProposalAutoActivationCharacters() {\r
-        return AUTO_ACTIVATION_CHARS;\r
-    }\r
-\r
-    @Override\r
-    public char[] getContextInformationAutoActivationCharacters() {\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-    public String getErrorMessage() {\r
-        return lastError;\r
-    }\r
-\r
-    @Override\r
-    public IContextInformationValidator getContextInformationValidator() {\r
-        return null;\r
-    }\r
-\r
-}\r
+package org.simantics.scl.ui.editor.completion;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+
+public class SCLCompletionAssistProcessor implements IContentAssistProcessor {
+    
+//    private String lastPrefix = null;
+    private String lastError = "";
+    private SCLTextEditorEnvironment sclTextEditorEnvironment;
+    
+    public SCLCompletionAssistProcessor(SCLTextEditorEnvironment sclTextEditorEnvironment) {
+        this.sclTextEditorEnvironment = sclTextEditorEnvironment;
+    }
+
+    @Override
+    public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int tmpOffset) {
+        ITextSelection selection= (ITextSelection) viewer.getSelectionProvider().getSelection();
+        // adjust offset to end of normalized selection
+        if (selection.getOffset() == tmpOffset)
+            tmpOffset = selection.getOffset() + selection.getLength();
+        final int offset = tmpOffset;
+        IDocument document = viewer.getDocument();
+        String tmpPrefix = "";
+        try {
+            tmpPrefix = getPrefix(document, offset);
+        } catch (BadLocationException e) {
+            e.printStackTrace();
+        }
+        sclTextEditorEnvironment.updateEnvironment(document);
+        return sclTextEditorEnvironment.getCompletionProposals(tmpPrefix, offset);
+    }
+    
+    private static String getPrefix(IDocument doc, int offset) throws BadLocationException {
+        int docLen = doc.getLength();
+        if (doc == null || offset > docLen || docLen == 0)
+            return "";
+
+        int length= 0;
+        while (--offset >= 0 && Character.isJavaIdentifierPart(doc.getChar(offset)) || doc.getChar(offset) == '.')
+            length++;
+
+        return doc.get(offset + 1, length);
+    }
+    
+    @Override
+    public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
+        return null;
+    }
+
+    private static final char[] AUTO_ACTIVATION_CHARS = new char[] { '.', '(' };
+    
+    @Override
+    public char[] getCompletionProposalAutoActivationCharacters() {
+        return AUTO_ACTIVATION_CHARS;
+    }
+
+    @Override
+    public char[] getContextInformationAutoActivationCharacters() {
+        return null;
+    }
+
+    @Override
+    public String getErrorMessage() {
+        return lastError;
+    }
+
+    @Override
+    public IContextInformationValidator getContextInformationValidator() {
+        return null;
+    }
+
+}