Merge pull request #215 from lopekpl/KT-1019
KT-1019 recover from missing parentheses in function declaration
This commit is contained in:
@@ -1042,7 +1042,12 @@ public class JetParsing extends AbstractJetParsing {
|
|||||||
typeParameterListOccurred = true;
|
typeParameterListOccurred = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
parseValueParameterList(false, valueParametersFollow);
|
if (at(LPAR)) {
|
||||||
|
parseValueParameterList(false, valueParametersFollow);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
error("Expecting '('");
|
||||||
|
}
|
||||||
|
|
||||||
if (at(COLON)) {
|
if (at(COLON)) {
|
||||||
advance(); // COLON
|
advance(); // COLON
|
||||||
@@ -1648,10 +1653,11 @@ public class JetParsing extends AbstractJetParsing {
|
|||||||
* ;
|
* ;
|
||||||
*/
|
*/
|
||||||
void parseValueParameterList(boolean isFunctionTypeContents, TokenSet recoverySet) {
|
void parseValueParameterList(boolean isFunctionTypeContents, TokenSet recoverySet) {
|
||||||
|
assert _at(LPAR);
|
||||||
PsiBuilder.Marker parameters = mark();
|
PsiBuilder.Marker parameters = mark();
|
||||||
|
|
||||||
myBuilder.disableNewlines();
|
myBuilder.disableNewlines();
|
||||||
expect(LPAR, "Expecting '(", recoverySet);
|
advance(); // LPAR
|
||||||
|
|
||||||
if (!parseIdeTemplate()) {
|
if (!parseIdeTemplate()) {
|
||||||
if (!at(RPAR) && !atSet(recoverySet)) {
|
if (!at(RPAR) && !atSet(recoverySet)) {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.jetbrains.jet.JetNodeTypes;
|
|||||||
import org.jetbrains.jet.lang.psi.stubs.PsiJetFunctionStub;
|
import org.jetbrains.jet.lang.psi.stubs.PsiJetFunctionStub;
|
||||||
import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes;
|
import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -83,7 +84,7 @@ public class JetNamedFunction extends JetTypeParameterListOwnerStub<PsiJetFuncti
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns full qualified name for function "package_fqn.function_name"
|
* Returns full qualified name for function "package_fqn.function_name"
|
||||||
* Not null for top level functions.
|
* Not null for top level functions unless syntax errors are present.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -101,7 +102,10 @@ public class JetNamedFunction extends JetTypeParameterListOwnerStub<PsiJetFuncti
|
|||||||
}
|
}
|
||||||
JetFile jetFile = (JetFile) parent;
|
JetFile jetFile = (JetFile) parent;
|
||||||
final FqName fileFQN = JetPsiUtil.getFQName(jetFile);
|
final FqName fileFQN = JetPsiUtil.getFQName(jetFile);
|
||||||
return fileFQN.child(getNameAsName());
|
Name nameAsName = getNameAsName();
|
||||||
|
if (nameAsName != null) {
|
||||||
|
return fileFQN.child(nameAsName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
fun<!SYNTAX, SYNTAX, SYNTAX, SYNTAX, SYNTAX!><!>
|
fun<!SYNTAX, SYNTAX!><!>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
class A {
|
||||||
|
fun foo
|
||||||
|
class B {}
|
||||||
|
fun bar
|
||||||
|
}
|
||||||
|
class C {}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
JetFile: FunctionNoParameterList.kt
|
||||||
|
NAMESPACE_HEADER
|
||||||
|
<empty list>
|
||||||
|
CLASS
|
||||||
|
PsiElement(class)('class')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('A')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
TYPE_PARAMETER_LIST
|
||||||
|
<empty list>
|
||||||
|
CLASS_BODY
|
||||||
|
PsiElement(LBRACE)('{')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
FUN
|
||||||
|
PsiElement(fun)('fun')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('foo')
|
||||||
|
PsiErrorElement:Expecting '('
|
||||||
|
<empty list>
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
CLASS
|
||||||
|
PsiElement(class)('class')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('B')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
TYPE_PARAMETER_LIST
|
||||||
|
<empty list>
|
||||||
|
CLASS_BODY
|
||||||
|
PsiElement(LBRACE)('{')
|
||||||
|
PsiElement(RBRACE)('}')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
FUN
|
||||||
|
PsiElement(fun)('fun')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('bar')
|
||||||
|
PsiErrorElement:Expecting '('
|
||||||
|
<empty list>
|
||||||
|
PsiWhiteSpace('\n')
|
||||||
|
PsiElement(RBRACE)('}')
|
||||||
|
PsiWhiteSpace('\n')
|
||||||
|
CLASS
|
||||||
|
PsiElement(class)('class')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('C')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
TYPE_PARAMETER_LIST
|
||||||
|
<empty list>
|
||||||
|
CLASS_BODY
|
||||||
|
PsiElement(LBRACE)('{')
|
||||||
|
PsiElement(RBRACE)('}')
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
fun foo)
|
fun foo)
|
||||||
fun [a] f foo()
|
|
||||||
fun [a] T.foo(a : ) : bar
|
fun [a] T.foo(a : ) : bar
|
||||||
fun [a()] T.foo<>(a : foo) : bar
|
fun [a()] T.foo<>(a : foo) : bar
|
||||||
fun [a()] T.foo<T, , T>(a : foo) : bar
|
fun [a()] T.foo<T, , T>(a : foo) : bar
|
||||||
|
|||||||
@@ -5,35 +5,10 @@ JetFile: Functions_ERR.jet
|
|||||||
PsiElement(fun)('fun')
|
PsiElement(fun)('fun')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(IDENTIFIER)('foo')
|
PsiElement(IDENTIFIER)('foo')
|
||||||
VALUE_PARAMETER_LIST
|
PsiErrorElement:Expecting '('
|
||||||
PsiErrorElement:Expecting '(
|
<empty list>
|
||||||
<empty list>
|
PsiErrorElement:Expecting package directive or top level declaration
|
||||||
PsiElement(RPAR)(')')
|
PsiElement(RPAR)(')')
|
||||||
PsiWhiteSpace('\n')
|
|
||||||
FUN
|
|
||||||
PsiElement(fun)('fun')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
ANNOTATION
|
|
||||||
PsiElement(LBRACKET)('[')
|
|
||||||
ANNOTATION_ENTRY
|
|
||||||
CONSTRUCTOR_CALLEE
|
|
||||||
TYPE_REFERENCE
|
|
||||||
USER_TYPE
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('a')
|
|
||||||
PsiElement(RBRACKET)(']')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
PsiElement(IDENTIFIER)('f')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
VALUE_PARAMETER_LIST
|
|
||||||
PsiErrorElement:Expecting '(
|
|
||||||
PsiElement(IDENTIFIER)('foo')
|
|
||||||
VALUE_PARAMETER
|
|
||||||
PsiErrorElement:Parameter name expected
|
|
||||||
PsiElement(LPAR)('(')
|
|
||||||
PsiErrorElement:Parameters must have type annotation
|
|
||||||
<empty list>
|
|
||||||
PsiElement(RPAR)(')')
|
|
||||||
PsiWhiteSpace('\n')
|
PsiWhiteSpace('\n')
|
||||||
FUN
|
FUN
|
||||||
PsiElement(fun)('fun')
|
PsiElement(fun)('fun')
|
||||||
|
|||||||
Reference in New Issue
Block a user