From e981c366fd0e3763987f11df9423a570ee499d1f Mon Sep 17 00:00:00 2001 From: Tomasz Zielinski Date: Wed, 18 Jul 2018 23:56:36 +0200 Subject: [PATCH 01/10] remove commented code from InlinedStatementConfigurator.java --- src/main/java/spoon/pattern/InlinedStatementConfigurator.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/spoon/pattern/InlinedStatementConfigurator.java b/src/main/java/spoon/pattern/InlinedStatementConfigurator.java index 2b1474ae81b..a661550c6c6 100644 --- a/src/main/java/spoon/pattern/InlinedStatementConfigurator.java +++ b/src/main/java/spoon/pattern/InlinedStatementConfigurator.java @@ -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(); From 5f9ecb326f304c4e1b1ec569e61bb68d74b148fb Mon Sep 17 00:00:00 2001 From: Tomasz Zielinski Date: Wed, 18 Jul 2018 23:57:20 +0200 Subject: [PATCH 02/10] remove commented code from PatternBuilder.java --- src/main/java/spoon/pattern/PatternBuilder.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/spoon/pattern/PatternBuilder.java b/src/main/java/spoon/pattern/PatternBuilder.java index e381a6da9f6..4ad653b7959 100644 --- a/src/main/java/spoon/pattern/PatternBuilder.java +++ b/src/main/java/spoon/pattern/PatternBuilder.java @@ -84,7 +84,6 @@ public static PatternBuilder create(CtElement... elems) { private CtTypeReference templateTypeRef; private final Map parameterInfos = new HashMap<>(); -// ListOfNodes pattern; CtQueryable patternQuery; private ValueConvertor valueConvertor; private boolean addGeneratedBy = false; From 927b22eedf4b8ca16e965180dba1f1bc0dcd0e06 Mon Sep 17 00:00:00 2001 From: Tomasz Zielinski Date: Wed, 18 Jul 2018 23:58:32 +0200 Subject: [PATCH 03/10] remove unused code from PatternParameterConfigurator.java --- .../pattern/PatternParameterConfigurator.java | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/src/main/java/spoon/pattern/PatternParameterConfigurator.java b/src/main/java/spoon/pattern/PatternParameterConfigurator.java index d2aaf3dcae5..df910db7c88 100644 --- a/src/main/java/spoon/pattern/PatternParameterConfigurator.java +++ b/src/main/java/spoon/pattern/PatternParameterConfigurator.java @@ -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 From 4b97825848c8822024f0f7d7fea74c5f35ca44f1 Mon Sep 17 00:00:00 2001 From: Tomasz Zielinski Date: Thu, 19 Jul 2018 00:03:37 +0200 Subject: [PATCH 04/10] remove unused code from TobeMatched.java --- src/main/java/spoon/pattern/internal/matcher/TobeMatched.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/spoon/pattern/internal/matcher/TobeMatched.java b/src/main/java/spoon/pattern/internal/matcher/TobeMatched.java index 142db89dd33..e4c54afa230 100644 --- a/src/main/java/spoon/pattern/internal/matcher/TobeMatched.java +++ b/src/main/java/spoon/pattern/internal/matcher/TobeMatched.java @@ -62,10 +62,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); From bd37f47bbcacdcee6248b286bce113493944c072 Mon Sep 17 00:00:00 2001 From: Tomasz Zielinski Date: Thu, 19 Jul 2018 00:05:37 +0200 Subject: [PATCH 05/10] remove unused code from ElementNode.java --- src/main/java/spoon/pattern/internal/node/ElementNode.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/spoon/pattern/internal/node/ElementNode.java b/src/main/java/spoon/pattern/internal/node/ElementNode.java index 165bcd250c0..78d4727a31e 100644 --- a/src/main/java/spoon/pattern/internal/node/ElementNode.java +++ b/src/main/java/spoon/pattern/internal/node/ElementNode.java @@ -170,10 +170,6 @@ private static RootNode create(ContainerKind containerKind, Object templates, Ma @SuppressWarnings({ "unchecked", "rawtypes" }) private static ListOfNodes listOfNodesToNode(List 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); } From 70744b61b402748802734b95e143c14d507b9667 Mon Sep 17 00:00:00 2001 From: Tomasz Zielinski Date: Thu, 19 Jul 2018 00:08:30 +0200 Subject: [PATCH 06/10] remove unused code from ElementNode.java --- .../pattern/internal/node/ElementNode.java | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/src/main/java/spoon/pattern/internal/node/ElementNode.java b/src/main/java/spoon/pattern/internal/node/ElementNode.java index 78d4727a31e..9536103874a 100644 --- a/src/main/java/spoon/pattern/internal/node/ElementNode.java +++ b/src/main/java/spoon/pattern/internal/node/ElementNode.java @@ -374,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; From 6a5be21679f7c793faa35a49b452f039cd287570 Mon Sep 17 00:00:00 2001 From: Tomasz Zielinski Date: Thu, 19 Jul 2018 00:10:17 +0200 Subject: [PATCH 07/10] remove unused code from SubFactory.java --- .../spoon/reflect/factory/SubFactory.java | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/src/main/java/spoon/reflect/factory/SubFactory.java b/src/main/java/spoon/reflect/factory/SubFactory.java index bb258447074..9a49a81b63f 100644 --- a/src/main/java/spoon/reflect/factory/SubFactory.java +++ b/src/main/java/spoon/reflect/factory/SubFactory.java @@ -16,7 +16,6 @@ */ package spoon.reflect.factory; - /** * This class is the superclass for all the sub-factories of * {@link spoon.reflect.factory.Factory}. @@ -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); - // } - // } - // } - // } - } From 55c0e888120a8e010eaed8ad3c559b9edb537c12 Mon Sep 17 00:00:00 2001 From: Tomasz Zielinski Date: Thu, 19 Jul 2018 00:12:46 +0200 Subject: [PATCH 08/10] remove unused code from TypeFactory.java --- .../java/spoon/reflect/factory/TypeFactory.java | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/main/java/spoon/reflect/factory/TypeFactory.java b/src/main/java/spoon/reflect/factory/TypeFactory.java index a622f22ca14..375c53c785c 100644 --- a/src/main/java/spoon/reflect/factory/TypeFactory.java +++ b/src/main/java/spoon/reflect/factory/TypeFactory.java @@ -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); } /** From e0ad2c642334c92c3c2ef40b8b4bc6c59e90a79c Mon Sep 17 00:00:00 2001 From: Tomasz Zielinski Date: Thu, 19 Jul 2018 00:14:38 +0200 Subject: [PATCH 09/10] remove unused code from SingleHandler.java --- src/main/java/spoon/reflect/meta/impl/SingleHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/spoon/reflect/meta/impl/SingleHandler.java b/src/main/java/spoon/reflect/meta/impl/SingleHandler.java index 2362d26b272..53bd906a03d 100644 --- a/src/main/java/spoon/reflect/meta/impl/SingleHandler.java +++ b/src/main/java/spoon/reflect/meta/impl/SingleHandler.java @@ -45,7 +45,6 @@ public java.util.Collection asCollection(W element) { } public java.util.List asList(W e) { -// return Collections.singletonList(getValue(element)); return new AbstractList() { T element = castTarget(e); boolean hasValue = SingleHandler.this.getValue(element) != null; @@ -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) { @@ -96,6 +96,7 @@ public X remove(int index) { hasValue = false; return oldValue; } + @Override public boolean remove(Object value) { if (hasValue == false) { @@ -111,6 +112,7 @@ public boolean remove(Object value) { } return false; } + private boolean equals(Object v1, Object v2) { if (v1 == v2) { return true; From b4c0d8dbdbac67514892b747464e0ed9cf3d1019 Mon Sep 17 00:00:00 2001 From: Tomasz Zielinski Date: Thu, 19 Jul 2018 20:24:34 +0200 Subject: [PATCH 10/10] restore comment --- src/main/java/spoon/pattern/internal/matcher/TobeMatched.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/spoon/pattern/internal/matcher/TobeMatched.java b/src/main/java/spoon/pattern/internal/matcher/TobeMatched.java index e4c54afa230..9bd241bc92c 100644 --- a/src/main/java/spoon/pattern/internal/matcher/TobeMatched.java +++ b/src/main/java/spoon/pattern/internal/matcher/TobeMatched.java @@ -62,6 +62,7 @@ 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 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);