Skip to content

Commit

Permalink
Issue checkstyle#3536: added import control dtd 1.2 to loader
Browse files Browse the repository at this point in the history
  • Loading branch information
rnveach authored and linelect committed Nov 17, 2016
1 parent 441d2d3 commit c893d37
Show file tree
Hide file tree
Showing 51 changed files with 44 additions and 43 deletions.
Expand Up @@ -26,7 +26,6 @@

import antlr.RecognitionException;
import antlr.TokenStreamException;

import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.DetailNode;
Expand Down
Expand Up @@ -29,7 +29,6 @@
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.Attributes;
Expand Down
Expand Up @@ -38,7 +38,6 @@
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;

import javax.xml.bind.DatatypeConverter;

import com.google.common.io.Closeables;
Expand Down
Expand Up @@ -23,7 +23,6 @@
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;

Expand Down
Expand Up @@ -23,7 +23,6 @@
import java.util.Set;

import antlr.collections.AST;

import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.utils.CommonUtils;
Expand Down
Expand Up @@ -23,7 +23,6 @@
import java.util.LinkedList;

import antlr.collections.AST;

import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
Expand Down
Expand Up @@ -25,7 +25,6 @@
import java.util.stream.Collectors;

import antlr.collections.AST;

import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.FullIdent;
Expand Down
Expand Up @@ -22,7 +22,6 @@
import java.util.Arrays;

import antlr.collections.AST;

import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
Expand Down
Expand Up @@ -20,7 +20,6 @@
package com.puppycrawl.tools.checkstyle.checks.coding;

import antlr.collections.AST;

import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
Expand Down
Expand Up @@ -20,7 +20,6 @@
package com.puppycrawl.tools.checkstyle.checks.coding;

import antlr.collections.AST;

import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
Expand Down
Expand Up @@ -27,7 +27,6 @@
import java.util.regex.Pattern;

import antlr.collections.ASTEnumeration;

import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.FullIdent;
Expand Down
Expand Up @@ -27,7 +27,6 @@
import java.util.Deque;
import java.util.HashMap;
import java.util.Map;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.Attributes;
Expand All @@ -50,6 +49,10 @@ final class ImportControlLoader extends AbstractLoader {
private static final String DTD_PUBLIC_ID_1_1 =
"-//Puppy Crawl//DTD Import Control 1.1//EN";

/** The public ID for the configuration dtd. */
private static final String DTD_PUBLIC_ID_1_2 =
"-//Puppy Crawl//DTD Import Control 1.2//EN";

/** The resource for the configuration dtd. */
private static final String DTD_RESOURCE_NAME_1_0 =
"com/puppycrawl/tools/checkstyle/checks/imports/import_control_1_0.dtd";
Expand All @@ -58,6 +61,10 @@ final class ImportControlLoader extends AbstractLoader {
private static final String DTD_RESOURCE_NAME_1_1 =
"com/puppycrawl/tools/checkstyle/checks/imports/import_control_1_1.dtd";

/** The resource for the configuration dtd. */
private static final String DTD_RESOURCE_NAME_1_2 =
"com/puppycrawl/tools/checkstyle/checks/imports/import_control_1_2.dtd";

/** The map to lookup the resource name by the id. */
private static final Map<String, String> DTD_RESOURCE_BY_ID = new HashMap<>();

Expand All @@ -76,6 +83,7 @@ final class ImportControlLoader extends AbstractLoader {
static {
DTD_RESOURCE_BY_ID.put(DTD_PUBLIC_ID_1_0, DTD_RESOURCE_NAME_1_0);
DTD_RESOURCE_BY_ID.put(DTD_PUBLIC_ID_1_1, DTD_RESOURCE_NAME_1_1);
DTD_RESOURCE_BY_ID.put(DTD_PUBLIC_ID_1_2, DTD_RESOURCE_NAME_1_2);
}

/**
Expand Down
Expand Up @@ -195,6 +195,12 @@ public class ImportOrderCheck
*/
public static final String MSG_ORDERING = "import.ordering";

/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_REDUNDANT_SEPARATION = "import.groups.separated.internally";

/** The special wildcard that catches all remaining groups. */
private static final String WILDCARD_GROUP_NAME = "*";

Expand Down Expand Up @@ -443,11 +449,26 @@ else if (groupIdx > lastGroup) {
else {
log(line, MSG_ORDERING, name);
}

checkRedundantSeparation(groupIdx, isStatic, line, name);
lastGroup = groupIdx;
lastImport = name;
}

/**
* Shares processing...
*
* @param groupIdx group number.
* @param isStatic whether the token is static or not.
* @param line the line of the current import.
* @param name the name of the current import.
*/
private void checkRedundantSeparation(int groupIdx, boolean isStatic, int line, String name) {
if (!beforeFirstImport && separated && groupIdx == lastGroup
&& isStatic == lastImportStatic && line - lastImportLine > 1) {
log(line, MSG_REDUNDANT_SEPARATION, name);
}
}

/**
* Checks whether static imports grouped by <b>top</b> or <b>bottom</b> option
* are sorted alphabetically or not.
Expand Down
Expand Up @@ -26,7 +26,6 @@
import java.util.Locale;
import java.util.Map;
import java.util.regex.PatternSyntaxException;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.Attributes;
Expand Down
Expand Up @@ -20,7 +20,6 @@
package com.puppycrawl.tools.checkstyle.gui;

import java.util.EventObject;

import javax.swing.CellEditor;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
Expand Down
Expand Up @@ -21,7 +21,6 @@

import java.awt.Color;
import java.util.List;

import javax.swing.JTextArea;

import com.puppycrawl.tools.checkstyle.api.DetailAST;
Expand Down
Expand Up @@ -29,7 +29,6 @@
import java.util.Collections;
import java.util.EventObject;
import java.util.List;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JTable;
Expand Down
Expand Up @@ -20,7 +20,6 @@
package com.puppycrawl.tools.checkstyle.gui;

import java.io.File;

import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

Expand Down
Expand Up @@ -24,7 +24,6 @@
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.io.File;

import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.JButton;
Expand Down
Expand Up @@ -24,7 +24,6 @@

import antlr.ASTFactory;
import antlr.collections.AST;

import com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.DetailNode;
Expand Down
Expand Up @@ -21,7 +21,6 @@

import java.awt.Component;
import java.awt.Graphics;

import javax.swing.JTable;
import javax.swing.JTree;
import javax.swing.UIManager;
Expand Down
Expand Up @@ -20,7 +20,6 @@
package com.puppycrawl.tools.checkstyle.utils;

import antlr.collections.AST;

import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.Scope;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
Expand Down
Expand Up @@ -10,6 +10,7 @@ import.separation=''{0}'' should be separated from previous imports.
import.control.missing.file=Missing an import control file.
import.control.disallowed=Disallowed import - {0}.
import.control.unknown.pkg=Import control file does not handle this package.
import.groups.separated.internally=Redundant separation in import group before ''{0}''
custom.import.order=Import statement for ''{2}'' is in the wrong order. Should be in the ''{0}'' group, expecting group ''{1}'' on this line.
custom.import.order.line.separator=''{0}'' should be separated from previous import group.
custom.import.order.lex=Wrong lexicographical order for ''{0}'' import. Should be before ''{1}''.
Expand Down
Expand Up @@ -16,3 +16,4 @@ custom.import.order.lex=Falsche lexikographische Reihenfolge des Imports von ''{
custom.import.order.nonGroup.import=Importe ohne Gruppe sollten an Ende der Import-Liste stehen: ''{0}''.
custom.import.order.nonGroup.expected=Import-Anweisung für ''{1}'' ist an der falschen Stelle. Sollte in der Import-Gruppe ''{0}'' Gruppe stehen. \
Erwartet wird in dieser Zeile ein Import, der keiner Import-Gruppe entspricht.
import.groups.separated.internally=Redundante Trennung in der Importgruppe vor ''{0}''
Expand Up @@ -15,3 +15,4 @@ custom.import.order.line.separator = ''{0}'' debe ser separado del grupo de impo
custom.import.order.lex = Orden lexicográfico incorrecto de ''{0}'' importación. En caso de ser antes de ''{1}''.
custom.import.order.nonGroup.import = Las importaciones sin grupos deben colocarse al final de la lista de importación: ''{0}''.
custom.import.order.nonGroup.expected = Declaración de importación de ''{1}'' es en el orden equivocado. En caso de estar en el ''{0}'' del grupo, esperando que las importaciones no asignadas en esta línea.
import.groups.separated.internally=Separación redundante en el grupo de importación antes ''{0}''
Expand Up @@ -15,3 +15,4 @@ custom.import.order.line.separator = ''{0}'' olisi erotettava edellisestä tuont
custom.import.order.lex = Väärä leksikografisessa jotta ''{0}'' tuonnilla. Pitäisi olla ennen ''{1}''.
custom.import.order.nonGroup.import = Tuonti ilman ryhmät olisi sijoitettava loppuun tuonti lista: ''{0}''.
custom.import.order.nonGroup.expected = Tuo lausuman ''{1}'' on väärässä järjestyksessä. Pitäisi olla ''{0}'' ryhmä, odottaa ei osoitettu tuontia tätä linjaa.
import.groups.separated.internally=Turhat erottaminen tuonti ryhmässä ennen ''{0}''
Expand Up @@ -15,3 +15,4 @@ custom.import.order.line.separator=''{0}'' doit être séparé du groupe d'impor
custom.import.order.lex=Mauvais ordre lexicographique pour l''import ''{0}''. Il devrait être avant ''{1}''.
custom.import.order.nonGroup.import=Les imports sans groupes doivent être placés à la fin de la liste : ''{0}''.
custom.import.order.nonGroup.expected=L''import pour ''{1}'' est dans le mauvais ordre. Il devrait être dans le groupe ''{0}''.
import.groups.separated.internally=Séparation redondante dans le groupe d'importation avant ''{0}''
Expand Up @@ -15,3 +15,4 @@ custom.import.order.line.separator = ''{0}'' 前のインポート・グルー
custom.import.order.lex = のための間違った辞書式順序 ''{0}'' インポート。の前にすべきである ''{1}''
custom.import.order.nonGroup.import = グループのない輸入はインポートリストの末尾に配置する必要があります: ''{0}''
custom.import.order.nonGroup.expected = のインポート文 ''{1}'' は、間違った順序です。 にする必要があります ''{0}'' この行に割り当てられていない輸入を期待して、グループ。
import.groups.separated.internally=前のインポートグループの冗長分離 ''{0}''
Expand Up @@ -15,3 +15,4 @@ custom.import.order.line.separator = ''{0}'' deve ser separado do grupo importa
custom.import.order.lex = Errado ordem lexicográfica para ''{0}'' importação. Deve ser antes ''{1}''.
custom.import.order.nonGroup.import = Importações sem grupos devem ser colocados no final da lista de importação: ''{0}''.
custom.import.order.nonGroup.expected = Declaração de importação para ''{1}'' está na ordem errada. Deve estar no ''{0}'' grupo, esperando que as importações não atribuídos nesta linha.
import.groups.separated.internally=Separação redundante no grupo de importação antes ''{0}''
Expand Up @@ -18,3 +18,4 @@ custom.import.order.line.separator = {0} önceki ithalat grubundan ayrılmalıd
custom.import.order.lex = Için yanlış lexicographical sipariş {0} ithal. Önce olmalı ''{1}''.
custom.import.order.nonGroup.import = Gruplar olmadan İthalat İthalat listenin en sonunda yer almalıdır: {0}
custom.import.order.nonGroup.expected = İthalat deyimi ''{1}'' yanlış sırayla yer almaktadır. Olmalıdır ''{0}'' bu hat üzerinde değil atanmış ithalatı bekliyor grubuna.
import.groups.separated.internally=önce ithalat grubunda gereksiz ayırma ''{0}''
Expand Up @@ -15,3 +15,4 @@ custom.import.order.line.separator=''{0}'' 应与之前的导入组分开。
custom.import.order.lex=导入语句''{0}'' 字典顺序错误。应在''{1}''之前。
custom.import.order.nonGroup.import=未分组导入应位于导入列表的最后: ''{0}''
custom.import.order.nonGroup.expected=导入语句''{1}''位置错误。应位于 ''{0}'' 组,此行不应导入。
import.groups.separated.internally=\ 进口组以前的冗余分离 ''{0}''
Expand Up @@ -29,7 +29,6 @@
import org.junit.Test;

import antlr.CommonHiddenStreamToken;

import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
Expand Down
Expand Up @@ -29,7 +29,6 @@
import org.junit.Test;

import antlr.CommonHiddenStreamToken;

import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
Expand Down
Expand Up @@ -30,7 +30,6 @@
import org.junit.Test;

import antlr.CommonHiddenStreamToken;

import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
Expand Down
Expand Up @@ -27,7 +27,6 @@
import org.junit.Test;

import antlr.CommonHiddenStreamToken;

import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
Expand Down
Expand Up @@ -27,7 +27,6 @@
import org.junit.Test;

import antlr.CommonHiddenStreamToken;

import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
Expand Down
Expand Up @@ -28,7 +28,6 @@
import org.junit.Test;

import antlr.CommonHiddenStreamToken;

import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
Expand Down
Expand Up @@ -27,7 +27,6 @@
import org.junit.Test;

import antlr.CommonHiddenStreamToken;

import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
Expand Down
Expand Up @@ -34,7 +34,6 @@
import org.junit.Test;

import antlr.CommonHiddenStreamToken;

import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
Expand Down
Expand Up @@ -30,7 +30,6 @@
import org.junit.Test;

import antlr.CommonHiddenStreamToken;

import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
Expand Down
Expand Up @@ -28,7 +28,6 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

import javax.tools.JavaFileObject;

import org.junit.Assert;
Expand Down
Expand Up @@ -47,7 +47,6 @@
import com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck;
import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck;
import com.puppycrawl.tools.checkstyle.utils.CommonUtils;

import nl.jqno.equalsverifier.EqualsVerifier;

public class SuppressWithNearbyCommentFilterTest
Expand Down
Expand Up @@ -47,7 +47,6 @@
import com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck;
import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck;
import com.puppycrawl.tools.checkstyle.utils.CommonUtils;

import nl.jqno.equalsverifier.EqualsVerifier;

public class SuppressionCommentFilterTest
Expand Down

0 comments on commit c893d37

Please sign in to comment.