Skip to content

Commit

Permalink
Exceptions support, plug in Signature processing. Prep for type annot…
Browse files Browse the repository at this point in the history
…ations
  • Loading branch information
n1hility committed Sep 27, 2014
1 parent 41d0223 commit 8ef4d7a
Show file tree
Hide file tree
Showing 16 changed files with 350 additions and 48 deletions.
21 changes: 7 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<jandexVersion>1.2.1.Final</jandexVersion>
<jandexVersion>2.0.0.Alpha1</jandexVersion>
</properties>

<parent>
Expand Down Expand Up @@ -37,25 +37,18 @@
<showWarnings>true</showWarnings>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<index>true</index>
<manifest>
<mainClass>org.jboss.jandex.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<archive>
<index>true</index>
<manifest>
<mainClass>org.jboss.jandex.Main</mainClass>
</manifest>
</archive>
<instructions>
<Bundle-SymbolicName>${pom.groupId}.${pom.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${jandexVersion}</Bundle-Version>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/jboss/jandex/ArrayType.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public Kind kind() {
return Kind.ARRAY;
}

@Override
public ArrayType asArrayType() {
return this;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down
46 changes: 46 additions & 0 deletions src/main/java/org/jboss/jandex/ClassInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.jboss.jandex;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -49,6 +50,11 @@ public final class ClassInfo implements AnnotationTarget {
private final DotName superName;
private final DotName[] interfaces;
private final Map<DotName, List<AnnotationInstance>> annotations;
private Collection<Type> interfaceTypes;
private Type superClassType;
private List<Type> typeParameters;
private Collection<MethodInfo> methods;
private Collection<FieldInfo> fields;

// Not final to allow lazy initialization, immutable once published
private boolean hasNoArgsConstructor;
Expand Down Expand Up @@ -105,6 +111,26 @@ public final Map<DotName, List<AnnotationInstance>> annotations() {
return annotations;
}

public final Collection<MethodInfo> methods() {
return methods;
}

public final Collection<FieldInfo> fields() {
return fields;
}

public final Collection<Type> interfaceTypes() {
return interfaceTypes;
}

public final Type superClassType() {
return superClassType;
}

public final List<Type> typeParameters() {
return typeParameters;
}

/**
* Returns a boolean indicating the presence of a no-arg constructor, if supported by the underlying index store.
* This information is available in indexes produced by Jandex 1.2.0 and later.
Expand All @@ -121,4 +147,24 @@ public final boolean hasNoArgsConstructor() {
void setHasNoArgsConstructor(boolean hasNoArgsConstructor) {
this.hasNoArgsConstructor = hasNoArgsConstructor;
}

void setFields(List<FieldInfo> fields) {
this.fields = fields;
}

void setMethods(List<MethodInfo> methods) {
this.methods = methods;
}

void setSuperClassType(Type superClassType) {
this.superClassType = superClassType;
}

void setInterfaceTypes(Collection<Type> interfaceTypes) {
this.interfaceTypes = interfaceTypes;
}

void setTypeParameters(List<Type> typeParameters) {
this.typeParameters = typeParameters;
}
}
5 changes: 5 additions & 0 deletions src/main/java/org/jboss/jandex/ClassType.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ public final class ClassType extends Type {
public Kind kind() {
return Kind.CLASS;
}

@Override
public ClassType asClassType() {
return this;
}
}
6 changes: 5 additions & 1 deletion src/main/java/org/jboss/jandex/FieldInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
public final class FieldInfo implements AnnotationTarget {
private final String name;
private final Type type;
private Type type;
private final short flags;
private final ClassInfo clazz;

Expand Down Expand Up @@ -101,4 +101,8 @@ public final short flags() {
public String toString() {
return type + " " + clazz.name() + "." + name;
}

void setType(Type type) {
this.type = type;
}
}
20 changes: 13 additions & 7 deletions src/main/java/org/jboss/jandex/GenericSignatureParser.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package org.jboss.jandex;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -102,7 +99,7 @@ class GenericSignatureParser {
private int pos;
private NameTable names;
private Map<String, TypeVariable> typeParameters;
private Map<String, TypeVariable> methodTypeParameters = new HashMap<String, TypeVariable>();
private Map<String, TypeVariable> elementTypeParameters = new HashMap<String, TypeVariable>();
private Map<String, TypeVariable> classTypeParameteres = new HashMap<String, TypeVariable>();

GenericSignatureParser() {
Expand Down Expand Up @@ -246,10 +243,19 @@ private void expect(char c) {
}
}

Type parseFieldSignature(String signature) {
this.signature = signature;
this.typeParameters = this.elementTypeParameters;
this.typeParameters.clear();
this.pos = 0;

return parseReferenceType();
}


MethodSignature parseMethodSignature(String signature) {
this.signature = signature;
this.typeParameters = this.methodTypeParameters;
this.typeParameters = this.elementTypeParameters;
this.typeParameters.clear();
this.pos = 0;

Expand Down Expand Up @@ -430,7 +436,7 @@ private Type parseArrayType() {

private Type parseTypeVariable() {
String name = names.intern(signature.substring(pos + 1, advancePast(';')));
Type type = typeParameters.get(name);
Type type = resolveType(name);
return type == null ? new UnresolvedTypeVariable(name) : type;
}

Expand All @@ -453,7 +459,7 @@ private Type resolveType(Type type) {
}

private Type resolveType(String identifier) {
Type ret = methodTypeParameters.get(identifier);
Type ret = elementTypeParameters.get(identifier);
return ret == null ? classTypeParameteres.get(identifier) : ret;
}

Expand Down
Loading

0 comments on commit 8ef4d7a

Please sign in to comment.