From 00eabde4ecd167a150323ebad544cf003419ee85 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Thu, 27 Mar 2014 14:42:23 +0400 Subject: [PATCH] Make JetSimpleNameExpression abstract, create subclasses for each element type It's not a good practice to have one PSI class to correspond to several element types --- .../src/org/jetbrains/jet/JetNodeTypes.java | 6 ++--- .../lang/psi/JetLabelReferenceExpression.java | 26 +++++++++++++++++++ .../lang/psi/JetNameReferenceExpression.java | 26 +++++++++++++++++++ .../psi/JetOperationReferenceExpression.java | 26 +++++++++++++++++++ .../jet/lang/psi/JetSimpleNameExpression.java | 2 +- 5 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/psi/JetLabelReferenceExpression.java create mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNameReferenceExpression.java create mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/psi/JetOperationReferenceExpression.java diff --git a/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java b/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java index 22b69298078..1c559cd7b78 100644 --- a/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java +++ b/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java @@ -115,9 +115,9 @@ public interface JetNodeTypes { JetNodeType FUNCTION_LITERAL = new JetNodeType("FUNCTION_LITERAL", JetFunctionLiteral.class); JetNodeType ANNOTATED_EXPRESSION = new JetNodeType("ANNOTATED_EXPRESSION", JetAnnotatedExpression.class); - JetNodeType REFERENCE_EXPRESSION = new JetNodeType("REFERENCE_EXPRESSION", JetSimpleNameExpression.class); - JetNodeType OPERATION_REFERENCE = new JetNodeType("OPERATION_REFERENCE", JetSimpleNameExpression.class); - JetNodeType LABEL = new JetNodeType("LABEL", JetSimpleNameExpression.class); + JetNodeType REFERENCE_EXPRESSION = new JetNodeType("REFERENCE_EXPRESSION", JetNameReferenceExpression.class); + JetNodeType OPERATION_REFERENCE = new JetNodeType("OPERATION_REFERENCE", JetOperationReferenceExpression.class); + JetNodeType LABEL = new JetNodeType("LABEL", JetLabelReferenceExpression.class); JetNodeType LABEL_QUALIFIER = new JetNodeType("LABEL_QUALIFIER", JetContainerNode.class); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetLabelReferenceExpression.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetLabelReferenceExpression.java new file mode 100644 index 00000000000..9a0655cf4ec --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetLabelReferenceExpression.java @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2014 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; + +public class JetLabelReferenceExpression extends JetSimpleNameExpression { + public JetLabelReferenceExpression(@NotNull ASTNode node) { + super(node); + } +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNameReferenceExpression.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNameReferenceExpression.java new file mode 100644 index 00000000000..bf0df184381 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNameReferenceExpression.java @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2014 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; + +public class JetNameReferenceExpression extends JetSimpleNameExpression { + public JetNameReferenceExpression(@NotNull ASTNode node) { + super(node); + } +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetOperationReferenceExpression.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetOperationReferenceExpression.java new file mode 100644 index 00000000000..531c649a3ef --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetOperationReferenceExpression.java @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2014 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; + +public class JetOperationReferenceExpression extends JetSimpleNameExpression { + public JetOperationReferenceExpression(@NotNull ASTNode node) { + super(node); + } +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetSimpleNameExpression.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetSimpleNameExpression.java index ae09ceeb6fa..6628ba65b11 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetSimpleNameExpression.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetSimpleNameExpression.java @@ -29,7 +29,7 @@ import org.jetbrains.jet.lexer.JetTokens; import static org.jetbrains.jet.lexer.JetTokens.*; -public class JetSimpleNameExpression extends JetReferenceExpression { +public abstract class JetSimpleNameExpression extends JetReferenceExpression { public static final TokenSet REFERENCE_TOKENS = TokenSet.create(LABEL_IDENTIFIER, IDENTIFIER, FIELD_IDENTIFIER, THIS_KEYWORD, SUPER_KEYWORD); public JetSimpleNameExpression(@NotNull ASTNode node) {