use of com.sun.tools.javac.util.ListBuffer in project ceylon-compiler by ceylon.
the class AbstractTransformer method makeAtTypeParameter.
final JCAnnotation makeAtTypeParameter(String name, java.util.List<Type> satisfiedTypes, java.util.List<Type> caseTypes, boolean covariant, boolean contravariant, Type defaultValue) {
ListBuffer<JCExpression> attributes = new ListBuffer<JCExpression>();
// name
attributes.add(make().Assign(naming.makeUnquotedIdent("value"), make().Literal(name)));
// variance
String variance = "NONE";
if (covariant)
variance = "OUT";
else if (contravariant)
variance = "IN";
JCExpression varianceAttribute = make().Assign(naming.makeUnquotedIdent("variance"), make().Select(makeIdent(syms().ceylonVarianceType), names().fromString(variance)));
attributes.add(varianceAttribute);
// upper bounds
ListBuffer<JCExpression> upperBounds = new ListBuffer<JCTree.JCExpression>();
for (Type satisfiedType : satisfiedTypes) {
String type = serialiseTypeSignature(satisfiedType);
upperBounds.append(make().Literal(type));
}
JCExpression satisfiesAttribute = make().Assign(naming.makeUnquotedIdent("satisfies"), make().NewArray(null, null, upperBounds.toList()));
attributes.add(satisfiesAttribute);
// case types
ListBuffer<JCExpression> caseTypesExpressions = new ListBuffer<JCTree.JCExpression>();
if (caseTypes != null) {
for (Type caseType : caseTypes) {
String type = serialiseTypeSignature(caseType);
caseTypesExpressions.append(make().Literal(type));
}
}
JCExpression caseTypeAttribute = make().Assign(naming.makeUnquotedIdent("caseTypes"), make().NewArray(null, null, caseTypesExpressions.toList()));
attributes.add(caseTypeAttribute);
if (defaultValue != null) {
attributes.add(make().Assign(naming.makeUnquotedIdent("defaultValue"), make().Literal(serialiseTypeSignature(defaultValue))));
}
// all done
return make().Annotation(makeIdent(syms().ceylonAtTypeParameter), attributes.toList());
}
use of com.sun.tools.javac.util.ListBuffer in project ceylon-compiler by ceylon.
the class JavacFileManager method getClassLoader.
public ClassLoader getClassLoader(Location location) {
nullCheck(location);
Iterable<? extends File> path = getLocation(location);
if (path == null)
return null;
ListBuffer<URL> lb = new ListBuffer<URL>();
for (File f : path) {
try {
lb.append(f.toURI().toURL());
} catch (MalformedURLException e) {
throw new AssertionError(e);
}
}
return getClassLoader(lb.toArray(new URL[lb.size()]));
}
use of com.sun.tools.javac.util.ListBuffer in project ceylon-compiler by ceylon.
the class Paths method getPathEntries.
/**
* Split a path into its elements. If emptyPathDefault is not null, all
* empty elements in the path, including empty elements at either end of
* the path, will be replaced with the value of emptyPathDefault.
* @param path The path to be split
* @param emptyPathDefault The value to substitute for empty path elements,
* or null, to ignore empty path elements
* @return The elements of the path
*/
private static Iterable<File> getPathEntries(String path, File emptyPathDefault) {
ListBuffer<File> entries = new ListBuffer<File>();
int start = 0;
while (start <= path.length()) {
int sep = path.indexOf(File.pathSeparatorChar, start);
if (sep == -1)
sep = path.length();
if (start < sep)
entries.add(new File(path.substring(start, sep)));
else if (emptyPathDefault != null)
entries.add(emptyPathDefault);
start = sep + 1;
}
return entries;
}
use of com.sun.tools.javac.util.ListBuffer in project bazel by bazelbuild.
the class TreeParser method parseExpression.
JCExpression parseExpression() {
JCExpression tree = fromToken(token);
while (tokenizer.hasMoreTokens()) {
String delim = nextToken();
if (".".equals(delim)) {
nextToken();
tree = maker.Select(tree, names.fromString(token));
} else if ("(".equals(delim)) {
nextToken();
ListBuffer<JCExpression> args = new ListBuffer<>();
while (!")".equals(token)) {
JCExpression arg = parseExpression();
args.append(arg);
if (",".equals(token))
nextToken();
}
// For now, handle empty args only
assert ")".equals(token);
tree = maker.Apply(List.<JCExpression>nil(), tree, args.toList());
} else if ("[".equals(token)) {
nextToken();
JCExpression index = parseExpression();
assert "]".equals(token);
tree = maker.Indexed(tree, index);
} else {
return tree;
}
}
return tree;
}
use of com.sun.tools.javac.util.ListBuffer in project checkstyle by checkstyle.
the class TokenTypesDocletTest method testEmptyJavadoc.
@Test
public void testEmptyJavadoc() throws Exception {
final ListBuffer<String[]> options = new ListBuffer<>();
options.add(new String[] { "-destfile", "target/tokentypes.properties" });
final ListBuffer<String> names = new ListBuffer<>();
names.add(getPath("InputTokenTypesDocletEmptyJavadoc.java"));
final Context context = new Context();
new TestMessager(context);
final JavadocTool javadocTool = JavadocTool.make0(context);
final RootDoc rootDoc = getRootDoc(javadocTool, options, names);
try {
TokenTypesDoclet.start(rootDoc);
fail("IllegalArgumentException is expected");
} catch (IllegalArgumentException expected) {
// Token types must have first sentence of Javadoc summary
// so that a brief description could be provided. Otherwise,
// an IllegalArgumentException is thrown.
}
}
Aggregations