From 6991e72ebc4e6f84c8e0a580bf9d54add46503b4 Mon Sep 17 00:00:00 2001 From: Pavel Vojtechovsky Date: Thu, 19 Oct 2017 20:07:55 +0200 Subject: [PATCH] refactor(role): CtCodeSnippet has CtRole.SNIPPET (#1623) --- .../java/spoon/reflect/declaration/CtCodeSnippet.java | 6 +++--- src/main/java/spoon/reflect/path/CtRole.java | 3 ++- .../reflect/code/CtCodeSnippetExpressionImpl.java | 9 +++++---- .../support/reflect/code/CtCodeSnippetStatementImpl.java | 9 +++++---- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/java/spoon/reflect/declaration/CtCodeSnippet.java b/src/main/java/spoon/reflect/declaration/CtCodeSnippet.java index 5745164a480..e3e774b5944 100644 --- a/src/main/java/spoon/reflect/declaration/CtCodeSnippet.java +++ b/src/main/java/spoon/reflect/declaration/CtCodeSnippet.java @@ -19,7 +19,7 @@ import spoon.reflect.annotations.PropertyGetter; import spoon.reflect.annotations.PropertySetter; -import static spoon.reflect.path.CtRole.EXPRESSION; +import static spoon.reflect.path.CtRole.SNIPPET; /** * This interface represents snippets of source code that can be used in the AST @@ -36,13 +36,13 @@ public interface CtCodeSnippet { /** * Sets the textual value of the code. */ - @PropertySetter(role = EXPRESSION) + @PropertySetter(role = SNIPPET) C setValue(String value); /** * Gets the textual value of the code. */ - @PropertyGetter(role = EXPRESSION) + @PropertyGetter(role = SNIPPET) String getValue(); } diff --git a/src/main/java/spoon/reflect/path/CtRole.java b/src/main/java/spoon/reflect/path/CtRole.java index 46769584f5e..8fa185011bc 100644 --- a/src/main/java/spoon/reflect/path/CtRole.java +++ b/src/main/java/spoon/reflect/path/CtRole.java @@ -83,7 +83,8 @@ public enum CtRole { COMMENT_TYPE, DOCUMENTATION_TYPE, JAVADOC_TAG_VALUE, - POSITION; + POSITION, + SNIPPET; /** * Get the {@link CtRole} associated to the field name diff --git a/src/main/java/spoon/support/reflect/code/CtCodeSnippetExpressionImpl.java b/src/main/java/spoon/support/reflect/code/CtCodeSnippetExpressionImpl.java index 48259b679bb..ecfdd9b6582 100644 --- a/src/main/java/spoon/support/reflect/code/CtCodeSnippetExpressionImpl.java +++ b/src/main/java/spoon/support/reflect/code/CtCodeSnippetExpressionImpl.java @@ -20,12 +20,11 @@ import spoon.reflect.code.CtCodeSnippetExpression; import spoon.reflect.code.CtExpression; import spoon.reflect.declaration.CtCodeSnippet; -import spoon.reflect.path.CtRole; import spoon.reflect.visitor.CtVisitor; import spoon.support.compiler.SnippetCompilationError; import spoon.support.compiler.SnippetCompilationHelper; -import static spoon.reflect.path.CtRole.EXPRESSION; +import static spoon.reflect.path.CtRole.SNIPPET; public class CtCodeSnippetExpressionImpl extends CtExpressionImpl implements CtCodeSnippetExpression { @@ -35,15 +34,17 @@ public void accept(CtVisitor visitor) { visitor.visitCtCodeSnippetExpression(this); } - @MetamodelPropertyField(role = CtRole.EXPRESSION) + @MetamodelPropertyField(role = SNIPPET) String value; + @Override public String getValue() { return value; } + @Override public C setValue(String value) { - getFactory().getEnvironment().getModelChangeListener().onObjectUpdate(this, EXPRESSION, value, this.value); + getFactory().getEnvironment().getModelChangeListener().onObjectUpdate(this, SNIPPET, value, this.value); this.value = value; return (C) this; } diff --git a/src/main/java/spoon/support/reflect/code/CtCodeSnippetStatementImpl.java b/src/main/java/spoon/support/reflect/code/CtCodeSnippetStatementImpl.java index c987546a20f..4058c2f3413 100644 --- a/src/main/java/spoon/support/reflect/code/CtCodeSnippetStatementImpl.java +++ b/src/main/java/spoon/support/reflect/code/CtCodeSnippetStatementImpl.java @@ -20,12 +20,11 @@ import spoon.reflect.code.CtCodeSnippetStatement; import spoon.reflect.code.CtStatement; import spoon.reflect.declaration.CtCodeSnippet; -import spoon.reflect.path.CtRole; import spoon.reflect.visitor.CtVisitor; import spoon.support.compiler.SnippetCompilationError; import spoon.support.compiler.SnippetCompilationHelper; -import static spoon.reflect.path.CtRole.EXPRESSION; +import static spoon.reflect.path.CtRole.SNIPPET; public class CtCodeSnippetStatementImpl extends CtStatementImpl implements CtCodeSnippetStatement { @@ -35,15 +34,17 @@ public void accept(CtVisitor visitor) { visitor.visitCtCodeSnippetStatement(this); } - @MetamodelPropertyField(role = CtRole.EXPRESSION) + @MetamodelPropertyField(role = SNIPPET) String value; + @Override public String getValue() { return value; } + @Override public C setValue(String value) { - getFactory().getEnvironment().getModelChangeListener().onObjectUpdate(this, EXPRESSION, value, this.value); + getFactory().getEnvironment().getModelChangeListener().onObjectUpdate(this, SNIPPET, value, this.value); this.value = value; return (C) this; }