Stubs - Extract interface for JetElement and JetExpression (Stub psi element should extend StubBasedPsiElementBase but JetElement extended ASTWrapperPsiElement)
This commit is contained in:
@@ -24,6 +24,7 @@ import com.intellij.psi.tree.IElementType;
|
|||||||
import org.jetbrains.annotations.NonNls;
|
import org.jetbrains.annotations.NonNls;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.psi.JetElement;
|
import org.jetbrains.jet.lang.psi.JetElement;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetElementImpl;
|
||||||
import org.jetbrains.jet.plugin.JetLanguage;
|
import org.jetbrains.jet.plugin.JetLanguage;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
@@ -49,7 +50,7 @@ public class JetNodeType extends IElementType {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (myPsiFactory == null) {
|
if (myPsiFactory == null) {
|
||||||
return new JetElement(node);
|
return new JetElementImpl(node);
|
||||||
}
|
}
|
||||||
return myPsiFactory.newInstance(node);
|
return myPsiFactory.newInstance(node);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -22,20 +22,19 @@ import com.intellij.psi.tree.IElementType;
|
|||||||
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.JetNodeTypes;
|
||||||
|
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.JetControlFlowInstructionsGenerator;
|
|
||||||
import org.jetbrains.jet.lang.cfg.pseudocode.PseudocodeImpl;
|
import org.jetbrains.jet.lang.cfg.pseudocode.PseudocodeImpl;
|
||||||
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;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||||
import org.jetbrains.jet.lang.resolve.constants.BooleanValue;
|
import org.jetbrains.jet.lang.resolve.constants.BooleanValue;
|
||||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
|
||||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstantResolver;
|
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstantResolver;
|
||||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
import org.jetbrains.jet.lang.types.expressions.OperatorConventions;
|
import org.jetbrains.jet.lang.types.expressions.OperatorConventions;
|
||||||
|
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetAnnotatedExpression extends JetExpression {
|
public class JetAnnotatedExpression extends JetExpressionImpl {
|
||||||
public JetAnnotatedExpression(@NotNull ASTNode node) {
|
public JetAnnotatedExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ public class JetAnnotatedExpression extends JetExpression {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public JetExpression getBaseExpression() {
|
public JetExpression getBaseExpression() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<JetAnnotation> getAttributeAnnotations() {
|
public List<JetAnnotation> getAttributeAnnotations() {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetAnnotation extends JetElement {
|
public class JetAnnotation extends JetElementImpl {
|
||||||
public JetAnnotation(@NotNull ASTNode node) {
|
public JetAnnotation(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetAnnotationEntry extends JetElement implements JetCallElement {
|
public class JetAnnotationEntry extends JetElementImpl implements JetCallElement {
|
||||||
public JetAnnotationEntry(@NotNull ASTNode node) {
|
public JetAnnotationEntry(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class JetArrayAccessExpression extends JetReferenceExpression {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetExpression getArrayExpression() {
|
public JetExpression getArrayExpression() {
|
||||||
JetExpression baseExpression = findChildByClass(JetExpression.class);
|
JetExpression baseExpression = findChildByClass(JetExpressionImpl.class);
|
||||||
assert baseExpression != null;
|
assert baseExpression != null;
|
||||||
return baseExpression;
|
return baseExpression;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.jetbrains.jet.JetNodeTypes;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetBinaryExpression extends JetExpression implements JetOperationExpression {
|
public class JetBinaryExpression extends JetExpressionImpl implements JetOperationExpression {
|
||||||
public JetBinaryExpression(@NotNull ASTNode node) {
|
public JetBinaryExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ public class JetBinaryExpression extends JetExpression implements JetOperationEx
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetExpression getLeft() {
|
public JetExpression getLeft() {
|
||||||
JetExpression left = findChildByClass(JetExpression.class);
|
JetExpression left = findChildByClass(JetExpressionImpl.class);
|
||||||
assert left != null;
|
assert left != null;
|
||||||
return left;
|
return left;
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ public class JetBinaryExpression extends JetExpression implements JetOperationEx
|
|||||||
ASTNode node = getOperationReference().getNode().getTreeNext();
|
ASTNode node = getOperationReference().getNode().getTreeNext();
|
||||||
while (node != null) {
|
while (node != null) {
|
||||||
PsiElement psi = node.getPsi();
|
PsiElement psi = node.getPsi();
|
||||||
if (psi instanceof JetExpression) {
|
if (psi instanceof JetExpressionImpl) {
|
||||||
return (JetExpression) psi;
|
return (JetExpression) psi;
|
||||||
}
|
}
|
||||||
node = node.getTreeNext();
|
node = node.getTreeNext();
|
||||||
|
|||||||
+2
-2
@@ -25,7 +25,7 @@ import org.jetbrains.jet.JetNodeTypes;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetBinaryExpressionWithTypeRHS extends JetExpression {
|
public class JetBinaryExpressionWithTypeRHS extends JetExpressionImpl {
|
||||||
public JetBinaryExpressionWithTypeRHS(@NotNull ASTNode node) {
|
public JetBinaryExpressionWithTypeRHS(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@ public class JetBinaryExpressionWithTypeRHS extends JetExpression {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetExpression getLeft() {
|
public JetExpression getLeft() {
|
||||||
JetExpression left = findChildByClass(JetExpression.class);
|
JetExpression left = findChildByClass(JetExpressionImpl.class);
|
||||||
assert left != null;
|
assert left != null;
|
||||||
return left;
|
return left;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetBlockExpression extends JetExpression implements JetStatementExpression, PsiModifiableCodeBlock {
|
public class JetBlockExpression extends JetExpressionImpl implements JetStatementExpression, PsiModifiableCodeBlock {
|
||||||
public JetBlockExpression(@NotNull ASTNode node) {
|
public JetBlockExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetCallExpression extends JetExpression implements JetCallElement {
|
public class JetCallExpression extends JetExpressionImpl implements JetCallElement {
|
||||||
public JetCallExpression(@NotNull ASTNode node) {
|
public JetCallExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ public class JetCallExpression extends JetExpression implements JetCallElement {
|
|||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public JetExpression getCalleeExpression() {
|
public JetExpression getCalleeExpression() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetCatchClause extends JetElement {
|
public class JetCatchClause extends JetElementImpl {
|
||||||
public JetCatchClause(@NotNull ASTNode node) {
|
public JetCatchClause(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
@@ -57,6 +57,6 @@ public class JetCatchClause extends JetElement {
|
|||||||
|
|
||||||
@Nullable @IfNotParsed
|
@Nullable @IfNotParsed
|
||||||
public JetExpression getCatchBody() {
|
public JetExpression getCatchBody() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,10 +46,10 @@ public class JetClass extends JetTypeParameterListOwner
|
|||||||
public JetClass(@NotNull ASTNode node) {
|
public JetClass(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
// TODO (stubs)
|
|
||||||
// public JetClass(final PsiJetClassStub stub) {
|
//public JetClass(@NotNull final PsiJetClassStub stub) {
|
||||||
// this.stub = stub;
|
// this.stub = stub;
|
||||||
// }
|
//}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<JetDeclaration> getDeclarations() {
|
public List<JetDeclaration> getDeclarations() {
|
||||||
@@ -237,4 +237,9 @@ public class JetClass extends JetTypeParameterListOwner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//@Override
|
||||||
|
//public ItemPresentation getPresentation() {
|
||||||
|
// return ItemPresentationProviders.getItemPresentation(this);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetClassBody extends JetElement implements JetDeclarationContainer {
|
public class JetClassBody extends JetElementImpl implements JetDeclarationContainer {
|
||||||
public JetClassBody(@NotNull ASTNode node) {
|
public JetClassBody(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class JetClassInitializer extends JetDeclaration implements JetStatementE
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetExpression getBody() {
|
public JetExpression getBody() {
|
||||||
JetExpression body = findChildByClass(JetExpression.class);
|
JetExpression body = findChildByClass(JetExpressionImpl.class);
|
||||||
assert body != null;
|
assert body != null;
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetConstantExpression extends JetExpression {
|
public class JetConstantExpression extends JetExpressionImpl {
|
||||||
public JetConstantExpression(@NotNull ASTNode node) {
|
public JetConstantExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public class JetConstructorCalleeExpression extends JetExpression {
|
public class JetConstructorCalleeExpression extends JetExpressionImpl {
|
||||||
public JetConstructorCalleeExpression(@NotNull ASTNode node) {
|
public JetConstructorCalleeExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetContainerNode extends JetElement {
|
public class JetContainerNode extends JetElementImpl {
|
||||||
public JetContainerNode(@NotNull ASTNode node) {
|
public JetContainerNode(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lexer.JetToken;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public abstract class JetDeclaration extends JetExpression implements JetModifierListOwner {
|
public abstract class JetDeclaration extends JetExpressionImpl implements JetModifierListOwner {
|
||||||
public JetDeclaration(@NotNull ASTNode node) {
|
public JetDeclaration(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class JetDecomposerPattern extends JetPattern {
|
|||||||
|
|
||||||
@Nullable @IfNotParsed
|
@Nullable @IfNotParsed
|
||||||
public JetExpression getDecomposerExpression() {
|
public JetExpression getDecomposerExpression() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import org.jetbrains.jet.JetNodeTypes;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetDelegationSpecifier extends JetElement{
|
public class JetDelegationSpecifier extends JetElementImpl {
|
||||||
public JetDelegationSpecifier(@NotNull ASTNode node) {
|
public JetDelegationSpecifier(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetDelegationSpecifierList extends JetElement {
|
public class JetDelegationSpecifierList extends JetElementImpl {
|
||||||
public JetDelegationSpecifierList(@NotNull ASTNode node) {
|
public JetDelegationSpecifierList(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -40,6 +40,6 @@ public class JetDelegatorByExpressionSpecifier extends JetDelegationSpecifier {
|
|||||||
|
|
||||||
@Nullable @IfNotParsed
|
@Nullable @IfNotParsed
|
||||||
public JetExpression getDelegateExpression() {
|
public JetExpression getDelegateExpression() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,85 +1,15 @@
|
|||||||
/*
|
|
||||||
* 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;
|
package org.jetbrains.jet.lang.psi;
|
||||||
|
|
||||||
import com.intellij.extapi.psi.ASTWrapperPsiElement;
|
import com.intellij.psi.NavigatablePsiElement;
|
||||||
import com.intellij.lang.ASTNode;
|
|
||||||
import com.intellij.lang.Language;
|
|
||||||
import com.intellij.psi.PsiElement;
|
|
||||||
import com.intellij.psi.PsiElementVisitor;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
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
|
* @author Nikolay Krasko
|
||||||
*/
|
*/
|
||||||
public class JetElement extends ASTWrapperPsiElement {
|
public interface JetElement extends NavigatablePsiElement {
|
||||||
public JetElement(@NotNull ASTNode node) {
|
<D> void acceptChildren(@NotNull JetTreeVisitor<D> visitor, D data);
|
||||||
super(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
void accept(@NotNull JetVisitorVoid visitor);
|
||||||
* Comes along with @Nullable to indicate null is only possible if parsing error present
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target({ElementType.METHOD})
|
|
||||||
public @interface IfNotParsed {}
|
|
||||||
|
|
||||||
@NotNull
|
<R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data);
|
||||||
@Override
|
|
||||||
public Language getLanguage() {
|
|
||||||
return JetLanguage.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return getNode().getElementType().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final void accept(@NotNull PsiElementVisitor visitor) {
|
|
||||||
if (visitor instanceof JetVisitorVoid) {
|
|
||||||
accept((JetVisitorVoid) visitor);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
visitor.visitElement(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public <D> void acceptChildren(@NotNull JetTreeVisitor<D> visitor, D data) {
|
|
||||||
PsiElement child = getFirstChild();
|
|
||||||
while (child != null) {
|
|
||||||
if (child instanceof JetElement) {
|
|
||||||
((JetElement) child).accept(visitor, data);
|
|
||||||
}
|
|
||||||
child = child.getNextSibling();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void accept(@NotNull JetVisitorVoid visitor) {
|
|
||||||
visitor.visitJetElement(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
|
|
||||||
return visitor.visitJetElement(this, data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* 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.extapi.psi.ASTWrapperPsiElement;
|
||||||
|
import com.intellij.lang.ASTNode;
|
||||||
|
import com.intellij.lang.Language;
|
||||||
|
import com.intellij.psi.PsiElement;
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
public class JetElementImpl extends ASTWrapperPsiElement implements JetElement {
|
||||||
|
public JetElementImpl(@NotNull ASTNode node) {
|
||||||
|
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() {
|
||||||
|
return JetLanguage.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getNode().getElementType().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void accept(@NotNull PsiElementVisitor visitor) {
|
||||||
|
if (visitor instanceof JetVisitorVoid) {
|
||||||
|
accept((JetVisitorVoid) visitor);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
visitor.visitElement(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <D> void acceptChildren(@NotNull JetTreeVisitor<D> visitor, D data) {
|
||||||
|
PsiElement child = getFirstChild();
|
||||||
|
while (child != null) {
|
||||||
|
if (child instanceof JetElementImpl) {
|
||||||
|
((JetElement) child).accept(visitor, data);
|
||||||
|
}
|
||||||
|
child = child.getNextSibling();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(@NotNull JetVisitorVoid visitor) {
|
||||||
|
visitor.visitJetElement(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
|
||||||
|
return visitor.visitJetElement(this, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,32 +16,16 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.lang.psi;
|
package org.jetbrains.jet.lang.psi;
|
||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
import com.intellij.psi.NavigatablePsiElement;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.JetNodeType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author max
|
* @author Nikolay Krasko
|
||||||
*/
|
*/
|
||||||
public abstract class JetExpression extends JetElement {
|
public interface JetExpression extends NavigatablePsiElement, JetElement {
|
||||||
public JetExpression(@NotNull ASTNode node) {
|
@Override
|
||||||
super(node);
|
void accept(@NotNull JetVisitorVoid visitor);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(@NotNull JetVisitorVoid visitor) {
|
<R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data);
|
||||||
visitor.visitExpression(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
|
|
||||||
return visitor.visitExpression(this, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected JetExpression findExpressionUnder(JetNodeType type) {
|
|
||||||
JetContainerNode containerNode = (JetContainerNode) findChildByType(type);
|
|
||||||
if (containerNode == null) return null;
|
|
||||||
|
|
||||||
return containerNode.findChildByClass(JetExpression.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* 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.JetNodeType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author max
|
||||||
|
*/
|
||||||
|
abstract class JetExpressionImpl extends JetElementImpl implements JetExpression {
|
||||||
|
public JetExpressionImpl(@NotNull ASTNode node) {
|
||||||
|
super(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(@NotNull JetVisitorVoid visitor) {
|
||||||
|
visitor.visitExpression(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
|
||||||
|
return visitor.visitExpression(this, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected JetExpression findExpressionUnder(JetNodeType type) {
|
||||||
|
JetContainerNode containerNode = (JetContainerNode) findChildByType(type);
|
||||||
|
if (containerNode == null) return null;
|
||||||
|
|
||||||
|
return containerNode.findChildByClass(JetExpressionImpl.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,7 +30,7 @@ public class JetExpressionPattern extends JetPattern {
|
|||||||
|
|
||||||
@Nullable @IfNotParsed
|
@Nullable @IfNotParsed
|
||||||
public JetExpression getExpression() {
|
public JetExpression getExpression() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import org.jetbrains.jet.JetNodeTypes;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetFinallySection extends JetElement {
|
public class JetFinallySection extends JetElementImpl {
|
||||||
public JetFinallySection(@NotNull ASTNode node) {
|
public JetFinallySection(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ abstract public class JetFunction extends JetTypeParameterListOwner
|
|||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public JetExpression getBodyExpression() {
|
public JetExpression getBodyExpression() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetFunctionLiteralExpression extends JetExpression implements JetDeclarationWithBody {
|
public class JetFunctionLiteralExpression extends JetExpressionImpl implements JetDeclarationWithBody {
|
||||||
public JetFunctionLiteralExpression(@NotNull ASTNode node) {
|
public JetFunctionLiteralExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.jetbrains.jet.lexer.JetTokens;
|
|||||||
* @author Evgeny Gerashchenko
|
* @author Evgeny Gerashchenko
|
||||||
* @since 2/8/12
|
* @since 2/8/12
|
||||||
*/
|
*/
|
||||||
public class JetIdeTemplateExpression extends JetExpression {
|
public class JetIdeTemplateExpression extends JetExpressionImpl {
|
||||||
public JetIdeTemplateExpression(@NotNull ASTNode node) {
|
public JetIdeTemplateExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import org.jetbrains.jet.JetNodeTypes;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetIfExpression extends JetExpression {
|
public class JetIfExpression extends JetExpressionImpl {
|
||||||
public JetIfExpression(@NotNull ASTNode node) {
|
public JetIfExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lexer.JetTokens;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetImportDirective extends JetElement {
|
public class JetImportDirective extends JetElementImpl {
|
||||||
public JetImportDirective(@NotNull ASTNode node) {
|
public JetImportDirective(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ public class JetImportDirective extends JetElement {
|
|||||||
|
|
||||||
@Nullable @IfNotParsed
|
@Nullable @IfNotParsed
|
||||||
public JetExpression getImportedReference() {
|
public JetExpression getImportedReference() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetInitializerList extends JetElement {
|
public class JetInitializerList extends JetElementImpl {
|
||||||
public JetInitializerList(@NotNull ASTNode node) {
|
public JetInitializerList(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lexer.JetTokens;
|
|||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public class JetIsExpression extends JetExpression {
|
public class JetIsExpression extends JetExpressionImpl {
|
||||||
public JetIsExpression(@NotNull ASTNode node) {
|
public JetIsExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@ public class JetIsExpression extends JetExpression {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetExpression getLeftHandSide() {
|
public JetExpression getLeftHandSide() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable @IfNotParsed
|
@Nullable @IfNotParsed
|
||||||
|
|||||||
@@ -20,12 +20,11 @@ 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.JetNodeTypes;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public class JetLabelQualifiedExpression extends JetExpression {
|
public class JetLabelQualifiedExpression extends JetExpressionImpl {
|
||||||
|
|
||||||
public JetLabelQualifiedExpression(@NotNull ASTNode node) {
|
public JetLabelQualifiedExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
@@ -40,7 +39,7 @@ public class JetLabelQualifiedExpression extends JetExpression {
|
|||||||
|
|
||||||
@Nullable @IfNotParsed
|
@Nullable @IfNotParsed
|
||||||
public JetExpression getLabeledExpression() {
|
public JetExpression getLabeledExpression() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import org.jetbrains.jet.JetNodeTypes;
|
|||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public abstract class JetLoopExpression extends JetExpression implements JetStatementExpression {
|
public abstract class JetLoopExpression extends JetExpressionImpl implements JetStatementExpression {
|
||||||
public JetLoopExpression(@NotNull ASTNode node) {
|
public JetLoopExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetModifierList extends JetElement {
|
public class JetModifierList extends JetElementImpl {
|
||||||
public JetModifierList(@NotNull ASTNode node) {
|
public JetModifierList(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetNamespaceBody extends JetElement implements JetDeclarationContainer {
|
public class JetNamespaceBody extends JetElementImpl implements JetDeclarationContainer {
|
||||||
public JetNamespaceBody(@NotNull ASTNode node) {
|
public JetNamespaceBody(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import org.jetbrains.jet.JetNodeTypes;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetObjectLiteralExpression extends JetExpression {
|
public class JetObjectLiteralExpression extends JetExpressionImpl {
|
||||||
public JetObjectLiteralExpression(@NotNull ASTNode node) {
|
public JetObjectLiteralExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class JetParameter extends JetNamedDeclaration {
|
|||||||
ASTNode child = getNode().getFirstChildNode();
|
ASTNode child = getNode().getFirstChildNode();
|
||||||
while (child != null) {
|
while (child != null) {
|
||||||
if (child.getElementType() == JetTokens.EQ) passedEQ = true;
|
if (child.getElementType() == JetTokens.EQ) passedEQ = true;
|
||||||
if (passedEQ && child.getPsi() instanceof JetExpression) {
|
if (passedEQ && child.getPsi() instanceof JetExpressionImpl) {
|
||||||
return (JetExpression) child.getPsi();
|
return (JetExpression) child.getPsi();
|
||||||
}
|
}
|
||||||
child = child.getTreeNext();
|
child = child.getTreeNext();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetParameterList extends JetElement {
|
public class JetParameterList extends JetElementImpl {
|
||||||
public JetParameterList(@NotNull ASTNode node) {
|
public JetParameterList(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetParenthesizedExpression extends JetExpression {
|
public class JetParenthesizedExpression extends JetExpressionImpl {
|
||||||
public JetParenthesizedExpression(@NotNull ASTNode node) {
|
public JetParenthesizedExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,6 @@ public class JetParenthesizedExpression extends JetExpression {
|
|||||||
|
|
||||||
@Nullable @IfNotParsed
|
@Nullable @IfNotParsed
|
||||||
public JetExpression getExpression() {
|
public JetExpression getExpression() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public class JetPattern extends JetElement {
|
public class JetPattern extends JetElementImpl {
|
||||||
public JetPattern(@NotNull ASTNode node) {
|
public JetPattern(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class JetPostfixExpression extends JetUnaryExpression {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetExpression getBaseExpression() {
|
public JetExpression getBaseExpression() {
|
||||||
JetExpression answer = findChildByClass(JetExpression.class);
|
JetExpression answer = findChildByClass(JetExpressionImpl.class);
|
||||||
assert answer != null;
|
assert answer != null;
|
||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class JetPrefixExpression extends JetUnaryExpression {
|
|||||||
@Nullable @IfNotParsed
|
@Nullable @IfNotParsed
|
||||||
public JetExpression getBaseExpression() {
|
public JetExpression getBaseExpression() {
|
||||||
PsiElement expression = getOperationReference().getNextSibling();
|
PsiElement expression = getOperationReference().getNextSibling();
|
||||||
while (expression != null && !(expression instanceof JetExpression)) {
|
while (expression != null && !(expression instanceof JetExpressionImpl)) {
|
||||||
expression = expression.getNextSibling();
|
expression = expression.getNextSibling();
|
||||||
}
|
}
|
||||||
return (JetExpression) expression;
|
return (JetExpression) expression;
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ public class JetProperty extends JetTypeParameterListOwner implements JetModifie
|
|||||||
@Nullable
|
@Nullable
|
||||||
public JetExpression getInitializer() {
|
public JetExpression getInitializer() {
|
||||||
PsiElement eq = findChildByType(EQ);
|
PsiElement eq = findChildByType(EQ);
|
||||||
return PsiTreeUtil.getNextSiblingOfType(eq, JetExpression.class);
|
return PsiTreeUtil.getNextSiblingOfType(eq, JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class JetPropertyAccessor extends JetDeclaration implements JetDeclaratio
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public JetExpression getBodyExpression() {
|
public JetExpression getBodyExpression() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ public class JetPsiUtil {
|
|||||||
return firstPart.child(functionName);
|
return firstPart.child(functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable @JetElement.IfNotParsed
|
@Nullable @JetElementImpl.IfNotParsed
|
||||||
public static ImportPath getImportPath(JetImportDirective importDirective) {
|
public static ImportPath getImportPath(JetImportDirective importDirective) {
|
||||||
final JetExpression importedReference = importDirective.getImportedReference();
|
final JetExpression importedReference = importDirective.getImportedReference();
|
||||||
if (importedReference == null) {
|
if (importedReference == null) {
|
||||||
|
|||||||
@@ -26,14 +26,14 @@ import org.jetbrains.jet.lexer.JetTokens;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public abstract class JetQualifiedExpression extends JetExpression {
|
public abstract class JetQualifiedExpression extends JetExpressionImpl {
|
||||||
public JetQualifiedExpression(@NotNull ASTNode node) {
|
public JetQualifiedExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetExpression getReceiverExpression() {
|
public JetExpression getReceiverExpression() {
|
||||||
JetExpression left = findChildByClass(JetExpression.class);
|
JetExpression left = findChildByClass(JetExpressionImpl.class);
|
||||||
assert left != null;
|
assert left != null;
|
||||||
return left;
|
return left;
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ public abstract class JetQualifiedExpression extends JetExpression {
|
|||||||
ASTNode node = getOperationTokenNode();
|
ASTNode node = getOperationTokenNode();
|
||||||
while (node != null) {
|
while (node != null) {
|
||||||
PsiElement psi = node.getPsi();
|
PsiElement psi = node.getPsi();
|
||||||
if (psi instanceof JetExpression) {
|
if (psi instanceof JetExpressionImpl) {
|
||||||
return (JetExpression) psi;
|
return (JetExpression) psi;
|
||||||
}
|
}
|
||||||
node = node.getTreeNext();
|
node = node.getTreeNext();
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public abstract class JetReferenceExpression extends JetExpression {
|
public abstract class JetReferenceExpression extends JetExpressionImpl {
|
||||||
public JetReferenceExpression(@NotNull ASTNode node) {
|
public JetReferenceExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,6 @@ public class JetReturnExpression extends JetLabelQualifiedExpression implements
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public JetExpression getReturnedExpression() {
|
public JetExpression getReturnedExpression() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetRootNamespaceExpression extends JetExpression {
|
public class JetRootNamespaceExpression extends JetExpressionImpl {
|
||||||
public JetRootNamespaceExpression(@NotNull ASTNode node) {
|
public JetRootNamespaceExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class JetSecondaryConstructor extends JetDeclaration implements JetDeclar
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetExpression getBodyExpression() {
|
public JetExpression getBodyExpression() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ package org.jetbrains.jet.lang.psi;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an interface to show that {@link JetExpression} is not
|
* This is an interface to show that {@link JetExpressionImpl} is not
|
||||||
* actually an expression (in meaning that this expression can be placed after "val x = ").
|
* actually an expression (in meaning that this expression can be placed after "val x = ").
|
||||||
* This is possibly redundant interface, all inheritors of this interface should be refactored that they are not
|
* This is possibly redundant interface, all inheritors of this interface should be refactored that they are not
|
||||||
* {@link JetExpression}, after such refactoring, this interface can be removed.
|
* {@link JetExpressionImpl}, after such refactoring, this interface can be removed.
|
||||||
*/
|
*/
|
||||||
public interface JetStatementExpression {
|
public interface JetStatementExpression {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public abstract class JetStringTemplateEntry extends JetElement {
|
public abstract class JetStringTemplateEntry extends JetElementImpl {
|
||||||
public JetStringTemplateEntry(@NotNull ASTNode node) {
|
public JetStringTemplateEntry(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public JetExpression getExpression() {
|
public JetExpression getExpression() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public class JetStringTemplateExpression extends JetExpression {
|
public class JetStringTemplateExpression extends JetExpressionImpl {
|
||||||
public JetStringTemplateExpression(@NotNull ASTNode node) {
|
public JetStringTemplateExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetThrowExpression extends JetExpression {
|
public class JetThrowExpression extends JetExpressionImpl {
|
||||||
public JetThrowExpression(@NotNull ASTNode node) {
|
public JetThrowExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,6 @@ public class JetThrowExpression extends JetExpression {
|
|||||||
|
|
||||||
@Nullable @IfNotParsed
|
@Nullable @IfNotParsed
|
||||||
public JetExpression getThrownExpression() {
|
public JetExpression getThrownExpression() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetTryExpression extends JetExpression {
|
public class JetTryExpression extends JetExpressionImpl {
|
||||||
public JetTryExpression(@NotNull ASTNode node) {
|
public JetTryExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetTupleExpression extends JetExpression {
|
public class JetTupleExpression extends JetExpressionImpl {
|
||||||
public JetTupleExpression(@NotNull ASTNode node) {
|
public JetTupleExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import org.jetbrains.jet.lexer.JetTokens;
|
|||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public class JetTuplePatternEntry extends JetElement {
|
public class JetTuplePatternEntry extends JetElementImpl {
|
||||||
public JetTuplePatternEntry(@NotNull ASTNode node) {
|
public JetTuplePatternEntry(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetTypeArgumentList extends JetElement {
|
public class JetTypeArgumentList extends JetElementImpl {
|
||||||
public JetTypeArgumentList(@NotNull ASTNode node) {
|
public JetTypeArgumentList(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.jetbrains.jet.lexer.JetTokens;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetTypeConstraint extends JetElement {
|
public class JetTypeConstraint extends JetElementImpl {
|
||||||
public JetTypeConstraint(@NotNull ASTNode node) {
|
public JetTypeConstraint(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetTypeConstraintList extends JetElement {
|
public class JetTypeConstraintList extends JetElementImpl {
|
||||||
public JetTypeConstraintList(@NotNull ASTNode node) {
|
public JetTypeConstraintList(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public abstract class JetTypeElement extends JetElement {
|
public abstract class JetTypeElement extends JetElementImpl {
|
||||||
public JetTypeElement(@NotNull ASTNode node) {
|
public JetTypeElement(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetTypeParameterList extends JetElement {
|
public class JetTypeParameterList extends JetElementImpl {
|
||||||
public JetTypeParameterList(@NotNull ASTNode node) {
|
public JetTypeParameterList(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import org.jetbrains.jet.lexer.JetTokens;
|
|||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public class JetTypeProjection extends JetElement implements JetModifierListOwner {
|
public class JetTypeProjection extends JetElementImpl implements JetModifierListOwner {
|
||||||
public JetTypeProjection(@NotNull ASTNode node) {
|
public JetTypeProjection(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetTypeReference extends JetElement {
|
public class JetTypeReference extends JetElementImpl {
|
||||||
public JetTypeReference(@NotNull ASTNode node) {
|
public JetTypeReference(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import org.jetbrains.jet.JetNodeTypes;
|
|||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public abstract class JetUnaryExpression extends JetExpression implements JetOperationExpression {
|
public abstract class JetUnaryExpression extends JetExpressionImpl implements JetOperationExpression {
|
||||||
public JetUnaryExpression(ASTNode node) {
|
public JetUnaryExpression(ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import org.jetbrains.jet.lexer.JetTokens;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetValueArgument extends JetElement implements ValueArgument {
|
public class JetValueArgument extends JetElementImpl implements ValueArgument {
|
||||||
public JetValueArgument(@NotNull ASTNode node) {
|
public JetValueArgument(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ public class JetValueArgument extends JetElement implements ValueArgument {
|
|||||||
@Override
|
@Override
|
||||||
@Nullable @IfNotParsed
|
@Nullable @IfNotParsed
|
||||||
public JetExpression getArgumentExpression() {
|
public JetExpression getArgumentExpression() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetValueArgumentList extends JetElement {
|
public class JetValueArgumentList extends JetElementImpl {
|
||||||
public JetValueArgumentList(@NotNull ASTNode node) {
|
public JetValueArgumentList(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import org.jetbrains.jet.JetNodeTypes;
|
|||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public class JetValueArgumentName extends JetElement {
|
public class JetValueArgumentName extends JetElementImpl {
|
||||||
public JetValueArgumentName(@NotNull ASTNode node) {
|
public JetValueArgumentName(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public abstract class JetWhenCondition extends JetElement {
|
public abstract class JetWhenCondition extends JetElementImpl {
|
||||||
public JetWhenCondition(@NotNull ASTNode node) {
|
public JetWhenCondition(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class JetWhenConditionInRange extends JetWhenCondition {
|
|||||||
ASTNode node = getOperationReference().getNode().getTreeNext();
|
ASTNode node = getOperationReference().getNode().getTreeNext();
|
||||||
while (node != null) {
|
while (node != null) {
|
||||||
PsiElement psi = node.getPsi();
|
PsiElement psi = node.getPsi();
|
||||||
if (psi instanceof JetExpression) {
|
if (psi instanceof JetExpressionImpl) {
|
||||||
return (JetExpression) psi;
|
return (JetExpression) psi;
|
||||||
}
|
}
|
||||||
node = node.getTreeNext();
|
node = node.getTreeNext();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lexer.JetTokens;
|
|||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public class JetWhenEntry extends JetElement {
|
public class JetWhenEntry extends JetElementImpl {
|
||||||
public JetWhenEntry(@NotNull ASTNode node) {
|
public JetWhenEntry(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ public class JetWhenEntry extends JetElement {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public JetExpression getExpression() {
|
public JetExpression getExpression() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public class JetWhenExpression extends JetExpression {
|
public class JetWhenExpression extends JetExpressionImpl {
|
||||||
public JetWhenExpression(@NotNull ASTNode node) {
|
public JetWhenExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ public class JetWhenExpression extends JetExpression {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public JetExpression getSubjectExpression() {
|
public JetExpression getSubjectExpression() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpressionImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
*/
|
*/
|
||||||
public interface ValueArgument {
|
public interface ValueArgument {
|
||||||
@Nullable
|
@Nullable
|
||||||
@JetElement.IfNotParsed
|
@JetElementImpl.IfNotParsed
|
||||||
JetExpression getArgumentExpression();
|
JetExpression getArgumentExpression();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
+2
-2
@@ -51,8 +51,8 @@ public class JetClassElementType extends JetStubElementType<PsiJetClassStub, Jet
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetClass createPsi(@NotNull PsiJetClassStub stub) {
|
public JetClass createPsi(@NotNull PsiJetClassStub stub) {
|
||||||
// return getPsiFactory(stub).createClass(stub);
|
//return getPsiFactory(stub).createClass(stub);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||||
import org.jetbrains.jet.lang.parsing.JetParserDefinition;
|
import org.jetbrains.jet.lang.parsing.JetParserDefinition;
|
||||||
import org.jetbrains.jet.lang.psi.JetElement;
|
import org.jetbrains.jet.lang.psi.JetElement;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetElementImpl;
|
||||||
import org.jetbrains.jet.lang.psi.JetVisitorVoid;
|
import org.jetbrains.jet.lang.psi.JetVisitorVoid;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -102,7 +103,7 @@ public class JetParsingTest extends ParsingTestCase {
|
|||||||
Object result = method.invoke(elem);
|
Object result = method.invoke(elem);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
for (Annotation annotation : method.getDeclaredAnnotations()) {
|
for (Annotation annotation : method.getDeclaredAnnotations()) {
|
||||||
if (annotation instanceof JetElement.IfNotParsed) {
|
if (annotation instanceof JetElementImpl.IfNotParsed) {
|
||||||
assertNotNull(
|
assertNotNull(
|
||||||
"Incomplete operation in parsed OK test, method " + methodName +
|
"Incomplete operation in parsed OK test, method " + methodName +
|
||||||
" in " + declaringClass.getSimpleName() + " returns null. Element text: \n" + elem.getText(),
|
" in " + declaringClass.getSimpleName() + " returns null. Element text: \n" + elem.getText(),
|
||||||
|
|||||||
+2
@@ -36,10 +36,12 @@ import java.util.List;
|
|||||||
* Originally from IDEA platform: StatementGroupSelectioner
|
* Originally from IDEA platform: StatementGroupSelectioner
|
||||||
*/
|
*/
|
||||||
public class JetStatementGroupSelectioner extends BasicSelectioner {
|
public class JetStatementGroupSelectioner extends BasicSelectioner {
|
||||||
|
@Override
|
||||||
public boolean canSelect(PsiElement e) {
|
public boolean canSelect(PsiElement e) {
|
||||||
return e instanceof JetExpression || e instanceof JetWhenEntry;
|
return e instanceof JetExpression || e instanceof JetWhenEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
|
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
|
||||||
List<TextRange> result = new ArrayList<TextRange>();
|
List<TextRange> result = new ArrayList<TextRange>();
|
||||||
|
|
||||||
|
|||||||
@@ -155,8 +155,9 @@ public class ResolveToolwindow extends JPanel implements Disposable {
|
|||||||
|
|
||||||
if (!callFound) {
|
if (!callFound) {
|
||||||
|
|
||||||
JetExpression parentExpression = (elementAtOffset instanceof JetExpression) ? (JetExpression) elementAtOffset
|
JetExpression parentExpression = (elementAtOffset instanceof JetExpression) ?
|
||||||
: PsiTreeUtil.getParentOfType(elementAtOffset, JetExpression.class);
|
(JetExpression) elementAtOffset :
|
||||||
|
PsiTreeUtil.getParentOfType(elementAtOffset, JetExpression.class);
|
||||||
if (parentExpression != null) {
|
if (parentExpression != null) {
|
||||||
JetType type = bindingContext.get(EXPRESSION_TYPE, parentExpression);
|
JetType type = bindingContext.get(EXPRESSION_TYPE, parentExpression);
|
||||||
String text = parentExpression + "|" + parentExpression.getText() + "| : " + type;
|
String text = parentExpression + "|" + parentExpression.getText() + "| : " + type;
|
||||||
@@ -173,7 +174,7 @@ public class ResolveToolwindow extends JPanel implements Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private <D> PsiElement findData(BindingContext bindingContext, PsiElement currentElement, ReadOnlySlice<PsiElement, D> slice) {
|
private static <D> PsiElement findData(BindingContext bindingContext, PsiElement currentElement, ReadOnlySlice<PsiElement, D> slice) {
|
||||||
while (currentElement != null && !(currentElement instanceof PsiFile)) {
|
while (currentElement != null && !(currentElement instanceof PsiFile)) {
|
||||||
if (currentElement instanceof JetElement) {
|
if (currentElement instanceof JetElement) {
|
||||||
JetElement atOffset = (JetElement) currentElement;
|
JetElement atOffset = (JetElement) currentElement;
|
||||||
@@ -188,7 +189,9 @@ public class ResolveToolwindow extends JPanel implements Disposable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String renderDebugInfo(PsiElement currentElement, @Nullable ResolutionDebugInfo.Data debugInfo, @Nullable ResolvedCall<? extends CallableDescriptor> call) {
|
private static String renderDebugInfo(PsiElement currentElement,
|
||||||
|
@Nullable ResolutionDebugInfo.Data debugInfo,
|
||||||
|
@Nullable ResolvedCall<? extends CallableDescriptor> call) {
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
|
|
||||||
if (debugInfo != null) {
|
if (debugInfo != null) {
|
||||||
@@ -208,11 +211,13 @@ public class ResolveToolwindow extends JPanel implements Disposable {
|
|||||||
else {
|
else {
|
||||||
result.append("Resolved call is null\n");
|
result.append("Resolved call is null\n");
|
||||||
}
|
}
|
||||||
result.append(currentElement + ": " + currentElement.getText());
|
result.append(currentElement).append(": ").append(currentElement.getText());
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderResolutionLogForCall(Data debugInfo, ResolvedCallWithTrace<? extends CallableDescriptor> resolvedCall, StringBuilder result) {
|
private static void renderResolutionLogForCall(Data debugInfo,
|
||||||
|
ResolvedCallWithTrace<? extends CallableDescriptor> resolvedCall,
|
||||||
|
StringBuilder result) {
|
||||||
result.append("Trying to call ").append(resolvedCall.getCandidateDescriptor()).append("\n");
|
result.append("Trying to call ").append(resolvedCall.getCandidateDescriptor()).append("\n");
|
||||||
StringBuilder errors = debugInfo.getByKey(ERRORS, resolvedCall);
|
StringBuilder errors = debugInfo.getByKey(ERRORS, resolvedCall);
|
||||||
if (errors != null) {
|
if (errors != null) {
|
||||||
@@ -232,7 +237,7 @@ public class ResolveToolwindow extends JPanel implements Disposable {
|
|||||||
result.append(BAR);
|
result.append(BAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <K> void renderMap(Map<K, BoundsOwner> map, StringBuilder builder) {
|
private static <K> void renderMap(Map<K, BoundsOwner> map, StringBuilder builder) {
|
||||||
if (map == null) return;
|
if (map == null) return;
|
||||||
|
|
||||||
for (Map.Entry<K, BoundsOwner> entry : map.entrySet()) {
|
for (Map.Entry<K, BoundsOwner> entry : map.entrySet()) {
|
||||||
@@ -248,7 +253,7 @@ public class ResolveToolwindow extends JPanel implements Disposable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String renderCall(StringBuilder builder, ResolvedCall<? extends CallableDescriptor> resolvedCall) {
|
private static String renderCall(StringBuilder builder, ResolvedCall<? extends CallableDescriptor> resolvedCall) {
|
||||||
|
|
||||||
CallableDescriptor resultingDescriptor = resolvedCall.getResultingDescriptor();
|
CallableDescriptor resultingDescriptor = resolvedCall.getResultingDescriptor();
|
||||||
ReceiverDescriptor receiverArgument = resolvedCall.getReceiverArgument();
|
ReceiverDescriptor receiverArgument = resolvedCall.getReceiverArgument();
|
||||||
@@ -283,7 +288,7 @@ public class ResolveToolwindow extends JPanel implements Disposable {
|
|||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderValueArguments(Map<ValueParameterDescriptor, ResolvedValueArgument> valueArguments, StringBuilder builder) {
|
private static void renderValueArguments(Map<ValueParameterDescriptor, ResolvedValueArgument> valueArguments, StringBuilder builder) {
|
||||||
ResolvedValueArgument[] args = new ResolvedValueArgument[valueArguments.size()];
|
ResolvedValueArgument[] args = new ResolvedValueArgument[valueArguments.size()];
|
||||||
for (Map.Entry<ValueParameterDescriptor, ResolvedValueArgument> entry : valueArguments.entrySet()) {
|
for (Map.Entry<ValueParameterDescriptor, ResolvedValueArgument> entry : valueArguments.entrySet()) {
|
||||||
ValueParameterDescriptor key = entry.getKey();
|
ValueParameterDescriptor key = entry.getKey();
|
||||||
@@ -302,7 +307,7 @@ public class ResolveToolwindow extends JPanel implements Disposable {
|
|||||||
builder.append(")");
|
builder.append(")");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderTypeArguments(Map<TypeParameterDescriptor, JetType> typeArguments, StringBuilder builder) {
|
private static void renderTypeArguments(Map<TypeParameterDescriptor, JetType> typeArguments, StringBuilder builder) {
|
||||||
JetType[] args = new JetType[typeArguments.size()];
|
JetType[] args = new JetType[typeArguments.size()];
|
||||||
for (Map.Entry<TypeParameterDescriptor, JetType> entry : typeArguments.entrySet()) {
|
for (Map.Entry<TypeParameterDescriptor, JetType> entry : typeArguments.entrySet()) {
|
||||||
TypeParameterDescriptor key = entry.getKey();
|
TypeParameterDescriptor key = entry.getKey();
|
||||||
@@ -320,7 +325,7 @@ public class ResolveToolwindow extends JPanel implements Disposable {
|
|||||||
builder.append(">");
|
builder.append(">");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderReceiver(ReceiverDescriptor receiverArgument, ReceiverDescriptor thisObject, StringBuilder builder) {
|
private static void renderReceiver(ReceiverDescriptor receiverArgument, ReceiverDescriptor thisObject, StringBuilder builder) {
|
||||||
if (receiverArgument.exists()) {
|
if (receiverArgument.exists()) {
|
||||||
builder.append("/").append(receiverArgument);
|
builder.append("/").append(receiverArgument);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.plugin.quickfix;
|
package org.jetbrains.jet.plugin.quickfix;
|
||||||
|
|
||||||
|
import com.intellij.extapi.psi.ASTDelegatePsiElement;
|
||||||
import com.intellij.openapi.editor.Editor;
|
import com.intellij.openapi.editor.Editor;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
@@ -25,7 +26,6 @@ import com.intellij.util.IncorrectOperationException;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||||
import org.jetbrains.jet.lang.psi.JetElement;
|
|
||||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||||
import org.jetbrains.jet.lang.psi.JetFunction;
|
import org.jetbrains.jet.lang.psi.JetFunction;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
@@ -79,7 +79,7 @@ public class RemoveFunctionBodyFix extends JetIntentionAction<JetFunction> {
|
|||||||
element.replace(function);
|
element.replace(function);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean removePossiblyEquationSign(@NotNull JetElement element, @Nullable PsiElement possiblyEq) {
|
private static boolean removePossiblyEquationSign(@NotNull ASTDelegatePsiElement element, @Nullable PsiElement possiblyEq) {
|
||||||
if (possiblyEq instanceof LeafPsiElement && ((LeafPsiElement)possiblyEq).getElementType() == JetTokens.EQ) {
|
if (possiblyEq instanceof LeafPsiElement && ((LeafPsiElement)possiblyEq).getElementType() == JetTokens.EQ) {
|
||||||
QuickFixUtil.removePossiblyWhiteSpace(element, possiblyEq.getNextSibling());
|
QuickFixUtil.removePossiblyWhiteSpace(element, possiblyEq.getNextSibling());
|
||||||
element.deleteChildInternal(possiblyEq.getNode());
|
element.deleteChildInternal(possiblyEq.getNode());
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.plugin.quickfix;
|
package org.jetbrains.jet.plugin.quickfix;
|
||||||
|
|
||||||
|
import com.intellij.extapi.psi.ASTDelegatePsiElement;
|
||||||
import com.intellij.lang.ASTNode;
|
import com.intellij.lang.ASTNode;
|
||||||
import com.intellij.openapi.editor.Editor;
|
import com.intellij.openapi.editor.Editor;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
@@ -26,7 +27,6 @@ import com.intellij.util.IncorrectOperationException;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||||
import org.jetbrains.jet.lang.psi.JetElement;
|
|
||||||
import org.jetbrains.jet.lang.psi.JetModifierList;
|
import org.jetbrains.jet.lang.psi.JetModifierList;
|
||||||
import org.jetbrains.jet.lang.psi.JetModifierListOwner;
|
import org.jetbrains.jet.lang.psi.JetModifierListOwner;
|
||||||
import org.jetbrains.jet.lexer.JetKeywordToken;
|
import org.jetbrains.jet.lexer.JetKeywordToken;
|
||||||
@@ -70,9 +70,9 @@ public class RemoveModifierFix extends JetIntentionAction<JetModifierListOwner>
|
|||||||
removeModifierFromList(modifierList, modifier);
|
removeModifierFromList(modifierList, modifier);
|
||||||
if (modifierList.getFirstChild() == null) {
|
if (modifierList.getFirstChild() == null) {
|
||||||
PsiElement whiteSpace = modifierList.getNextSibling();
|
PsiElement whiteSpace = modifierList.getNextSibling();
|
||||||
assert element instanceof JetElement;
|
assert element instanceof ASTDelegatePsiElement;
|
||||||
((JetElement) element).deleteChildInternal(modifierList.getNode());
|
((ASTDelegatePsiElement) element).deleteChildInternal(modifierList.getNode());
|
||||||
QuickFixUtil.removePossiblyWhiteSpace((JetElement) element, whiteSpace);
|
QuickFixUtil.removePossiblyWhiteSpace((ASTDelegatePsiElement) element, whiteSpace);
|
||||||
}
|
}
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user