Merge remote-tracking branch 'origin/master'

This commit is contained in:
Evgeny Gerashchenko
2012-05-11 20:39:00 +04:00
10 changed files with 105 additions and 32 deletions
@@ -69,12 +69,12 @@ public class MutableClassDescriptorLite extends MutableDeclarationDescriptor
@Override
public void forceResolve() {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public boolean isAlreadyResolved() {
return false; //To change body of implemented methods use File | Settings | File Templates.
return false;
}
private static boolean isStatic(DeclarationDescriptor declarationDescriptor) {
@@ -105,11 +105,11 @@ public class NamespaceDescriptorImpl extends AbstractNamespaceDescriptorImpl imp
@Override
public void forceResolve() {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public boolean isAlreadyResolved() {
return false; //To change body of implemented methods use File | Settings | File Templates.
return false;
}
}
@@ -0,0 +1,25 @@
/*
* 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.descriptors;
/**
* @author Nikolay Krasko
*/
public interface WithDeferredResolve {
void forceResolve();
boolean isAlreadyResolved();
}
@@ -17,8 +17,12 @@
package org.jetbrains.jet.lang.psi;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.StubBasedPsiElement;
import com.intellij.psi.stubs.IStubElementType;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -27,6 +31,7 @@ import org.jetbrains.jet.lang.psi.stubs.PsiJetClassStub;
import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes;
import org.jetbrains.jet.lexer.JetTokens;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -41,11 +46,10 @@ public class JetClass extends JetTypeParameterListOwner
public JetClass(@NotNull ASTNode node) {
super(node);
}
// TODO (stubs)
// public JetClass(final PsiJetClassStub stub) {
// this.stub = stub;
// }
// public JetClass(final PsiJetClassStub stub) {
// this.stub = stub;
// }
@Override
public List<JetDeclaration> getDeclarations() {
@@ -163,4 +167,35 @@ public class JetClass extends JetTypeParameterListOwner
public void delete() throws IncorrectOperationException {
JetPsiUtil.deleteClass(this);
}
@Override
public boolean isEquivalentTo(PsiElement another) {
if (super.isEquivalentTo(another)) {
return true;
}
if (another instanceof JetClass) {
String fq1 = getQualifiedName();
String fq2 = ((JetClass) another).getQualifiedName();
return fq1 != null && fq2 != null && fq1.equals(fq2);
}
return true;
}
@Nullable
private String getQualifiedName() {
List<String> parts = new ArrayList<String>();
JetClassOrObject current = this;
while (current != null) {
parts.add(current.getName());
current = PsiTreeUtil.getParentOfType(current, JetClassOrObject.class);
}
PsiFile file = getContainingFile();
if (!(file instanceof JetFile)) return null;
String fileQualifiedName = ((JetFile) file).getNamespaceHeader().getQualifiedName();
if (!fileQualifiedName.isEmpty()) {
parts.add(fileQualifiedName);
}
Collections.reverse(parts);
return StringUtil.join(parts, ".");
}
}
@@ -81,5 +81,16 @@ public class JetNamespaceHeader extends JetReferenceExpression {
public boolean isRoot() {
return getName().length() == 0;
}
public String getQualifiedName() {
StringBuilder builder = new StringBuilder();
for (JetSimpleNameExpression e : findChildrenByClass(JetSimpleNameExpression.class)) {
if (builder.length() > 0) {
builder.append(".");
}
builder.append(e.getName());
}
return builder.toString();
}
}
@@ -45,7 +45,7 @@ public class JetClassElementType extends JetStubElementType<PsiJetClassStub, Jet
@Override
public PsiJetClassStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) {
return null; //To change body of implemented methods use File | Settings | File Templates.
return null;
}
@Override
@@ -49,12 +49,12 @@ public class JetFunctionElementType extends JetStubElementType<PsiJetFunctionStu
@Override
public PsiJetFunctionStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) {
return null; //To change body of implemented methods use File | Settings | File Templates.
return null;
}
@Override
public JetNamedFunction createPsi(@NotNull PsiJetFunctionStub stub) {
return null; //To change body of implemented methods use File | Settings | File Templates.
return null;
}
@Override
@@ -54,6 +54,6 @@ public class PsiJetFileStubImpl extends PsiFileStubImpl<JetFile> implements PsiJ
@Override
public PsiClass[] getClasses() {
return new PsiClass[0]; //To change body of implemented methods use File | Settings | File Templates.
return new PsiClass[0];
}
}
@@ -29,6 +29,26 @@ error:
sink:
<SINK> NEXT:[] PREV:[<END>]
=====================
== O ==
object O {
val x : Int
{
$x = 1
}
}
---------------------
l0:
<START> NEXT:[v(val x : Int)] PREV:[]
v(val x : Int) NEXT:[r(1)] PREV:[<START>]
r(1) NEXT:[w($x)] PREV:[v(val x : Int)]
w($x) NEXT:[<END>] PREV:[r(1)]
l1:
<END> NEXT:[<SINK>] PREV:[w($x)]
error:
<ERROR> NEXT:[] PREV:[]
sink:
<SINK> NEXT:[] PREV:[<END>]
=====================
== null ==
object {
val x : Int
@@ -56,26 +76,6 @@ error:
sink:
<SINK> NEXT:[] PREV:[<END>]
=====================
== O ==
object O {
val x : Int
{
$x = 1
}
}
---------------------
l0:
<START> NEXT:[v(val x : Int)] PREV:[]
v(val x : Int) NEXT:[r(1)] PREV:[<START>]
r(1) NEXT:[w($x)] PREV:[v(val x : Int)]
w($x) NEXT:[<END>] PREV:[r(1)]
l1:
<END> NEXT:[<SINK>] PREV:[w($x)]
error:
<ERROR> NEXT:[] PREV:[]
sink:
<SINK> NEXT:[] PREV:[<END>]
=====================
== doSmth ==
fun doSmth(i: Int) {}
---------------------
@@ -38,6 +38,7 @@ import java.io.File;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
public class JetParsingTest extends ParsingTestCase {
static {
@@ -88,6 +89,7 @@ public class JetParsingTest extends ParsingTestCase {
String methodName = method.getName();
if (!methodName.startsWith("get") && !methodName.startsWith("find") || methodName.equals("getReference") ||
methodName.equals("getReferences") || methodName.equals("getUseScope")) continue;
if (!Modifier.isPublic(method.getModifiers())) continue;
if (method.getParameterTypes().length > 0) continue;
Class<?> declaringClass = method.getDeclaringClass();
if (!declaringClass.getName().startsWith("org.jetbrains.jet")) continue;