Skip to content

Commit

Permalink
Diamond operator #195
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkravin authored and Daniil Yaroslavtsev committed Aug 27, 2014
1 parent c72d31b commit 704bfd3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ public class DiamondOperatorForVariableDefinitionCheckTest extends BaseCheckTest
@Test
public void testDefault() throws Exception {
String[] expected = {
"31:58: " + getCheckMessage(MSG_KEY),
"33:26: " + getCheckMessage(MSG_KEY),
"35:41: " + getCheckMessage(MSG_KEY),
"152:88: " + getCheckMessage(MSG_KEY)
"25:58: " + getCheckMessage(MSG_KEY),
"27:26: " + getCheckMessage(MSG_KEY),
"28:50: " + getCheckMessage(MSG_KEY),
"29:41: " + getCheckMessage(MSG_KEY),
"59:40: " + getCheckMessage(MSG_KEY),
"60:83: " + getCheckMessage(MSG_KEY)
};
verify(checkConfig,
getPath("InputDiamondOperatorForVariableDefinitionCheck.java"), expected);
}

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.github.sevntu.checkstyle.checks.coding;

import java.io.File;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.lang.reflect.Method;
Expand All @@ -17,63 +17,33 @@

import javax.print.attribute.Attribute;
import javax.print.attribute.AttributeSet;
import javax.sql.rowset.Predicate;
import javax.swing.tree.TreePath;

import org.aspectj.weaver.tools.PointcutExpression;
import org.aspectj.weaver.tools.ShadowMatch;
import org.springframework.beans.factory.BeanFactory;
import javax.swing.tree.TreePath;

import testforbid.Classifier;
import testforbid.JointClassification;

public class InputDiamondOperatorForVariableDefinitionCheck {
static Map<String, List<String>> myMap1 = new TreeMap<String, List<String>>();
List<Integer> list =
List<Integer> list1 =
new ArrayList<Integer>();
Map<String, List<String>> myMap = new HashMap<>();
Map<String, List<String>> myMap = new HashMap<String, List<String>>();
List<Character> abc = new LinkedList<Character>();
private TreePath[] suppressParentPaths(TreePath[] paths) {
List<TreePath> selectedPaths = Arrays.asList(paths);
Collections.sort(selectedPaths, new Comparator<TreePath>() {
@Override
public int compare(TreePath o1, TreePath o2) {
int count1 = o1.getPathCount();
int count2 = o2.getPathCount();
if (count1 < count2) {
return -1;
}
if (count1 == count2) {
return 0;
}
return 1;
}
});
return paths;
}


private static class DemoAttributeSet implements AttributeSet {
public Enumeration<?> getAttributeNames() {
return (Enumeration<?>) new ArrayList<String>();
}

}

private TreePath[] suppressParentPaths1(TreePath[] paths) {
List<TreePath> selectedPaths = Arrays.asList(paths);
Collections.sort(selectedPaths, new Comparator<TreePath>() {
@Override
public int compare(TreePath o1, TreePath o2) {
int count1 = o1.getPathCount();
int count2 = o2.getPathCount();
if (count1 < count2) {
return -1;
}
if (count1 == count2) {
return 0;
}
return 1;
return 0;
}
});

Expand All @@ -86,71 +56,9 @@ public int compare(Object s1, Object s2) {
});
return paths; }

List<Number> list = new LinkedList<Integer>();

public class XReqLib {
private static final String SLASH = "/";

private final String base;

public XReqLib(String base) {
if (base.endsWith(SLASH)) {
this.base = base.substring(0, base.length() - 1);
} else {
this.base = base;
}
}

public String contextPath(String path) {
if (path.startsWith(SLASH)) {
return base + SLASH + path.substring(1);
} else {
return base + SLASH + path;
}
}

}

private Classifier<CharSequence, JointClassification> classifier;

public void MnaNewsClassifier() {
// see AbstractExternalizable.readObject(File)

InputStream in = getClass().getResourceAsStream("mna-model.bin");
if (in == null) {
throw new IllegalStateException("cannot find mna-model.bin in " + getClass().getPackage().getName());
}
try {
try {
ObjectInputStream objIn = new ObjectInputStream(in);
Object obj = objIn.readObject();
this.classifier = (Classifier<CharSequence, JointClassification>) obj;
} finally {
in.close();
}
} catch (Exception e) {
throw new IllegalStateException("failed to load classifier: " + e, e);
}
}

public boolean isMna(CharSequence text) {
JointClassification jc = this.classifier.classify(text);
String bestCategory = jc.bestCategory();
return "mna".equals(bestCategory);
}

private Class<?> pointcutDeclarationScope;

private Class<?>[] pointcutParameterTypes = new Class<?>[0];

private BeanFactory beanFactory;

private transient ClassLoader pointcutClassLoader;

private transient PointcutExpression pointcutExpression;

private transient Map<Method, ShadowMatch> shadowMatchCache = new ConcurrentHashMap<Method, ShadowMatch>(32);
List<Integer> list = new LinkedList<Integer>();
private transient Map<Method, String> shadowMatchCache = new ConcurrentHashMap<Method, String>(32);

}



0 comments on commit 704bfd3

Please sign in to comment.