Removing obsolete PSI classes, error message and CF-handling
#KT-2359 In Progress
This commit is contained in:
@@ -26,7 +26,6 @@ import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowInstructionsGenerator
|
|||||||
import org.jetbrains.jet.lang.cfg.pseudocode.LocalDeclarationInstruction;
|
import org.jetbrains.jet.lang.cfg.pseudocode.LocalDeclarationInstruction;
|
||||||
import org.jetbrains.jet.lang.cfg.pseudocode.Pseudocode;
|
import org.jetbrains.jet.lang.cfg.pseudocode.Pseudocode;
|
||||||
import org.jetbrains.jet.lang.cfg.pseudocode.PseudocodeImpl;
|
import org.jetbrains.jet.lang.cfg.pseudocode.PseudocodeImpl;
|
||||||
import org.jetbrains.jet.lang.diagnostics.AbstractDiagnosticFactory;
|
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||||
@@ -109,18 +108,12 @@ public class JetControlFlowProcessor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitWhenConditionIsPattern(JetWhenConditionIsPattern condition) {
|
public void visitWhenConditionIsPattern(JetWhenConditionIsPattern condition) {
|
||||||
JetPattern pattern = condition.getPattern();
|
// TODO: types in CF?
|
||||||
if (pattern != null) {
|
|
||||||
pattern.accept(patternVisitor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitWhenConditionWithExpression(JetWhenConditionWithExpression condition) {
|
public void visitWhenConditionWithExpression(JetWhenConditionWithExpression condition) {
|
||||||
JetExpressionPattern pattern = condition.getPattern();
|
value(condition.getExpression(), inCondition);
|
||||||
if (pattern != null) {
|
|
||||||
pattern.accept(patternVisitor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -129,50 +122,6 @@ public class JetControlFlowProcessor {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
private final JetVisitorVoid patternVisitor = new JetVisitorVoid() {
|
private final JetVisitorVoid patternVisitor = new JetVisitorVoid() {
|
||||||
@Override
|
|
||||||
public void visitTypePattern(JetTypePattern typePattern) {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void visitWildcardPattern(JetWildcardPattern pattern) {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void visitExpressionPattern(JetExpressionPattern pattern) {
|
|
||||||
value(pattern.getExpression(), inCondition);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void visitTuplePattern(JetTuplePattern pattern) {
|
|
||||||
List<JetTuplePatternEntry> entries = pattern.getEntries();
|
|
||||||
for (JetTuplePatternEntry entry : entries) {
|
|
||||||
JetPattern entryPattern = entry.getPattern();
|
|
||||||
if (entryPattern != null) {
|
|
||||||
entryPattern.accept(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void visitDecomposerPattern(JetDecomposerPattern pattern) {
|
|
||||||
value(pattern.getDecomposerExpression(), inCondition);
|
|
||||||
JetTuplePattern argumentList = pattern.getArgumentList();
|
|
||||||
if (argumentList != null) {
|
|
||||||
argumentList.accept(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void visitBindingPattern(JetBindingPattern pattern) {
|
|
||||||
JetProperty variableDeclaration = pattern.getVariableDeclaration();
|
|
||||||
builder.write(pattern, variableDeclaration);
|
|
||||||
JetWhenCondition condition = pattern.getCondition();
|
|
||||||
if (condition != null) {
|
|
||||||
condition.accept(conditionVisitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitJetElement(JetElement element) {
|
public void visitJetElement(JetElement element) {
|
||||||
@@ -807,10 +756,7 @@ public class JetControlFlowProcessor {
|
|||||||
@Override
|
@Override
|
||||||
public void visitIsExpression(final JetIsExpression expression) {
|
public void visitIsExpression(final JetIsExpression expression) {
|
||||||
value(expression.getLeftHandSide(), inCondition);
|
value(expression.getLeftHandSide(), inCondition);
|
||||||
JetPattern pattern = expression.getPattern();
|
// no CF for types
|
||||||
if (pattern != null) {
|
|
||||||
pattern.accept(patternVisitor);
|
|
||||||
}
|
|
||||||
// TODO : builder.read(expression.getPattern());
|
// TODO : builder.read(expression.getPattern());
|
||||||
builder.read(expression);
|
builder.read(expression);
|
||||||
}
|
}
|
||||||
@@ -837,7 +783,7 @@ public class JetControlFlowProcessor {
|
|||||||
trace.report(ELSE_MISPLACED_IN_WHEN.on(whenEntry));
|
trace.report(ELSE_MISPLACED_IN_WHEN.on(whenEntry));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean isIrrefutable = JetPsiUtil.isIrrefutable(whenEntry);
|
boolean isIrrefutable = whenEntry.isElse();
|
||||||
if (isIrrefutable) {
|
if (isIrrefutable) {
|
||||||
hasElseOrIrrefutableBranch = true;
|
hasElseOrIrrefutableBranch = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,9 +70,7 @@ public class WhenChecker {
|
|||||||
for (JetWhenEntry whenEntry : whenExpression.getEntries()) {
|
for (JetWhenEntry whenEntry : whenExpression.getEntries()) {
|
||||||
for (JetWhenCondition condition : whenEntry.getConditions()) {
|
for (JetWhenCondition condition : whenEntry.getConditions()) {
|
||||||
if (condition instanceof JetWhenConditionWithExpression) {
|
if (condition instanceof JetWhenConditionWithExpression) {
|
||||||
JetExpressionPattern pattern = ((JetWhenConditionWithExpression) condition).getPattern();
|
JetExpression patternExpression = ((JetWhenConditionWithExpression) condition).getExpression();
|
||||||
if (pattern == null) continue;
|
|
||||||
JetExpression patternExpression = pattern.getExpression();
|
|
||||||
JetType type = trace.get(BindingContext.EXPRESSION_TYPE, patternExpression);
|
JetType type = trace.get(BindingContext.EXPRESSION_TYPE, patternExpression);
|
||||||
if (type == null) continue;
|
if (type == null) continue;
|
||||||
if (type.getConstructor().getDeclarationDescriptor() == enumEntry) {
|
if (type.getConstructor().getDeclarationDescriptor() == enumEntry) {
|
||||||
|
|||||||
@@ -276,8 +276,6 @@ public interface Errors {
|
|||||||
|
|
||||||
DiagnosticFactory2<JetTypeReference, JetType, JetType> TYPE_MISMATCH_IN_FOR_LOOP = DiagnosticFactory2.create(ERROR);
|
DiagnosticFactory2<JetTypeReference, JetType, JetType> TYPE_MISMATCH_IN_FOR_LOOP = DiagnosticFactory2.create(ERROR);
|
||||||
DiagnosticFactory1<JetElement, JetType> TYPE_MISMATCH_IN_CONDITION = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<JetElement, JetType> TYPE_MISMATCH_IN_CONDITION = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory2<JetTuplePattern, JetType, Integer> TYPE_MISMATCH_IN_TUPLE_PATTERN = DiagnosticFactory2.create(ERROR);
|
|
||||||
DiagnosticFactory2<JetTypeReference, JetType, JetType> TYPE_MISMATCH_IN_BINDING_PATTERN = DiagnosticFactory2.create(ERROR);
|
|
||||||
DiagnosticFactory2<JetElement, JetType, JetType> INCOMPATIBLE_TYPES = DiagnosticFactory2.create(ERROR);
|
DiagnosticFactory2<JetElement, JetType, JetType> INCOMPATIBLE_TYPES = DiagnosticFactory2.create(ERROR);
|
||||||
SimpleDiagnosticFactory<JetWhenCondition> EXPECTED_CONDITION = SimpleDiagnosticFactory.create(ERROR);
|
SimpleDiagnosticFactory<JetWhenCondition> EXPECTED_CONDITION = SimpleDiagnosticFactory.create(ERROR);
|
||||||
|
|
||||||
|
|||||||
-2
@@ -312,8 +312,6 @@ public class DefaultErrorMessages {
|
|||||||
MAP.put(TYPE_MISMATCH_IN_FOR_LOOP, "The loop iterates over values of type {0} but the parameter is declared to be {1}", RENDER_TYPE,
|
MAP.put(TYPE_MISMATCH_IN_FOR_LOOP, "The loop iterates over values of type {0} but the parameter is declared to be {1}", RENDER_TYPE,
|
||||||
RENDER_TYPE);
|
RENDER_TYPE);
|
||||||
MAP.put(TYPE_MISMATCH_IN_CONDITION, "Condition must be of type jet.Boolean, but is of type {0}", RENDER_TYPE);
|
MAP.put(TYPE_MISMATCH_IN_CONDITION, "Condition must be of type jet.Boolean, but is of type {0}", RENDER_TYPE);
|
||||||
MAP.put(TYPE_MISMATCH_IN_TUPLE_PATTERN, "Type mismatch: subject is of type {0} but the pattern is a {1}-tuple", RENDER_TYPE, TO_STRING);
|
|
||||||
MAP.put(TYPE_MISMATCH_IN_BINDING_PATTERN, "{0} is not a supertype of {1}. Use ''is'' to match against {0}", RENDER_TYPE, RENDER_TYPE);
|
|
||||||
MAP.put(INCOMPATIBLE_TYPES, "Incompatible types: {0} and {1}", RENDER_TYPE, RENDER_TYPE);
|
MAP.put(INCOMPATIBLE_TYPES, "Incompatible types: {0} and {1}", RENDER_TYPE, RENDER_TYPE);
|
||||||
MAP.put(EXPECTED_CONDITION, "Expected condition of jet.Boolean type");
|
MAP.put(EXPECTED_CONDITION, "Expected condition of jet.Boolean type");
|
||||||
|
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2012 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.jet.lang.psi;
|
|
||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jetbrains.jet.JetNodeTypes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author abreslav
|
|
||||||
*/
|
|
||||||
public class JetBindingPattern extends JetPattern {
|
|
||||||
public JetBindingPattern(@NotNull ASTNode node) {
|
|
||||||
super(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public JetProperty getVariableDeclaration() {
|
|
||||||
return (JetProperty) findChildByType(JetNodeTypes.PROPERTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public JetWhenCondition getCondition() {
|
|
||||||
return findChildByClass(JetWhenCondition.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(@NotNull JetVisitorVoid visitor) {
|
|
||||||
visitor.visitBindingPattern(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
|
|
||||||
return visitor.visitBindingPattern(this, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2012 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.jet.lang.psi;
|
|
||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jetbrains.jet.JetNodeTypes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author abreslav
|
|
||||||
*/
|
|
||||||
public class JetDecomposerPattern extends JetPattern {
|
|
||||||
public JetDecomposerPattern(@NotNull ASTNode node) {
|
|
||||||
super(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @IfNotParsed
|
|
||||||
public JetExpression getDecomposerExpression() {
|
|
||||||
return findChildByClass(JetExpression.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public JetTuplePattern getArgumentList() {
|
|
||||||
return (JetTuplePattern) findChildByType(JetNodeTypes.DECOMPOSER_ARGUMENT_LIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(@NotNull JetVisitorVoid visitor) {
|
|
||||||
visitor.visitDecomposerPattern(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
|
|
||||||
return visitor.visitDecomposerPattern(this, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2012 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.jet.lang.psi;
|
|
||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author abreslav
|
|
||||||
*/
|
|
||||||
public class JetExpressionPattern extends JetPattern {
|
|
||||||
public JetExpressionPattern(@NotNull ASTNode node) {
|
|
||||||
super(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @IfNotParsed
|
|
||||||
public JetExpression getExpression() {
|
|
||||||
return findChildByClass(JetExpression.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(@NotNull JetVisitorVoid visitor) {
|
|
||||||
visitor.visitExpressionPattern(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
|
|
||||||
return visitor.visitExpressionPattern(this, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -46,8 +46,8 @@ public class JetIsExpression extends JetExpressionImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable @IfNotParsed
|
@Nullable @IfNotParsed
|
||||||
public JetPattern getPattern() {
|
public JetTypeReference getTypeRef() {
|
||||||
return findChildByClass(JetPattern.class);
|
return (JetTypeReference) findChildByType(JetNodeTypes.TYPE_REFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2012 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.jet.lang.psi;
|
|
||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author abreslav
|
|
||||||
*/
|
|
||||||
public class JetPattern extends JetElementImpl {
|
|
||||||
public JetPattern(@NotNull ASTNode node) {
|
|
||||||
super(node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -200,25 +200,6 @@ public class JetPsiUtil {
|
|||||||
return new ImportPath(text.replaceAll(" ", "") + (importDirective.isAllUnder() ? ".*" : ""));
|
return new ImportPath(text.replaceAll(" ", "") + (importDirective.isAllUnder() ? ".*" : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isIrrefutable(JetWhenEntry entry) {
|
|
||||||
if (entry.isElse()) return true;
|
|
||||||
for (JetWhenCondition condition : entry.getConditions()) {
|
|
||||||
if (condition instanceof JetWhenConditionIsPattern) {
|
|
||||||
JetPattern pattern = ((JetWhenConditionIsPattern) condition).getPattern();
|
|
||||||
if (pattern instanceof JetWildcardPattern) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (pattern instanceof JetBindingPattern) {
|
|
||||||
JetBindingPattern bindingPattern = (JetBindingPattern) pattern;
|
|
||||||
if (bindingPattern.getVariableDeclaration().getTypeRef() == null && bindingPattern.getCondition() == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static <T extends PsiElement> T getDirectParentOfTypeForBlock(@NotNull JetBlockExpression block, @NotNull Class<T> aClass) {
|
public static <T extends PsiElement> T getDirectParentOfTypeForBlock(@NotNull JetBlockExpression block, @NotNull Class<T> aClass) {
|
||||||
T parent = PsiTreeUtil.getParentOfType(block, aClass);
|
T parent = PsiTreeUtil.getParentOfType(block, aClass);
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2012 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.jet.lang.psi;
|
|
||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.jet.JetNodeTypes;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author abreslav
|
|
||||||
*/
|
|
||||||
public class JetTuplePattern extends JetPattern {
|
|
||||||
public JetTuplePattern(@NotNull ASTNode node) {
|
|
||||||
super(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(@NotNull JetVisitorVoid visitor) {
|
|
||||||
visitor.visitTuplePattern(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
|
|
||||||
return visitor.visitTuplePattern(this, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public List<JetTuplePatternEntry> getEntries() {
|
|
||||||
return findChildrenByType(JetNodeTypes.TUPLE_PATTERN_ENTRY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2012 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.jet.lang.psi;
|
|
||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author abreslav
|
|
||||||
*/
|
|
||||||
public class JetTuplePatternEntry extends JetElementImpl {
|
|
||||||
public JetTuplePatternEntry(@NotNull ASTNode node) {
|
|
||||||
super(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public ASTNode getNameLabelNode() {
|
|
||||||
return getNode().findChildByType(JetTokens.IDENTIFIER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public String getNameLabel() {
|
|
||||||
ASTNode nameLabelNode = getNameLabelNode();
|
|
||||||
return nameLabelNode == null ? null : nameLabelNode.getText();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @IfNotParsed
|
|
||||||
public JetPattern getPattern() {
|
|
||||||
return findChildByClass(JetPattern.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2012 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.jet.lang.psi;
|
|
||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author abreslav
|
|
||||||
*/
|
|
||||||
public class JetTypePattern extends JetPattern {
|
|
||||||
public JetTypePattern(@NotNull ASTNode node) {
|
|
||||||
super(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @IfNotParsed
|
|
||||||
public JetTypeReference getTypeReference() {
|
|
||||||
return findChildByClass(JetTypeReference.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(@NotNull JetVisitorVoid visitor) {
|
|
||||||
visitor.visitTypePattern(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
|
|
||||||
return visitor.visitTypePattern(this, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -388,30 +388,6 @@ public class JetVisitor<R, D> extends PsiElementVisitor {
|
|||||||
return visitJetElement(condition, data);
|
return visitJetElement(condition, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public R visitTypePattern(JetTypePattern pattern, D data) {
|
|
||||||
return visitPattern(pattern, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public R visitWildcardPattern(JetWildcardPattern pattern, D data) {
|
|
||||||
return visitPattern(pattern, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public R visitExpressionPattern(JetExpressionPattern pattern, D data) {
|
|
||||||
return visitPattern(pattern, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public R visitTuplePattern(JetTuplePattern pattern, D data) {
|
|
||||||
return visitPattern(pattern, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
private R visitPattern(JetPattern pattern, D data) {
|
|
||||||
return visitJetElement(pattern, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public R visitDecomposerPattern(JetDecomposerPattern pattern, D data) {
|
|
||||||
return visitPattern(pattern, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public R visitObjectDeclaration(JetObjectDeclaration declaration, D data) {
|
public R visitObjectDeclaration(JetObjectDeclaration declaration, D data) {
|
||||||
return visitNamedDeclaration(declaration, data);
|
return visitNamedDeclaration(declaration, data);
|
||||||
}
|
}
|
||||||
@@ -420,10 +396,6 @@ public class JetVisitor<R, D> extends PsiElementVisitor {
|
|||||||
return visitNamedDeclaration(declarationName, data);
|
return visitNamedDeclaration(declarationName, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public R visitBindingPattern(JetBindingPattern pattern, D data) {
|
|
||||||
return visitPattern(pattern, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public R visitStringTemplateEntry(JetStringTemplateEntry entry, D data) {
|
public R visitStringTemplateEntry(JetStringTemplateEntry entry, D data) {
|
||||||
return visitJetElement(entry, data);
|
return visitJetElement(entry, data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -377,30 +377,6 @@ public class JetVisitorVoid extends PsiElementVisitor {
|
|||||||
visitJetElement(condition);
|
visitJetElement(condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void visitTypePattern(JetTypePattern pattern) {
|
|
||||||
visitPattern(pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void visitWildcardPattern(JetWildcardPattern pattern) {
|
|
||||||
visitPattern(pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void visitExpressionPattern(JetExpressionPattern pattern) {
|
|
||||||
visitPattern(pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void visitTuplePattern(JetTuplePattern pattern) {
|
|
||||||
visitPattern(pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void visitPattern(JetPattern pattern) {
|
|
||||||
visitJetElement(pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void visitDecomposerPattern(JetDecomposerPattern pattern) {
|
|
||||||
visitPattern(pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void visitObjectDeclaration(JetObjectDeclaration declaration) {
|
public void visitObjectDeclaration(JetObjectDeclaration declaration) {
|
||||||
visitNamedDeclaration(declaration);
|
visitNamedDeclaration(declaration);
|
||||||
}
|
}
|
||||||
@@ -409,10 +385,6 @@ public class JetVisitorVoid extends PsiElementVisitor {
|
|||||||
visitNamedDeclaration(declaration);
|
visitNamedDeclaration(declaration);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void visitBindingPattern(JetBindingPattern pattern) {
|
|
||||||
visitPattern(pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void visitStringTemplateEntry(JetStringTemplateEntry entry) {
|
public void visitStringTemplateEntry(JetStringTemplateEntry entry) {
|
||||||
visitJetElement(entry);
|
visitJetElement(entry);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.psi;
|
|||||||
import com.intellij.lang.ASTNode;
|
import com.intellij.lang.ASTNode;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.jet.JetNodeTypes;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,8 +35,8 @@ public class JetWhenConditionIsPattern extends JetWhenCondition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable @IfNotParsed
|
@Nullable @IfNotParsed
|
||||||
public JetPattern getPattern() {
|
public JetTypeReference getTypeRef() {
|
||||||
return findChildByClass(JetPattern.class);
|
return (JetTypeReference) findChildByType(JetNodeTypes.TYPE_REFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+2
-2
@@ -30,8 +30,8 @@ public class JetWhenConditionWithExpression extends JetWhenCondition {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@IfNotParsed
|
@IfNotParsed
|
||||||
public JetExpressionPattern getPattern() {
|
public JetExpression getExpression() {
|
||||||
return findChildByClass(JetExpressionPattern.class);
|
return findChildByClass(JetExpression.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2012 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.jet.lang.psi;
|
|
||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author abreslav
|
|
||||||
*/
|
|
||||||
public class JetWildcardPattern extends JetPattern {
|
|
||||||
public JetWildcardPattern(@NotNull ASTNode node) {
|
|
||||||
super(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(@NotNull JetVisitorVoid visitor) {
|
|
||||||
visitor.visitWildcardPattern(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
|
|
||||||
return visitor.visitWildcardPattern(this, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user