simpler GrLabeledStatement, get rid of GrLabel, error if labeled statement does not contain statement

This commit is contained in:
Max Medvedev
2013-06-03 20:19:30 +04:00
parent b918a38c49
commit 50dcbcffdb
28 changed files with 97 additions and 164 deletions
@@ -363,3 +363,4 @@ expected.0.to.be.inline.constant=Expected ''{0}'' to be an inline constant
cannot.assign.a.value.to.final.field.0=Cannot assign a value to final field ''{0}''
variable.0.might.not.have.been.initialized=Variable ''{0}'' might not have been initialized
unexpected.symbol=Unexpected symbol
statement.expected=Statement expected
@@ -34,6 +34,7 @@ import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrClassInitializer;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrLabeledStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrAssignmentExpression;
@@ -181,6 +182,9 @@ public class GrHighlightUtil {
boolean reassigned = isReassigned((GrVariable)resolved);
return reassigned ? REASSIGNED_LOCAL_VARIABLE : LOCAL_VARIABLE;
}
else if (resolved instanceof GrLabeledStatement) {
return LABEL;
}
return null;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,6 @@ import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
import org.jetbrains.plugins.groovy.lang.psi.GrNamedElement;
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrLabel;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationNameValuePair;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentLabel;
@@ -47,7 +46,8 @@ import java.util.ArrayList;
import java.util.List;
import static com.intellij.codeInsight.daemon.impl.HighlightInfoType.INFORMATION;
import static org.jetbrains.plugins.groovy.highlighter.DefaultHighlighter.*;
import static org.jetbrains.plugins.groovy.highlighter.DefaultHighlighter.ANNOTATION;
import static org.jetbrains.plugins.groovy.highlighter.DefaultHighlighter.KEYWORD;
/**
* @author Max Medvedev
@@ -81,9 +81,6 @@ public class GrKeywordAndDeclarationHighlighter extends TextEditorHighlightingPa
}
}
else {
if (element instanceof GrLabel) {
addInfo(element, LABEL);
}
super.visitElement(element);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,7 +63,7 @@ public class GroovyLabeledStatementInspection extends BaseInspection {
public void visitLabeledStatement(GrLabeledStatement labeledStatement) {
super.visitLabeledStatement(labeledStatement);
final String name = labeledStatement.getLabelName();
final String name = labeledStatement.getName();
GrLabeledStatement existing = ResolveUtil.resolveLabeledStatement(name, labeledStatement, true);
if (existing != null && PsiTreeUtil.isAncestor(existing, labeledStatement, true)) {
registerError(labeledStatement.getLabel(), name);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -127,8 +127,8 @@ public class GroovyPostHighlightingPass extends TextEditorHighlightingPass {
}
if (deadCodeEnabled &&
element instanceof GrNamedElement &&
!PostHighlightingPass.isImplicitUsage((GrNamedElement)element, progress) &&
element instanceof GrNamedElement && element instanceof PsiModifierListOwner &&
!PostHighlightingPass.isImplicitUsage((PsiModifierListOwner)element, progress) &&
!GroovySuppressableInspectionTool.isElementToolSuppressedIn(element, GroovyUnusedDeclarationInspection.SHORT_NAME)) {
PsiElement nameId = ((GrNamedElement)element).getNameIdentifierGroovy();
if (nameId.getNode().getElementType() == GroovyTokenTypes.mIDENT) {
@@ -90,7 +90,7 @@ public class GroovyFindUsagesProvider implements FindUsagesProvider {
return name;
}
} else if (element instanceof GrLabeledStatement) {
return ((GrLabeledStatement)element).getLabelName();
return ((GrLabeledStatement)element).getName();
} else if (element instanceof PropertyForRename) {
return ((PropertyForRename)element).getPropertyName();
} else if (element instanceof GrClosableBlock) {
@@ -145,7 +145,7 @@ public class GroovyIndentProcessor extends GroovyElementVisitor {
@Override
public void visitLabeledStatement(GrLabeledStatement labeledStatement) {
if (myChildType == LABEL) {
if (myChildType == mIDENT) {
CommonCodeStyleSettings.IndentOptions indentOptions = myBlock.getContext().getSettings().getIndentOptions();
if (indentOptions != null && indentOptions.LABEL_INDENT_ABSOLUTE) {
myResult = Indent.getAbsoluteLabelIndent();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,7 +52,7 @@ public abstract class GrChangeMemberVisibilityModifierBase extends Intention {
final PsiElement parent = element.getParent();
return parent instanceof GrMember &&
parent instanceof GrNamedElement &&
(((GrNamedElement)parent).getNameIdentifierGroovy() == element || ((GrNamedElement)parent).getModifierList() == element) &&
(((GrNamedElement)parent).getNameIdentifierGroovy() == element || ((GrMember)parent).getModifierList() == element) &&
((GrMember)parent).getModifierList() != null && !((GrMember)parent).getModifierList().hasExplicitModifier(myModifier);
}
};
@@ -226,8 +226,6 @@ public interface GroovyElementTypes extends GroovyTokenTypes, GroovyDocElementTy
GroovyElementType PATH_INDEX_PROPERTY = new GroovyElementType("Index property");
GroovyElementType PARENTHESIZED_EXPRESSION = new GroovyElementType("Parenthesized expression");
// Plain label
GroovyElementType LABEL = new GroovyElementType("Label");
// Arguments
GroovyElementType ARGUMENTS = new GroovyElementType("Arguments");
@@ -247,7 +247,8 @@ public class GroovyParser implements PsiParser {
if (parseSeparatorsWithoutLastNls(builder, plainStatement, until)) {
return false;
}
} else {
}
else {
builder.error(GroovyBundle.message("wrong.statement"));
assert builder.getTokenType() != mLCURLY && builder.getTokenType() != mRCURLY;
builder.advanceLexer();
@@ -272,7 +273,8 @@ public class GroovyParser implements PsiParser {
return true;
}
beforeNls.drop();
} else {
}
else {
break;
}
}
@@ -334,7 +336,8 @@ public class GroovyParser implements PsiParser {
if (SynchronizedStatement.parse(builder, this)) {
synMarker.drop();
return true;
} else {
}
else {
synMarker.rollbackTo();
}
}
@@ -373,24 +376,25 @@ public class GroovyParser implements PsiParser {
if (BranchStatement.BRANCH_KEYWORDS.contains(builder.getTokenType())) {
return BranchStatement.parse(builder, this);
}
if (ParserUtils.lookAhead(builder, GroovyTokenTypes.mIDENT, GroovyTokenTypes.mCOLON)) {
return parseLabeledStatement(builder);
if (parseLabeledStatement(builder)) {
return true;
}
if (parseDeclaration(builder, false, false, null)) return true;
return AssignmentExpression.parse(builder, this, true);
}
/**
* parses imports (marks them as not allowed), type definitions, methods, variables or fields (if isInClass), initializers (if isInClass), constructors
* with corresponding typeDefinitionName
*
* <p/>
* If non of preceding elements was found rolls back and return false
*
*/
public boolean parseDeclaration(@NotNull PsiBuilder builder, boolean isInClass, boolean isInAnnotation, @Nullable String typeDefinitionName) {
public boolean parseDeclaration(@NotNull PsiBuilder builder,
boolean isInClass,
boolean isInAnnotation,
@Nullable String typeDefinitionName) {
PsiBuilder.Marker declMarker = builder.mark();
boolean modifiersParsed = Modifiers.parse(builder, this);
@@ -419,7 +423,8 @@ public class GroovyParser implements PsiParser {
return true;
}
final IElementType declType = Declaration.parseAfterModifiers(builder, isInClass, isInAnnotation, typeDefinitionName, this, modifiersParsed);
final IElementType declType =
Declaration.parseAfterModifiers(builder, isInClass, isInAnnotation, typeDefinitionName, this, modifiersParsed);
if (declType != WRONGWAY) {
if (declType != null) {
declMarker.done(declType);
@@ -455,7 +460,8 @@ public class GroovyParser implements PsiParser {
public boolean parseStatementWithImports(PsiBuilder builder) {
if (ImportStatement.parse(builder, this)) {
return true;
} else {
}
else {
return parseStatement(builder, false);
}
}
@@ -463,12 +469,22 @@ public class GroovyParser implements PsiParser {
private boolean parseLabeledStatement(PsiBuilder builder) {
PsiBuilder.Marker marker = builder.mark();
ParserUtils.eatElement(builder, LABEL);
ParserUtils.getToken(builder, GroovyTokenTypes.mCOLON);
if (!ParserUtils.getToken(builder, mIDENT) || !ParserUtils.getToken(builder, GroovyTokenTypes.mCOLON)) {
marker.rollbackTo();
return false;
}
final PsiBuilder.Marker nlsMarker = builder.mark();
ParserUtils.getToken(builder, GroovyTokenTypes.mNLS);
parseStatement(builder, true);
if (parseStatement(builder, true)) {
nlsMarker.drop();
}
else {
nlsMarker.rollbackTo();
builder.error(GroovyBundle.message("statement.expected"));
}
marker.done(LABELED_STATEMENT);
return true;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,6 @@ import org.jetbrains.plugins.groovy.lang.groovydoc.psi.GroovyDocPsiCreator;
import org.jetbrains.plugins.groovy.lang.lexer.GroovyElementType;
import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyASTPsiElementImpl;
import org.jetbrains.plugins.groovy.lang.psi.impl.auxiliary.GrLabelImpl;
import org.jetbrains.plugins.groovy.lang.psi.impl.auxiliary.GrListOrMapImpl;
import org.jetbrains.plugins.groovy.lang.psi.impl.auxiliary.GrThrowsClauseImpl;
import org.jetbrains.plugins.groovy.lang.psi.impl.auxiliary.annotation.GrAnnotationArgumentListImpl;
@@ -98,7 +97,6 @@ public class GroovyPsiCreator implements GroovyElementTypes {
//Identifiers & literal
if (elem == LITERAL) return new GrLiteralImpl(node);
if (elem == LABEL) return new GrLabelImpl(node);
// if (elem.equals(IDENTIFIER)) return new GrIdentifierImpl(node);
//Lists, maps etc...
if (elem == LIST_OR_MAP) return new GrListOrMapImpl(node);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,15 +16,14 @@
package org.jetbrains.plugins.groovy.lang.psi;
import com.intellij.psi.PsiModifierListOwner;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import org.jetbrains.annotations.NotNull;
/**
* @author ven
*/
public interface GrNamedElement extends PsiNamedElement, GroovyPsiElement, PsiModifierListOwner {
public interface GrNamedElement extends PsiNamedElement, GroovyPsiElement {
@NotNull
PsiElement getNameIdentifierGroovy();
}
@@ -16,7 +16,6 @@
package org.jetbrains.plugins.groovy.lang.psi;
import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.*;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrLabel;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrThrowsClause;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
@@ -212,10 +211,6 @@ public abstract class GroovyElementVisitor {
visitExpression(expression);
}
public void visitLabel(GrLabel label) {
visitElement(label);
}
public void visitArgumentList(GrArgumentList list) {
visitElement(list);
}
@@ -27,7 +27,6 @@ import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment;
import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMemberReference;
import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocReferenceElement;
import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocTag;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrLabel;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrClosureSignature;
@@ -228,8 +227,6 @@ public abstract class GroovyPsiElementFactory implements JVMElementFactory {
public abstract GrMethod createConstructorFromText(String constructorName, CharSequence constructorText, @Nullable PsiElement context);
public abstract GrLabel createLabel(@NotNull String name);
public abstract GrDocComment createDocCommentFromText(String text) ;
public abstract GrDocTag createDocTagFromText(String text) ;
@@ -1,26 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.plugins.groovy.lang.psi.api.auxiliary;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
/**
* @author ilyas
*/
public interface GrLabel extends GroovyPsiElement {
String getName();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,21 +16,22 @@
package org.jetbrains.plugins.groovy.lang.psi.api.statements;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrLabel;
import org.jetbrains.plugins.groovy.lang.psi.GrNamedElement;
/**
* @author ilyas
*/
public interface GrLabeledStatement extends GrStatement, PsiNamedElement{
@NotNull
String getLabelName();
public interface GrLabeledStatement extends GrStatement, GrNamedElement {
@Nullable
GrStatement getStatement();
@NotNull
GrLabel getLabel();
PsiElement getLabel();
@NotNull
@Override
String getName();
}
@@ -41,7 +41,6 @@ import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMemberReference;
import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocReferenceElement;
import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocTag;
import org.jetbrains.plugins.groovy.lang.psi.*;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrLabel;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrClosureSignature;
@@ -501,14 +500,6 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
return methods[0];
}
@Override
public GrLabel createLabel(@NotNull String name) {
GroovyFileBase file = createGroovyFileChecked(name + ": println()");
GrTopStatement definition = file.getTopStatements()[0];
assert definition instanceof GrLabeledStatement;
return ((GrLabeledStatement)definition).getLabel();
}
@NotNull
public GrMethod createMethodFromText(@NotNull String methodText, @Nullable PsiElement context) {
GroovyFile file = createGroovyFile(methodText, false, context);
@@ -1,51 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.plugins.groovy.lang.psi.impl.auxiliary;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrLabel;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl;
/**
* @author ilyas
*/
public class GrLabelImpl extends GroovyPsiElementImpl implements GrLabel {
public GrLabelImpl(@NotNull ASTNode node) {
super(node);
}
public void accept(GroovyElementVisitor visitor) {
visitor.visitLabel(this);
}
public String toString() {
return "Label";
}
public String getName() {
final PsiElement id = findChildByType(GroovyElementTypes.mIDENT);
assert id != null;
return id.getText();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@ public class GrLabelReference implements PsiReference {
public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
if (element instanceof GrLabeledStatement) {
myStatement = handleElementRename(((GrLabeledStatement)element).getLabelName());
myStatement = handleElementRename(((GrLabeledStatement)element).getName());
}
throw new IncorrectOperationException("Can't bind not to labeled statement");
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,9 +26,9 @@ import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrLabel;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrLabeledStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl;
@@ -51,13 +51,12 @@ public class GrLabeledStatementImpl extends GroovyPsiElementImpl implements GrLa
@NotNull
public String getLabelName() {
final GrLabel label = getLabel();
return label.getName();
return getName();
}
@NotNull
public GrLabel getLabel() {
final GrLabel label = findChildByClass(GrLabel.class);
public PsiElement getLabel() {
final PsiElement label = findChildByType(GroovyTokenTypes.mIDENT);
assert label != null;
return label;
}
@@ -69,7 +68,7 @@ public class GrLabeledStatementImpl extends GroovyPsiElementImpl implements GrLa
public boolean processDeclarations(@NotNull PsiScopeProcessor processor,
@NotNull ResolveState state,
PsiElement lastParent,
@Nullable PsiElement lastParent,
@NotNull PsiElement place) {
GrStatement statement = getStatement();
return statement == null || statement == lastParent || statement.processDeclarations(processor, state, lastParent, place);
@@ -82,14 +81,22 @@ public class GrLabeledStatementImpl extends GroovyPsiElementImpl implements GrLa
}
public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException {
final GrLabel labelElement = getLabel();
final GrLabel newLabel = GroovyPsiElementFactory.getInstance(getProject()).createLabel(name);
final PsiElement labelElement = getLabel();
final PsiElement newLabel = GroovyPsiElementFactory.getInstance(getProject()).createReferenceNameFromText(name);
labelElement.replace(newLabel);
return this;
}
@NotNull
@Override
public String getName() {
return getLabelName();
final PsiElement label = getLabel();
return label.getText();
}
@NotNull
@Override
public PsiElement getNameIdentifierGroovy() {
return getLabel();
}
}
@@ -448,7 +448,7 @@ public class ResolveUtil {
}
private static boolean isApplicableLabelStatement(PsiElement element, String labelName) {
return ((element instanceof GrLabeledStatement && labelName.equals(((GrLabeledStatement)element).getLabelName())));
return ((element instanceof GrLabeledStatement && labelName.equals(((GrLabeledStatement)element).getName())));
}
@Nullable
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -305,7 +305,7 @@ public class CodeBlockGenerator extends Generator {
GenerationUtil.writeStatement(builder, context, labeledStatement, new StatementWriter() {
@Override
public void writeStatement(StringBuilder builder, ExpressionContext context) {
final String label = labeledStatement.getLabelName();
final String label = labeledStatement.getName();
final GrStatement statement = labeledStatement.getStatement();
builder.append(label).append(": ");
@@ -93,7 +93,7 @@ public class SpockUtils {
while (true) {
GrStatement statement = l.getStatement();
if ("where".equals(l.getLabelName())) {
if ("where".equals(l.getName())) {
elementUnderLabel = statement;
break main;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -100,6 +100,7 @@ public class StatementsParsingTest extends GroovyParsingTestCase {
public void testKing_regex$king4() throws Throwable { doTest(); }
public void testLabeled$label1() throws Throwable { doTest(); }
public void testLabeled$label2() throws Throwable { doTest(); }
public void testLabeled$label3() throws Throwable { doTest(); }
public void testLoop$while1() throws Throwable { doTest(); }
public void testLoop$while2() throws Throwable { doTest(); }
public void testLoop$while3() throws Throwable { doTest(); }
@@ -2,8 +2,7 @@ L:{ x + y }.getClass()
-----
Groovy script
Labeled statement
Label
PsiElement(identifier)('L')
PsiElement(identifier)('L')
PsiElement(:)(':')
Block statement
Open block
@@ -6,8 +6,7 @@ Groovy script
PsiElement(Integer)('1')
PsiElement(new line)('\n')
Labeled statement
Label
PsiElement(identifier)('l')
PsiElement(identifier)('l')
PsiElement(:)(':')
PsiWhiteSpace(' ')
Block statement
@@ -3,8 +3,7 @@ myLabel:
-----
Groovy script
Labeled statement
Label
PsiElement(identifier)('myLabel')
PsiElement(identifier)('myLabel')
PsiElement(:)(':')
PsiElement(new line)('\n')
Additive expression
@@ -0,0 +1,8 @@
myLabel:
-----
Groovy script
Labeled statement
PsiElement(identifier)('myLabel')
PsiElement(:)(':')
PsiErrorElement:Statement expected
<empty list>