-
-
Notifications
You must be signed in to change notification settings - Fork 60
Language annotation support #343
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
Merged
+539
−82
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
{ | ||
# Basic language annotation cases | ||
luaScript = /* lua */ '' | ||
print("Hello, world!") | ||
local x = 42 | ||
''; | ||
|
||
# With extra whitespace | ||
jsCode = /* javascript */ '' | ||
console.log("Hello from JS"); | ||
const x = 42; | ||
''; | ||
|
||
# missing whitespace after comment | ||
noSpace = /*python*/'' | ||
print("No space after comment") | ||
''; | ||
|
||
# Language annotation with indented multiline string | ||
indentedCode = { | ||
script = /* python */ '' | ||
import os | ||
def main(): | ||
print("Indented Python") | ||
''; | ||
}; | ||
|
||
# Language annotation followed by regular string | ||
regularString = /* json */ "{ \"key\": \"value\" }"; | ||
multilineRegularString = /* js */ " | ||
console.log('Hello, world!'); | ||
"; | ||
|
||
# Multiple block comments in sequence | ||
sequentialComments = /* first */ /* second */ '' | ||
some content | ||
''; | ||
|
||
# Block comment with line breaks | ||
multilineBlockComment = /* this is a | ||
multiline comment */ '' | ||
content | ||
''; | ||
|
||
# Mixed comment styles | ||
mixedComments = /* inline */ # line comment | ||
'' | ||
content | ||
''; | ||
|
||
# Language annotation in function arguments | ||
processCode = builtins.readFile (/* lua */ '' | ||
return "Hello" | ||
''); | ||
# without parentheses | ||
processCode2 = builtins.readFile /* lua */ '' | ||
return "Hello" | ||
''; | ||
|
||
# Language annotation in list | ||
scripts = [ | ||
/* bash */ '' | ||
echo "Script 1" | ||
'' | ||
/* python */ '' | ||
print("Script 2") | ||
'' | ||
/* ruby */ "puts 'Script 3'" | ||
/* js */ | ||
"console.log('Script 4');" | ||
]; | ||
|
||
aboveString = | ||
/* bash */ | ||
"echo 'Above string'"; | ||
|
||
# Language annotation in attribute set | ||
languages = { | ||
lua = /* lua */ '' | ||
print("Lua") | ||
''; | ||
python = /* python */ '' | ||
print("Python") | ||
''; | ||
}; | ||
|
||
# Edge case: empty language annotation | ||
emptyAnnotation = /**/ '' | ||
content without annotation | ||
''; | ||
|
||
# Edge case: language annotation with special characters | ||
specialChars = /* c++ */ '' | ||
#include <iostream> | ||
int main() { return 0; } | ||
''; | ||
withDot = /* .ts */ '' | ||
let x: number = 42; | ||
''; | ||
|
||
# Edge case: very long language annotation | ||
longAnnotation = /* this-is-a-very-long-language-annotation-that-might-affect-line-length */ '' | ||
content | ||
''; | ||
|
||
# Language annotation not followed by string | ||
object = /* json */ { key = "value"; }; | ||
fn = /* foo */ x: x + 1; | ||
fnCall = /* foo */ fnName "bar"; | ||
|
||
|
||
# Language annotation with interpolated expressions | ||
interpolatedExpr = /* bash */ '' | ||
${/* inline-comment */ "echo hello"} | ||
''; | ||
|
||
# Language annotation in let expression | ||
letExpr = let | ||
code = /* python */ '' | ||
print("In let") | ||
''; | ||
in code; | ||
|
||
# Language annotation in function definition | ||
mkScript = lang: content: /* lang */ '' | ||
${content} | ||
''; | ||
|
||
# on in block | ||
expr = | ||
let | ||
in | ||
/* bash */ '' | ||
echo "Hello" | ||
''; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This input is not idempotent in master
so we're also fixing this bug here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but also I can imagine inputs not covered by this PR which still exhibit this bug, so it might be worth tracking separately