Skip to content

Commit ebb2d57

Browse files
#10 - [WARNING] Attempt to create a file for type 'package.to.MyEditor_field_Context' multiple times when running tests (#16)
Also changed version of auto-common to 1.1 & auto-version to 1.0 Fixes #10
1 parent 6b33de0 commit ebb2d57

File tree

22 files changed

+469
-68
lines changed

22 files changed

+469
-68
lines changed

gwt-editor-gwt2-tests/src/test/java/org/gwtproject/editor/client/EditorErrorTest.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public String getModuleName() {
3131
return "org.gwtproject.editor.EditorGwt2Test";
3232
}
3333

34-
class AddressEditorWithErrors extends AddressEditor implements ValueAwareEditor<Address> {
34+
public static class AddressEditorWithErrors extends AddressEditor
35+
implements ValueAwareEditor<Address> {
3536

3637
private EditorDelegate<Address> delegate;
3738

@@ -52,7 +53,8 @@ public void setDelegate(EditorDelegate<Address> delegate) {
5253
public void setValue(Address value) {}
5354
}
5455

55-
class AddressEditorReceivesErrors extends AddressEditor implements HasEditorErrors<Address> {
56+
public static class AddressEditorReceivesErrors extends AddressEditor
57+
implements HasEditorErrors<Address> {
5658
List<EditorError> errors;
5759

5860
@Override
@@ -64,7 +66,8 @@ public void showErrors(List<EditorError> errors) {
6466
}
6567
}
6668

67-
class PersonEditorReceivesErrors extends PersonEditor implements HasEditorErrors<Person> {
69+
public static class PersonEditorReceivesErrors extends PersonEditor
70+
implements HasEditorErrors<Person> {
6871
List<EditorError> errors;
6972

7073
@Override
@@ -76,15 +79,15 @@ public void showErrors(List<EditorError> errors) {
7679
}
7780
}
7881

79-
class Workgroup {
82+
public static class Workgroup {
8083
List<Person> people = new ArrayList<Person>();
8184

8285
List<Person> getPeople() {
8386
return people;
8487
}
8588
}
8689

87-
class WorkgroupEditor implements HasEditorErrors<Workgroup> {
90+
public static class WorkgroupEditor implements HasEditorErrors<Workgroup> {
8891
ListEditor<Person, PersonEditor> people =
8992
ListEditor.of(
9093
new EditorSource<PersonEditor>() {
@@ -107,7 +110,7 @@ public void showErrors(List<EditorError> errors) {
107110
@IsDriver
108111
interface WorkgroupEditorDriver extends SimpleBeanEditorDriver<Workgroup, WorkgroupEditor> {}
109112

110-
class WorkgroupNestedErrorsEditor implements HasEditorErrors<Workgroup> {
113+
public static class WorkgroupNestedErrorsEditor implements HasEditorErrors<Workgroup> {
111114
ListEditor<Person, PersonEditorReceivesErrors> people =
112115
ListEditor.of(
113116
new EditorSource<PersonEditorReceivesErrors>() {

gwt-editor-gwt2-tests/src/test/java/org/gwtproject/editor/client/PersonEditor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import org.gwtproject.editor.client.adapters.SimpleEditor;
1919

2020
/** Simple editor used by multiple tests. */
21-
class PersonEditor implements Editor<Person> {
21+
public class PersonEditor implements Editor<Person> {
2222
public AddressEditor addressEditor = new AddressEditor();
2323
public SimpleEditor<Long> localTime = SimpleEditor.of(System.currentTimeMillis());
2424
public SimpleEditor<String> name = SimpleEditor.of(SimpleBeanEditorTest.UNINITIALIZED);

gwt-editor-gwt2-tests/src/test/java/org/gwtproject/editor/client/SimpleBeanEditorTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ public void setDelegate(EditorDelegate<T> delegate) {
295295
}
296296
}
297297

298-
class ValueAwareAddressEditor extends AddressEditor implements ValueAwareEditor<Address> {
298+
public static class ValueAwareAddressEditor extends AddressEditor
299+
implements ValueAwareEditor<Address> {
299300
int flushCalled;
300301
int setDelegateCalled;
301302
int setValueCalled;

gwt-editor-j2cl-tests/src/test/java/org/gwtproject/editor/client/EditorErrorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void showErrors(List<EditorError> errors) {
6363
}
6464
}
6565

66-
class PersonEditorReceivesErrors extends PersonEditor implements HasEditorErrors<Person> {
66+
public class PersonEditorReceivesErrors extends PersonEditor implements HasEditorErrors<Person> {
6767
List<EditorError> errors;
6868

6969
@Override

gwt-editor-j2cl-tests/src/test/java/org/gwtproject/editor/client/PersonEditor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import org.gwtproject.editor.client.adapters.SimpleEditor;
1919

2020
/** Simple editor used by multiple tests. */
21-
class PersonEditor implements Editor<Person> {
21+
public class PersonEditor implements Editor<Person> {
2222
public AddressEditor addressEditor = new AddressEditor();
2323
public SimpleEditor<Long> localTime = SimpleEditor.of(System.currentTimeMillis());
2424
public SimpleEditor<String> name = SimpleEditor.of(SimpleBeanEditorTest.UNINITIALIZED);

gwt-editor-j2cl-tests/src/test/java/org/gwtproject/editor/client/SimpleBeanEditorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ public void setDelegate(EditorDelegate<T> delegate) {
295295
}
296296
}
297297

298-
class ValueAwareAddressEditor extends AddressEditor implements ValueAwareEditor<Address> {
298+
public class ValueAwareAddressEditor extends AddressEditor implements ValueAwareEditor<Address> {
299299
int flushCalled;
300300
int setDelegateCalled;
301301
int setValueCalled;

gwt-editor-processor/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
<maven.compiler.source>1.8</maven.compiler.source>
5050
<maven.compiler.target>1.8</maven.compiler.target>
5151

52-
<auto.common.version>0.10</auto.common.version>
53-
<auto.service.version>1.0-rc6</auto.service.version>
52+
<auto.common.version>1.1</auto.common.version>
53+
<auto.service.version>1.0</auto.service.version>
5454
<compile-testing.version>0.18</compile-testing.version>
5555
<gwt.version>2.8.2</gwt.version>
5656
<javapoet.version>1.12.1</javapoet.version>

gwt-editor-processor/src/main/java/org/gwtproject/editor/processor/DriverProcessor.java

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ protected void generate(TypeElement interfaceToImplement, EditorModel rootEditor
147147
String pkgName = this.elements.getPackageOf(interfaceToImplement).getQualifiedName().toString();
148148
String typeName = createNameFromEnclosedTypes(interfaceToImplement, "_Impl");
149149

150+
String classNameToGenerate = pkgName + "." + typeName;
151+
// check, if typename is already generated ...
152+
if (this.generatedDelegates.contains(classNameToGenerate)) {
153+
// alreday generated ... nothing to do
154+
return;
155+
}
156+
this.generatedDelegates.add(classNameToGenerate);
157+
150158
// impl accept(visitor) method
151159
ParameterizedTypeName rootEdContextType =
152160
ParameterizedTypeName.get(
@@ -216,8 +224,8 @@ protected void generate(TypeElement interfaceToImplement, EditorModel rootEditor
216224
driverFile.writeTo(this.filer);
217225
} catch (IOException e) {
218226
this.createMessage(
219-
Diagnostic.Kind.WARNING,
220-
"Exception: type >>"
227+
Diagnostic.Kind.NOTE,
228+
"type >>"
221229
+ rootEditorModel.getEditorType().toString()
222230
+ " << - trying to write: >>"
223231
+ driverFile.packageName
@@ -250,13 +258,13 @@ protected ClassName getEditorDelegate(EditorModel editorModel, EditorProperty da
250258
.getQualifiedName()
251259
.toString();
252260

253-
String delegateClassName = packageName + "." + delegateSimpleName;
254-
// check, if delegate is already generatd ...
255-
if (this.generatedDelegates.contains(delegateClassName)) {
261+
String classNameToGenerate = packageName + "." + delegateSimpleName;
262+
// check, if delegate is already generated ...
263+
if (this.generatedDelegates.contains(classNameToGenerate)) {
256264
// alreday generated ... nothing to do
257265
return ClassName.get(packageName, delegateSimpleName);
258266
}
259-
this.generatedDelegates.add(delegateClassName);
267+
this.generatedDelegates.add(classNameToGenerate);
260268

261269
TypeName rawEditorType = ClassName.get(types.erasure(data.getEditorType()));
262270

@@ -403,8 +411,8 @@ protected ClassName getEditorDelegate(EditorModel editorModel, EditorProperty da
403411
delegateFile.writeTo(filer);
404412
} catch (IOException e) {
405413
this.createMessage(
406-
Diagnostic.Kind.WARNING,
407-
"Exception: type >>"
414+
Diagnostic.Kind.NOTE,
415+
"type >>"
408416
+ editorModel.getEditorType().toString()
409417
+ " << - trying to write: >>"
410418
+ delegateFile.packageName
@@ -454,6 +462,14 @@ private ClassName getEditorContext(EditorProperty parent, EditorProperty data) {
454462
.getQualifiedName()
455463
.toString();
456464

465+
String classNameToGenerate = packageName + "." + contextSimpleName;
466+
// check, if context is already generated ...
467+
if (this.generatedDelegates.contains(classNameToGenerate)) {
468+
// already generated ... nothing to do
469+
return ClassName.get(packageName, contextSimpleName);
470+
}
471+
this.generatedDelegates.add(classNameToGenerate);
472+
457473
// try {
458474
TypeSpec.Builder contextTypeBuilder =
459475
TypeSpec.classBuilder(contextSimpleName)
@@ -548,8 +564,8 @@ private ClassName getEditorContext(EditorProperty parent, EditorProperty data) {
548564
contextFile.writeTo(filer);
549565
} catch (IOException e) {
550566
this.createMessage(
551-
Diagnostic.Kind.WARNING,
552-
"Exception: type >>"
567+
Diagnostic.Kind.NOTE,
568+
"type >>"
553569
+ parent.getEditorType().toString()
554570
+ " << - trying to write: >>"
555571
+ contextFile.packageName

gwt-editor-processor/src/test/java/org/gwtproject/editor/client/EditorErrorTest.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626

2727
/** Tests error propagation in generated code. */
2828
public class EditorErrorTest extends TestCase {
29-
class AddressEditorWithErrors extends AddressEditor implements ValueAwareEditor<Address> {
29+
public static class AddressEditorWithErrors extends AddressEditor
30+
implements ValueAwareEditor<Address> {
3031

3132
private EditorDelegate<Address> delegate;
3233

@@ -47,7 +48,8 @@ public void setDelegate(EditorDelegate<Address> delegate) {
4748
public void setValue(Address value) {}
4849
}
4950

50-
class AddressEditorReceivesErrors extends AddressEditor implements HasEditorErrors<Address> {
51+
public static class AddressEditorReceivesErrors extends AddressEditor
52+
implements HasEditorErrors<Address> {
5153
List<EditorError> errors;
5254

5355
@Override
@@ -59,7 +61,8 @@ public void showErrors(List<EditorError> errors) {
5961
}
6062
}
6163

62-
class PersonEditorReceivesErrors extends PersonEditor implements HasEditorErrors<Person> {
64+
public static class PersonEditorReceivesErrors extends PersonEditor
65+
implements HasEditorErrors<Person> {
6366
List<EditorError> errors;
6467

6568
@Override
@@ -71,15 +74,15 @@ public void showErrors(List<EditorError> errors) {
7174
}
7275
}
7376

74-
class Workgroup {
77+
public static class Workgroup {
7578
List<Person> people = new ArrayList<Person>();
7679

7780
List<Person> getPeople() {
7881
return people;
7982
}
8083
}
8184

82-
class WorkgroupEditor implements HasEditorErrors<Workgroup> {
85+
public static class WorkgroupEditor implements HasEditorErrors<Workgroup> {
8386
ListEditor<Person, PersonEditor> people =
8487
ListEditor.of(
8588
new EditorSource<PersonEditor>() {
@@ -102,7 +105,7 @@ public void showErrors(List<EditorError> errors) {
102105
@IsDriver
103106
interface WorkgroupEditorDriver extends SimpleBeanEditorDriver<Workgroup, WorkgroupEditor> {}
104107

105-
class WorkgroupNestedErrorsEditor implements HasEditorErrors<Workgroup> {
108+
public static class WorkgroupNestedErrorsEditor implements HasEditorErrors<Workgroup> {
106109
ListEditor<Person, PersonEditorReceivesErrors> people =
107110
ListEditor.of(
108111
new EditorSource<PersonEditorReceivesErrors>() {

gwt-editor-processor/src/test/java/org/gwtproject/editor/client/PersonEditor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import org.gwtproject.editor.client.adapters.SimpleEditor;
1919

2020
/** Simple editor used by multiple tests. */
21-
class PersonEditor implements Editor<Person> {
21+
public class PersonEditor implements Editor<Person> {
2222
public AddressEditor addressEditor = new AddressEditor();
2323
public SimpleEditor<Long> localTime = SimpleEditor.of(System.currentTimeMillis());
2424
public SimpleEditor<String> name = SimpleEditor.of(SimpleBeanEditorTest.UNINITIALIZED);

0 commit comments

Comments
 (0)