src/share/classes/com/sun/tools/javac/parser/Tokens.java

changeset 1280
5c0b3faeb0b0
parent 1145
3343b22e2761
child 1281
067f51db3402
equal deleted inserted replaced
1279:34e254ffd0e7 1280:5c0b3faeb0b0
1 /* 1 /*
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
369 369
370 /** 370 /**
371 * Preserve classic semantics - if multiple javadocs are found on the token 371 * Preserve classic semantics - if multiple javadocs are found on the token
372 * the last one is returned 372 * the last one is returned
373 */ 373 */
374 public String comment(Comment.CommentStyle style) { 374 public Comment comment(Comment.CommentStyle style) {
375 List<Comment> readers = getReaders(Comment.CommentStyle.JAVADOC); 375 List<Comment> comments = getComments(Comment.CommentStyle.JAVADOC);
376 return readers.isEmpty() ? 376 return comments.isEmpty() ?
377 null : 377 null :
378 readers.head.getText(); 378 comments.head;
379 } 379 }
380 380
381 /** 381 /**
382 * Preserve classic semantics - deprecated should be set if at least one 382 * Preserve classic semantics - deprecated should be set if at least one
383 * javadoc comment attached to this token contains the '@deprecated' string 383 * javadoc comment attached to this token contains the '@deprecated' string
384 */ 384 */
385 public boolean deprecatedFlag() { 385 public boolean deprecatedFlag() {
386 for (Comment r : getReaders(Comment.CommentStyle.JAVADOC)) { 386 for (Comment c : getComments(Comment.CommentStyle.JAVADOC)) {
387 if (r.isDeprecated()) { 387 if (c.isDeprecated()) {
388 return true; 388 return true;
389 } 389 }
390 } 390 }
391 return false; 391 return false;
392 } 392 }
393 393
394 private List<Comment> getReaders(Comment.CommentStyle style) { 394 private List<Comment> getComments(Comment.CommentStyle style) {
395 if (comments == null) { 395 if (comments == null) {
396 return List.nil(); 396 return List.nil();
397 } else { 397 } else {
398 ListBuffer<Comment> buf = ListBuffer.lb(); 398 ListBuffer<Comment> buf = ListBuffer.lb();
399 for (Comment r : comments) { 399 for (Comment c : comments) {
400 if (r.getStyle() == style) { 400 if (c.getStyle() == style) {
401 buf.add(r); 401 buf.add(c);
402 } 402 }
403 } 403 }
404 return buf.toList(); 404 return buf.toList();
405 } 405 }
406 } 406 }

mercurial