Skip to content

Commit

Permalink
Issue #1566: MemberName and MethodName violations fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
rdiachenko authored and romani committed Aug 14, 2015
1 parent 443e534 commit 66d73fe
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private static Set<String> processJavadoc(TextBlock cmt) {
: getValidTags(cmt, JavadocUtils.JavadocTagType.BLOCK)) {
if (tag.canReferenceImports()) {
references.addAll(
matchPattern(tag.getArg1(), FIRST_CLASS_NAME));
matchPattern(tag.getFirstArg(), FIRST_CLASS_NAME));
}
}
return references;
Expand All @@ -266,7 +266,7 @@ private static List<JavadocTag> getValidTags(TextBlock cmt,
*/
private static Set<String> processJavadocTag(JavadocTag tag) {
final Set<String> references = new HashSet<>();
final String identifier = tag.getArg1().trim();
final String identifier = tag.getFirstArg().trim();
for (Pattern pattern : new Pattern[]
{FIRST_CLASS_NAME, ARGUMENT_NAME}) {
references.addAll(matchPattern(identifier, pattern));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private ParseStatus parseJavadocAsDetailNode(DetailAST javadocCommentAst) {
}

if (parseErrorMessage == null) {
final DetailNode tree = convertParseTree2DetailNode(parseTree);
final DetailNode tree = convertParseTreeToDetailNode(parseTree);
result.setTree(tree);
}
else {
Expand All @@ -234,7 +234,7 @@ private ParseStatus parseJavadocAsDetailNode(DetailAST javadocCommentAst) {
* @param parseTreeNode root node of ParseTree
* @return root of DetailNode tree
*/
private DetailNode convertParseTree2DetailNode(ParseTree parseTreeNode) {
private DetailNode convertParseTreeToDetailNode(ParseTree parseTreeNode) {
final JavadocNodeImpl rootJavadocNode = createJavadocNode(parseTreeNode, null, -1);

int childCount = parseTreeNode.getChildCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ private void checkParamTags(final List<JavadocTag> tags,

// Loop looking for matching param
final Iterator<DetailAST> paramIt = params.iterator();
final String arg1 = tag.getArg1();
final String arg1 = tag.getFirstArg();
while (paramIt.hasNext()) {
final DetailAST param = paramIt.next();
if (param.getText().equals(arg1)) {
Expand Down Expand Up @@ -857,8 +857,8 @@ private void checkThrowsTags(List<JavadocTag> tags,
tagIt.remove();

// Loop looking for matching throw
final String documentedEx = tag.getArg1();
final Token token = new Token(tag.getArg1(), tag.getLineNo(), tag
final String documentedEx = tag.getFirstArg();
final Token token = new Token(tag.getFirstArg(), tag.getLineNo(), tag
.getColumnNo());
final AbstractClassInfo documentedCI = createClassInfo(token,
getCurrentClassName());
Expand Down Expand Up @@ -902,7 +902,7 @@ else if (allowThrowsTagsForSubclasses) {
if (reqd && validateThrows) {
log(tag.getLineNo(), tag.getColumnNo(),
MSG_UNUSED_TAG,
JavadocTagInfo.THROWS.getText(), tag.getArg1());
JavadocTagInfo.THROWS.getText(), tag.getFirstArg());

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class JavadocTag {
/** the column number of the tag **/
private final int columnNo;
/** an optional first argument. For example the parameter name. **/
private final String arg1;
private final String firstArg;
/** the JavadocTagInfo representing this tag **/
private final JavadocTagInfo tagInfo;

Expand All @@ -40,12 +40,12 @@ public class JavadocTag {
* @param line the line number of the tag
* @param column the column number of the tag
* @param tag the tag string
* @param arg1 the tag argument
* @param firstArg the tag argument
**/
public JavadocTag(int line, int column, String tag, String arg1) {
public JavadocTag(int line, int column, String tag, String firstArg) {
lineNo = line;
columnNo = column;
this.arg1 = arg1;
this.firstArg = firstArg;
tagInfo = JavadocTagInfo.fromName(tag);
}

Expand All @@ -65,8 +65,8 @@ public String getTagName() {
}

/** @return the first argument. null if not set. **/
public String getArg1() {
return arg1;
public String getFirstArg() {
return firstArg;
}

/** @return the line number **/
Expand All @@ -82,7 +82,7 @@ public int getColumnNo() {
@Override
public String toString() {
return "JavadocTag{tag='" + getTagName() + "' lineNo=" + lineNo + ", columnNo=" + columnNo
+ ", arg1='" + arg1 + "'}";
+ ", firstArg='" + firstArg + "'}";
}

/** @return whether the tag is an 'return' tag **/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ private void checkTag(int lineNo, List<JavadocTag> tags, String tagName,
final JavadocTag tag = tags.get(i);
if (tag.getTagName().equals(tagName)) {
tagCount++;
if (!formatPattern.matcher(tag.getArg1()).find()) {
if (!formatPattern.matcher(tag.getFirstArg()).find()) {
log(lineNo, TAG_FORMAT, "@" + tagName, format);
}
}
Expand All @@ -289,7 +289,7 @@ private void checkTypeParamTag(final int lineNo,
for (int i = tags.size() - 1; i >= 0; i--) {
final JavadocTag tag = tags.get(i);
if (tag.isParamTag()
&& tag.getArg1().indexOf("<" + typeParamName + ">") == 0) {
&& tag.getFirstArg().indexOf("<" + typeParamName + ">") == 0) {
found = true;
}
}
Expand All @@ -312,7 +312,7 @@ private void checkUnusedTypeParamTags(
final JavadocTag tag = tags.get(i);
if (tag.isParamTag()) {

final Matcher matcher = pattern.matcher(tag.getArg1());
final Matcher matcher = pattern.matcher(tag.getFirstArg());
matcher.find();
final String typeParamName = matcher.group(1).trim();
if (!typeParamNames.contains(typeParamName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class ListToTreeSelectionModelWrapper extends DefaultTreeSelectionModel {
/** Set to true when we are updating the ListSelectionModel. */
protected boolean updatingListSelectionModel;
/** JTreeTable to perform updates on */
private final JTreeTable jTreeTable;
private final JTreeTable treeTable;

public ListToTreeSelectionModelWrapper(JTreeTable jTreeTable) {
this.jTreeTable = jTreeTable;
this.treeTable = jTreeTable;
getListSelectionModel().addListSelectionListener(createListSelectionListener());
}

Expand Down Expand Up @@ -122,7 +122,7 @@ protected void updateSelectedPathsFromSelectedRows() {
*/
private void updateSelectedPathIfRowIsSelected(int counter) {
if (listSelectionModel.isSelectedIndex(counter)) {
final TreePath selPath = jTreeTable.tree.getPathForRow(counter);
final TreePath selPath = treeTable.tree.getPathForRow(counter);

if (selPath != null) {
addSelectionPath(selPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public class ParseTreeInfoPanel extends JPanel {
private static final long serialVersionUID = -4243405131202059043L;

private final transient ParseTreeModel parseTreeModel;
private final JTextArea jTextArea;
private final JTextArea textArea;
private File lastDirectory;
private File currentFile;
private final Action reloadAction;
private final List<Integer> lines2position = new ArrayList<>();
private final List<Integer> linesToPosition = new ArrayList<>();

/**
* Create a new ParseTreeInfoPanel instance.
Expand All @@ -85,12 +85,12 @@ public ParseTreeInfoPanel() {
reloadAction.setEnabled(false);
final JButton reloadButton = new JButton(reloadAction);

jTextArea = new JTextArea(20, 15);
jTextArea.setEditable(false);
treeTable.setEditor(jTextArea);
treeTable.setLinePositionMap(lines2position);
textArea = new JTextArea(20, 15);
textArea.setEditable(false);
treeTable.setEditor(textArea);
treeTable.setLinePositionMap(linesToPosition);

final JScrollPane sp2 = new JScrollPane(jTextArea);
final JScrollPane sp2 = new JScrollPane(textArea);
add(sp2, BorderLayout.CENTER);

final JPanel p = new JPanel(new GridLayout(1, 2));
Expand All @@ -112,18 +112,18 @@ public void openAst(DetailAST parseTree, final Component parent) {
reloadAction.setEnabled(true);

// clear for each new file
getLines2position().clear();
getLinesToPosition().clear();
// starts line counting at 1
getLines2position().add(0);
getLinesToPosition().add(0);
// insert the contents of the file to the text area

// clean the text area before inserting the lines of the new file
if (!jTextArea.getText().isEmpty()) {
jTextArea.replaceRange("", 0, jTextArea.getText().length());
if (!textArea.getText().isEmpty()) {
textArea.replaceRange("", 0, textArea.getText().length());
}

// move back to the top of the file
jTextArea.moveCaretPosition(0);
textArea.moveCaretPosition(0);
}

public void openFile(File file, final Component parent) {
Expand All @@ -141,28 +141,28 @@ public void openFile(File file, final Component parent) {
final String[] sourceLines = text.toLinesArray();

// clear for each new file
getLines2position().clear();
getLinesToPosition().clear();
// starts line counting at 1
getLines2position().add(0);
getLinesToPosition().add(0);
// insert the contents of the file to the text area
for (String element : sourceLines) {
getLines2position().add(jTextArea.getText().length());
jTextArea.append(element + "\n");
getLinesToPosition().add(textArea.getText().length());
textArea.append(element + "\n");
}

//clean the text area before inserting the lines of the new file
if (!jTextArea.getText().isEmpty()) {
jTextArea.replaceRange("", 0, jTextArea.getText()
if (!textArea.getText().isEmpty()) {
textArea.replaceRange("", 0, textArea.getText()
.length());
}

// insert the contents of the file to the text area
for (final String element : sourceLines) {
jTextArea.append(element + "\n");
textArea.append(element + "\n");
}

// move back to the top of the file
jTextArea.moveCaretPosition(0);
textArea.moveCaretPosition(0);
}
catch (final IOException | ANTLRException ex) {
showErrorDialog(
Expand Down Expand Up @@ -199,8 +199,8 @@ private static void showErrorDialog(final Component parent, final String msg) {
SwingUtilities.invokeLater(showError);
}

public List<Integer> getLines2position() {
return Collections.unmodifiableList(lines2position);
public List<Integer> getLinesToPosition() {
return Collections.unmodifiableList(linesToPosition);
}

/**
Expand Down Expand Up @@ -294,17 +294,17 @@ public void actionPerformed(ActionEvent e) {
}

private class FileDropListener implements FileDrop.Listener {
private final JScrollPane mSp;
private final JScrollPane scrollPane;

public FileDropListener(JScrollPane aSp) {
mSp = aSp;
public FileDropListener(JScrollPane scrollPane) {
this.scrollPane = scrollPane;
}

@Override
public void filesDropped(File... files) {
if (files != null && files.length > 0) {
final File file = files[0];
openFile(file, mSp);
openFile(file, scrollPane);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
public class JavadocTagTest {
@Test
public void testToString() {
JavadocTag javadocTag = new JavadocTag(0, 1, "author", "arg1");
JavadocTag javadocTag = new JavadocTag(0, 1, "author", "firstArg");

String result = javadocTag.toString();

assertEquals("JavadocTag{tag='author' lineNo=0, columnNo=1, arg1='arg1'}", result);
assertEquals("JavadocTag{tag='author' lineNo=0, columnNo=1, firstArg='firstArg'}", result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void testInlineTagLinkText() {
final Comment comment = new Comment(text, 1, 1, text[0].length());
final List<JavadocTag> tags = JavadocUtils.getJavadocTags(
comment, JavadocUtils.JavadocTagType.ALL).getValidTags();
assertEquals("List link text", tags.get(0).getArg1());
assertEquals("List link text", tags.get(0).getFirstArg());
}

@Test
Expand All @@ -85,7 +85,7 @@ public void testInlineTagMethodRef() {
final Comment comment = new Comment(text, 1, 1, text[0].length());
final List<JavadocTag> tags = JavadocUtils.getJavadocTags(
comment, JavadocUtils.JavadocTagType.ALL).getValidTags();
assertEquals("List#add(Object)", tags.get(0).getArg1());
assertEquals("List#add(Object)", tags.get(0).getFirstArg());
}

@Test
Expand Down

0 comments on commit 66d73fe

Please sign in to comment.