com.sun.tools.javac.util.ListBuffer Java Examples
The following examples show how to use
com.sun.tools.javac.util.ListBuffer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommandLine.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static void loadCmdFile(String name, ListBuffer<String> args) throws IOException { Reader r = new BufferedReader(new FileReader(name)); StreamTokenizer st = new StreamTokenizer(r); st.resetSyntax(); st.wordChars(' ', 255); st.whitespaceChars(0, ' '); st.commentChar('#'); st.quoteChar('"'); st.quoteChar('\''); while (st.nextToken() != StreamTokenizer.TT_EOF) { args.append(st.sval); } r.close(); }
Example #2
Source File: TypeAnnotations.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private void locateNestedTypes(Type type, TypeAnnotationPosition p) { // The number of "steps" to get from the full type to the // left-most outer type. ListBuffer<TypePathEntry> depth = new ListBuffer<>(); Type encl = type.getEnclosingType(); while (encl != null && encl.getKind() != TypeKind.NONE && encl.getKind() != TypeKind.ERROR) { depth = depth.append(TypePathEntry.INNER_TYPE); encl = encl.getEnclosingType(); } if (depth.nonEmpty()) { p.location = p.location.prependList(depth.toList()); } }
Example #3
Source File: PackageDocImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Return a list of all classes contained in this package, including * member classes of those classes, and their member classes, etc. */ private List<ClassDocImpl> getClasses(boolean filtered) { if (allClasses != null && !filtered) { return allClasses; } if (allClassesFiltered != null && filtered) { return allClassesFiltered; } ListBuffer<ClassDocImpl> classes = new ListBuffer<ClassDocImpl>(); for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) { if (e.sym != null) { ClassSymbol s = (ClassSymbol)e.sym; ClassDocImpl c = env.getClassDoc(s); if (c != null && !c.isSynthetic()) c.addAllClasses(classes, filtered); } } if (filtered) return allClassesFiltered = classes.toList(); else return allClasses = classes.toList(); }
Example #4
Source File: Types.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public List<Type> freshTypeVariables(List<Type> types) { ListBuffer<Type> result = lb(); for (Type t : types) { if (t.tag == WILDCARD) { Type bound = ((WildcardType)t).getExtendsBound(); if (bound == null) bound = syms.objectType; result.append(new CapturedType(capturedName, syms.noSymbol, bound, syms.botType, (WildcardType)t)); } else { result.append(t); } } return result.toList(); }
Example #5
Source File: PackageDocImpl.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Return a list of all classes contained in this package, including * member classes of those classes, and their member classes, etc. */ private List<ClassDocImpl> getClasses(boolean filtered) { if (allClasses != null && !filtered) { return allClasses; } if (allClassesFiltered != null && filtered) { return allClassesFiltered; } ListBuffer<ClassDocImpl> classes = new ListBuffer<ClassDocImpl>(); for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) { if (e.sym != null) { ClassSymbol s = (ClassSymbol)e.sym; ClassDocImpl c = env.getClassDoc(s); if (c != null && !c.isSynthetic()) c.addAllClasses(classes, filtered); } } if (filtered) return allClassesFiltered = classes.toList(); else return allClasses = classes.toList(); }
Example #6
Source File: PackageGenerator.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
ListBuffer<JCTree> processConstants(Element constNode, HashMap<String, Integer> scope) { String baseName = constNode.getAttribute("basename"); int count = 1; try { count = Integer.parseInt(constNode.getAttribute("count")); } catch (Exception e) {} // nothing to do, will use count = 1 long declFlags = Flags.PUBLIC | Flags.STATIC | Flags.FINAL | Flags.ENUM; ListBuffer<JCTree> fields = new ListBuffer<>(); for (int i = 0; i < count; i++) { String declName = baseName + ((count == 1) ? "" : getUniqIndex(scope, baseName)); JCVariableDecl constDecl = make.VarDef( make.Modifiers(declFlags), names.fromString(declName), null, // no need for type in enum decl null); // no init fields.append(constDecl); } return fields; }
Example #7
Source File: SymbolMetadata.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private <T extends Attribute.Compound> T replaceOne(Placeholder<T> placeholder, Annotate.AnnotateRepeatedContext<T> ctx) { Log log = ctx.log; // Process repeated annotations T validRepeated = ctx.processRepeatedAnnotations(placeholder.getPlaceholderFor(), sym); if (validRepeated != null) { // Check that the container isn't manually // present along with repeated instances of // its contained annotation. ListBuffer<T> manualContainer = ctx.annotated.get(validRepeated.type.tsym); if (manualContainer != null) { log.error(ctx.pos.get(manualContainer.first()), "invalid.repeatable.annotation.repeated.and.container.present", manualContainer.first().type.tsym); } } // A null return will delete the Placeholder return validRepeated; }
Example #8
Source File: TypeAnnotations.java From hottub with GNU General Public License v2.0 | 6 votes |
private void locateNestedTypes(Type type, TypeAnnotationPosition p) { // The number of "steps" to get from the full type to the // left-most outer type. ListBuffer<TypePathEntry> depth = new ListBuffer<>(); Type encl = type.getEnclosingType(); while (encl != null && encl.getKind() != TypeKind.NONE && encl.getKind() != TypeKind.ERROR) { depth = depth.append(TypePathEntry.INNER_TYPE); encl = encl.getEnclosingType(); } if (depth.nonEmpty()) { p.location = p.location.prependList(depth.toList()); } }
Example #9
Source File: ListBufferTest.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private static void testRemove() { ListBuffer<String> lb1 = new ListBuffer<>(); lb1.add("a"); lb1.add("b"); lb1.add("c"); assertListEquals(lb1.toList(), "a", "b", "c"); assertEquals(lb1.next(), "a"); assertListEquals(lb1.toList(), "b", "c"); assertEquals(lb1.next(), "b"); assertListEquals(lb1.toList(), "c"); assertEquals(lb1.next(), "c"); assertListEquals(lb1.toList()); assertEquals(lb1.next(), null); lb1.add("d"); assertEquals(lb1.next(), "d"); }
Example #10
Source File: Infer.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
private List<Pair<Type, Type>> getParameterizedSupers(Type t, Type s) { Type lubResult = types.lub(t, s); if (lubResult == syms.errType || lubResult == syms.botType) { return List.nil(); } List<Type> supertypesToCheck = lubResult.isIntersection() ? ((IntersectionClassType)lubResult).getComponents() : List.of(lubResult); ListBuffer<Pair<Type, Type>> commonSupertypes = new ListBuffer<>(); for (Type sup : supertypesToCheck) { if (sup.isParameterized()) { Type asSuperOfT = asSuper(t, sup); Type asSuperOfS = asSuper(s, sup); commonSupertypes.add(new Pair<>(asSuperOfT, asSuperOfS)); } } return commonSupertypes.toList(); }
Example #11
Source File: SmartFileManager.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse) throws IOException { // Acquire the list of files. Iterable<JavaFileObject> files = super.list(location, packageName, kinds, recurse); if (visibleSources.isEmpty()) { return files; } // Now filter! ListBuffer<JavaFileObject> filteredFiles = new ListBuffer<JavaFileObject>(); for (JavaFileObject f : files) { URI uri = f.toUri(); String t = uri.toString(); if (t.startsWith("jar:") || t.endsWith(".class") || visibleSources.contains(uri)) { filteredFiles.add(f); } } return filteredFiles; }
Example #12
Source File: ListBufferTest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private static void testCopiedEndsWithList_nil() { ListBuffer<String> lb = new ListBuffer<>(); lb.add("a"); lb.add("b"); lb.add("c"); List<String> l1 = lb.toList(); assertListEquals(l1, "a", "b", "c"); assertEndsWithNil(l1); lb.add("d"); List<String> l2 = lb.toList(); assertListEquals(l2, "a", "b", "c", "d"); assertEndsWithNil(l2); assertListEquals(l1, "a", "b", "c"); }
Example #13
Source File: TypeAnnotations.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private void locateNestedTypes(Type type, TypeAnnotationPosition p) { // The number of "steps" to get from the full type to the // left-most outer type. ListBuffer<TypePathEntry> depth = new ListBuffer<>(); Type encl = type.getEnclosingType(); while (encl != null && encl.getKind() != TypeKind.NONE && encl.getKind() != TypeKind.ERROR) { depth = depth.append(TypePathEntry.INNER_TYPE); encl = encl.getEnclosingType(); } if (depth.nonEmpty()) { p.location = p.location.prependList(depth.toList()); } }
Example #14
Source File: Locations.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #15
Source File: JavacFileManager.java From hottub with GNU General Public License v2.0 | 6 votes |
public Iterable<JavaFileObject> list(Location location, String packageName, Set<JavaFileObject.Kind> kinds, boolean recurse) throws IOException { // validatePackageName(packageName); nullCheck(packageName); nullCheck(kinds); Iterable<? extends File> path = getLocation(location); if (path == null) return List.nil(); RelativeDirectory subdirectory = RelativeDirectory.forPackage(packageName); ListBuffer<JavaFileObject> results = new ListBuffer<JavaFileObject>(); for (File directory : path) listContainer(directory, subdirectory, kinds, recurse, results); return results.toList(); }
Example #16
Source File: Types.java From javaide with GNU General Public License v3.0 | 6 votes |
@Override public Type visitClassType(ClassType t, Void s) { ListBuffer<Type> rewritten = new ListBuffer<Type>(); boolean changed = false; for (Type arg : t.allparams()) { Type bound = visit(arg); if (arg != bound) { changed = true; } rewritten.append(bound); } if (changed) return subst(t.tsym.type, t.tsym.type.allparams(), rewritten.toList()); else return t; }
Example #17
Source File: JavacJavaUtilListSetSingularizer.java From EasyMPermission with MIT License | 6 votes |
void generateSingularMethod(JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent) { List<JCTypeParameter> typeParams = List.nil(); List<JCExpression> thrown = List.nil(); JCModifiers mods = maker.Modifiers(Flags.PUBLIC); ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>(); statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, false, source)); JCExpression thisDotFieldDotAdd = chainDots(builderType, "this", data.getPluralName().toString(), "add"); JCExpression invokeAdd = maker.Apply(List.<JCExpression>nil(), thisDotFieldDotAdd, List.<JCExpression>of(maker.Ident(data.getSingularName()))); statements.append(maker.Exec(invokeAdd)); if (returnStatement != null) statements.append(returnStatement); JCBlock body = maker.Block(0, statements.toList()); Name name = data.getSingularName(); long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext()); if (!fluent) name = builderType.toName(HandlerUtil.buildAccessorName("add", name.toString())); JCExpression paramType = cloneParamType(0, maker, data.getTypeArgs(), builderType, source); JCVariableDecl param = maker.VarDef(maker.Modifiers(paramFlags), data.getSingularName(), paramType, null); JCMethodDecl method = maker.MethodDef(mods, name, returnType, typeParams, List.of(param), thrown, body, null); injectMethod(builderType, method); }
Example #18
Source File: JavacPathFileManager.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse) throws IOException { // validatePackageName(packageName); nullCheck(packageName); nullCheck(kinds); Iterable<? extends Path> paths = getLocation(location); if (paths == null) return List.nil(); ListBuffer<JavaFileObject> results = new ListBuffer<JavaFileObject>(); for (Path path : paths) list(path, packageName, kinds, recurse, results); return results.toList(); }
Example #19
Source File: PackageDocImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Return a list of all classes contained in this package, including * member classes of those classes, and their member classes, etc. */ private List<ClassDocImpl> getClasses(boolean filtered) { if (allClasses != null && !filtered) { return allClasses; } if (allClassesFiltered != null && filtered) { return allClassesFiltered; } ListBuffer<ClassDocImpl> classes = new ListBuffer<>(); for (Symbol enumerated : sym.members().getSymbols(NON_RECURSIVE)) { if (enumerated != null) { ClassSymbol s = (ClassSymbol)enumerated; ClassDocImpl c = env.getClassDoc(s); if (c != null && !c.isSynthetic()) c.addAllClasses(classes, filtered); } } if (filtered) return allClassesFiltered = classes.toList(); else return allClasses = classes.toList(); }
Example #20
Source File: Paths.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
/** * 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; //System.out.println("SPARTACUS : getPathEntries "+path); 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; }
Example #21
Source File: DocCommentParser.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
List<JCTree> parseParams(String s) throws ParseException { if (s.trim().isEmpty()) return List.nil(); JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false); ListBuffer<JCTree> paramTypes = new ListBuffer<>(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); while (p.token().kind == TokenKind.COMMA) { p.nextToken(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); } if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return paramTypes.toList(); }
Example #22
Source File: JavadocTool.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Recursively search all directories in path for subdirectory name. * Add all packages found in such a directory to packages list. */ private void searchSubPackage(String packageName, ListBuffer<String> packages, List<String> excludedPackages, Collection<File> pathnames) { if (excludedPackages.contains(packageName)) return; String packageFilename = packageName.replace('.', File.separatorChar); boolean addedPackage = false; for (File pathname : pathnames) { File f = new File(pathname, packageFilename); String filenames[] = f.list(); // if filenames not null, then found directory if (filenames != null) { for (String filename : filenames) { if (!addedPackage && (isValidJavaSourceFile(filename) || isValidJavaClassFile(filename)) && !packages.contains(packageName)) { packages.append(packageName); addedPackage = true; } else if (isValidClassName(filename) && (new File(f, filename)).isDirectory()) { searchSubPackage(packageName + "." + filename, packages, excludedPackages, pathnames); } } } } }
Example #23
Source File: DeferredLintHandler.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/**Associate the given logger with the current position as set by {@link #setPos(DiagnosticPosition) }. * Will be invoked when {@link #flush(DiagnosticPosition) } will be invoked with the same position. * <br> * Will invoke the logger synchronously if {@link #immediate() } was called * instead of {@link #setPos(DiagnosticPosition) }. */ public void report(LintLogger logger) { if (currentPos == IMMEDIATE_POSITION) { logger.report(); } else { ListBuffer<LintLogger> loggers = loggersQueue.get(currentPos); if (loggers == null) { loggersQueue.put(currentPos, loggers = new ListBuffer<>()); } loggers.append(logger); } }
Example #24
Source File: AnnoConstruct.java From hottub with GNU General Public License v2.0 | 5 votes |
private Attribute.Compound[] unpackContained(Attribute.Compound container) { // Pack them in an array Attribute[] contained0 = null; if (container != null) contained0 = unpackAttributes(container); ListBuffer<Attribute.Compound> compounds = new ListBuffer<>(); if (contained0 != null) { for (Attribute a : contained0) if (a instanceof Attribute.Compound) compounds = compounds.append((Attribute.Compound)a); } return compounds.toArray(new Attribute.Compound[compounds.size()]); }
Example #25
Source File: PackageDocImpl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Get included enum types in this package. * * @return included enum types in this package. */ public ClassDoc[] enums() { ListBuffer<ClassDocImpl> ret = new ListBuffer<ClassDocImpl>(); for (ClassDocImpl c : getClasses(true)) { if (c.isEnum()) { ret.append(c); } } return ret.toArray(new ClassDocImpl[ret.length()]); }
Example #26
Source File: ToolOption.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
protected void addToList(ListBuffer<String> list, String str){ StringTokenizer st = new StringTokenizer(str, ":"); String current; while(st.hasMoreTokens()){ current = st.nextToken(); list.append(current); } }
Example #27
Source File: Comment.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Return tags of the specified kind in this comment. */ Tag[] tags(String tagname) { ListBuffer<Tag> found = new ListBuffer<Tag>(); String target = tagname; if (target.charAt(0) != '@') { target = "@" + target; } for (Tag tag : tagList) { if (tag.kind().equals(target)) { found.append(tag); } } return found.toArray(new Tag[found.length()]); }
Example #28
Source File: JavacFileManager.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
/** * Insert all files in subdirectory subdirectory of archive archive * which match fileKinds into resultList */ private void listArchive(Archive archive, RelativeDirectory subdirectory, Set<JavaFileObject.Kind> fileKinds, boolean recurse, ListBuffer<JavaFileObject> resultList) { // Get the files directly in the subdir List<String> files = archive.getFiles(subdirectory); if (files != null) { for (; !files.isEmpty(); files = files.tail) { String file = files.head; if (isValidFile(file, fileKinds)) { resultList.append(archive.getFileObject(subdirectory, file)); } } } if (recurse) { for (RelativeDirectory s : archive.getSubdirectories()) { if (subdirectory.contains(s)) { // Because the archive map is a flat list of directories, // the enclosing loop will pick up all child subdirectories. // Therefore, there is no need to recurse deeper. listArchive(archive, s, fileKinds, false, resultList); } } } }
Example #29
Source File: DeferredLintHandler.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/**Invoke all {@link LintLogger}s that were associated with the provided {@code pos}. */ public void flush(DiagnosticPosition pos) { ListBuffer<LintLogger> loggers = loggersQueue.get(pos); if (loggers != null) { for (LintLogger lintLogger : loggers) { lintLogger.report(); } loggersQueue.remove(pos); } }
Example #30
Source File: Printer.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * * Get a localized string representation for all the symbols in the input list. * * @param ts symbols to be displayed * @param locale the locale in which the string is to be rendered * @return localized string representation */ public String visitSymbols(List<Symbol> ts, Locale locale) { ListBuffer<String> sbuf = new ListBuffer<>(); for (Symbol t : ts) { sbuf.append(visit(t, locale)); } return sbuf.toList().toString(); }