From 3c1fb3951b5fe2b59f4a780871508c5d9b251464 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Fri, 15 Jun 2012 16:20:03 +0400 Subject: [PATCH] Move IfNotParsed interface to separate class --- .../jetbrains/jet/lang/psi/IfNotParsed.java | 29 +++++++++++++++++++ .../jet/lang/psi/JetElementImpl.java | 12 -------- .../jetbrains/jet/lang/psi/JetPsiUtil.java | 2 +- .../jet/lang/psi/JetSimpleNameExpression.java | 1 - .../jetbrains/jet/lang/psi/ValueArgument.java | 2 +- .../jetbrains/jet/parsing/JetParsingTest.java | 4 +-- 6 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/psi/IfNotParsed.java diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/IfNotParsed.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/IfNotParsed.java new file mode 100644 index 00000000000..65575006958 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/IfNotParsed.java @@ -0,0 +1,29 @@ +/* + * 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 java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Comes along with @Nullable to indicate null is only possible if parsing error present + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD}) +public @interface IfNotParsed {} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetElementImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetElementImpl.java index 03a016f97d3..c07078f1397 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetElementImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetElementImpl.java @@ -24,11 +24,6 @@ import com.intellij.psi.PsiElementVisitor; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.plugin.JetLanguage; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - /** * @author max */ @@ -37,13 +32,6 @@ public class JetElementImpl extends ASTWrapperPsiElement implements JetElement { super(node); } - /** - * Comes along with @Nullable to indicate null is only possible if parsing error present - */ - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.METHOD}) - public @interface IfNotParsed {} - @NotNull @Override public Language getLanguage() { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java index cf249e15c53..64d371ff8ab 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java @@ -191,7 +191,7 @@ public class JetPsiUtil { return firstPart.child(functionName); } - @Nullable @JetElementImpl.IfNotParsed + @Nullable @IfNotParsed public static ImportPath getImportPath(JetImportDirective importDirective) { final JetExpression importedReference = importDirective.getImportedReference(); if (importedReference == null) { 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 38ae917aea4..b47e6f295bf 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetSimpleNameExpression.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetSimpleNameExpression.java @@ -25,7 +25,6 @@ import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.TokenSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.JetNodeTypes; import org.jetbrains.jet.lang.parsing.JetExpressionParsing; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lexer.JetTokens; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/ValueArgument.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/ValueArgument.java index d06e81d7422..88a72ae2595 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/ValueArgument.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/ValueArgument.java @@ -26,7 +26,7 @@ import org.jetbrains.annotations.Nullable; */ public interface ValueArgument { @Nullable - @JetElementImpl.IfNotParsed + @IfNotParsed JetExpression getArgumentExpression(); @Nullable diff --git a/compiler/tests/org/jetbrains/jet/parsing/JetParsingTest.java b/compiler/tests/org/jetbrains/jet/parsing/JetParsingTest.java index 6dda0793743..5a026cdffa6 100644 --- a/compiler/tests/org/jetbrains/jet/parsing/JetParsingTest.java +++ b/compiler/tests/org/jetbrains/jet/parsing/JetParsingTest.java @@ -32,8 +32,8 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.JetTestCaseBuilder; import org.jetbrains.jet.lang.parsing.JetParserDefinition; +import org.jetbrains.jet.lang.psi.IfNotParsed; import org.jetbrains.jet.lang.psi.JetElement; -import org.jetbrains.jet.lang.psi.JetElementImpl; import org.jetbrains.jet.lang.psi.JetVisitorVoid; import java.io.File; @@ -103,7 +103,7 @@ public class JetParsingTest extends ParsingTestCase { Object result = method.invoke(elem); if (result == null) { for (Annotation annotation : method.getDeclaredAnnotations()) { - if (annotation instanceof JetElementImpl.IfNotParsed) { + if (annotation instanceof IfNotParsed) { assertNotNull( "Incomplete operation in parsed OK test, method " + methodName + " in " + declaringClass.getSimpleName() + " returns null. Element text: \n" + elem.getText(),