mirror of
https://github.com/revanced/smali.git
synced 2025-05-06 17:34:34 +02:00
Move some implementation from SmaliBaseReferenceList to its implementors
This commit is contained in:
parent
6a520231e7
commit
e0aff4bda5
@ -31,7 +31,6 @@
|
||||
|
||||
package org.jf.smalidea.psi.impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiReferenceList;
|
||||
import com.intellij.psi.StubBasedPsiElement;
|
||||
@ -39,8 +38,6 @@ import com.intellij.psi.stubs.IStubElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jf.smalidea.psi.stub.SmaliBaseReferenceListStub;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class SmaliBaseReferenceList<StubT extends SmaliBaseReferenceListStub>
|
||||
extends SmaliStubBasedPsiElement<StubT> implements StubBasedPsiElement<StubT>, PsiReferenceList {
|
||||
protected SmaliBaseReferenceList(@NotNull StubT stub, @NotNull IStubElementType nodeType) {
|
||||
@ -89,32 +86,4 @@ public abstract class SmaliBaseReferenceList<StubT extends SmaliBaseReferenceLis
|
||||
}
|
||||
|
||||
@NotNull @Override public abstract SmaliClassTypeElement[] getReferenceElements();
|
||||
|
||||
protected SmaliClassTypeElement[] getImplementsElements() {
|
||||
SmaliImplementsStatement[] implementsStatements = ((SmaliClass)getParent()).getImplementsStatements();
|
||||
if (implementsStatements.length > 0) {
|
||||
// all implemented interfaces go in the extends list for an interface
|
||||
List<SmaliClassTypeElement> types = Lists.newArrayList();
|
||||
|
||||
for (SmaliImplementsStatement implementsStatement: implementsStatements) {
|
||||
SmaliClassTypeElement classReference = implementsStatement.getClassReference();
|
||||
if (classReference != null) {
|
||||
types.add(classReference);
|
||||
}
|
||||
}
|
||||
return types.toArray(new SmaliClassTypeElement[types.size()]);
|
||||
}
|
||||
return new SmaliClassTypeElement[0];
|
||||
}
|
||||
|
||||
protected SmaliClassTypeElement[] getExtendsElement() {
|
||||
SmaliSuperStatement superStatement = ((SmaliClass)getParent()).getSuperStatement();
|
||||
if (superStatement != null) {
|
||||
SmaliClassTypeElement classReference = superStatement.getClassReference();
|
||||
if (classReference != null) {
|
||||
return new SmaliClassTypeElement[] { classReference };
|
||||
}
|
||||
}
|
||||
return new SmaliClassTypeElement[0];
|
||||
}
|
||||
}
|
||||
|
@ -31,11 +31,14 @@
|
||||
|
||||
package org.jf.smalidea.psi.impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jf.smalidea.psi.SmaliElementTypes;
|
||||
import org.jf.smalidea.psi.stub.SmaliExtendsListStub;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SmaliExtendsList extends SmaliBaseReferenceList<SmaliExtendsListStub> {
|
||||
public SmaliExtendsList(@NotNull SmaliExtendsListStub stub) {
|
||||
super(stub, SmaliElementTypes.EXTENDS_LIST);
|
||||
@ -53,6 +56,34 @@ public class SmaliExtendsList extends SmaliBaseReferenceList<SmaliExtendsListStu
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull private SmaliClassTypeElement[] getImplementsElements() {
|
||||
SmaliImplementsStatement[] implementsStatements = ((SmaliClass)getParent()).getImplementsStatements();
|
||||
if (implementsStatements.length > 0) {
|
||||
// all implemented interfaces go in the extends list for an interface
|
||||
List<SmaliClassTypeElement> types = Lists.newArrayList();
|
||||
|
||||
for (SmaliImplementsStatement implementsStatement: implementsStatements) {
|
||||
SmaliClassTypeElement classReference = implementsStatement.getClassReference();
|
||||
if (classReference != null) {
|
||||
types.add(classReference);
|
||||
}
|
||||
}
|
||||
return types.toArray(new SmaliClassTypeElement[types.size()]);
|
||||
}
|
||||
return new SmaliClassTypeElement[0];
|
||||
}
|
||||
|
||||
@NotNull private SmaliClassTypeElement[] getExtendsElement() {
|
||||
SmaliSuperStatement superStatement = ((SmaliClass)getParent()).getSuperStatement();
|
||||
if (superStatement != null) {
|
||||
SmaliClassTypeElement classReference = superStatement.getClassReference();
|
||||
if (classReference != null) {
|
||||
return new SmaliClassTypeElement[] { classReference };
|
||||
}
|
||||
}
|
||||
return new SmaliClassTypeElement[0];
|
||||
}
|
||||
|
||||
@Override public Role getRole() {
|
||||
return Role.EXTENDS_LIST;
|
||||
}
|
||||
|
@ -31,11 +31,14 @@
|
||||
|
||||
package org.jf.smalidea.psi.impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jf.smalidea.psi.SmaliElementTypes;
|
||||
import org.jf.smalidea.psi.stub.SmaliImplementsListStub;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SmaliImplementsList extends SmaliBaseReferenceList<SmaliImplementsListStub> {
|
||||
public SmaliImplementsList(@NotNull SmaliImplementsListStub stub) {
|
||||
super(stub, SmaliElementTypes.IMPLEMENTS_LIST);
|
||||
@ -52,6 +55,23 @@ public class SmaliImplementsList extends SmaliBaseReferenceList<SmaliImplementsL
|
||||
return new SmaliClassTypeElement[0];
|
||||
}
|
||||
|
||||
@NotNull private SmaliClassTypeElement[] getImplementsElements() {
|
||||
SmaliImplementsStatement[] implementsStatements = ((SmaliClass)getParent()).getImplementsStatements();
|
||||
if (implementsStatements.length > 0) {
|
||||
// all implemented interfaces go in the extends list for an interface
|
||||
List<SmaliClassTypeElement> types = Lists.newArrayList();
|
||||
|
||||
for (SmaliImplementsStatement implementsStatement: implementsStatements) {
|
||||
SmaliClassTypeElement classReference = implementsStatement.getClassReference();
|
||||
if (classReference != null) {
|
||||
types.add(classReference);
|
||||
}
|
||||
}
|
||||
return types.toArray(new SmaliClassTypeElement[types.size()]);
|
||||
}
|
||||
return new SmaliClassTypeElement[0];
|
||||
}
|
||||
|
||||
@Override public Role getRole() {
|
||||
return Role.IMPLEMENTS_LIST;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user