aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2015-10-20 19:02:53 +0100
committerMichael Williamson <mike@zwobble.org>2015-10-20 19:02:53 +0100
commitd0b2d1e1b447b2bb7b5f5275dfbc3bbd44b6c87b (patch)
treeee92575319814f6acabd2939c74399843ebe9c0e /src/main/java/org
parent4054a250df414bb2c756d12b133aaaa8cd6bbce3 (diff)
Extract typeOf(Type)
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/zwobble/couscous/frontends/java/JavaReader.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main/java/org/zwobble/couscous/frontends/java/JavaReader.java b/src/main/java/org/zwobble/couscous/frontends/java/JavaReader.java
index 22d42ab..04ed784 100644
--- a/src/main/java/org/zwobble/couscous/frontends/java/JavaReader.java
+++ b/src/main/java/org/zwobble/couscous/frontends/java/JavaReader.java
@@ -26,6 +26,7 @@ import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
import org.eclipse.jdt.core.dom.Statement;
import org.eclipse.jdt.core.dom.StringLiteral;
import org.eclipse.jdt.core.dom.ThisExpression;
+import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
@@ -88,7 +89,7 @@ public class JavaReader {
private static void readField(FieldDeclaration field, ClassNodeBuilder classBuilder) {
for (val fragment : field.fragments()) {
val name = ((VariableDeclarationFragment)fragment).getName().getIdentifier();
- classBuilder.field(name, typeOf(field.getType().resolveBinding()));
+ classBuilder.field(name, typeOf(field.getType()));
}
}
@@ -145,7 +146,7 @@ public class JavaReader {
private static List<StatementNode> readVariableDeclarationStatement(VariableDeclarationStatement statement) {
@SuppressWarnings("unchecked")
val fragments = (List<VariableDeclarationFragment>)statement.fragments();
- val type = typeOf(statement.getType().resolveBinding());
+ val type = typeOf(statement.getType());
return Lists.transform(fragments, fragment ->
localVariableDeclaration(
fragment.resolveBinding().getKey(),
@@ -203,7 +204,7 @@ public class JavaReader {
}
private static ExpressionNode readVariableBinding(IVariableBinding binding) {
- val type = typeOf(binding.getType());
+ val type = typeOf(binding);
if (binding.getDeclaringClass() == null) {
return reference(var(
binding.getKey(),
@@ -295,6 +296,10 @@ public class JavaReader {
return typeOf(variableBinding.getType());
}
+ private static TypeName typeOf(Type type) {
+ return typeOf(type.resolveBinding());
+ }
+
private static TypeName typeOf(ITypeBinding typeBinding) {
return TypeName.of(typeBinding.getQualifiedName());
}