1 /*
2  * Mode.java
3  *
4  * Copyright (C) 2021 by RStudio, PBC
5  *
6  * Unless you have received this program directly from RStudio pursuant
7  * to the terms of a commercial license agreement with RStudio, then
8  * this program is licensed to you under the terms of version 3 of the
9  * GNU Affero General Public License. This program is distributed WITHOUT
10  * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
11  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
12  * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
13  *
14  */
15 package org.rstudio.studio.client.workbench.views.source.editors.text.ace;
16 
17 import com.google.gwt.core.client.JavaScriptObject;
18 
19 public class Mode extends JavaScriptObject
20 {
21    public static class InsertChunkInfo extends JavaScriptObject
22    {
InsertChunkInfo()23       protected InsertChunkInfo() {}
24 
getValue()25       public native final String getValue() /*-{
26          return this.value;
27       }-*/;
28 
setValue(String value)29       public native final void setValue(String value) /*-{
30          this.value = value;
31       }-*/;
32 
33       /**
34        * @return Position cursor should be navigated to, relative to the
35        *       beginning of the value.
36        */
getCursorPosition()37       public native final Position getCursorPosition() /*-{
38          return this.position || {row: 0, column: 0};
39       }-*/;
40 
41       /**
42        * @return Position of content, relative to the beginning of the value.
43        */
getContentPosition()44       public native final Position getContentPosition() /*-{
45          return this.content_position || {row: 0, column: 0};
46       }-*/;
47 
48 
49    }
50 
Mode()51    protected Mode()
52    {
53    }
54 
hasCodeModel()55    public native final boolean hasCodeModel() /*-{
56       return typeof this.codeModel !== "undefined";
57    }-*/;
58 
getCodeModel()59    public native final CodeModel getCodeModel() /*-{
60       return this.codeModel || {};
61    }-*/;
62 
getRCodeModel()63    public native final CodeModel getRCodeModel() /*-{
64       if (typeof this.r_codeModel !== "undefined")
65          return this.r_codeModel;
66       else
67          return this.codeModel || {};
68    }-*/;
69 
getLanguageMode(Position position)70    public native final String getLanguageMode(Position position) /*-{
71       if (!this.getLanguageMode)
72          return null;
73       return this.getLanguageMode(position);
74    }-*/;
75 
getFoldingRules()76    public native final FoldingRules getFoldingRules() /*-{
77       return this.foldingRules;
78    }-*/;
79 
getInsertChunkInfo()80    public native final InsertChunkInfo getInsertChunkInfo() /*-{
81       return this.insertChunkInfo || null;
82    }-*/;
83 
getNextLineIndent( String state, String line, String tab, int tabSize, int row)84    public native final String getNextLineIndent(
85          String state,
86          String line,
87          String tab,
88          int tabSize,
89          int row) /*-{
90       return this.getNextLineIndent(state, line, tab, tabSize, row);
91    }-*/;
92 
getTokenizer()93    public native final Tokenizer getTokenizer() /*-{
94       return this.$tokenizer;
95    }-*/;
96 
getId()97    public native final String getId() /*-{ return this.$id; }-*/;
98 
setHighlightRFunctionCalls(boolean show)99    public native final void setHighlightRFunctionCalls(boolean show) /*-{
100       this.setHighlightRFunctionCalls && this.setHighlightRFunctionCalls(show);
101    }-*/;
102 
setInsertMatching(boolean value)103    public native final void setInsertMatching(boolean value) /*-{
104       this.insertMatching = value;
105    }-*/;
106 
107 }
108