Skip to content
  • Sponsor Camelcade/Perl5-IDEA

  • Notifications You must be signed in to change notification settings
  • Fork 75

Commit 563c276

Browse files
committedAug 18, 2024·
#2876 #2873 Better handling of async/await syntax
- `await` is now parsed as an unary named operator - `async`/`await` are now implicitly declared and auto-imported as subs from the package, making completion and quickdoc work as expected Fixes #2876 #2873 See also: #2878 #2877 #2875
1 parent b006c36 commit 563c276

File tree

16 files changed

+9725
-8852
lines changed

16 files changed

+9725
-8852
lines changed
 

‎plugin/core/grammar/Perl.flex

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ TYPES_TINY = "ArrayRef"|"ConsumerOf"|"CycleTuple"|"Dict"|"Enum"|"HasMethods"|"Ha
134134
READONLY="Readonly"
135135

136136
// auto-generated by handlesubs.pl
137-
NAMED_UNARY_OPERATORS = "umask"|"srand"|"sleep"|"setservent"|"setprotoent"|"setnetent"|"sethostent"|"reset"|"readline"|"rand"|"prototype"|"localtime"|"gmtime"|"getsockname"|"getpwuid"|"getpwnam"|"getprotobyname"|"getpgrp"|"getpeername"|"getnetbyname"|"gethostbyname"|"getgrnam"|"getgrgid"|"exists"|"caller"
137+
NAMED_UNARY_OPERATORS = "umask"|"srand"|"sleep"|"setservent"|"setprotoent"|"setnetent"|"sethostent"|"reset"|"readline"|"rand"|"prototype"|"localtime"|"gmtime"|"getsockname"|"getpwuid"|"getpwnam"|"getprotobyname"|"getpgrp"|"getpeername"|"getnetbyname"|"gethostbyname"|"getgrnam"|"getgrgid"|"exists"|"caller"|"await"
138138
BARE_HANDLE_ACCEPTORS = "truncate"|"syswrite"|"sysseek"|"sysread"|"sysopen"|"stat"|"select"|"seekdir"|"seek"|"read"|"opendir"|"open"|"lstat"|"ioctl"|"flock"|"fcntl"|"binmode"
139139
NAMED_UNARY_BARE_HANDLE_ACCEPTORS = "write"|"telldir"|"tell"|"rewinddir"|"readdir"|"getc"|"fileno"|"eof"|"closedir"|"close"|"chdir"
140140
LIST_OPERATORS = "warn"|"waitpid"|"vec"|"utime"|"untie"|"tied"|"tie"|"system"|"syscall"|"symlink"|"substr"|"sprintf"|"socketpair"|"socket"|"shutdown"|"shmwrite"|"shmread"|"shmget"|"shmctl"|"setsockopt"|"setpriority"|"setpgrp"|"send"|"semop"|"semget"|"semctl"|"rindex"|"rename"|"recv"|"pipe"|"pack"|"msgsnd"|"msgrcv"|"msgget"|"msgctl"|"lock"|"listen"|"link"|"kill"|"join"|"index"|"getsockopt"|"getservbyport"|"getservbyname"|"getprotobynumber"|"getpriority"|"getnetbyaddr"|"gethostbyaddr"|"formline"|"exec"|"dump"|"die"|"dbmopen"|"dbmclose"|"crypt"|"connect"|"chown"|"chmod"|"bind"|"atan2"|"accept"

‎plugin/core/src/main/gen/com/perl5/lang/perl/lexer/PerlLexer.java

+8,863-8,843
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2015-2024 Alexandr Evstigneev
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.perl5.lang.perl.extensions.futureAsyncAwait;
18+
19+
import com.perl5.lang.perl.psi.references.PerlImplicitDeclarationsProvider;
20+
import org.jetbrains.annotations.NotNull;
21+
22+
public class FutureAsyncAwaitImplicitDeclarationsProvider extends PerlImplicitDeclarationsProvider {
23+
@Override
24+
public @NotNull String getDataFileName() {
25+
return "perlData/FutureAsyncAwait.xml";
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2015-2024 Alexandr Evstigneev
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.perl5.lang.perl.extensions.futureAsyncAwait;
18+
19+
import com.perl5.lang.perl.extensions.packageprocessor.PerlPackageOptionsProvider;
20+
import com.perl5.lang.perl.extensions.packageprocessor.PerlPackageProcessorBase;
21+
import com.perl5.lang.perl.psi.impl.PerlUseStatementElement;
22+
import org.jetbrains.annotations.NotNull;
23+
24+
import java.util.Collections;
25+
import java.util.List;
26+
import java.util.Map;
27+
import java.util.Set;
28+
29+
public class FutureAsyncAwaitPackageProcessor extends PerlPackageProcessorBase implements PerlPackageOptionsProvider {
30+
/**
31+
* These are actually keywords, but to avoid writing custom code for documentation/completion, we treat them here as exported methods
32+
* and lexer handles the rest.
33+
*/
34+
private static final List<String> METHODS = List.of("async", "await");
35+
36+
@Override
37+
public void addExports(@NotNull PerlUseStatementElement useStatement,
38+
@NotNull Set<? super String> export,
39+
@NotNull Set<? super String> exportOk) {
40+
export.addAll(METHODS);
41+
exportOk.addAll(METHODS);
42+
}
43+
44+
@Override
45+
public @NotNull Map<String, String> getOptions() {
46+
return Collections.emptyMap();
47+
}
48+
49+
@Override
50+
public @NotNull Map<String, String> getOptionsBundles() {
51+
return Collections.emptyMap();
52+
}
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!--
2+
~ Copyright 2015-2020 Alexandr Evstigneev
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
<xml>
17+
<package name="Future::AsyncAwait">
18+
<!-- This is actually a keyword used for async subs declarations -->
19+
<sub name="async"/>
20+
<!-- This is actually a keyword behaving like unary named operator -->
21+
<sub name="await">
22+
<arguments>
23+
<argument name="future" type="$"/>
24+
</arguments>
25+
</sub>
26+
</package>
27+
</xml>

‎plugin/src/main/resources/META-INF/plugin.xml

+3
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@
169169
implementationClass="com.perl5.lang.perl.extensions.packageprocessor.impl.FileSpecFunctionsProcessor"/>
170170
<packageProcessor key="Log::Log4perl"
171171
implementationClass="com.perl5.lang.perl.extensions.log4perl.Log4PerlPackageProcessor"/>
172+
<packageProcessor key="Future::AsyncAwait"
173+
implementationClass="com.perl5.lang.perl.extensions.futureAsyncAwait.FutureAsyncAwaitPackageProcessor"/>
172174

173175
<parserExtension implementation="com.perl5.lang.perl.parser.PerlSwitchParserExtensionImpl"/>
174176
<parserExtension implementation="com.perl5.lang.perl.parser.MooseParserExtension"/>
@@ -191,6 +193,7 @@
191193
<implicitSubsProvider implementation="com.perl5.lang.perl.extensions.readonly.ReadonlyImplicitDeclarationsProvider"/>
192194
<implicitSubsProvider implementation="com.perl5.lang.perl.extensions.log4perl.Log4PerlImplicitDeclarationsProvider"/>
193195
<implicitSubsProvider implementation="com.perl5.lang.perl.extensions.moo.MooImplicitSubsProvider"/>
196+
<implicitSubsProvider implementation="com.perl5.lang.perl.extensions.futureAsyncAwait.FutureAsyncAwaitImplicitDeclarationsProvider"/>
194197
</extensions>
195198

196199
<extensions defaultExtensionNs="com.intellij">

‎plugin/src/test/java/completion/PerlCompletionTest.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2023 Alexandr Evstigneev
2+
* Copyright 2015-2024 Alexandr Evstigneev
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,6 +36,14 @@ protected String getBaseDataPath() {
3636
return "completion/perl";
3737
}
3838

39+
@Test
40+
public void testAsyncAwait() { doTestFuture(); }
41+
42+
private void doTestFuture() {
43+
withFuture();
44+
doTestWithTypeText();
45+
}
46+
3947
@Test
4048
public void testUseCGISubs() { doTestCgi(); }
4149

‎plugin/src/test/java/documentation/PerlQuickDocTest.java

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2023 Alexandr Evstigneev
2+
* Copyright 2015-2024 Alexandr Evstigneev
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -56,21 +56,28 @@ public void testIsaOperator() {
5656
}
5757

5858
@Test
59-
public void testAsyncSub() {
59+
public void testAwaitSub() {
60+
doTestFuture();
61+
}
62+
63+
private void doTestFuture() {
6064
withFuture();
6165
doTest528();
6266
}
6367

68+
@Test
69+
public void testAsyncSub() {
70+
doTestFuture();
71+
}
72+
6473
@Test
6574
public void testAsyncSubExpr() {
66-
withFuture();
67-
doTest528();
75+
doTestFuture();
6876
}
6977

7078
@Test
7179
public void testAsyncMethod() {
72-
withFuture();
73-
doTest528();
80+
doTestFuture();
7481
}
7582

7683
@Test

‎plugin/src/test/java/unit/perl/parser/PerlParserLikeTest.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2023 Alexandr Evstigneev
2+
* Copyright 2015-2024 Alexandr Evstigneev
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,6 +29,9 @@ protected String getBaseDataPath() {
2929
@Test
3030
public void testSubSignatureDefault() { doTest(); }
3131

32+
@Test
33+
public void testAsyncAwait() { doTest(); }
34+
3235
@Test
3336
public void testUndefHash() { doTest(); }
3437

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
use Future::AsyncAwait;
2+
a<caret>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Text: af; Tail: null; Type: after statement; Icon: /template.svg; Type Icon: null
2+
Lookups: af
3+
Live template: Perl5: Moose/af
4+
Text: ar; Tail: null; Type: around statement; Icon: /template.svg; Type Icon: null
5+
Lookups: ar
6+
Live template: Perl5: Moose/ar
7+
Text: as; Tail: null; Type: async sub definition; Icon: /template.svg; Type Icon: null
8+
Lookups: as
9+
Live template: Perl5/as
10+
Text: async; Tail: null; Type: Future::AsyncAwait; Icon: /subroutine_gutter_icon.png; Type Icon: null
11+
Lookups: async
12+
PsiElement: Implicit sub: async()
13+
Text: au; Tail: null; Type: augment statement; Icon: /template.svg; Type Icon: null
14+
Lookups: au
15+
Live template: Perl5: Moose/au
16+
Text: await; Tail: ($future); Type: Future::AsyncAwait; Icon: /subroutine_gutter_icon.png; Type Icon: null
17+
Lookups: await
18+
PsiElement: Implicit sub: await($future)($future)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
use Future::AsyncAwait;
2+
say aw<caret>ait something();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<p><a href="psi_element://Future%3A%3AAsyncAwait">Future::AsyncAwait</a>: <a href="psi_element://Future%3A%3AAsyncAwait%2FDESCRIPTION">DESCRIPTION</a></p><h2><code>await</code></h2><p style="padding-bottom: 10px;">The <code>await</code> keyword forms an expression which takes a <code>Future</code> instance as
2+
an operand and yields the eventual result of it. Superficially it can be
3+
thought of similar to invoking the <code>get</code> method on the future.</p>
4+
<div style="padding-bottom: 10px;"><pre><code> my $result = await $f;
5+
6+
my $result = $f-&gt;get;</code></pre></div>
7+
<p style="padding-bottom: 10px;">However, the key difference (and indeed the entire reason for being a new
8+
syntax keyword) is the behaviour when the future is still pending and is not
9+
yet complete. Whereas the simple <code>get</code> method would block until the future is
10+
complete, the <code>await</code> keyword causes its entire containing function to become
11+
suspended, making it return a new (pending) future instance. It waits in this
12+
state until the future it was waiting on completes, at which point it wakes up
13+
and resumes execution from the point of the <code>await</code> expression. When the
14+
now-resumed function eventually finishes (either by returning a value or
15+
throwing an exception), this value is set as the result of the future it had
16+
returned earlier.</p>
17+
<p style="padding-bottom: 10px;"><code>await</code> provides scalar context to its controlling expression.</p>
18+
<div style="padding-bottom: 10px;"><pre><code> async sub func {
19+
# this function is invoked in scalar context
20+
}
21+
22+
await func();</code></pre></div>
23+
<p style="padding-bottom: 10px;">Because the <code>await</code> keyword may cause its containing function to suspend
24+
early, returning a pending future instance, it is only allowed inside
25+
<code>async</code>-marked subs.</p>
26+
<p style="padding-bottom: 10px;">The converse is not true; just because a function is marked as <code>async</code> does
27+
not require it to make use of the <code>await</code> expression. It is still useful to
28+
turn the result of that function into a future, entirely without <code>await</code>ing
29+
on any itself.</p>
30+
<p style="padding-bottom: 10px;">Any function that doesn't actually await anything, and just returns immediate
31+
futures can be neatened by this module too.</p>
32+
<p style="padding-bottom: 10px;">Instead of writing</p>
33+
<div style="padding-bottom: 10px;"><pre><code> sub imm
34+
{
35+
...
36+
return Future-&gt;done( @result );
37+
}</code></pre></div>
38+
<p style="padding-bottom: 10px;">you can now simply write</p>
39+
<div style="padding-bottom: 10px;"><pre><code> async sub imm
40+
{
41+
...
42+
return @result;
43+
}</code></pre></div>
44+
<p style="padding-bottom: 10px;">with the added side-benefit that any exceptions thrown by the elided code will
45+
be turned into an immediate-failed <code>Future</code> rather than making the call
46+
itself propagate the exception, which is usually what you wanted when dealing
47+
with futures.</p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,314 @@
1+
use
2+
PERL_KEYWORD => DEFAULT_KEYWORD
3+
v5.14
4+
PERL_VERSION => PERL_NUMBER => DEFAULT_NUMBER
5+
;
6+
PERL_SEMICOLON => DEFAULT_SEMICOLON
7+
use
8+
PERL_KEYWORD => DEFAULT_KEYWORD
9+
Future::AsyncAwait
10+
PERL_PACKAGE => DEFAULT_CLASS_NAME => DEFAULT_IDENTIFIER => TEXT
11+
;
12+
PERL_SEMICOLON => DEFAULT_SEMICOLON
13+
use
14+
PERL_KEYWORD => DEFAULT_KEYWORD
15+
warnings
16+
PERL_PACKAGE => DEFAULT_CLASS_NAME => DEFAULT_IDENTIFIER => TEXT
17+
FATAL
18+
PERL_SQ_STRING => DEFAULT_STRING
19+
=>
20+
PERL_COMMA => DEFAULT_COMMA
21+
'
22+
PERL_SQ_STRING => DEFAULT_STRING
23+
all
24+
PERL_SQ_STRING => DEFAULT_STRING
25+
'
26+
PERL_SQ_STRING => DEFAULT_STRING
27+
;
28+
PERL_SEMICOLON => DEFAULT_SEMICOLON
29+
use
30+
PERL_KEYWORD => DEFAULT_KEYWORD
31+
strict
32+
PERL_PACKAGE => DEFAULT_CLASS_NAME => DEFAULT_IDENTIFIER => TEXT
33+
;
34+
PERL_SEMICOLON => DEFAULT_SEMICOLON
35+
sub
36+
PERL_KEYWORD => DEFAULT_KEYWORD
37+
myecho
38+
PERL_SUB => DEFAULT_FUNCTION_CALL => DEFAULT_IDENTIFIER => TEXT
39+
{
40+
PERL_BRACES => DEFAULT_BRACES
41+
return
42+
PERL_KEYWORD => DEFAULT_KEYWORD
43+
shift
44+
PERL_KEYWORD => DEFAULT_KEYWORD
45+
;
46+
PERL_SEMICOLON => DEFAULT_SEMICOLON
47+
}
48+
PERL_BRACES => DEFAULT_BRACES
49+
async
50+
PERL_KEYWORD => DEFAULT_KEYWORD
51+
sub
52+
PERL_KEYWORD => DEFAULT_KEYWORD
53+
asyncecho
54+
PERL_SUB => DEFAULT_FUNCTION_CALL => DEFAULT_IDENTIFIER => TEXT
55+
{
56+
PERL_BRACES => DEFAULT_BRACES
57+
return
58+
PERL_KEYWORD => DEFAULT_KEYWORD
59+
shift
60+
PERL_KEYWORD => DEFAULT_KEYWORD
61+
;
62+
PERL_SEMICOLON => DEFAULT_SEMICOLON
63+
}
64+
PERL_BRACES => DEFAULT_BRACES
65+
async
66+
PERL_KEYWORD => DEFAULT_KEYWORD
67+
sub
68+
PERL_KEYWORD => DEFAULT_KEYWORD
69+
mysub
70+
PERL_SUB => DEFAULT_FUNCTION_CALL => DEFAULT_IDENTIFIER => TEXT
71+
{
72+
PERL_BRACES => DEFAULT_BRACES
73+
say
74+
PERL_KEYWORD => DEFAULT_KEYWORD
75+
myecho
76+
PERL_HANDLE => PERL_GLOB => DEFAULT_IDENTIFIER => TEXT
77+
42
78+
PERL_NUMBER => DEFAULT_NUMBER
79+
+
80+
PERL_OPERATOR => DEFAULT_OPERATION_SIGN
81+
42
82+
PERL_NUMBER => DEFAULT_NUMBER
83+
;
84+
PERL_SEMICOLON => DEFAULT_SEMICOLON
85+
say
86+
PERL_KEYWORD => DEFAULT_KEYWORD
87+
myecho
88+
PERL_SUB => DEFAULT_FUNCTION_CALL => DEFAULT_IDENTIFIER => TEXT
89+
(
90+
PERL_PARENTESS => DEFAULT_PARENTHS
91+
42
92+
PERL_NUMBER => DEFAULT_NUMBER
93+
)
94+
PERL_PARENTESS => DEFAULT_PARENTHS
95+
+
96+
PERL_OPERATOR => DEFAULT_OPERATION_SIGN
97+
42
98+
PERL_NUMBER => DEFAULT_NUMBER
99+
;
100+
PERL_SEMICOLON => DEFAULT_SEMICOLON
101+
say
102+
PERL_KEYWORD => DEFAULT_KEYWORD
103+
await
104+
PERL_SUB_BUILTIN => PERL_SUB => DEFAULT_FUNCTION_CALL => DEFAULT_IDENTIFIER => TEXT
105+
asyncecho
106+
PERL_SUB => DEFAULT_FUNCTION_CALL => DEFAULT_IDENTIFIER => TEXT
107+
(
108+
PERL_PARENTESS => DEFAULT_PARENTHS
109+
42
110+
PERL_NUMBER => DEFAULT_NUMBER
111+
)
112+
PERL_PARENTESS => DEFAULT_PARENTHS
113+
+
114+
PERL_OPERATOR => DEFAULT_OPERATION_SIGN
115+
42
116+
PERL_NUMBER => DEFAULT_NUMBER
117+
;
118+
PERL_SEMICOLON => DEFAULT_SEMICOLON
119+
# Expected a blessed object reference to await at ... unary operator
120+
PERL_COMMENT => DEFAULT_LINE_COMMENT
121+
say
122+
PERL_KEYWORD => DEFAULT_KEYWORD
123+
await
124+
PERL_SUB_BUILTIN => PERL_SUB => DEFAULT_FUNCTION_CALL => DEFAULT_IDENTIFIER => TEXT
125+
(
126+
PERL_PARENTESS => DEFAULT_PARENTHS
127+
asyncecho
128+
PERL_SUB => DEFAULT_FUNCTION_CALL => DEFAULT_IDENTIFIER => TEXT
129+
(
130+
PERL_PARENTESS => DEFAULT_PARENTHS
131+
42
132+
PERL_NUMBER => DEFAULT_NUMBER
133+
)
134+
PERL_PARENTESS => DEFAULT_PARENTHS
135+
)
136+
PERL_PARENTESS => DEFAULT_PARENTHS
137+
+
138+
PERL_OPERATOR => DEFAULT_OPERATION_SIGN
139+
42
140+
PERL_NUMBER => DEFAULT_NUMBER
141+
;
142+
PERL_SEMICOLON => DEFAULT_SEMICOLON
143+
say
144+
PERL_KEYWORD => DEFAULT_KEYWORD
145+
await
146+
PERL_SUB_BUILTIN => PERL_SUB => DEFAULT_FUNCTION_CALL => DEFAULT_IDENTIFIER => TEXT
147+
asyncecho
148+
PERL_SUB => DEFAULT_FUNCTION_CALL => DEFAULT_IDENTIFIER => TEXT
149+
(
150+
PERL_PARENTESS => DEFAULT_PARENTHS
151+
42
152+
PERL_NUMBER => DEFAULT_NUMBER
153+
)
154+
PERL_PARENTESS => DEFAULT_PARENTHS
155+
,
156+
PERL_COMMA => DEFAULT_COMMA
157+
24
158+
PERL_NUMBER => DEFAULT_NUMBER
159+
;
160+
PERL_SEMICOLON => DEFAULT_SEMICOLON
161+
return
162+
PERL_KEYWORD => DEFAULT_KEYWORD
163+
(
164+
PERL_PARENTESS => DEFAULT_PARENTHS
165+
(
166+
PERL_PARENTESS => DEFAULT_PARENTHS
167+
await
168+
PERL_SUB_BUILTIN => PERL_SUB => DEFAULT_FUNCTION_CALL => DEFAULT_IDENTIFIER => TEXT
169+
asyncecho
170+
PERL_SUB => DEFAULT_FUNCTION_CALL => DEFAULT_IDENTIFIER => TEXT
171+
(
172+
PERL_PARENTESS => DEFAULT_PARENTHS
173+
42
174+
PERL_NUMBER => DEFAULT_NUMBER
175+
)
176+
PERL_PARENTESS => DEFAULT_PARENTHS
177+
)
178+
PERL_PARENTESS => DEFAULT_PARENTHS
179+
+
180+
PERL_OPERATOR => DEFAULT_OPERATION_SIGN
181+
42
182+
PERL_NUMBER => DEFAULT_NUMBER
183+
)
184+
PERL_PARENTESS => DEFAULT_PARENTHS
185+
;
186+
PERL_SEMICOLON => DEFAULT_SEMICOLON
187+
}
188+
PERL_BRACES => DEFAULT_BRACES
189+
async
190+
PERL_KEYWORD => DEFAULT_KEYWORD
191+
sub
192+
PERL_KEYWORD => DEFAULT_KEYWORD
193+
sample_syntax
194+
PERL_SUB => DEFAULT_FUNCTION_CALL => DEFAULT_IDENTIFIER => TEXT
195+
{
196+
PERL_BRACES => DEFAULT_BRACES
197+
my
198+
PERL_KEYWORD => DEFAULT_KEYWORD
199+
$
200+
PERL_SCALAR => DEFAULT_IDENTIFIER => TEXT
201+
result
202+
PERL_SCALAR => DEFAULT_IDENTIFIER => TEXT
203+
=
204+
PERL_OPERATOR => DEFAULT_OPERATION_SIGN
205+
await
206+
PERL_SUB_BUILTIN => PERL_SUB => DEFAULT_FUNCTION_CALL => DEFAULT_IDENTIFIER => TEXT
207+
some_async_func
208+
PERL_SUB => DEFAULT_FUNCTION_CALL => DEFAULT_IDENTIFIER => TEXT
209+
(
210+
PERL_PARENTESS => DEFAULT_PARENTHS
211+
)
212+
PERL_PARENTESS => DEFAULT_PARENTHS
213+
;
214+
PERL_SEMICOLON => DEFAULT_SEMICOLON
215+
my
216+
PERL_KEYWORD => DEFAULT_KEYWORD
217+
$
218+
PERL_SCALAR => DEFAULT_IDENTIFIER => TEXT
219+
place
220+
PERL_SCALAR => DEFAULT_IDENTIFIER => TEXT
221+
=
222+
PERL_OPERATOR => DEFAULT_OPERATION_SIGN
223+
await
224+
PERL_SUB_BUILTIN => PERL_SUB => DEFAULT_FUNCTION_CALL => DEFAULT_IDENTIFIER => TEXT
225+
RT::API::Google::Places::
226+
PERL_PACKAGE => DEFAULT_CLASS_NAME => DEFAULT_IDENTIFIER => TEXT
227+
->
228+
PERL_DEREFERENCE => DEFAULT_OPERATION_SIGN
229+
something
230+
PERL_SUB => DEFAULT_FUNCTION_CALL => DEFAULT_IDENTIFIER => TEXT
231+
(
232+
PERL_PARENTESS => DEFAULT_PARENTHS
233+
{
234+
PERL_BRACES => DEFAULT_BRACES
235+
$
236+
PERL_SCALAR => DEFAULT_IDENTIFIER => TEXT
237+
params
238+
PERL_SCALAR => DEFAULT_IDENTIFIER => TEXT
239+
->
240+
PERL_DEREFERENCE => DEFAULT_OPERATION_SIGN
241+
%
242+
PERL_HASH => DEFAULT_IDENTIFIER => TEXT
243+
{
244+
PERL_BRACES => DEFAULT_BRACES
245+
qw
246+
PERL_KEYWORD => DEFAULT_KEYWORD
247+
(
248+
PERL_SQ_STRING => DEFAULT_STRING
249+
input
250+
PERL_SQ_STRING => DEFAULT_STRING
251+
)
252+
PERL_SQ_STRING => DEFAULT_STRING
253+
}
254+
PERL_BRACES => DEFAULT_BRACES
255+
}
256+
PERL_BRACES => DEFAULT_BRACES
257+
)
258+
PERL_PARENTESS => DEFAULT_PARENTHS
259+
;
260+
PERL_SEMICOLON => DEFAULT_SEMICOLON
261+
}
262+
PERL_BRACES => DEFAULT_BRACES
263+
my
264+
PERL_KEYWORD => DEFAULT_KEYWORD
265+
$
266+
PERL_SCALAR => DEFAULT_IDENTIFIER => TEXT
267+
var
268+
PERL_SCALAR => DEFAULT_IDENTIFIER => TEXT
269+
=
270+
PERL_OPERATOR => DEFAULT_OPERATION_SIGN
271+
mysub
272+
PERL_SUB => DEFAULT_FUNCTION_CALL => DEFAULT_IDENTIFIER => TEXT
273+
(
274+
PERL_PARENTESS => DEFAULT_PARENTHS
275+
)
276+
PERL_PARENTESS => DEFAULT_PARENTHS
277+
;
278+
PERL_SEMICOLON => DEFAULT_SEMICOLON
279+
say
280+
PERL_KEYWORD => DEFAULT_KEYWORD
281+
$
282+
PERL_SCALAR => DEFAULT_IDENTIFIER => TEXT
283+
var
284+
PERL_SCALAR => DEFAULT_IDENTIFIER => TEXT
285+
;
286+
PERL_SEMICOLON => DEFAULT_SEMICOLON
287+
say
288+
PERL_KEYWORD => DEFAULT_KEYWORD
289+
$
290+
PERL_SCALAR => DEFAULT_IDENTIFIER => TEXT
291+
var
292+
PERL_SCALAR => DEFAULT_IDENTIFIER => TEXT
293+
->
294+
PERL_DEREFERENCE => DEFAULT_OPERATION_SIGN
295+
get
296+
PERL_SUB => DEFAULT_FUNCTION_CALL => DEFAULT_IDENTIFIER => TEXT
297+
(
298+
PERL_PARENTESS => DEFAULT_PARENTHS
299+
)
300+
PERL_PARENTESS => DEFAULT_PARENTHS
301+
;
302+
PERL_SEMICOLON => DEFAULT_SEMICOLON
303+
say
304+
PERL_KEYWORD => DEFAULT_KEYWORD
305+
$
306+
PERL_SCALAR => DEFAULT_IDENTIFIER => TEXT
307+
var
308+
PERL_SCALAR => DEFAULT_IDENTIFIER => TEXT
309+
+
310+
PERL_OPERATOR => DEFAULT_OPERATION_SIGN
311+
42
312+
PERL_NUMBER => DEFAULT_NUMBER
313+
;
314+
PERL_SEMICOLON => DEFAULT_SEMICOLON
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
use v5.14;
2+
use Future::AsyncAwait;
3+
use warnings FATAL => 'all';
4+
use strict;
5+
6+
7+
sub myecho{
8+
return shift;
9+
}
10+
11+
async sub asyncecho{
12+
return shift;
13+
}
14+
15+
async sub mysub{
16+
say myecho 42 + 42;
17+
say myecho(42) + 42;
18+
say await asyncecho(42) + 42; # Expected a blessed object reference to await at ... unary operator
19+
say await(asyncecho(42)) + 42;
20+
say await asyncecho(42), 24;
21+
return ((await asyncecho(42)) + 42);
22+
}
23+
24+
async sub sample_syntax{
25+
my $result = await some_async_func();
26+
my $place = await RT::API::Google::Places::->something({$params->%{qw(input)}});
27+
}
28+
29+
my $var = mysub();
30+
say $var;
31+
say $var->get();
32+
say $var + 42;
33+
34+

‎plugin/src/test/resources/unit/perl/parser/asyncAwait.txt

+308
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.