Skip to content

Enable initial r support #2721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions data/fixtures/scopes/r/anonymousFunction.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
lapply(1:10, function(x) x^2)
---

[Content] =
[Domain] = 0:13-0:28
>---------------<
0| lapply(1:10, function(x) x^2)

[Removal] = 0:12-0:28
>----------------<
0| lapply(1:10, function(x) x^2)

[Leading delimiter] = 0:12-0:13
>-<
0| lapply(1:10, function(x) x^2)

[Insertion delimiter] = "\n"
30 changes: 30 additions & 0 deletions data/fixtures/scopes/r/argument.actual.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
func(1)
func(...)
func(x=1)
---

[#1 Content] =
[#1 Removal] =
[#1 Domain] = 0:5-0:6
>-<
0| func(1)

[#1 Insertion delimiter] = " "


[#2 Content] =
[#2 Removal] =
[#2 Domain] = 1:5-1:8
>---<
1| func(...)

[#2 Insertion delimiter] = " "


[#3 Content] =
[#3 Removal] =
[#3 Domain] = 2:5-2:8
>---<
2| func(x=1)

[#3 Insertion delimiter] = " "
13 changes: 13 additions & 0 deletions data/fixtures/scopes/r/argumentList.formal.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
abc <- function(x, y){ }
---

[Content] =
[Removal] = 0:16-0:20
>----<
0| abc <- function(x, y){ }

[Domain] = 0:7-0:24
>-----------------<
0| abc <- function(x, y){ }

[Insertion delimiter] = ", "
10 changes: 10 additions & 0 deletions data/fixtures/scopes/r/comment.line.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Hello world
---

[Content] =
[Removal] =
[Domain] = 0:0-0:13
>-------------<
0| # Hello world

[Insertion delimiter] = "\n"
10 changes: 10 additions & 0 deletions data/fixtures/scopes/r/functionCall.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
lapply(1:10, function(x) x^2)
---

[Content] =
[Removal] =
[Domain] = 0:0-0:29
>-----------------------------<
0| lapply(1:10, function(x) x^2)

[Insertion delimiter] = " "
10 changes: 10 additions & 0 deletions data/fixtures/scopes/r/functionCallee.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
lapply(1:10, function(x) x^2)
---

[Content] =
[Removal] =
[Domain] = 0:0-0:6
>------<
0| lapply(1:10, function(x) x^2)

[Insertion delimiter] = " "
19 changes: 19 additions & 0 deletions data/fixtures/scopes/r/functionName.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
abc <- function(arg){
TRUE
}
---

[Content] =
[Domain] = 0:0-0:3
>---<
0| abc <- function(arg){
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only case that I'm unsure about and is likely to need review, I'm wondering if it would make more sense to include the operator in this for removal and insertion? Although I might struggle a little bit with adding them as custom delimiters

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<- should probably be added as a trailing range. That way it will be deleted if you delete the name.
We do the same thing with = in value = 2


[Removal] = 0:0-0:4
>----<
0| abc <- function(arg){

[Trailing delimiter] = 0:3-0:4
>-<
0| abc <- function(arg){

[Insertion delimiter] = " "
63 changes: 63 additions & 0 deletions data/fixtures/scopes/r/ifStatement.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
if(FALSE) 0

if(TRUE){ 1 }

if(TRUE){
1
} else {
0
}
---

[#1 Content] =
[#1 Domain] = 0:0-0:11
>-----------<
0| if(FALSE) 0

[#1 Removal] = 0:0-2:0
>-----------
0| if(FALSE) 0
1|
2| if(TRUE){ 1 }
<

[#1 Insertion delimiter] = "\n"


[#2 Content] =
[#2 Domain] = 2:0-2:13
>-------------<
2| if(TRUE){ 1 }

[#2 Removal] = 2:0-4:0
>-------------
2| if(TRUE){ 1 }
3|
4| if(TRUE){
<

[#2 Insertion delimiter] = "\n"


[#3 Content] =
[#3 Domain] = 4:0-8:1
>---------
4| if(TRUE){
5| 1
6| } else {
7| 0
8| }
-<

[#3 Removal] = 2:13-8:1
>
2| if(TRUE){ 1 }
3|
4| if(TRUE){
5| 1
6| } else {
7| 0
8| }
-<

[#3 Insertion delimiter] = "\n"
34 changes: 34 additions & 0 deletions data/fixtures/scopes/r/name.assignment.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
hello <- "world"
hello = "world"
---

[#1 Content] =
[#1 Domain] = 0:0-0:5
>-----<
0| hello <- "world"

[#1 Removal] = 0:0-0:6
>------<
0| hello <- "world"

[#1 Trailing delimiter] = 0:5-0:6
>-<
0| hello <- "world"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<- should be part off the trailing range. Have a look at how we do this in other languages.


[#1 Insertion delimiter] = " "


[#2 Content] =
[#2 Domain] = 1:0-1:5
>-----<
1| hello = "world"

[#2 Removal] = 1:0-1:6
>------<
1| hello = "world"

[#2 Trailing delimiter] = 1:5-1:6
>-<
1| hello = "world"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= should be part of the trailing range


[#2 Insertion delimiter] = " "
34 changes: 34 additions & 0 deletions data/fixtures/scopes/r/name.variable.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
hello <- "world"
hello = "world"
---

[#1 Content] =
[#1 Domain] = 0:0-0:5
>-----<
0| hello <- "world"

[#1 Removal] = 0:0-0:6
>------<
0| hello <- "world"

[#1 Trailing delimiter] = 0:5-0:6
>-<
0| hello <- "world"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<- should be part of the trailing range


[#1 Insertion delimiter] = " "


[#2 Content] =
[#2 Domain] = 1:0-1:5
>-----<
1| hello = "world"

[#2 Removal] = 1:0-1:6
>------<
1| hello = "world"

[#2 Trailing delimiter] = 1:5-1:6
>-<
1| hello = "world"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= should be part of the trailing range


[#2 Insertion delimiter] = " "
44 changes: 44 additions & 0 deletions data/fixtures/scopes/r/namedFunction.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
abc <- function(arg){
TRUE
}
abc = function(arg){
TRUE
}
---

[#1 Content] =
[#1 Domain] = 0:0-2:1
>---------------------
0| abc <- function(arg){
1| TRUE
2| }
-<

[#1 Removal] = 0:0-3:0
>---------------------
0| abc <- function(arg){
1| TRUE
2| }
3| abc = function(arg){
<

[#1 Insertion delimiter] = "\n\n"


[#2 Content] =
[#2 Domain] = 3:0-5:1
>--------------------
3| abc = function(arg){
4| TRUE
5| }
-<

[#2 Removal] = 2:1-5:1
>
2| }
3| abc = function(arg){
4| TRUE
5| }
-<

[#2 Insertion delimiter] = "\n\n"
34 changes: 34 additions & 0 deletions data/fixtures/scopes/r/value.assignment.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
hello <- "world"
hello = "world"
---

[#1 Content] =
[#1 Domain] = 0:9-0:16
>-------<
0| hello <- "world"

[#1 Removal] = 0:8-0:16
>--------<
0| hello <- "world"

[#1 Leading delimiter] = 0:8-0:9
>-<
0| hello <- "world"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<- should be part of the leading range


[#1 Insertion delimiter] = " "


[#2 Content] =
[#2 Domain] = 1:8-1:15
>-------<
1| hello = "world"

[#2 Removal] = 1:7-1:15
>--------<
1| hello = "world"

[#2 Leading delimiter] = 1:7-1:8
>-<
1| hello = "world"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= should be part of the leading range


[#2 Insertion delimiter] = " "
34 changes: 34 additions & 0 deletions data/fixtures/scopes/r/value.variable.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
hello <- "world"
hello = "world"
---

[#1 Content] =
[#1 Domain] = 0:9-0:16
>-------<
0| hello <- "world"

[#1 Removal] = 0:8-0:16
>--------<
0| hello <- "world"

[#1 Leading delimiter] = 0:8-0:9
>-<
0| hello <- "world"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<- should be part of the leading range


[#1 Insertion delimiter] = " "


[#2 Content] =
[#2 Domain] = 1:8-1:15
>-------<
1| hello = "world"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= should be part of the leading range


[#2 Removal] = 1:7-1:15
>--------<
1| hello = "world"

[#2 Leading delimiter] = 1:7-1:8
>-<
1| hello = "world"

[#2 Insertion delimiter] = " "
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { luaScopeSupport } from "./lua";
import { markdownScopeSupport } from "./markdown";
import { phpScopeSupport } from "./php";
import { pythonScopeSupport } from "./python";
import { rScopeSupport } from "./r";
import { rubyScopeSupport } from "./ruby";
import { rustScopeSupport } from "./rust";
import { scalaScopeSupport } from "./scala";
Expand Down Expand Up @@ -51,6 +52,7 @@ export const languageScopeSupport: StringRecord<LanguageScopeSupportFacetMap> =
markdown: markdownScopeSupport,
php: phpScopeSupport,
python: pythonScopeSupport,
r: rScopeSupport,
ruby: rubyScopeSupport,
rust: rustScopeSupport,
scala: scalaScopeSupport,
Expand Down
Loading