working on reading class data from .class files

This commit is contained in:
Stepan Koltsov
2011-12-06 16:54:52 +04:00
parent 1ad4b73f5e
commit 29ebb124c8
11 changed files with 308 additions and 6 deletions
@@ -332,7 +332,6 @@ public class JavaDescriptorResolver {
}
private ValueParameterDescriptor resolveParameterDescriptor(DeclarationDescriptor containingDeclaration, int i, PsiParameter parameter) {
String name = parameter.getName();
PsiType psiType = parameter.getType();
JetType varargElementType;
@@ -343,14 +342,41 @@ public class JavaDescriptorResolver {
else {
varargElementType = null;
}
boolean nullable = true;
// TODO: must be very slow, make it lazy?
String name = parameter.getName() != null ? parameter.getName() : "p" + i;
for (PsiAnnotation annotation : parameter.getModifierList().getAnnotations()) {
// TODO: softcode annotation name
PsiNameValuePair[] attributes = annotation.getParameterList().getAttributes();
attributes.toString();
if (annotation.getQualifiedName().equals("jet.typeinfo.JetParameter")) {
PsiLiteralExpression nameExpression = (PsiLiteralExpression) annotation.findAttributeValue("name");
if (nameExpression != null) {
name = (String) nameExpression.getValue();
}
PsiLiteralExpression nullableExpression = (PsiLiteralExpression) annotation.findAttributeValue("nullable");
if (nullableExpression != null) {
nullable = (Boolean) nullableExpression.getValue();
} else {
// default value of parameter
nullable = false;
}
}
}
JetType outType = semanticServices.getTypeTransformer().transformToType(psiType);
return new ValueParameterDescriptorImpl(
containingDeclaration,
i,
Collections.<AnnotationDescriptor>emptyList(), // TODO
name == null ? "p" + i : name,
name,
null, // TODO : review
outType,
TypeUtils.makeNullableAsSpecified(outType, nullable),
false,
varargElementType
);
@@ -1,5 +1,6 @@
package org.jetbrains.jet.lang.resolve.java;
import com.intellij.psi.PsiClass;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.resolve.scopes.JetScopeImpl;
@@ -34,7 +35,17 @@ public class JavaPackageScope extends JetScopeImpl {
@NotNull
@Override
public Set<FunctionDescriptor> getFunctions(@NotNull String name) {
return Collections.emptySet();
// TODO: what is GlobalSearchScope
PsiClass psiClass = semanticServices.getDescriptorResolver().javaFacade.findClass(packagePrefix + "namespace");
if (psiClass == null) {
return Collections.emptySet();
}
if (containingDescriptor == null) {
return Collections.emptySet();
}
return semanticServices.getDescriptorResolver().resolveFunctionGroup(containingDescriptor, psiClass, null, name, true);
}
@NotNull