Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sonarqube remove commented code #2248

Merged
merged 10 commits into from
Jul 19, 2018
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ public InlinedStatementConfigurator markAsInlined(CtForEach foreach) {
throw new SpoonException("Each inline `for(x : iterable)` statement must have defined pattern parameter for `iterable` expression");
}
PrimitiveMatcher parameterOfExpression = (PrimitiveMatcher) vr;
// PatternBuilder localPatternBuilder = patternBuilder.create(bodyToStatements(foreach.getBody()));
ForEachNode mvr = new ForEachNode();
mvr.setIterableParameter(parameterOfExpression);
CtLocalVariable<?> lv = foreach.getVariable();
Expand Down
1 change: 0 additions & 1 deletion src/main/java/spoon/pattern/PatternBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public static PatternBuilder create(CtElement... elems) {

private CtTypeReference<?> templateTypeRef;
private final Map<String, AbstractParameterInfo> parameterInfos = new HashMap<>();
// ListOfNodes pattern;
CtQueryable patternQuery;
private ValueConvertor valueConvertor;
private boolean addGeneratedBy = false;
Expand Down
26 changes: 0 additions & 26 deletions src/main/java/spoon/pattern/PatternParameterConfigurator.java
Original file line number Diff line number Diff line change
Expand Up @@ -571,32 +571,6 @@ public PatternParameterConfigurator byTemplateParameterReference(CtVariable<?> v
return this;
}

/**
* CodeElement element identified by `simpleName`
* @param simpleName the name of the element or reference
* @return {@link PatternParameterConfigurator} to support fluent API
*/
// public PatternParameterConfigurator codeElementBySimpleName(String simpleName) {
// ParameterInfo pi = getCurrentParameter();
// pattern.getModel().filterChildren((CtNamedElement named) -> simpleName.equals(named.getSimpleName()))
// .forEach((CtNamedElement named) -> {
// if (named instanceof CtCodeElement) {
// addSubstitutionRequest(pi, named);
// }
// });
// pattern.getModel().filterChildren((CtReference ref) -> simpleName.equals(ref.getSimpleName()))
// .forEach((CtReference ref) -> {
// if (ref instanceof CtTypeReference<?>) {
// return;
// }
// CtCodeElement codeElement = ref.getParent(CtCodeElement.class);
// if (codeElement != null) {
// addSubstitutionRequest(pi, codeElement);
// }
// });
// return this;
// }

/**
* All spoon model string attributes whose value is equal to `stringMarker`
* are subject for substitution by current parameter
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/spoon/pattern/internal/matcher/TobeMatched.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ public static TobeMatched create(ImmutableMap parameters, ContainerKind containe

private TobeMatched(ImmutableMap parameters, Object target) {
//It is correct to put whole container as single value in cases when ParameterNode matches agains whole attribute value
// if (target instanceof Collection || target instanceof Map) {
// throw new SpoonException("Invalid argument. Use other constructors");
// }
this.parameters = parameters;
//make a copy of origin collection, because it might be modified during matching process (by a refactoring algorithm)
this.targets = Collections.singletonList(target);
Expand Down
31 changes: 0 additions & 31 deletions src/main/java/spoon/pattern/internal/node/ElementNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,6 @@ private static RootNode create(ContainerKind containerKind, Object templates, Ma

@SuppressWarnings({ "unchecked", "rawtypes" })
private static ListOfNodes listOfNodesToNode(List<? extends RootNode> nodes) {
//The attribute is matched different if there is List of one ParameterizedNode and when there is one ParameterizedNode
// if (nodes.size() == 1) {
// return nodes.get(0);
// }
return new ListOfNodes((List) nodes);
}

Expand Down Expand Up @@ -378,33 +374,6 @@ private static boolean isMatchingRole(CtRole role, Class<?> targetClass) {
public String toString() {
return elementType.getName() + ": " + super.toString();
}
// @Override
// public String toString() {
// PrinterHelper printer = new PrinterHelper(getTemplateNode().getFactory().getEnvironment());
// printer.write(NodeAttributeSubstitutionRequest.getElementTypeName(getTemplateNode().getParent())).writeln().incTab();
// appendDescription(printer);
// return printer.toString();
// }
//
// public void appendDescription(PrinterHelper printer) {
// if (attributeSubstititionRequests == null || attributeSubstititionRequests.values().isEmpty()) {
// printer.write("** no attribute substitution **");
// } else {
// boolean multipleAttrs = attributeSubstititionRequests.size() > 1;
// if (multipleAttrs) {
// printer.incTab();
// }
// for (Node node : attributeSubstititionRequests.values()) {
// if (multipleAttrs) {
// printer.writeln();
// }
// printer.write(node.toString());
// }
// if (multipleAttrs) {
// printer.decTab();
// }
// }
// }

public MetamodelConcept getElementType() {
return elementType;
Expand Down
22 changes: 0 additions & 22 deletions src/main/java/spoon/reflect/factory/SubFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package spoon.reflect.factory;


/**
* This class is the superclass for all the sub-factories of
* {@link spoon.reflect.factory.Factory}.
Expand All @@ -32,26 +31,5 @@ public SubFactory(Factory factory) {
super();
this.factory = factory;
}

/**
* Generically sets the parent of a set of elements or lists of elements.
*
* @param parent
* the parent
* @param elements
* some {@link CtElement} or lists of {@link CtElement}
*/
// protected void setParent(CtElement parent, Object... elements) {
// for (Object o : elements) {
// if (o instanceof CtElement) {
// ((CtElement) o).setParent(parent);
// } else if (o instanceof Collection) {
// for (Object o2 : (Collection<?>) o) {
// ((CtElement) o2).setParent(parent);
// }
// }
// }
// }

}

13 changes: 1 addition & 12 deletions src/main/java/spoon/reflect/factory/TypeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -605,18 +605,7 @@ protected String getSimpleName(String qualifiedName) {
* Tells if a given Java qualified name is that of an inner type.
*/
protected int hasInnerType(String qualifiedName) {
int ret = qualifiedName.lastIndexOf(CtType.INNERTTYPE_SEPARATOR);
// if (ret < 0) {
// if (hasPackage(qualifiedName) > 0) {
// String buf = qualifiedName.substring(0,
// hasPackage(qualifiedName));
// int tmp = buf.lastIndexOf(CtPackage.PACKAGE_SEPARATOR);
// if (Character.isUpperCase(buf.charAt(tmp + 1))) {
// ret = hasPackage(qualifiedName);
// }
// }
// }
return ret;
return qualifiedName.lastIndexOf(CtType.INNERTTYPE_SEPARATOR);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/spoon/reflect/meta/impl/SingleHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public <W, X> java.util.Collection<X> asCollection(W element) {
}

public <W, X> java.util.List<X> asList(W e) {
// return Collections.<X>singletonList(getValue(element));
return new AbstractList<X>() {
T element = castTarget(e);
boolean hasValue = SingleHandler.this.getValue(element) != null;
Expand Down Expand Up @@ -73,6 +72,7 @@ public X set(int index, X value) {
SingleHandler.this.setValue(element, value);
return (X) oldValue;
}

@Override
public boolean add(X value) {
if (hasValue) {
Expand All @@ -96,6 +96,7 @@ public X remove(int index) {
hasValue = false;
return oldValue;
}

@Override
public boolean remove(Object value) {
if (hasValue == false) {
Expand All @@ -111,6 +112,7 @@ public boolean remove(Object value) {
}
return false;
}

private boolean equals(Object v1, Object v2) {
if (v1 == v2) {
return true;
Expand Down