Skip to content

Commit

Permalink
Merge ff4a9ee into 76b5f7e
Browse files Browse the repository at this point in the history
  • Loading branch information
SeeSharpSoft committed Jul 4, 2018
2 parents 76b5f7e + ff4a9ee commit 8a99372
Show file tree
Hide file tree
Showing 37 changed files with 431 additions and 215 deletions.
2 changes: 2 additions & 0 deletions README.md
@@ -1,6 +1,8 @@
[![Plugin version](https://img.shields.io/jetbrains/plugin/d/10037-csv-plugin.svg)](https://plugins.jetbrains.com/plugin/10037-csv-plugin)
[![Build Status](https://travis-ci.org/SeeSharpSoft/intellij-csv-validator.svg?branch=master)](https://travis-ci.org/SeeSharpSoft/intellij-csv-validator)
[![Coverage Status](https://coveralls.io/repos/github/SeeSharpSoft/intellij-csv-validator/badge.svg?branch=master)](https://coveralls.io/github/SeeSharpSoft/intellij-csv-validator?branch=master)
[![Known Vulnerabilities](https://snyk.io/test/github/SeeSharpSoft/intellij-csv-validator/badge.svg?targetFile=build.gradle)](https://snyk.io/test/github/SeeSharpSoft/intellij-csv-validator?targetFile=build.gradle)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/97769359388e44bfb7101346d510fccf)](https://www.codacy.com/app/github_124/intellij-csv-validator?utm_source=github.com&utm_medium=referral&utm_content=SeeSharpSoft/intellij-csv-validator&utm_campaign=Badge_Grade)

# Lightweight CSV Plugin for JetBrains IDE family

Expand Down
185 changes: 185 additions & 0 deletions checkstyle.xml
@@ -0,0 +1,185 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">

<!--
Checkstyle configuration that checks the sun coding conventions from:
- the Java Language Specification at
http://java.sun.com/docs/books/jls/second_edition/html/index.html
- the Sun Code Conventions at http://java.sun.com/docs/codeconv/
- the Javadoc guidelines at
http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
- the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html
- some best practices
Checkstyle is very configurable. Be sure to read the documentation at
http://checkstyle.sf.net (or in your downloaded distribution).
Most Checks are configurable, be sure to consult the documentation.
To completely disable a check, just comment it out or delete it from the file.
Finally, it is worth reading the documentation.
-->

<module name="Checker">

<module name="SuppressWarningsFilter" />

<!--
If you set the basedir property below, then all reported file
names will be relative to the specified directory. See
http://checkstyle.sourceforge.net/5.x/config.html#Checker
<property name="basedir" value="${basedir}"/>
-->

<property name="fileExtensions" value="java, properties, xml"/>

<!-- Checks that a package-info.java file exists for each package. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage -->
<!--<module name="JavadocPackage"/>-->

<!-- Checks whether files end with a new line. -->
<!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
<!--<module name="NewlineAtEndOfFile"/>-->

<!-- Checks that property files contain the same keys. -->
<!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
<module name="Translation"/>

<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="FileLength"/>

<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="FileTabCharacter"/>

<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="minimum" value="0"/>
<property name="maximum" value="0"/>
<property name="message" value="Line has trailing spaces."/>
</module>

<!-- Checks for Headers -->
<!-- See http://checkstyle.sf.net/config_header.html -->
<!-- <module name="Header"> -->
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
<!-- <property name="fileExtensions" value="java"/> -->
<!-- </module> -->

<module name="TreeWalker">

<module name="SuppressWarningsHolder" />

<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<!--<module name="JavadocMethod"/>-->
<!--<module name="JavadocType"/>-->
<!--<module name="JavadocVariable"/>-->
<!--<module name="JavadocStyle"/>-->

<!-- Checks for Naming Conventions. -->
<!-- See http://checkstyle.sf.net/config_naming.html -->
<module name="ConstantName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>

<!-- Checks for imports -->
<!-- See http://checkstyle.sf.net/config_import.html -->
<!--<module name="AvoidStarImport"/>-->
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
<module name="RedundantImport"/>
<module name="UnusedImports">
<property name="processJavadoc" value="false"/>
</module>

<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="LineLength">
<property name="max" value="180"/>
</module>
<module name="MethodLength"/>
<module name="ParameterNumber"/>

<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="EmptyForIteratorPad"/>
<module name="GenericWhitespace"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap">
<property name="option" value="eol"/>
</module>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter">
<property name="tokens" value="COMMA, SEMI, LITERAL_IF, LITERAL_ELSE, LITERAL_WHILE, LITERAL_DO, LITERAL_FOR, DO_WHILE" />
</module>
<module name="WhitespaceAround"/>

<!-- Modifier Checks -->
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>

<!-- Checks for blocks. You know, those {}'s -->
<!-- See http://checkstyle.sf.net/config_blocks.html -->
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock"/>
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="RightCurly"/>

<!-- Checks for common coding problems -->
<!-- See http://checkstyle.sf.net/config_coding.html -->
<!--<module name="AvoidInlineConditionals"/>-->
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="HiddenField"/>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MagicNumber"/>
<module name="MissingSwitchDefault"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>

<!-- Checks for class design -->
<!-- See http://checkstyle.sf.net/config_design.html -->
<!--<module name="DesignForExtension"/>-->
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="VisibilityModifier">
<property name="protectedAllowed" value="true"/>
</module>

<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->
<module name="ArrayTypeStyle"/>
<!--<module name="FinalParameters"/>-->
<module name="TodoComment"/>
<module name="UpperEll"/>

</module>

</module>
Expand Up @@ -8,104 +8,104 @@
public class CsvColumnInfo<T> {

public class RowInfo {
private final T myElement;
private final int myRow;
private final TextRange myTextRange;

RowInfo(T element, int row) {
this(element, row, -1, -1);
}

RowInfo(@NotNull T element, @NotNull int row, int startIndex, int endIndex) {
this.element = element;
this.row = row;
this.myElement = element;
this.myRow = row;
if (startIndex <= endIndex && startIndex >= 0) {
this.textRange = TextRange.create(startIndex, endIndex);
this.myTextRange = TextRange.create(startIndex, endIndex);
} else {
this.textRange = null;
this.myTextRange = null;
}
}

final T element;
final int row;
final TextRange textRange;

public T getElement() {
return element;
return myElement;
}

public int getRowIndex() {
return row;
return myRow;
}

public TextRange getTextRange() {
return textRange;
return myTextRange;
}

@Override
public int hashCode() {
return element.hashCode();
return myElement.hashCode();
}

@Override
public boolean equals(Object other) {
if (!(other instanceof CsvColumnInfo.RowInfo)) {
return false;
}
return this.element.equals(((RowInfo) other).element);
return this.myElement.equals(((RowInfo) other).myElement);
}
}

private int columnIndex;
private int maxLength;
private Map<T, RowInfo> elementInfos;
private T headerElement;
private int size;
private int myColumnIndex;
private int myMaxLength;
private Map<T, RowInfo> myElementInfos;
private T myHeaderElement;
private int mySize;

public CsvColumnInfo(int columnIndex, int maxLength) {
this.columnIndex = columnIndex;
this.maxLength = maxLength;
this.elementInfos = new HashMap<>();
this.headerElement = null;
this.size = 0;
this.myColumnIndex = columnIndex;
this.myMaxLength = maxLength;
this.myElementInfos = new HashMap<>();
this.myHeaderElement = null;
this.mySize = 0;
}

public RowInfo getRowInfo(T element) {
return elementInfos.get(element);
return myElementInfos.get(element);
}

public int getColumnIndex() {
return columnIndex;
return myColumnIndex;
}

public int getMaxLength() {
return maxLength;
return myMaxLength;
}

public void setMaxLength(int maxLength) {
this.maxLength = maxLength;
this.myMaxLength = maxLength;
}

public int getSize() {
return this.size;
return this.mySize;
}

public List<T> getElements() {
List<T> result = new ArrayList<>(getSize());
result.addAll(Collections.nCopies(getSize(), null));
elementInfos.values()
.forEach(rowInfo -> result.set(rowInfo.row, rowInfo.element));
myElementInfos.values()
.forEach(rowInfo -> result.set(rowInfo.myRow, rowInfo.myElement));
return result;
}

protected void put(@NotNull T element, @NotNull RowInfo rowInfo) {
RowInfo previous = elementInfos.put(element, rowInfo);
if (this.getSize() <= rowInfo.row) {
this.size = rowInfo.row + 1;
RowInfo previous = myElementInfos.put(element, rowInfo);
if (this.getSize() <= rowInfo.myRow) {
this.mySize = rowInfo.myRow + 1;
}
if (rowInfo.row == 0) {
this.headerElement = element;
if (rowInfo.myRow == 0) {
this.myHeaderElement = element;
}
}

public void addElement(T element, int startIndex, int endIndex) {
this.put(element, new RowInfo(element, elementInfos.size(), startIndex, endIndex));
this.put(element, new RowInfo(element, myElementInfos.size(), startIndex, endIndex));
}

public void addElement(T element) {
Expand All @@ -121,14 +121,14 @@ public void addElement(T element, int row) {
}

public boolean containsElement(T needle) {
return elementInfos.containsKey(needle);
return myElementInfos.containsKey(needle);
}

public boolean isHeaderElement(@NotNull T element) {
return element.equals(getHeaderElement());
}

public T getHeaderElement() {
return this.headerElement;
return this.myHeaderElement;
}
}
Expand Up @@ -6,29 +6,29 @@

public class CsvColumnInfoMap<T> {

private final Map<Integer, CsvColumnInfo<T>> infoColumnMap;
private final Map<T, CsvColumnInfo<T>> reverseInfoColumnMap;
private final Map<Integer, CsvColumnInfo<T>> myInfoColumnMap;
private final Map<T, CsvColumnInfo<T>> myReverseInfoColumnMap;

public CsvColumnInfoMap(Map<Integer, CsvColumnInfo<T>> infoColumnMap) {
this.infoColumnMap = infoColumnMap;
this.reverseInfoColumnMap = new HashMap<>();
this.myInfoColumnMap = infoColumnMap;
this.myReverseInfoColumnMap = new HashMap<>();
buildReverseMap();
}

private void buildReverseMap() {
for (CsvColumnInfo<T> columnInfo : this.infoColumnMap.values()) {
for (CsvColumnInfo<T> columnInfo : this.myInfoColumnMap.values()) {
for (T element : columnInfo.getElements()) {
this.reverseInfoColumnMap.put(element, columnInfo);
this.myReverseInfoColumnMap.put(element, columnInfo);
}
}
}

public CsvColumnInfo<T> getColumnInfo(T element) {
return reverseInfoColumnMap.get(element);
return myReverseInfoColumnMap.get(element);
}

public CsvColumnInfo<T> getColumnInfo(int columnIndex) {
return infoColumnMap.get(columnIndex);
return myInfoColumnMap.get(columnIndex);
}

public CsvColumnInfo<T>.RowInfo getRowInfo(T element) {
Expand All @@ -37,6 +37,6 @@ public CsvColumnInfo<T>.RowInfo getRowInfo(T element) {
}

public Map<Integer, CsvColumnInfo<T>> getColumnInfos() {
return Collections.unmodifiableMap(this.infoColumnMap);
return Collections.unmodifiableMap(this.myInfoColumnMap);
}
}

0 comments on commit 8a99372

Please sign in to comment.