From 44a078d12cbaef6f318f6c02e8e944342491d9df Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Wed, 22 Jul 2015 14:07:40 +0300 Subject: [PATCH] introduce SpecType, fix #1739 --- gen/com/goide/GoTypes.java | 4 + gen/com/goide/parser/GoParser.java | 32 +- gen/com/goide/psi/GoSpecType.java | 16 + gen/com/goide/psi/GoTypeSpec.java | 8 +- gen/com/goide/psi/GoVisitor.java | 4 + gen/com/goide/psi/impl/GoSpecTypeImpl.java | 41 +++ gen/com/goide/psi/impl/GoTypeSpecImpl.java | 17 +- grammars/go.bnf | 5 +- .../goide/completion/GoCompletionUtil.java | 2 +- .../GoKeywordCompletionContributor.java | 2 +- src/com/goide/editor/GoFoldingBuilder.java | 2 +- .../goide/psi/impl/GoFieldNameReference.java | 6 +- .../goide/psi/impl/GoNamedElementImpl.java | 3 +- src/com/goide/psi/impl/GoPsiImplUtil.java | 19 +- src/com/goide/psi/impl/GoReference.java | 26 +- src/com/goide/psi/impl/GoTypeReference.java | 2 +- .../goide/stubs/GoStubElementTypeFactory.java | 1 + .../goide/tree/GoStructureViewFactory.java | 6 +- testData/highlighting/simple.go | 8 + testData/parser/ArrayTypesInRanges.txt | 11 +- testData/parser/Cars.txt | 61 ++-- testData/parser/ElementRecover.txt | 11 +- testData/parser/Error.txt | 138 ++++---- testData/parser/If.txt | 22 +- testData/parser/IfComposite.txt | 29 +- testData/parser/IfWithNew.txt | 37 +-- testData/parser/LiteralValues.txt | 304 +++++++++--------- testData/parser/MethodExpr.txt | 23 +- testData/parser/Primer.txt | 182 ++++++----- testData/parser/Recover.txt | 11 +- testData/parser/Simple.txt | 49 +-- testData/parser/Torture.txt | 187 +++++------ testData/parser/Types.txt | 180 ++++++----- testData/parser/Writer.txt | 93 +++--- 34 files changed, 843 insertions(+), 699 deletions(-) create mode 100644 gen/com/goide/psi/GoSpecType.java create mode 100644 gen/com/goide/psi/impl/GoSpecTypeImpl.java diff --git a/gen/com/goide/GoTypes.java b/gen/com/goide/GoTypes.java index b2fe37c11d..9362776e81 100644 --- a/gen/com/goide/GoTypes.java +++ b/gen/com/goide/GoTypes.java @@ -91,6 +91,7 @@ public interface GoTypes { IElementType SHORT_VAR_DECLARATION = GoStubElementTypeFactory.factory("SHORT_VAR_DECLARATION"); IElementType SIGNATURE = GoStubElementTypeFactory.factory("SIGNATURE"); IElementType SIMPLE_STATEMENT = new GoCompositeElementType("SIMPLE_STATEMENT"); + IElementType SPEC_TYPE = GoStubElementTypeFactory.factory("SPEC_TYPE"); IElementType STATEMENT = new GoCompositeElementType("STATEMENT"); IElementType STRING_LITERAL = new GoCompositeElementType("STRING_LITERAL"); IElementType STRUCT_TYPE = GoStubElementTypeFactory.factory("STRUCT_TYPE"); @@ -440,6 +441,9 @@ else if (type == SIGNATURE) { else if (type == SIMPLE_STATEMENT) { return new GoSimpleStatementImpl(node); } + else if (type == SPEC_TYPE) { + return new GoSpecTypeImpl(node); + } else if (type == STATEMENT) { return new GoStatementImpl(node); } diff --git a/gen/com/goide/parser/GoParser.java b/gen/com/goide/parser/GoParser.java index 818cd8a5c3..86aeaca89a 100644 --- a/gen/com/goide/parser/GoParser.java +++ b/gen/com/goide/parser/GoParser.java @@ -259,6 +259,9 @@ else if (t == SIGNATURE) { else if (t == SIMPLE_STATEMENT) { r = SimpleStatement(b, 0); } + else if (t == SPEC_TYPE) { + r = SpecType(b, 0); + } else if (t == STATEMENT) { r = Statement(b, 0); } @@ -342,7 +345,7 @@ protected boolean parse_root_(IElementType t, PsiBuilder b, int l) { SELECTOR_EXPR), create_token_set_(ARRAY_OR_SLICE_TYPE, CHANNEL_TYPE, FUNCTION_TYPE, INTERFACE_TYPE, MAP_TYPE, PAR_TYPE, POINTER_TYPE, RECEIVER_TYPE, - STRUCT_TYPE, TYPE, TYPE_LIST), + SPEC_TYPE, STRUCT_TYPE, TYPE, TYPE_LIST), create_token_set_(ASSIGNMENT_STATEMENT, BREAK_STATEMENT, CONTINUE_STATEMENT, DEFER_STATEMENT, ELSE_STATEMENT, EXPR_SWITCH_STATEMENT, FALLTHROUGH_STATEMENT, FOR_STATEMENT, GOTO_STATEMENT, GO_STATEMENT, IF_STATEMENT, LABELED_STATEMENT, @@ -3297,6 +3300,19 @@ static boolean SliceExprBodyInner(PsiBuilder b, int l) { return SliceExprBody(b, l + 1); } + /* ********************************************************** */ + // identifier Type + public static boolean SpecType(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "SpecType")) return false; + if (!nextTokenIs(b, IDENTIFIER)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, IDENTIFIER); + r = r && Type(b, l + 1); + exit_section_(b, m, SPEC_TYPE, r); + return r; + } + /* ********************************************************** */ // ConstDeclaration // | TypeDeclaration @@ -3838,17 +3854,15 @@ public static boolean TypeReferenceExpression(PsiBuilder b, int l) { } /* ********************************************************** */ - // identifier Type + // SpecType public static boolean TypeSpec(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "TypeSpec")) return false; if (!nextTokenIs(b, IDENTIFIER)) return false; - boolean r, p; - Marker m = enter_section_(b, l, _NONE_, null); - r = consumeToken(b, IDENTIFIER); - p = r; // pin = 1 - r = r && Type(b, l + 1); - exit_section_(b, l, m, TYPE_SPEC, r, p, null); - return r || p; + boolean r; + Marker m = enter_section_(b); + r = SpecType(b, l + 1); + exit_section_(b, m, TYPE_SPEC, r); + return r; } /* ********************************************************** */ diff --git a/gen/com/goide/psi/GoSpecType.java b/gen/com/goide/psi/GoSpecType.java new file mode 100644 index 0000000000..060a20c682 --- /dev/null +++ b/gen/com/goide/psi/GoSpecType.java @@ -0,0 +1,16 @@ +// This is a generated file. Not intended for manual editing. +package com.goide.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface GoSpecType extends GoType { + + @NotNull + GoType getType(); + + @NotNull + PsiElement getIdentifier(); + +} diff --git a/gen/com/goide/psi/GoTypeSpec.java b/gen/com/goide/psi/GoTypeSpec.java index 6eb501b14c..d3ceddfeba 100644 --- a/gen/com/goide/psi/GoTypeSpec.java +++ b/gen/com/goide/psi/GoTypeSpec.java @@ -10,11 +10,8 @@ public interface GoTypeSpec extends GoNamedElement, StubBasedPsiElement { - @Nullable - GoType getType(); - @NotNull - PsiElement getIdentifier(); + GoSpecType getSpecType(); @Nullable GoType getGoTypeInner(ResolveState context); @@ -24,4 +21,7 @@ public interface GoTypeSpec extends GoNamedElement, StubBasedPsiElement getTypeConversionInsertHandler(@NotNull GoTypeSpec t) { - GoType type = t.getType(); + GoType type = t.getSpecType().getType(); return type instanceof GoStructType || type instanceof GoArrayOrSliceType || type instanceof GoMapType ? BracesInsertHandler.ONE_LINER : ParenthesesInsertHandler.WITH_PARAMETERS; diff --git a/src/com/goide/completion/GoKeywordCompletionContributor.java b/src/com/goide/completion/GoKeywordCompletionContributor.java index edc5936862..58784767b8 100644 --- a/src/com/goide/completion/GoKeywordCompletionContributor.java +++ b/src/com/goide/completion/GoKeywordCompletionContributor.java @@ -116,7 +116,7 @@ private static ElementPattern insideSwitchStatement() { private static ElementPattern typeDeclaration() { return psiElement(GoTypes.IDENTIFIER) - .withParent(psiElement(GoTypeReferenceExpression.class).withParent(psiElement(GoType.class).withParent(GoTypeSpec.class))); + .withParent(psiElement(GoTypeReferenceExpression.class).withParent(psiElement(GoType.class).withParent(GoSpecType.class))); } private static PsiElementPattern.Capture insideGoOrDeferStatements(@NotNull IElementType tokenType) { diff --git a/src/com/goide/editor/GoFoldingBuilder.java b/src/com/goide/editor/GoFoldingBuilder.java index 8795b419b8..82cb98732f 100644 --- a/src/com/goide/editor/GoFoldingBuilder.java +++ b/src/com/goide/editor/GoFoldingBuilder.java @@ -71,7 +71,7 @@ public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement root, @NotNull D } for (GoTypeSpec type : file.getTypes()) { - foldTypes(type.getType(), result); + foldTypes(type.getSpecType().getType(), result); } if (!quick) { diff --git a/src/com/goide/psi/impl/GoFieldNameReference.java b/src/com/goide/psi/impl/GoFieldNameReference.java index f94d9a691d..82e8c0829e 100644 --- a/src/com/goide/psi/impl/GoFieldNameReference.java +++ b/src/com/goide/psi/impl/GoFieldNameReference.java @@ -65,12 +65,12 @@ public boolean execute(@NotNull PsiElement psiElement, @NotNull ResolveState res } @Nullable - private GoType getType(GoType type) { // todo: rethink and unify this algorithm + private GoType getType(@Nullable GoType type) { // todo: rethink and unify this algorithm boolean inValue = myValue != null; if (inValue && type instanceof GoArrayOrSliceType) type = ((GoArrayOrSliceType)type).getType(); else if (type instanceof GoMapType) type = inValue ? ((GoMapType)type).getValueType() : ((GoMapType)type).getKeyType(); - else if (inValue && type instanceof GoStructType) { + else if (inValue && type instanceof GoSpecType && ((GoSpecType)type).getType() instanceof GoStructType) { GoKey key = PsiTreeUtil.getPrevSiblingOfType(myValue, GoKey.class); GoFieldName field = key != null ? key.getFieldName() : null; PsiReference reference = field != null ? field.getReference() : null; @@ -91,7 +91,7 @@ else if (inValue && type instanceof GoStructType) { } } - return type; + return type instanceof GoSpecType ? ((GoSpecType)type).getType() : type; } @Nullable diff --git a/src/com/goide/psi/impl/GoNamedElementImpl.java b/src/com/goide/psi/impl/GoNamedElementImpl.java index 97312e1ff3..5d6f264560 100644 --- a/src/com/goide/psi/impl/GoNamedElementImpl.java +++ b/src/com/goide/psi/impl/GoNamedElementImpl.java @@ -49,8 +49,7 @@ import javax.swing.*; -public abstract class GoNamedElementImpl> extends GoStubbedElementImpl - implements GoCompositeElement, GoNamedElement { +public abstract class GoNamedElementImpl> extends GoStubbedElementImpl implements GoCompositeElement, GoNamedElement { public GoNamedElementImpl(@NotNull T stub, @NotNull IStubElementType nodeType) { super(stub, nodeType); diff --git a/src/com/goide/psi/impl/GoPsiImplUtil.java b/src/com/goide/psi/impl/GoPsiImplUtil.java index cd39a077d7..15dacddac7 100644 --- a/src/com/goide/psi/impl/GoPsiImplUtil.java +++ b/src/com/goide/psi/impl/GoPsiImplUtil.java @@ -363,6 +363,7 @@ else if (o instanceof GoIndexOrSliceExpr) { if (typeRef != null) { type = getType(typeRef); } + if (type instanceof GoSpecType) type = ((GoSpecType)type).getType(); if (type instanceof GoMapType) { List list = ((GoMapType)type).getTypeList(); if (list.size() == 2) { @@ -411,7 +412,7 @@ public boolean value(GoTypeSpec spec) { } }); if (str != null) { - return str.getType(); + return str.getSpecType(); // todo } } return null; @@ -507,7 +508,7 @@ public boolean shouldGoDeeper() { public static GoType getType(@Nullable GoTypeReferenceExpression expression) { PsiReference reference = expression != null ? expression.getReference() : null; PsiElement resolve = reference != null ? reference.resolve() : null; - return resolve instanceof GoTypeSpec ? ((GoTypeSpec)resolve).getType() : null; + return resolve instanceof GoTypeSpec ? ((GoTypeSpec)resolve).getSpecType() : null; } public static boolean isVariadic(@NotNull GoParamDefinition o) { @@ -522,7 +523,7 @@ public static boolean isVariadic(@NotNull GoParameterDeclaration o) { @Nullable public static GoType getGoTypeInner(@NotNull GoTypeSpec o, @SuppressWarnings("UnusedParameters") @Nullable ResolveState context) { - return o.getType(); + return o.getSpecType(); } @Nullable @@ -565,7 +566,10 @@ private static GoType findTypeInVarSpec(@NotNull GoVarDefinition o, @Nullable Re if (exprs.size() == 1 && exprs.get(0) instanceof GoCallExpr) { GoExpression call = exprs.get(0); GoType fromCall = call.getGoType(context); - GoType type = funcType(typeFromRefOrType(fromCall)); + boolean canDecouple = varList.size() > 1; + GoType underlyingType = canDecouple && fromCall instanceof GoSpecType ? ((GoSpecType)fromCall).getType() : fromCall; + GoType byRef = typeFromRefOrType(underlyingType); + GoType type = funcType(canDecouple && byRef instanceof GoSpecType ? ((GoSpecType)byRef).getType() : byRef); if (type == null) return fromCall; if (type instanceof GoTypeList) { if (((GoTypeList)type).getTypeList().size() > i) { @@ -607,7 +611,7 @@ private static GoType processRangeClause(@NotNull GoVarDefinition o, @NotNull Go if (typeRef != null) { PsiElement resolve = typeRef.getReference().resolve(); if (resolve instanceof GoTypeSpec) { - type = ((GoTypeSpec)resolve).getType(); + type = ((GoTypeSpec)resolve).getSpecType().getType(); if (type instanceof GoChannelType) { return ((GoChannelType)type).getType(); } @@ -680,6 +684,11 @@ public Result> compute() { return calcMethods(o); } + @NotNull + public PsiElement getType(@NotNull GoTypeSpec o) { + return o.getSpecType(); + } + @NotNull private static List calcMethods(@NotNull GoTypeSpec o) { PsiFile file = o.getContainingFile().getOriginalFile(); diff --git a/src/com/goide/psi/impl/GoReference.java b/src/com/goide/psi/impl/GoReference.java index b72a82fdaa..4af55ec87b 100644 --- a/src/com/goide/psi/impl/GoReference.java +++ b/src/com/goide/psi/impl/GoReference.java @@ -19,6 +19,7 @@ import com.goide.psi.*; import com.goide.runconfig.testing.GoTestFinder; import com.goide.sdk.GoSdkUtil; +import com.goide.stubs.GoTypeStub; import com.goide.util.GoUtil; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Key; @@ -171,11 +172,11 @@ private boolean processExistingType(@NotNull GoType type, GoFile o2 = (GoFile)file.getOriginalFile(); boolean localResolve = Comparing.equal(o1.getImportPath(), o2.getImportPath()) && Comparing.equal(o1.getPackageName(), o2.getPackageName()); - PsiElement parent = type.getStub() == null ? type.getParent() : type.getStub().getParentStub().getPsi(); - if (parent instanceof GoTypeSpec && !processNamedElements(processor, state, ((GoTypeSpec)parent).getMethods(), localResolve, true)) { - return false; - } + GoTypeStub stub = type.getStub(); + PsiElement parent = stub == null ? type.getParent() : stub.getParentStub().getPsi(); + if (parent instanceof GoTypeSpec && !processNamedElements(processor, state, ((GoTypeSpec)parent).getMethods(), localResolve, true)) return false; + if (type instanceof GoSpecType) type = ((GoSpecType)type).getType(); if (type instanceof GoStructType) { GoScopeProcessorBase delegate = createDelegate(processor); type.processDeclarations(delegate, ResolveState.initial(), null, myElement); @@ -221,19 +222,22 @@ private boolean processInTypeRef(@Nullable GoTypeReferenceExpression refExpr, @NotNull ResolveState state) { PsiReference reference = refExpr != null ? refExpr.getReference() : null; PsiElement resolve = reference != null ? reference.resolve() : null; - if (resolve instanceof GoTypeSpec) { - GoType resolveType = ((GoTypeSpec)resolve).getType(); - if (notMatchRecursiveStopper(recursiveStopper, resolveType) && !processGoType(resolveType, processor, state)) return false; - } - else if (resolve instanceof GoTypeOwner) { + if (resolve instanceof GoTypeOwner) { GoType type = ((GoTypeOwner)resolve).getGoType(state); - if (notMatchRecursiveStopper(recursiveStopper, type) && !processGoType(type, processor, state)) return false; + if (notMatchRecursiveStopper(recursiveStopper, type)) { + if (!processGoType(type, processor, state)) return false; + if (type instanceof GoSpecType && !processGoType(((GoSpecType)type).getType(), processor, state)) return false; + } } return true; } private static boolean notMatchRecursiveStopper(@Nullable GoType recursiveStopper, @Nullable GoType resolveType) { - return resolveType != null && (recursiveStopper == null || !resolveType.textMatches(recursiveStopper)); + if (resolveType == null) return false; + if (recursiveStopper == null) return true; + if (!resolveType.isEquivalentTo(recursiveStopper) && + !(resolveType instanceof GoSpecType && ((GoSpecType)resolveType).getType().isEquivalentTo(recursiveStopper))) return true; + return false; } @Nullable diff --git a/src/com/goide/psi/impl/GoTypeReference.java b/src/com/goide/psi/impl/GoTypeReference.java index 2dad4d82a6..65ca50ba8a 100644 --- a/src/com/goide/psi/impl/GoTypeReference.java +++ b/src/com/goide/psi/impl/GoTypeReference.java @@ -175,7 +175,7 @@ private boolean processNamedElements(@NotNull PsiScopeProcessor processor, } public boolean allowed(@NotNull GoTypeSpec definition) { - return !myInsideInterfaceType || (definition.getType() instanceof GoInterfaceType); + return !myInsideInterfaceType || (definition.getSpecType().getType() instanceof GoInterfaceType); } @Override diff --git a/src/com/goide/stubs/GoStubElementTypeFactory.java b/src/com/goide/stubs/GoStubElementTypeFactory.java index 1e41c74e8b..1a3e0c29b1 100644 --- a/src/com/goide/stubs/GoStubElementTypeFactory.java +++ b/src/com/goide/stubs/GoStubElementTypeFactory.java @@ -40,6 +40,7 @@ public class GoStubElementTypeFactory { put("STRUCT_TYPE", GoStructTypeImpl.class); put("TYPE", GoTypeImpl.class); put("PAR_TYPE", GoParTypeImpl.class); + put("SPEC_TYPE", GoSpecTypeImpl.class); put("TYPE_LIST", GoTypeListImpl.class); } }; diff --git a/src/com/goide/tree/GoStructureViewFactory.java b/src/com/goide/tree/GoStructureViewFactory.java index 2a9e1d024f..bdade6fbe4 100644 --- a/src/com/goide/tree/GoStructureViewFactory.java +++ b/src/com/goide/tree/GoStructureViewFactory.java @@ -196,7 +196,7 @@ public TreeElement[] getChildren() { } else if (myElement instanceof GoTypeSpec) { GoTypeSpec typeSpec = (GoTypeSpec)myElement; - GoType type = (typeSpec).getType(); + GoType type = typeSpec.getSpecType().getType(); for (GoMethodDeclaration m : GoPsiImplUtil.getMethods(typeSpec)) result.add(new Element(m)); if (type instanceof GoStructType) { for (GoFieldDeclaration field : ((GoStructType)type).getFieldDeclarationList()) { @@ -223,10 +223,10 @@ else if (myElement instanceof GoNamedSignatureOwner) { return (id != null ? id.getText() : "") + signatureText; } else if (myElement instanceof GoTypeSpec) { - GoType type = ((GoTypeSpec)myElement).getType(); + GoType type = ((GoTypeSpec)myElement).getSpecType().getType(); String appendix = type instanceof GoStructType || type instanceof GoInterfaceType ? "" : - (type != null ? separator + GoPsiImplUtil.getText(type) : ""); + separator + GoPsiImplUtil.getText(type); return ((GoTypeSpec)myElement).getName() + appendix; } else if (myElement instanceof GoNamedElement) { diff --git a/testData/highlighting/simple.go b/testData/highlighting/simple.go index d6b4fc7e05..2721839bf8 100644 --- a/testData/highlighting/simple.go +++ b/testData/highlighting/simple.go @@ -402,3 +402,11 @@ func _(c Conn) { String(c.Do("GET", "somekey")) } +type MyType string + +func (t MyType) Get(key string) string { return "hello" } + +func _() { + st := MyType("tag") + st.Get("key") // <- unresolved Get +} diff --git a/testData/parser/ArrayTypesInRanges.txt b/testData/parser/ArrayTypesInRanges.txt index 09e8ff4902..9672ca2f5b 100644 --- a/testData/parser/ArrayTypesInRanges.txt +++ b/testData/parser/ArrayTypesInRanges.txt @@ -7,11 +7,12 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('File') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('File') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + PsiElement(})('}') FUNCTION_DECLARATION PsiElement(func)('func') PsiElement(identifier)('main') diff --git a/testData/parser/Cars.txt b/testData/parser/Cars.txt index 3e9221684e..97d98b0827 100644 --- a/testData/parser/Cars.txt +++ b/testData/parser/Cars.txt @@ -11,17 +11,18 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('Car') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('wheelCount') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('int') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('Car') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('wheelCount') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('int') + PsiElement(})('}') METHOD_DECLARATION PsiElement(func)('func') RECEIVER @@ -53,15 +54,16 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('Ferrari') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - ANONYMOUS_FIELD_DEFINITION - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('Car') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('Ferrari') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + ANONYMOUS_FIELD_DEFINITION + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('Car') + PsiElement(})('}') METHOD_DECLARATION PsiElement(func)('func') RECEIVER @@ -95,15 +97,16 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('AstonMartin') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - ANONYMOUS_FIELD_DEFINITION - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('Car') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('AstonMartin') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + ANONYMOUS_FIELD_DEFINITION + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('Car') + PsiElement(})('}') METHOD_DECLARATION PsiElement(func)('func') RECEIVER diff --git a/testData/parser/ElementRecover.txt b/testData/parser/ElementRecover.txt index cbee322913..926741a0be 100644 --- a/testData/parser/ElementRecover.txt +++ b/testData/parser/ElementRecover.txt @@ -7,11 +7,12 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('connection') - INTERFACE_TYPE - PsiElement(interface)('interface') - PsiElement({)('{') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('connection') + INTERFACE_TYPE + PsiElement(interface)('interface') + PsiElement({)('{') + PsiElement(})('}') METHOD_DECLARATION PsiElement(func)('func') RECEIVER diff --git a/testData/parser/Error.txt b/testData/parser/Error.txt index 92f99b140b..20702836e0 100644 --- a/testData/parser/Error.txt +++ b/testData/parser/Error.txt @@ -11,58 +11,60 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('Error') - INTERFACE_TYPE - PsiElement(interface)('interface') - PsiElement({)('{') - METHOD_SPEC - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('error') - PsiComment(GO_LINE_COMMENT)('// RuntimeError is a no-op function but') - PsiComment(GO_LINE_COMMENT)('// serves to distinguish types that are runtime') - PsiComment(GO_LINE_COMMENT)('// errors from ordinary errors: a type is a') - PsiComment(GO_LINE_COMMENT)('// runtime error if it has a RuntimeError method.') - METHOD_SPEC - PsiElement(identifier)('RuntimeError') - SIGNATURE - PARAMETERS - PsiElement(()('(') - PsiElement())(')') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('Error') + INTERFACE_TYPE + PsiElement(interface)('interface') + PsiElement({)('{') + METHOD_SPEC + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('error') + PsiComment(GO_LINE_COMMENT)('// RuntimeError is a no-op function but') + PsiComment(GO_LINE_COMMENT)('// serves to distinguish types that are runtime') + PsiComment(GO_LINE_COMMENT)('// errors from ordinary errors: a type is a') + PsiComment(GO_LINE_COMMENT)('// runtime error if it has a RuntimeError method.') + METHOD_SPEC + PsiElement(identifier)('RuntimeError') + SIGNATURE + PARAMETERS + PsiElement(()('(') + PsiElement())(')') + PsiElement(})('}') PsiComment(GO_LINE_COMMENT)('// A TypeAssertionError explains a failed type assertion.') TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('TypeAssertionError') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('interfaceString') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('string') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('concreteString') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('string') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('assertedString') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('string') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('missingMethod') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('string') - PsiComment(GO_LINE_COMMENT)('// one method needed by Interface, missing from Concrete') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('TypeAssertionError') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('interfaceString') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('string') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('concreteString') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('string') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('assertedString') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('string') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('missingMethod') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('string') + PsiComment(GO_LINE_COMMENT)('// one method needed by Interface, missing from Concrete') + PsiElement(})('}') METHOD_DECLARATION PsiElement(func)('func') RECEIVER @@ -440,10 +442,11 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('errorString') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('string') + SPEC_TYPE + PsiElement(identifier)('errorString') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('string') METHOD_DECLARATION PsiElement(func)('func') RECEIVER @@ -542,21 +545,22 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('stringer') - INTERFACE_TYPE - PsiElement(interface)('interface') - PsiElement({)('{') - METHOD_SPEC - PsiElement(identifier)('String') - SIGNATURE - PARAMETERS - PsiElement(()('(') - PsiElement())(')') - RESULT - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('string') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('stringer') + INTERFACE_TYPE + PsiElement(interface)('interface') + PsiElement({)('{') + METHOD_SPEC + PsiElement(identifier)('String') + SIGNATURE + PARAMETERS + PsiElement(()('(') + PsiElement())(')') + RESULT + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('string') + PsiElement(})('}') FUNCTION_DECLARATION PsiElement(func)('func') PsiElement(identifier)('typestring') diff --git a/testData/parser/If.txt b/testData/parser/If.txt index 17fbc7540c..4ae85a8e2e 100644 --- a/testData/parser/If.txt +++ b/testData/parser/If.txt @@ -11,11 +11,12 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('A') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('A') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + PsiElement(})('}') FUNCTION_DECLARATION PsiElement(func)('func') PsiElement(identifier)('main') @@ -165,11 +166,12 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('A') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('A') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + PsiElement(})('}') IF_STATEMENT PsiElement(if)('if') SIMPLE_STATEMENT diff --git a/testData/parser/IfComposite.txt b/testData/parser/IfComposite.txt index 1095e75886..53dd6dbb85 100644 --- a/testData/parser/IfComposite.txt +++ b/testData/parser/IfComposite.txt @@ -44,20 +44,21 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('osPkg') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('goos') - PsiElement(,)(',') - FIELD_DEFINITION - PsiElement(identifier)('pkg') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('string') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('osPkg') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('goos') + PsiElement(,)(',') + FIELD_DEFINITION + PsiElement(identifier)('pkg') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('string') + PsiElement(})('}') VAR_DECLARATION PsiElement(var)('var') VAR_SPEC diff --git a/testData/parser/IfWithNew.txt b/testData/parser/IfWithNew.txt index c427acd0e6..58b805c585 100644 --- a/testData/parser/IfWithNew.txt +++ b/testData/parser/IfWithNew.txt @@ -238,24 +238,25 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('M2') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('name') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('string') - PsiElement(;)(';') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('want') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('int') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('M2') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('name') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('string') + PsiElement(;)(';') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('want') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('int') + PsiElement(})('}') FOR_STATEMENT PsiElement(for)('for') RANGE_CLAUSE diff --git a/testData/parser/LiteralValues.txt b/testData/parser/LiteralValues.txt index 6198fcd5be..930896a8ed 100644 --- a/testData/parser/LiteralValues.txt +++ b/testData/parser/LiteralValues.txt @@ -41,132 +41,134 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('session') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - ANONYMOUS_FIELD_DEFINITION - PsiElement(*)('*') - TYPE_REFERENCE_EXPRESSION + SPEC_TYPE + PsiElement(identifier)('session') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + ANONYMOUS_FIELD_DEFINITION + PsiElement(*)('*') TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('textproto') - PsiElement(.)('.') - PsiElement(identifier)('Conn') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('netConn') - TYPE - TYPE_REFERENCE_EXPRESSION + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('textproto') + PsiElement(.)('.') + PsiElement(identifier)('Conn') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('netConn') + TYPE TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('net') - PsiElement(.)('.') - PsiElement(identifier)('Conn') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('lineBuffer') - TYPE - TYPE_REFERENCE_EXPRESSION + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('net') + PsiElement(.)('.') + PsiElement(identifier)('Conn') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('lineBuffer') + TYPE TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('bytes') - PsiElement(.)('.') - PsiElement(identifier)('Buffer') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('requestId') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('uint32') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('sessionId') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('uint32') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('outType') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('int') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('closed') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('bool') - PsiElement(})('}') + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('bytes') + PsiElement(.)('.') + PsiElement(identifier)('Buffer') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('requestId') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('uint32') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('sessionId') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('uint32') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('outType') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('int') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('closed') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('bool') + PsiElement(})('}') TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('θ_parse_node') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('name') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('string') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('ident') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('bool') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('bindings') - ARRAY_OR_SLICE_TYPE - PsiElement([)('[') - PsiElement(])(']') + SPEC_TYPE + PsiElement(identifier)('θ_parse_node') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('name') TYPE TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('int') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('action') - FUNCTION_TYPE - PsiElement(func)('func') - SIGNATURE - PARAMETERS - PsiElement(()('(') - PARAMETER_DECLARATION - POINTER_TYPE - PsiElement(*)('*') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('session') - PsiElement(,)(',') - PARAMETER_DECLARATION - ARRAY_OR_SLICE_TYPE - PsiElement([)('[') - PsiElement(])(']') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('string') - PsiElement())(')') - RESULT - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('error') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('doc') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('string') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('next') - ARRAY_OR_SLICE_TYPE - PsiElement([)('[') - PsiElement(])(']') + PsiElement(identifier)('string') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('ident') TYPE TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('θ_parse_node') - PsiElement(})('}') + PsiElement(identifier)('bool') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('bindings') + ARRAY_OR_SLICE_TYPE + PsiElement([)('[') + PsiElement(])(']') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('int') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('action') + FUNCTION_TYPE + PsiElement(func)('func') + SIGNATURE + PARAMETERS + PsiElement(()('(') + PARAMETER_DECLARATION + POINTER_TYPE + PsiElement(*)('*') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('session') + PsiElement(,)(',') + PARAMETER_DECLARATION + ARRAY_OR_SLICE_TYPE + PsiElement([)('[') + PsiElement(])(']') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('string') + PsiElement())(')') + RESULT + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('error') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('doc') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('string') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('next') + ARRAY_OR_SLICE_TYPE + PsiElement([)('[') + PsiElement(])(']') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('θ_parse_node') + PsiElement(})('}') METHOD_DECLARATION PsiElement(func)('func') RECEIVER @@ -2195,46 +2197,48 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('stru') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('Field') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('string') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('Field1') - MAP_TYPE - PsiElement(map)('map') - PsiElement([)('[') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('string') - PsiElement(])(']') + SPEC_TYPE + PsiElement(identifier)('stru') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('Field') TYPE TYPE_REFERENCE_EXPRESSION PsiElement(identifier)('string') - PsiElement(})('}') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('Field1') + MAP_TYPE + PsiElement(map)('map') + PsiElement([)('[') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('string') + PsiElement(])(']') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('string') + PsiElement(})('}') TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('str') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('Fiel') - POINTER_TYPE - PsiElement(*)('*') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('stru') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('str') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('Fiel') + POINTER_TYPE + PsiElement(*)('*') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('stru') + PsiElement(})('}') FUNCTION_DECLARATION PsiElement(func)('func') PsiElement(identifier)('de') diff --git a/testData/parser/MethodExpr.txt b/testData/parser/MethodExpr.txt index 9eb32a2b4e..82164b7b5d 100644 --- a/testData/parser/MethodExpr.txt +++ b/testData/parser/MethodExpr.txt @@ -7,17 +7,18 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('T') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('a') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('int') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('T') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('a') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('int') + PsiElement(})('}') METHOD_DECLARATION PsiElement(func)('func') RECEIVER diff --git a/testData/parser/Primer.txt b/testData/parser/Primer.txt index 80c6a43a3b..5992b7bad1 100644 --- a/testData/parser/Primer.txt +++ b/testData/parser/Primer.txt @@ -340,30 +340,32 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('Example') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('Val') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('string') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('count') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('int') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('Example') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('Val') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('string') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('count') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('int') + PsiElement(})('}') TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('integer') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('int') + SPEC_TYPE + PsiElement(identifier)('integer') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('int') METHOD_DECLARATION PsiElement(func)('func') RECEIVER @@ -452,37 +454,39 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('cartesianPoint') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('x') - PsiElement(,)(',') - FIELD_DEFINITION - PsiElement(identifier)('y') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('float64') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('cartesianPoint') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('x') + PsiElement(,)(',') + FIELD_DEFINITION + PsiElement(identifier)('y') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('float64') + PsiElement(})('}') TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('polarPoint') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('r') - PsiElement(,)(',') - FIELD_DEFINITION - PsiElement(identifier)('θ') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('float64') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('polarPoint') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('r') + PsiElement(,)(',') + FIELD_DEFINITION + PsiElement(identifier)('θ') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('float64') + PsiElement(})('}') METHOD_DECLARATION PsiElement(func)('func') RECEIVER @@ -714,45 +718,47 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('Point') - INTERFACE_TYPE - PsiElement(interface)('interface') - PsiElement({)('{') - METHOD_SPEC - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('Printer') - METHOD_SPEC - PsiElement(identifier)('X') - SIGNATURE - PARAMETERS - PsiElement(()('(') - PsiElement())(')') - RESULT - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('float64') - METHOD_SPEC - PsiElement(identifier)('Y') - SIGNATURE - PARAMETERS - PsiElement(()('(') - PsiElement())(')') - RESULT - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('float64') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('Point') + INTERFACE_TYPE + PsiElement(interface)('interface') + PsiElement({)('{') + METHOD_SPEC + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('Printer') + METHOD_SPEC + PsiElement(identifier)('X') + SIGNATURE + PARAMETERS + PsiElement(()('(') + PsiElement())(')') + RESULT + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('float64') + METHOD_SPEC + PsiElement(identifier)('Y') + SIGNATURE + PARAMETERS + PsiElement(()('(') + PsiElement())(')') + RESULT + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('float64') + PsiElement(})('}') TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('Printer') - INTERFACE_TYPE - PsiElement(interface)('interface') - PsiElement({)('{') - METHOD_SPEC - PsiElement(identifier)('Print') - SIGNATURE - PARAMETERS - PsiElement(()('(') - PsiElement())(')') - PsiElement(})('}') \ No newline at end of file + SPEC_TYPE + PsiElement(identifier)('Printer') + INTERFACE_TYPE + PsiElement(interface)('interface') + PsiElement({)('{') + METHOD_SPEC + PsiElement(identifier)('Print') + SIGNATURE + PARAMETERS + PsiElement(()('(') + PsiElement())(')') + PsiElement(})('}') \ No newline at end of file diff --git a/testData/parser/Recover.txt b/testData/parser/Recover.txt index e08942e5b9..4a456e7d5c 100644 --- a/testData/parser/Recover.txt +++ b/testData/parser/Recover.txt @@ -19,11 +19,12 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('T') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('T') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + PsiElement(})('}') PsiErrorElement:'bb' unexpected PsiElement(identifier)('bb') VAR_DECLARATION diff --git a/testData/parser/Simple.txt b/testData/parser/Simple.txt index da4d91f1f1..5bc4a0769e 100644 --- a/testData/parser/Simple.txt +++ b/testData/parser/Simple.txt @@ -853,11 +853,12 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('test') - INTERFACE_TYPE - PsiElement(interface)('interface') - PsiElement({)('{') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('test') + INTERFACE_TYPE + PsiElement(interface)('interface') + PsiElement({)('{') + PsiElement(})('}') SIMPLE_STATEMENT SHORT_VAR_DECLARATION VAR_DEFINITION @@ -1558,19 +1559,20 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('name') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('foo') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('string') - TAG - PsiElement(raw_string)('`xml:""`') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('name') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('foo') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('string') + TAG + PsiElement(raw_string)('`xml:""`') + PsiElement(})('}') FUNCTION_DECLARATION PsiElement(func)('func') PsiElement(identifier)('TestFor') @@ -1584,11 +1586,12 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('name1234') - INTERFACE_TYPE - PsiElement(interface)('interface') - PsiElement({)('{') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('name1234') + INTERFACE_TYPE + PsiElement(interface)('interface') + PsiElement({)('{') + PsiElement(})('}') STATEMENT VAR_DECLARATION PsiElement(var)('var') diff --git a/testData/parser/Torture.txt b/testData/parser/Torture.txt index c01ee1b90b..f193617bcc 100644 --- a/testData/parser/Torture.txt +++ b/testData/parser/Torture.txt @@ -4520,13 +4520,14 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('A') - ARRAY_OR_SLICE_TYPE - PsiElement([)('[') - PsiElement(])(']') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('A') + SPEC_TYPE + PsiElement(identifier)('A') + ARRAY_OR_SLICE_TYPE + PsiElement([)('[') + PsiElement(])(']') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('A') PsiComment(GO_LINE_COMMENT)('// A sequence of constant indexings.') FUNCTION_DECLARATION PsiElement(func)('func') @@ -5249,25 +5250,27 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('T') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('Next') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('I') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('T') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('Next') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('I') + PsiElement(})('}') TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('I') - INTERFACE_TYPE - PsiElement(interface)('interface') - PsiElement({)('{') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('I') + INTERFACE_TYPE + PsiElement(interface)('interface') + PsiElement({)('{') + PsiElement(})('}') PsiComment(GO_LINE_COMMENT)('// A chains of type assertions.') FUNCTION_DECLARATION PsiElement(func)('func') @@ -5559,20 +5562,21 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('U') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('Children') - ARRAY_OR_SLICE_TYPE - PsiElement([)('[') - PsiElement(])(']') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('J') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('U') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('Children') + ARRAY_OR_SLICE_TYPE + PsiElement([)('[') + PsiElement(])(']') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('J') + PsiElement(})('}') METHOD_DECLARATION PsiElement(func)('func') RECEIVER @@ -5616,27 +5620,28 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('J') - INTERFACE_TYPE - PsiElement(interface)('interface') - PsiElement({)('{') - METHOD_SPEC - PsiElement(identifier)('Child') - SIGNATURE - PARAMETERS - PsiElement(()('(') - PARAMETER_DECLARATION - PARAM_DEFINITION - PsiElement(identifier)('n') + SPEC_TYPE + PsiElement(identifier)('J') + INTERFACE_TYPE + PsiElement(interface)('interface') + PsiElement({)('{') + METHOD_SPEC + PsiElement(identifier)('Child') + SIGNATURE + PARAMETERS + PsiElement(()('(') + PARAMETER_DECLARATION + PARAM_DEFINITION + PsiElement(identifier)('n') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('int') + PsiElement())(')') + RESULT TYPE TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('int') - PsiElement())(')') - RESULT - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('J') - PsiElement(})('}') + PsiElement(identifier)('J') + PsiElement(})('}') FUNCTION_DECLARATION PsiElement(func)('func') PsiElement(identifier)('ChainUAssert') @@ -6610,22 +6615,23 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('UArr') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('Children') - ARRAY_OR_SLICE_TYPE - PsiElement([)('[') - LITERAL - PsiElement(int)('2') - PsiElement(])(']') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('J') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('UArr') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('Children') + ARRAY_OR_SLICE_TYPE + PsiElement([)('[') + LITERAL + PsiElement(int)('2') + PsiElement(])(']') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('J') + PsiElement(})('}') METHOD_DECLARATION PsiElement(func)('func') RECEIVER @@ -6937,24 +6943,25 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('UArrPtr') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('Children') - POINTER_TYPE - PsiElement(*)('*') - ARRAY_OR_SLICE_TYPE - PsiElement([)('[') - LITERAL - PsiElement(int)('2') - PsiElement(])(']') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('J') - PsiElement(})('}') + SPEC_TYPE + PsiElement(identifier)('UArrPtr') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('Children') + POINTER_TYPE + PsiElement(*)('*') + ARRAY_OR_SLICE_TYPE + PsiElement([)('[') + LITERAL + PsiElement(int)('2') + PsiElement(])(']') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('J') + PsiElement(})('}') METHOD_DECLARATION PsiElement(func)('func') RECEIVER diff --git a/testData/parser/Types.txt b/testData/parser/Types.txt index 188549ef72..4a16b3c7ce 100644 --- a/testData/parser/Types.txt +++ b/testData/parser/Types.txt @@ -8,102 +8,108 @@ GO_FILE PsiElement(type)('type') PsiElement(()('(') TYPE_SPEC - PsiElement(identifier)('T0') - ARRAY_OR_SLICE_TYPE - PsiElement([)('[') - PsiElement(])(']') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('string') - TYPE_SPEC - PsiElement(identifier)('T1') - ARRAY_OR_SLICE_TYPE - PsiElement([)('[') - PsiElement(])(']') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('string') - TYPE_SPEC - PsiElement(identifier)('T2') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('a') - PsiElement(,)(',') - FIELD_DEFINITION - PsiElement(identifier)('b') + SPEC_TYPE + PsiElement(identifier)('T0') + ARRAY_OR_SLICE_TYPE + PsiElement([)('[') + PsiElement(])(']') TYPE TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('int') - PsiElement(})('}') + PsiElement(identifier)('string') TYPE_SPEC - PsiElement(identifier)('T3') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('a') - PsiElement(,)(',') - FIELD_DEFINITION - PsiElement(identifier)('c') + SPEC_TYPE + PsiElement(identifier)('T1') + ARRAY_OR_SLICE_TYPE + PsiElement([)('[') + PsiElement(])(']') TYPE TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('int') - PsiElement(})('}') + PsiElement(identifier)('string') TYPE_SPEC - PsiElement(identifier)('T4') - FUNCTION_TYPE - PsiElement(func)('func') - SIGNATURE - PARAMETERS - PsiElement(()('(') - PARAMETER_DECLARATION - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('int') + SPEC_TYPE + PsiElement(identifier)('T2') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('a') PsiElement(,)(',') - PARAMETER_DECLARATION - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('float64') - PsiElement())(')') - RESULT - POINTER_TYPE - PsiElement(*)('*') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('T0') + FIELD_DEFINITION + PsiElement(identifier)('b') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('int') + PsiElement(})('}') TYPE_SPEC - PsiElement(identifier)('T5') - FUNCTION_TYPE - PsiElement(func)('func') - SIGNATURE - PARAMETERS - PsiElement(()('(') - PARAMETER_DECLARATION - PARAM_DEFINITION - PsiElement(identifier)('x') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('int') + SPEC_TYPE + PsiElement(identifier)('T3') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('a') PsiElement(,)(',') - PARAMETER_DECLARATION - PARAM_DEFINITION - PsiElement(identifier)('y') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('float64') - PsiElement())(')') - RESULT - POINTER_TYPE - PsiElement(*)('*') - ARRAY_OR_SLICE_TYPE - PsiElement([)('[') - PsiElement(])(']') + FIELD_DEFINITION + PsiElement(identifier)('c') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('int') + PsiElement(})('}') + TYPE_SPEC + SPEC_TYPE + PsiElement(identifier)('T4') + FUNCTION_TYPE + PsiElement(func)('func') + SIGNATURE + PARAMETERS + PsiElement(()('(') + PARAMETER_DECLARATION + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('int') + PsiElement(,)(',') + PARAMETER_DECLARATION + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('float64') + PsiElement())(')') + RESULT + POINTER_TYPE + PsiElement(*)('*') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('T0') + TYPE_SPEC + SPEC_TYPE + PsiElement(identifier)('T5') + FUNCTION_TYPE + PsiElement(func)('func') + SIGNATURE + PARAMETERS + PsiElement(()('(') + PARAMETER_DECLARATION + PARAM_DEFINITION + PsiElement(identifier)('x') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('int') + PsiElement(,)(',') + PARAMETER_DECLARATION + PARAM_DEFINITION + PsiElement(identifier)('y') TYPE TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('string') + PsiElement(identifier)('float64') + PsiElement())(')') + RESULT + POINTER_TYPE + PsiElement(*)('*') + ARRAY_OR_SLICE_TYPE + PsiElement([)('[') + PsiElement(])(']') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('string') PsiElement())(')') \ No newline at end of file diff --git a/testData/parser/Writer.txt b/testData/parser/Writer.txt index f43bf62b71..0fb057c1c7 100644 --- a/testData/parser/Writer.txt +++ b/testData/parser/Writer.txt @@ -110,53 +110,54 @@ GO_FILE TYPE_DECLARATION PsiElement(type)('type') TYPE_SPEC - PsiElement(identifier)('Writer') - STRUCT_TYPE - PsiElement(struct)('struct') - PsiElement({)('{') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('w') - TYPE - TYPE_REFERENCE_EXPRESSION + SPEC_TYPE + PsiElement(identifier)('Writer') + STRUCT_TYPE + PsiElement(struct)('struct') + PsiElement({)('{') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('w') + TYPE TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('io') - PsiElement(.)('.') - PsiElement(identifier)('Writer') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('err') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('error') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('nb') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('int64') - PsiComment(GO_LINE_COMMENT)('// number of unwritten bytes for current file entry') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('pad') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('int64') - PsiComment(GO_LINE_COMMENT)('// amount of padding to write after current file entry') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('closed') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('bool') - FIELD_DECLARATION - FIELD_DEFINITION - PsiElement(identifier)('usedBinary') - TYPE - TYPE_REFERENCE_EXPRESSION - PsiElement(identifier)('bool') - PsiComment(GO_LINE_COMMENT)('// whether the binary numeric field extension was used') - PsiElement(})('}') + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('io') + PsiElement(.)('.') + PsiElement(identifier)('Writer') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('err') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('error') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('nb') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('int64') + PsiComment(GO_LINE_COMMENT)('// number of unwritten bytes for current file entry') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('pad') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('int64') + PsiComment(GO_LINE_COMMENT)('// amount of padding to write after current file entry') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('closed') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('bool') + FIELD_DECLARATION + FIELD_DEFINITION + PsiElement(identifier)('usedBinary') + TYPE + TYPE_REFERENCE_EXPRESSION + PsiElement(identifier)('bool') + PsiComment(GO_LINE_COMMENT)('// whether the binary numeric field extension was used') + PsiElement(})('}') PsiComment(GO_LINE_COMMENT)('// NewWriter creates a new Writer writing to w.') FUNCTION_DECLARATION PsiElement(func)('func')