Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,7 @@
/trunk/codemodel/codemodel-annotation-compiler/target
/trunk/codemodel/codemodel-annotation-compiler/velocity.log
/trunk/codemodel/codemodel-annotation-compiler/*.iml

.gradle/
codemodel/build/
codemodel/target/
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ allprojects {
apply plugin: 'maven'

group = 'com.unquietcode.tools.jcodemodel'
version = '1.0.2'
version = '1.0.2-SNAPSHOT'
}

subprojects {
Expand Down
6 changes: 3 additions & 3 deletions codemodel-annotation-compiler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@
<modelVersion>4.0.0</modelVersion>
<groupId>unquietcode.tools.jcodemodel</groupId>
<artifactId>codemodel-annotation-compiler</artifactId>
<version>1.0.2</version>
<version>1.0.2-SNAPSHOT</version>
<name>Codemodel Annotation Compiler</name>
<description>The annotation compiler ant task for the CodeModel java source code generation library</description>
<parent>
<groupId>unquietcode.tools.jcodemodel</groupId>
<artifactId>codemodel-project</artifactId>
<version>1.0.2</version>
<version>1.0.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>unquietcode.tools.jcodemodel</groupId>
<artifactId>codemodel</artifactId>
<version>1.0.2</version>
<version>1.0.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.sun.istack</groupId>
Expand Down
12 changes: 6 additions & 6 deletions codemodel/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ artifacts {
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
//beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
authentication(userName: hasProperty('ossrhUsername')?ossrhUsername:'', password: hasProperty('ossrhPassword')?ossrhPassword:'')
}

snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
authentication(userName: hasProperty('ossrhUsername')?ossrhUsername:'', password: hasProperty('ossrhPassword')?ossrhPassword:'')
}

pom.project {
Expand Down Expand Up @@ -70,6 +70,6 @@ uploadArchives {
}
}

signing {
sign configurations.archives
}
//signing {
// sign configurations.archives
//}
2 changes: 1 addition & 1 deletion codemodel/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<parent>
<groupId>unquietcode.tools.jcodemodel</groupId>
<artifactId>codemodel-project</artifactId>
<version>1.0.2</version>
<version>1.0.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
8 changes: 4 additions & 4 deletions codemodel/src/main/java/com/sun/codemodel/JAnnotationUse.java
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ public JAnnotationUse param(String name, JEnumConstant value){
* This can be used for e.g to specify
* <pre>
* &#64;XmlCollectionItem(type=Integer.class);
* <pre>
* For adding a value of Class<? extends Annotation>
* @link
* #annotationParam(java.lang.String, java.lang.Class<? extends java.lang.annotation.Annotation>)
* </pre>
* For adding a value of {@code Class<? extends Annotation>}
* {@link
* #annotationParam(java.lang.String, java.lang.Class)}
* @param name
* The simple name for this annotation param
*
Expand Down
54 changes: 36 additions & 18 deletions codemodel/src/main/java/com/sun/codemodel/JArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,66 +37,84 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/

package com.sun.codemodel;

import java.util.ArrayList;
import java.util.List;


/**
* array creation and initialization.
*/
public final class JArray extends JExpressionImpl {

private final JType type;
private final JExpression size;
private final List<JExpression> sizes = new ArrayList<JExpression>();
private List<JExpression> exprs = null;

/**
* Add an element to the array initializer
* @param e
* @return
*/
public JArray add(JExpression e) {
if (exprs == null)
if (exprs == null) {
exprs = new ArrayList<JExpression>();
}
exprs.add(e);
return this;
}

public JArray addSize(JExpression e) {
if (e != null) {
sizes.add(e);
}
return this;
}

JArray(JType type, JExpression size) {
this.type = type;
this.size = size;
if (size != null) {
sizes.add(size);
}
}

public void generate(JFormatter f) {

// generally we produce new T[x], but when T is an array type (T=T'[])
// then new T'[][x] is wrong. It has to be new T'[x][].
int arrayCount = 0;
JType t = type;
while( t.isArray() ) {

while (t.isArray()) {
t = t.elementType();
arrayCount++;
}

f.p("new").g(t).p('[');
if (size != null)
f.g(size);
f.p(']');

for( int i=0; i<arrayCount; i++ )
f.p("[]");

if ((size == null) || (exprs != null))
if (arrayCount < sizes.size()) {
arrayCount = sizes.size();
}

f.p("new").g(t);

for (int i = 0; i < arrayCount; i++) {
f.p('[');
if (sizes.get(i) != null) {
f.g(sizes.get(i));
}
f.p(']');
}

if ((sizes.isEmpty()) || (exprs != null)) {
f.p('{');
}
if (exprs != null) {
f.g(exprs);
} else {
f.p(' ');
}
if ((size == null) || (exprs != null))
if ((sizes.isEmpty()) || (exprs != null)) {
f.p('}');
}
}

}
7 changes: 6 additions & 1 deletion codemodel/src/main/java/com/sun/codemodel/JArrayClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@

package com.sun.codemodel;

import java.util.Iterator;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

/**
Expand Down Expand Up @@ -135,4 +135,9 @@ protected JClass substituteParams(JTypeVar[] variables, List<JClass> bindings) {
return new JArrayClass(owner(),c);
}

@Override
public JClass inner(String name) {
return null;
}

}
27 changes: 22 additions & 5 deletions codemodel/src/main/java/com/sun/codemodel/JBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
package com.sun.codemodel;

import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
import java.util.List;

/**
* A block of Java code, which may contain statements and local declarations.
Expand All @@ -66,19 +66,29 @@ public final class JBlock implements JGenerable, JStatement {
*/
private boolean bracesRequired = true;
private boolean indentRequired = true;
private boolean newlineRequired = true;

/**
* Current position.
*/
private int pos;

public JBlock() {
this(true,true);
this(true, true, true);
}

public JBlock(boolean bracesRequired, boolean indentRequired) {
this(bracesRequired, indentRequired, true);
}

public JBlock(boolean bracesRequired, boolean indentRequired, boolean newlineRequired) {
this.bracesRequired = bracesRequired;
this.indentRequired = indentRequired;
this.newlineRequired = newlineRequired;
}

public void setNewlineRequired(boolean val) {
this.newlineRequired = val;
}

/**
Expand Down Expand Up @@ -402,10 +412,17 @@ public void _continue() {
*/
public JBlock block() {
JBlock b = new JBlock();
b.bracesRequired = false;
b.indentRequired = false;
// why false? of course they are both required
// b.bracesRequired = false;
// b.indentRequired = false;
return insert(b);
}

public JSynchronized _synchronized(JExpression lock) {
JSynchronized syn = new JSynchronized(lock);
insert(syn);
return syn;
}

/**
* Creates a "literal" statement directly.
Expand Down Expand Up @@ -462,7 +479,7 @@ public JForEach forEach(JType varType, String name, JExpression collection) {
}
public void state(JFormatter f) {
f.g(this);
if (bracesRequired)
if (newlineRequired)
f.nl();
}

Expand Down
5 changes: 4 additions & 1 deletion codemodel/src/main/java/com/sun/codemodel/JCatchBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,18 @@
* Catch block for a try/catch/finally statement
*/

public class JCatchBlock implements JGenerable {
public class JCatchBlock implements JTryBlock.CatchBlock {

JClass exception;
private JVar var = null;
private JBlock body = new JBlock();
private boolean isMulti = false;

JCatchBlock(JClass exception) {
this.exception = exception;
}



public JVar param(String name) {
if (var != null) throw new IllegalStateException();
Expand Down
Loading