Move the return type to the MethodPrototype stub
diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethod.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethod.java
index 2aec4bb..b583d87 100644
--- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethod.java
+++ b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethod.java
@@ -98,24 +98,13 @@
}
@Nullable @Override public PsiType getReturnType() {
- SmaliMethodStub stub = getStub();
- if (stub != null) {
- String returnType = stub.getReturnType();
- if (returnType == null) {
- return null;
- }
- PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
- return factory.createTypeByFQClassName(returnType, getResolveScope());
- }
- PsiTypeElement returnTypeElement = getReturnTypeElement();
- if (returnTypeElement == null) {
- return null;
- }
- return returnTypeElement.getType();
+ if (isConstructor()) return null;
+ return getMethodPrototype().getReturnType();
}
@Nullable @Override public PsiTypeElement getReturnTypeElement() {
- return getMethodPrototype().getReturnType();
+ if (isConstructor()) return null;
+ return getMethodPrototype().getReturnTypeElement();
}
@NotNull @Override public SmaliMethodParamList getParameterList() {
diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethodPrototype.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethodPrototype.java
index 1514289..f7b493d 100644
--- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethodPrototype.java
+++ b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethodPrototype.java
@@ -32,6 +32,9 @@
package org.jf.smalidea.psi.impl;
import com.intellij.lang.ASTNode;
+import com.intellij.psi.JavaPsiFacade;
+import com.intellij.psi.PsiElementFactory;
+import com.intellij.psi.PsiType;
import com.intellij.psi.PsiTypeElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -48,7 +51,25 @@
}
@Nullable
- public PsiTypeElement getReturnType() {
+ public PsiType getReturnType() {
+ SmaliMethodPrototypeStub stub = getStub();
+ if (stub != null) {
+ String returnType = stub.getReturnType();
+ if (returnType == null) {
+ return null;
+ }
+ PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
+ return factory.createTypeByFQClassName(returnType, getResolveScope());
+ }
+
+ PsiTypeElement returnTypeElement = getReturnTypeElement();
+ if (returnTypeElement == null) {
+ return null;
+ }
+ return returnTypeElement.getType();
+ }
+
+ @Nullable public PsiTypeElement getReturnTypeElement() {
return findChildByClass(PsiTypeElement.class);
}
diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodPrototypeStub.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodPrototypeStub.java
index d5869e1..81e42c5 100644
--- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodPrototypeStub.java
+++ b/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodPrototypeStub.java
@@ -34,11 +34,19 @@
import com.intellij.psi.stubs.StubBase;
import com.intellij.psi.stubs.StubElement;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.jf.smalidea.psi.SmaliElementTypes;
import org.jf.smalidea.psi.impl.SmaliMethodPrototype;
public class SmaliMethodPrototypeStub extends StubBase<SmaliMethodPrototype> {
- public SmaliMethodPrototypeStub(@NotNull StubElement parent) {
+ @Nullable private final String returnType;
+
+ public SmaliMethodPrototypeStub(@NotNull StubElement parent, @Nullable String returnType) {
super(parent, SmaliElementTypes.METHOD_PROTOTYPE);
+ this.returnType = returnType;
+ }
+
+ @Nullable public String getReturnType() {
+ return returnType;
}
}
diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodStub.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodStub.java
index ce8d49a..1412980 100644
--- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodStub.java
+++ b/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodStub.java
@@ -41,19 +41,13 @@
public class SmaliMethodStub extends StubBase<SmaliMethod> {
@Nullable private final String name;
- @Nullable private final String returnType;
- public SmaliMethodStub(@NotNull StubElement parent, @Nullable String name, @Nullable String returnType) {
+ public SmaliMethodStub(@NotNull StubElement parent, @Nullable String name) {
super(parent, SmaliElementTypes.METHOD);
this.name = name;
- this.returnType = returnType;
}
@Nullable public String getName() {
return name;
}
-
- @Nullable public String getReturnType() {
- return returnType;
- }
}
diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodElementType.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodElementType.java
index a783319..d5bf804 100644
--- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodElementType.java
+++ b/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodElementType.java
@@ -32,7 +32,6 @@
package org.jf.smalidea.psi.stub.element;
import com.intellij.lang.ASTNode;
-import com.intellij.psi.PsiType;
import com.intellij.psi.stubs.IndexSink;
import com.intellij.psi.stubs.StubElement;
import com.intellij.psi.stubs.StubInputStream;
@@ -64,29 +63,18 @@
}
@Override public SmaliMethodStub createStub(@NotNull SmaliMethod psi, StubElement parentStub) {
- String returnTypeText = null;
- PsiType returnType = psi.getReturnType();
- if (returnType != null) {
- returnTypeText = returnType.getCanonicalText();
- }
- return new SmaliMethodStub(parentStub, psi.getName(), returnTypeText);
+ return new SmaliMethodStub(parentStub, psi.getName());
}
@Override
public void serialize(@NotNull SmaliMethodStub stub, @NotNull StubOutputStream dataStream) throws IOException {
dataStream.writeName(stub.getName());
- dataStream.writeName(stub.getReturnType());
}
@NotNull @Override
public SmaliMethodStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
StringRef methodNameRef = dataStream.readName();
- StringRef returnTypeRef = dataStream.readName();
- String returnType = null;
- if (returnTypeRef != null) {
- returnType = returnTypeRef.getString();
- }
- return new SmaliMethodStub(parentStub, methodNameRef.getString(), returnType);
+ return new SmaliMethodStub(parentStub, methodNameRef.getString());
}
@Override public void indexStub(@NotNull SmaliMethodStub stub, @NotNull IndexSink sink) {
diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodPrototypeElementType.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodPrototypeElementType.java
index dd4c39c..9c06c49 100644
--- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodPrototypeElementType.java
+++ b/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodPrototypeElementType.java
@@ -32,10 +32,12 @@
package org.jf.smalidea.psi.stub.element;
import com.intellij.lang.ASTNode;
+import com.intellij.psi.PsiType;
import com.intellij.psi.stubs.IndexSink;
import com.intellij.psi.stubs.StubElement;
import com.intellij.psi.stubs.StubInputStream;
import com.intellij.psi.stubs.StubOutputStream;
+import com.intellij.util.io.StringRef;
import org.jetbrains.annotations.NotNull;
import org.jf.smalidea.psi.impl.SmaliMethodPrototype;
import org.jf.smalidea.psi.stub.SmaliMethodPrototypeStub;
@@ -63,18 +65,30 @@
}
@Override public SmaliMethodPrototypeStub createStub(@NotNull SmaliMethodPrototype psi, StubElement parentStub) {
- return new SmaliMethodPrototypeStub(parentStub);
+ PsiType returnType = psi.getReturnType();
+ String returnTypeText = null;
+ if (returnType != null) {
+ returnTypeText = returnType.getCanonicalText();
+ }
+
+ return new SmaliMethodPrototypeStub(parentStub, returnTypeText);
}
@Override
public void serialize(@NotNull SmaliMethodPrototypeStub stub, @NotNull StubOutputStream dataStream)
throws IOException {
+ dataStream.writeName(stub.getReturnType());
}
@NotNull @Override
public SmaliMethodPrototypeStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub)
throws IOException {
- return new SmaliMethodPrototypeStub(parentStub);
+ StringRef returnTypeRef = dataStream.readName();
+ String returnType = null;
+ if (returnTypeRef != null) {
+ returnType = returnTypeRef.getString();
+ }
+ return new SmaliMethodPrototypeStub(parentStub, returnType);
}
@Override public void indexStub(@NotNull SmaliMethodPrototypeStub stub, @NotNull IndexSink sink) {