Get rid of JetNodeTypes#LOOP_PARAMETER
This commit is contained in:
@@ -108,7 +108,6 @@ public interface JetNodeTypes {
|
||||
JetNodeType FOR = new JetNodeType("FOR", JetForExpression.class);
|
||||
JetNodeType WHILE = new JetNodeType("WHILE", JetWhileExpression.class);
|
||||
JetNodeType DO_WHILE = new JetNodeType("DO_WHILE", JetDoWhileExpression.class);
|
||||
JetNodeType LOOP_PARAMETER = new JetNodeType("LOOP_PARAMETER", JetParameter.class); // TODO: Do we need separate type?
|
||||
JetNodeType LOOP_RANGE = new JetNodeType("LOOP_RANGE", JetContainerNode.class);
|
||||
JetNodeType BODY = new JetNodeType("BODY", JetContainerNode.class);
|
||||
JetNodeType BLOCK = new JetNodeType("BLOCK", JetBlockExpression.class);
|
||||
|
||||
@@ -1374,7 +1374,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
advance(); // COLON
|
||||
myJetParsing.parseTypeRef(TokenSet.create(IN_KEYWORD));
|
||||
}
|
||||
parameter.done(LOOP_PARAMETER);
|
||||
parameter.done(VALUE_PARAMETER);
|
||||
}
|
||||
|
||||
expect(IN_KEYWORD, "Expecting 'in'", TokenSet.create(LPAR, LBRACE));
|
||||
|
||||
@@ -34,7 +34,7 @@ public class JetForExpression extends JetLoopExpression {
|
||||
|
||||
@Nullable
|
||||
public JetParameter getLoopParameter() {
|
||||
return (JetParameter) findChildByType(JetNodeTypes.LOOP_PARAMETER);
|
||||
return (JetParameter) findChildByType(JetNodeTypes.VALUE_PARAMETER);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -108,4 +108,8 @@ public class JetParameter extends JetNamedDeclarationStub<PsiJetParameterStub> {
|
||||
public ItemPresentation getPresentation() {
|
||||
return ItemPresentationProviders.getItemPresentation(this);
|
||||
}
|
||||
|
||||
public boolean isLoopParameter() {
|
||||
return getParent() instanceof JetForExpression;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.jet.lang.psi.stubs.elements;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.stubs.IndexSink;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
@@ -60,7 +61,11 @@ public class JetParameterElementType extends JetStubElementType<PsiJetParameterS
|
||||
|
||||
@Override
|
||||
public boolean shouldCreateStub(ASTNode node) {
|
||||
return node.getElementType() == JetStubElementTypes.VALUE_PARAMETER;
|
||||
if (!super.shouldCreateStub(node)) {
|
||||
return false;
|
||||
}
|
||||
PsiElement psi = node.getPsi();
|
||||
return psi instanceof JetParameter && !((JetParameter) psi).isLoopParameter();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -453,7 +453,7 @@ JetFile: ControlStructures.kt
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
LOOP_PARAMETER
|
||||
VALUE_PARAMETER
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
@@ -473,7 +473,7 @@ JetFile: ControlStructures.kt
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
LOOP_PARAMETER
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
@@ -491,7 +491,7 @@ JetFile: ControlStructures.kt
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
LOOP_PARAMETER
|
||||
VALUE_PARAMETER
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
@@ -518,7 +518,7 @@ JetFile: ControlStructures.kt
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
LOOP_PARAMETER
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(COLON)(':')
|
||||
@@ -588,7 +588,7 @@ JetFile: ControlStructures.kt
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
LOOP_PARAMETER
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('a')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
@@ -606,7 +606,7 @@ JetFile: ControlStructures.kt
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
LOOP_PARAMETER
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('a')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
@@ -625,7 +625,7 @@ JetFile: ControlStructures.kt
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
LOOP_PARAMETER
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('a')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
@@ -648,7 +648,7 @@ JetFile: ControlStructures.kt
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
LOOP_PARAMETER
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('a')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
|
||||
@@ -356,7 +356,7 @@ JetFile: PolymorphicClassObjects.kt
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
LOOP_PARAMETER
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('e')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
|
||||
@@ -724,7 +724,7 @@ JetFile: ArrayList.kt
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
LOOP_PARAMETER
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('i')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
@@ -845,7 +845,7 @@ JetFile: ArrayList.kt
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
LOOP_PARAMETER
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('i')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
|
||||
@@ -306,7 +306,7 @@ JetFile: IIterator.kt
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
LOOP_PARAMETER
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('i')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
|
||||
@@ -823,7 +823,7 @@ JetFile: LinkedList.kt
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
LOOP_PARAMETER
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('i')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
|
||||
@@ -167,7 +167,7 @@ JetFile: IOSamples.kt
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
LOOP_PARAMETER
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('item')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
|
||||
@@ -16,7 +16,7 @@ JetFile: ForRecovery.kt
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
LOOP_PARAMETER
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('v')
|
||||
PsiElement(COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
|
||||
@@ -75,7 +75,7 @@ JetFile: SameLineStatementRecovery.kt
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
LOOP_PARAMETER
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('a')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
|
||||
@@ -99,7 +99,7 @@ JetFile: ComplexScript.ktscript
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
LOOP_PARAMETER
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('arg')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
|
||||
@@ -81,8 +81,6 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder {
|
||||
afterInside(COLON, VALUE_PARAMETER).spaceIf(jetSettings.SPACE_AFTER_TYPE_COLON)
|
||||
beforeInside(COLON, MULTI_VARIABLE_DECLARATION_ENTRY).spaceIf(jetSettings.SPACE_BEFORE_TYPE_COLON)
|
||||
afterInside(COLON, MULTI_VARIABLE_DECLARATION_ENTRY).spaceIf(jetSettings.SPACE_AFTER_TYPE_COLON)
|
||||
beforeInside(COLON, LOOP_PARAMETER).spaceIf(jetSettings.SPACE_BEFORE_TYPE_COLON)
|
||||
afterInside(COLON, LOOP_PARAMETER).spaceIf(jetSettings.SPACE_AFTER_TYPE_COLON)
|
||||
beforeInside(COLON, FUNCTION_LITERAL).spaceIf(jetSettings.SPACE_BEFORE_TYPE_COLON)
|
||||
afterInside(COLON, FUNCTION_LITERAL).spaceIf(jetSettings.SPACE_AFTER_TYPE_COLON)
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
|
||||
&& !((JetNamedFunction) declaration).hasBlockBody()) {
|
||||
setText(JetBundle.message("specify.type.explicitly.add.return.type.action.name"));
|
||||
}
|
||||
else if (declaration instanceof JetParameter && JetNodeTypes.LOOP_PARAMETER == declaration.getNode().getElementType()) {
|
||||
else if (declaration instanceof JetParameter && ((JetParameter) declaration).isLoopParameter()) {
|
||||
if (((JetParameter) declaration).getTypeReference() != null) {
|
||||
setText(JetBundle.message("specify.type.explicitly.remove.action.name"));
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user