forked from INRIA/spoon
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request INRIA#554 from tdurieux/feat_comments
- Loading branch information
Showing
26 changed files
with
1,773 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
language: java | ||
|
||
sudo: required | ||
|
||
jdk: | ||
- oraclejdk8 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--- | ||
title: Comments | ||
keywords: comments | ||
last_updated: Mars 22, 2016 | ||
--- | ||
|
||
### Comments in Spoon | ||
|
||
In Spoon there are different kinds of comments: | ||
|
||
* Line comments (from // to end line) | ||
* Block comments (from /* to */) | ||
* Javadoc comments (from /** to */) | ||
|
||
#### Javadoc Comments | ||
|
||
The Javadoc comments are available via the API ```CtElement.getDocComment()``` and return a ```String```. | ||
|
||
#### Other Comments | ||
|
||
The block and line comments are represented with a ```CtComment``` class ([javadoc](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/declaration/CtComment.html)). | ||
This class exposes API to get the position and the content of the comment. | ||
|
||
We also try to understand to which element they are attached. | ||
We use simple heuristics that work well in nominal cases but it is not possible to address all specific cases. | ||
You can receive the comments of each ```CtElement``` via the API ```CtElement.getComments()``` that returns a ```List<CtComment>```. | ||
|
||
The reprint of the comments can be disable in the Environment. | ||
|
||
##### Comment Attribution | ||
|
||
* Each comment can have multiple comments | ||
* Comments in the same line of a statement is attached to the statement | ||
* Comments which are alone in one line (or more than one lines) are associated to the first element following them. | ||
* Comments cannot be associated to other comment | ||
* Comments at the end of a block are considered as orphans comment | ||
* Comments in a class level is attached to the class | ||
|
||
##### Comment Example | ||
Class comment | ||
```Java | ||
// class comment | ||
class A { | ||
// class comment | ||
} | ||
``` | ||
|
||
Statement comment | ||
```Java | ||
// Statement comment | ||
int a; // Statement comment | ||
``` | ||
|
||
Orphan comment | ||
```Java | ||
try { | ||
|
||
} exception (Exception e) { | ||
// Orphan comment | ||
} | ||
``` | ||
|
||
Multiple line comment | ||
```Java | ||
// Statement comment 1 | ||
// Statement comment 2 | ||
// Statement comment 3 | ||
int a; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* Copyright (C) 2006-2015 INRIA and contributors | ||
* Spoon - http://spoon.gforge.inria.fr/ | ||
* | ||
* This software is governed by the CeCILL-C License under French law and | ||
* abiding by the rules of distribution of free software. You can use, modify | ||
* and/or redistribute the software under the terms of the CeCILL-C license as | ||
* circulated by CEA, CNRS and INRIA at http://www.cecill.info. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details. | ||
* | ||
* The fact that you are presently reading this means that you have had | ||
* knowledge of the CeCILL-C license and that you accept its terms. | ||
*/ | ||
package spoon.reflect.code; | ||
|
||
/** | ||
* This code element defines a comment | ||
* | ||
*/ | ||
public interface CtComment extends CtStatement { | ||
enum CommentType { | ||
/** | ||
* before the package line (typically the license) | ||
*/ | ||
FILE, | ||
/** | ||
* JavaDoc comment: before methods, fields, types | ||
*/ | ||
JAVADOC, | ||
/** | ||
* Inline comment (//) | ||
*/ | ||
INLINE, | ||
/** | ||
* Block comment (/* *\/) | ||
*/ | ||
BLOCK | ||
} | ||
|
||
/** | ||
* Get the content of the comment | ||
* @return the content of the comment | ||
*/ | ||
String getContent(); | ||
|
||
<E extends CtComment> E setContent(String content); | ||
|
||
/** | ||
* Get the type of the comment | ||
* @return the comment type | ||
*/ | ||
CommentType getCommentType(); | ||
|
||
<E extends CtComment> E setCommentType(CommentType commentType); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.