Skip to content

Commit

Permalink
Suppress this-escape warning in all auto-generated entities more prop…
Browse files Browse the repository at this point in the history
…erly (#458)

Suppress this-escape warning in all auto-generated entities more properly (#430)

Co-authored-by: Dominik Skorupowski <[email protected]>
  • Loading branch information
Plondrein and Dominik Skorupowski authored Jun 1, 2024
1 parent 01ae5e1 commit ce9eac4
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public final class Symbols {

public static final String THIS = "this";

public static final String THIS_ESCAPE = "this-escape";

public static final String UNCHECKED = "unchecked";

private Symbols() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/
package com.querydsl.codegen;

import static com.querydsl.codegen.utils.Symbols.THIS_ESCAPE;

import com.querydsl.codegen.utils.CodeWriter;
import com.querydsl.codegen.utils.model.ClassType;
import com.querydsl.codegen.utils.model.Parameter;
Expand Down Expand Up @@ -179,6 +181,7 @@ public void serialize(EntityType model, SerializerConfig serializerConfig, CodeW
writer.annotation(annotation);
}

writer.suppressWarnings(THIS_ESCAPE);
writer.line("@", generatedAnnotationClass.getSimpleName(), "(\"", getClass().getName(), "\")");

if (!interfaces.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package com.querydsl.codegen;

import static com.querydsl.codegen.utils.Symbols.THIS_ESCAPE;
import static com.querydsl.codegen.utils.Symbols.UNCHECKED;

import com.querydsl.codegen.utils.CodeWriter;
Expand Down Expand Up @@ -110,6 +111,7 @@ protected void introClassHeader(CodeWriter writer, EntityType model) throws IOEx
writer.annotation(annotation);
}

writer.suppressWarnings(THIS_ESCAPE);
writer.line("@", generatedAnnotationClass.getSimpleName(), "(\"", getClass().getName(), "\")");

if (category == TypeCategory.BOOLEAN || category == TypeCategory.STRING) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ protected void introClassHeader(CodeWriter writer, EntityType model) throws IOEx
writer.annotation(annotation);
}

writer.suppressWarnings(THIS_ESCAPE);
writer.line("@", generatedAnnotationClass.getSimpleName(), "(\"", getClass().getName(), "\")");

if (category == TypeCategory.BOOLEAN || category == TypeCategory.STRING) {
Expand Down Expand Up @@ -407,7 +408,7 @@ protected void introFactoryMethods(CodeWriter writer, final EntityType model) th
for (Constructor c : model.getConstructors()) {
// begin
if (!localName.equals(genericName)) {
writer.suppressWarnings(UNCHECKED, "this-escape");
writer.suppressWarnings(UNCHECKED);
}
Type returnType = new ClassType(ConstructorExpression.class, model);
final boolean asExpr = sizes.add(c.getParameters().size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/
package com.querydsl.codegen;

import static com.querydsl.codegen.utils.Symbols.THIS_ESCAPE;

import com.querydsl.codegen.utils.CodeWriter;
import com.querydsl.codegen.utils.model.*;
import com.querydsl.core.types.ConstructorExpression;
Expand Down Expand Up @@ -88,6 +90,7 @@ protected void intro(EntityType model, CodeWriter writer) throws IOException {
// javadoc
writer.javadoc(queryType + " is a Querydsl Projection type for " + simpleName);

writer.suppressWarnings(THIS_ESCAPE);
writer.line("@", generatedAnnotationClass.getSimpleName(), "(\"", getClass().getName(), "\")");

// class header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static com.querydsl.codegen.utils.Symbols.COMMA;
import static com.querydsl.codegen.utils.Symbols.NEW;
import static com.querydsl.codegen.utils.Symbols.SUPER;
import static com.querydsl.codegen.utils.Symbols.THIS_ESCAPE;

import com.querydsl.codegen.*;
import com.querydsl.codegen.utils.CodeWriter;
Expand Down Expand Up @@ -177,6 +178,7 @@ protected void constructorContent(CodeWriter writer, EntityType model) throws IO
protected void introClassHeader(CodeWriter writer, EntityType model) throws IOException {
Type queryType = typeMappings.getPathType(model, model, true);

writer.suppressWarnings(THIS_ESCAPE);
writer.line("@", generatedAnnotationClass.getSimpleName(), "(\"", getClass().getName(), "\")");

TypeCategory category = model.getOriginalCategory();
Expand Down

0 comments on commit ce9eac4

Please sign in to comment.