diff --git a/compiler/extensions/python/build.xml b/compiler/extensions/python/build.xml index 76099b6b7..f88a3f6b0 100644 --- a/compiler/extensions/python/build.xml +++ b/compiler/extensions/python/build.xml @@ -18,6 +18,7 @@ zserio_python.install_dir - Directory where to install Zserio Python Extensi zserio_core.jar_file - Zserio core jar file used for classpath. Default is "${zserio_extensions.build_dir}/../core/${ant.java.version}/jar/ zserio_core.jar". +clang_format.exe_file - Clang-format executable file. If not set, clang-format is not run. spotbugs.home_dir - Location of the spotbugs tool. If not set, spotbugs is not run. --> @@ -164,7 +165,22 @@ spotbugs.home_dir - Location of the spotbugs tool. If not set, spotb - + + +Command hints to reformat source using clang-format tool: + git clang-format + clang-format --style=file -i [SOURCE] + + + + + + + + + + + @@ -205,7 +221,22 @@ spotbugs.home_dir - Location of the spotbugs tool. If not set, spotb - + + +Command hints to reformat source using clang-format tool: + git clang-format + clang-format --style=file -i [SOURCE] + + + + + + + + + + + diff --git a/compiler/extensions/python/src/zserio/extension/python/ApiEmitterTemplateData.java b/compiler/extensions/python/src/zserio/extension/python/ApiEmitterTemplateData.java index 907f597ba..289c93485 100644 --- a/compiler/extensions/python/src/zserio/extension/python/ApiEmitterTemplateData.java +++ b/compiler/extensions/python/src/zserio/extension/python/ApiEmitterTemplateData.java @@ -1,9 +1,9 @@ package zserio.extension.python; +import java.util.ArrayList; +import java.util.List; import java.util.Set; import java.util.TreeSet; -import java.util.List; -import java.util.ArrayList; import zserio.ast.PackageName; import zserio.extension.python.symbols.PythonNativeSymbol; @@ -51,7 +51,7 @@ public String getSymbol() public boolean equals(Object otherObject) { if (!(otherObject instanceof ApiImport)) - return false; + return false; final ApiImport other = (ApiImport)otherObject; diff --git a/compiler/extensions/python/src/zserio/extension/python/BitmaskEmitterTemplateData.java b/compiler/extensions/python/src/zserio/extension/python/BitmaskEmitterTemplateData.java index 7dd4b8cd0..aa7dd82fd 100644 --- a/compiler/extensions/python/src/zserio/extension/python/BitmaskEmitterTemplateData.java +++ b/compiler/extensions/python/src/zserio/extension/python/BitmaskEmitterTemplateData.java @@ -41,8 +41,8 @@ public BitmaskEmitterTemplateData(TemplateDataContext context, BitmaskType bitma bitSize = createBitSize(bitmaskTypeInstantiation); final ExpressionFormatter pythonExpressionFormatter = context.getPythonExpressionFormatter(this); - runtimeFunction = RuntimeFunctionDataCreator.createData( - bitmaskTypeInstantiation, pythonExpressionFormatter); + runtimeFunction = + RuntimeFunctionDataCreator.createData(bitmaskTypeInstantiation, pythonExpressionFormatter); lowerBound = PythonLiteralFormatter.formatDecimalLiteral(getLowerBound(bitmaskTypeInstantiation)); upperBound = PythonLiteralFormatter.formatDecimalLiteral(getUpperBound(bitmaskTypeInstantiation)); diff --git a/compiler/extensions/python/src/zserio/extension/python/ChoiceEmitterTemplateData.java b/compiler/extensions/python/src/zserio/extension/python/ChoiceEmitterTemplateData.java index 538a44245..47217519d 100644 --- a/compiler/extensions/python/src/zserio/extension/python/ChoiceEmitterTemplateData.java +++ b/compiler/extensions/python/src/zserio/extension/python/ChoiceEmitterTemplateData.java @@ -30,13 +30,13 @@ public ChoiceEmitterTemplateData(TemplateDataContext context, ChoiceType choiceT final Iterable choiceCases = choiceType.getChoiceCases(); for (ChoiceCase choiceCase : choiceCases) { - caseMemberList.add(new CaseMember( - context, choiceType, choiceCase, pythonExpressionFormatter, this)); + caseMemberList.add( + new CaseMember(context, choiceType, choiceCase, pythonExpressionFormatter, this)); } final ChoiceDefault choiceDefault = choiceType.getChoiceDefault(); - defaultMember = (choiceDefault == null) ? null: - new DefaultMember(context, choiceType, choiceDefault, this); + defaultMember = + (choiceDefault == null) ? null : new DefaultMember(context, choiceType, choiceDefault, this); isDefaultUnreachable = choiceType.isChoiceDefaultUnreachable(); } @@ -65,7 +65,7 @@ public static final class CaseMember { public CaseMember(TemplateDataContext context, ChoiceType choiceType, ChoiceCase choiceCase, ExpressionFormatter expressionFormatter, ImportCollector importCollector) - throws ZserioExtensionException + throws ZserioExtensionException { expressionList = new ArrayList(); final Iterable caseExpressions = choiceCase.getExpressions(); @@ -73,8 +73,9 @@ public CaseMember(TemplateDataContext context, ChoiceType choiceType, ChoiceCase expressionList.add(expressionFormatter.formatGetter(caseExpression.getExpression())); final Field fieldType = choiceCase.getField(); - compoundField = (fieldType != null) ? - new CompoundFieldTemplateData(context, choiceType, fieldType, importCollector) : null; + compoundField = (fieldType != null) + ? new CompoundFieldTemplateData(context, choiceType, fieldType, importCollector) + : null; } public Iterable getExpressionList() @@ -97,8 +98,9 @@ public DefaultMember(TemplateDataContext context, ChoiceType choiceType, ChoiceD ImportCollector importCollector) throws ZserioExtensionException { final Field fieldType = choiceDefault.getField(); - compoundField = (fieldType != null) ? - new CompoundFieldTemplateData(context, choiceType, fieldType, importCollector) : null; + compoundField = (fieldType != null) + ? new CompoundFieldTemplateData(context, choiceType, fieldType, importCollector) + : null; } public CompoundFieldTemplateData getCompoundField() diff --git a/compiler/extensions/python/src/zserio/extension/python/ChoiceTemplateDataContext.java b/compiler/extensions/python/src/zserio/extension/python/ChoiceTemplateDataContext.java index 619fd1de5..d83b6a53e 100644 --- a/compiler/extensions/python/src/zserio/extension/python/ChoiceTemplateDataContext.java +++ b/compiler/extensions/python/src/zserio/extension/python/ChoiceTemplateDataContext.java @@ -9,8 +9,8 @@ */ public final class ChoiceTemplateDataContext extends TemplateDataContext { - public ChoiceTemplateDataContext(PythonExtensionParameters pythonParameters, - PackedTypesCollector packedTypesCollector) + public ChoiceTemplateDataContext( + PythonExtensionParameters pythonParameters, PackedTypesCollector packedTypesCollector) { super(pythonParameters, packedTypesCollector); } @@ -27,8 +27,9 @@ public ExpressionFormatter getPythonExpressionFormatter(ImportCollector importCo @Override public ExpressionFormatter getPythonOwnerIndirectExpressionFormatter(ImportCollector importCollector) { - final ExpressionFormattingPolicy expressionFormattingPolicy = new PythonChoiceExpressionFormattingPolicy( - this, importCollector, TemplateDataContext.PYTHON_OWNER_PREFIX); + final ExpressionFormattingPolicy expressionFormattingPolicy = + new PythonChoiceExpressionFormattingPolicy( + this, importCollector, TemplateDataContext.PYTHON_OWNER_PREFIX); return new ExpressionFormatter(expressionFormattingPolicy); } diff --git a/compiler/extensions/python/src/zserio/extension/python/CompoundFieldTemplateData.java b/compiler/extensions/python/src/zserio/extension/python/CompoundFieldTemplateData.java index 49f9ed0f1..daa90e628 100644 --- a/compiler/extensions/python/src/zserio/extension/python/CompoundFieldTemplateData.java +++ b/compiler/extensions/python/src/zserio/extension/python/CompoundFieldTemplateData.java @@ -8,15 +8,15 @@ import zserio.ast.ChoiceType; import zserio.ast.CompoundType; import zserio.ast.DynamicBitFieldInstantiation; +import zserio.ast.Expression; +import zserio.ast.Field; +import zserio.ast.FixedSizeType; import zserio.ast.IntegerType; import zserio.ast.ParameterizedTypeInstantiation; import zserio.ast.ParameterizedTypeInstantiation.InstantiatedParameter; +import zserio.ast.TypeInstantiation; import zserio.ast.UnionType; import zserio.ast.ZserioType; -import zserio.ast.Expression; -import zserio.ast.Field; -import zserio.ast.FixedSizeType; -import zserio.ast.TypeInstantiation; import zserio.extension.common.ExpressionFormatter; import zserio.extension.common.ZserioExtensionException; import zserio.extension.python.types.PythonNativeType; @@ -60,8 +60,8 @@ public CompoundFieldTemplateData(TemplateDataContext context, CompoundType paren bitSize = new BitSize(fieldTypeInstantiation, pythonExpressionFormatter); offset = createOffset(field, pythonExpressionFormatter); array = createArray(context, fieldTypeInstantiation, parentType, importCollector); - runtimeFunction = RuntimeFunctionDataCreator.createData(fieldTypeInstantiation, - pythonExpressionFormatter); + runtimeFunction = + RuntimeFunctionDataCreator.createData(fieldTypeInstantiation, pythonExpressionFormatter); compound = createCompound(context, fieldTypeInstantiation, importCollector); docComments = DocCommentsDataCreator.createData(context, field); } @@ -195,8 +195,8 @@ public static final class BitFieldWithExpression public BitFieldWithExpression(DynamicBitFieldInstantiation dynamicBitFieldInstantiation, ExpressionFormatter pythonExpressionFormatter) throws ZserioExtensionException { - lengthExpression = pythonExpressionFormatter.formatGetter( - dynamicBitFieldInstantiation.getLengthExpression()); + lengthExpression = + pythonExpressionFormatter.formatGetter(dynamicBitFieldInstantiation.getLengthExpression()); isSigned = dynamicBitFieldInstantiation.getBaseType().isSigned(); } @@ -220,8 +220,9 @@ public Optional(Field field, ExpressionFormatter pythonExpressionFormatter, bool throws ZserioExtensionException { final Expression optionalClauseExpression = field.getOptionalClauseExpr(); - clause = (optionalClauseExpression == null) ? null : - pythonExpressionFormatter.formatGetter(optionalClauseExpression); + clause = (optionalClauseExpression == null) + ? null + : pythonExpressionFormatter.formatGetter(optionalClauseExpression); isUsedIndicatorName = AccessorNameFormatter.getIsUsedIndicatorName(field); isSetIndicatorName = AccessorNameFormatter.getIsSetIndicatorName(field); @@ -267,8 +268,9 @@ public BitSize(TypeInstantiation typeInstantiation, ExpressionFormatter pythonEx throws ZserioExtensionException { value = createValue(typeInstantiation, pythonExpressionFormatter); - runtimeFunction = (value != null) ? null : - RuntimeFunctionDataCreator.createData(typeInstantiation, pythonExpressionFormatter); + runtimeFunction = (value != null) + ? null + : RuntimeFunctionDataCreator.createData(typeInstantiation, pythonExpressionFormatter); } public String getValue() @@ -454,7 +456,7 @@ public static final class Compound { public Compound(TemplateDataContext context, ParameterizedTypeInstantiation parameterizedTypeInstantiation, ImportCollector importCollector) - throws ZserioExtensionException + throws ZserioExtensionException { this(context, parameterizedTypeInstantiation.getBaseType(), importCollector); @@ -483,8 +485,9 @@ public CompoundParameterTemplateData getParameters() public static final class InstantiatedParameterData { - public InstantiatedParameterData(TemplateDataContext context, InstantiatedParameter instantiatedParameter, - ImportCollector importCollector) throws ZserioExtensionException + public InstantiatedParameterData(TemplateDataContext context, + InstantiatedParameter instantiatedParameter, ImportCollector importCollector) + throws ZserioExtensionException { final Expression argumentExpression = instantiatedParameter.getArgumentExpression(); final ExpressionFormatter pythonExpressionFormatter = @@ -530,16 +533,16 @@ private static RangeCheck createRangeCheck(TypeInstantiation typeInstantiation, return null; final IntegerType integerType = (IntegerType)baseType; - final BitFieldWithExpression bitFieldWithExpression = createBitFieldWithExpression(typeInstantiation, - pythonExpressionFormatter); + final BitFieldWithExpression bitFieldWithExpression = + createBitFieldWithExpression(typeInstantiation, pythonExpressionFormatter); final BigInteger zserioLowerBound = integerType.getLowerBound(typeInstantiation); - final String lowerBound = zserioLowerBound != null ? - PythonLiteralFormatter.formatDecimalLiteral(zserioLowerBound) : null; + final String lowerBound = + zserioLowerBound != null ? PythonLiteralFormatter.formatDecimalLiteral(zserioLowerBound) : null; final BigInteger zserioUpperBound = integerType.getUpperBound(typeInstantiation); - final String upperBound = zserioUpperBound != null ? - PythonLiteralFormatter.formatDecimalLiteral(zserioUpperBound) : null; + final String upperBound = + zserioUpperBound != null ? PythonLiteralFormatter.formatDecimalLiteral(zserioUpperBound) : null; return new RangeCheck(bitFieldWithExpression, lowerBound, upperBound); } diff --git a/compiler/extensions/python/src/zserio/extension/python/CompoundParameterTemplateData.java b/compiler/extensions/python/src/zserio/extension/python/CompoundParameterTemplateData.java index a7aca4ce2..581811c5d 100644 --- a/compiler/extensions/python/src/zserio/extension/python/CompoundParameterTemplateData.java +++ b/compiler/extensions/python/src/zserio/extension/python/CompoundParameterTemplateData.java @@ -37,13 +37,13 @@ public static final class CompoundParameter { public CompoundParameter(TemplateDataContext context, Parameter parameter, ImportCollector importCollector, List compoundDocComments) - throws ZserioExtensionException + throws ZserioExtensionException { name = parameter.getName(); snakeCaseName = PythonSymbolConverter.toLowerSnakeCase(name); final TypeReference parameterTypeReference = parameter.getTypeReference(); - final PythonNativeType nativeType = context.getPythonNativeMapper().getPythonType( - parameterTypeReference); + final PythonNativeType nativeType = + context.getPythonNativeMapper().getPythonType(parameterTypeReference); importCollector.importType(nativeType); typeInfo = new NativeTypeInfoTemplateData(nativeType, parameterTypeReference); propertyName = AccessorNameFormatter.getPropertyName(parameter); diff --git a/compiler/extensions/python/src/zserio/extension/python/DocCommentsDataCreator.java b/compiler/extensions/python/src/zserio/extension/python/DocCommentsDataCreator.java index ce0859e57..c7c6bc5e4 100644 --- a/compiler/extensions/python/src/zserio/extension/python/DocCommentsDataCreator.java +++ b/compiler/extensions/python/src/zserio/extension/python/DocCommentsDataCreator.java @@ -12,14 +12,14 @@ */ final class DocCommentsDataCreator { - public static DocCommentsTemplateData createData(TemplateDataContext context, - DocumentableAstNode documentableNode) throws ZserioExtensionException + public static DocCommentsTemplateData createData( + TemplateDataContext context, DocumentableAstNode documentableNode) throws ZserioExtensionException { return createData(context, documentableNode.getDocComments()); } - public static DocCommentsTemplateData createData(TemplateDataContext context, - List docComments) throws ZserioExtensionException + public static DocCommentsTemplateData createData(TemplateDataContext context, List docComments) + throws ZserioExtensionException { final int numComments = docComments.size(); int firstStickyCommentIndex = numComments; diff --git a/compiler/extensions/python/src/zserio/extension/python/DocCommentsTemplateData.java b/compiler/extensions/python/src/zserio/extension/python/DocCommentsTemplateData.java index 4d24025be..d6f74a786 100644 --- a/compiler/extensions/python/src/zserio/extension/python/DocCommentsTemplateData.java +++ b/compiler/extensions/python/src/zserio/extension/python/DocCommentsTemplateData.java @@ -19,9 +19,6 @@ import zserio.ast.EnumItem; import zserio.ast.Field; import zserio.ast.Function; -import zserio.ast.SymbolReference; -import zserio.extension.common.ZserioExtensionException; -import zserio.extension.python.symbols.PythonNativeSymbol; import zserio.ast.Package; import zserio.ast.PackageSymbol; import zserio.ast.Parameter; @@ -29,6 +26,9 @@ import zserio.ast.ScopeSymbol; import zserio.ast.ServiceMethod; import zserio.ast.SqlTableType; +import zserio.ast.SymbolReference; +import zserio.extension.common.ZserioExtensionException; +import zserio.extension.python.symbols.PythonNativeSymbol; /** * FreeMarker template data for documentation comments. @@ -185,8 +185,7 @@ public DocTagSeeData getSeeTag() public static final class DocTagSeeData { - public DocTagSeeData(TemplateDataContext context, DocTagSee docTagSee) - throws ZserioExtensionException + public DocTagSeeData(TemplateDataContext context, DocTagSee docTagSee) throws ZserioExtensionException { alias = docTagSee.getLinkAlias(); diff --git a/compiler/extensions/python/src/zserio/extension/python/EnumerationEmitterTemplateData.java b/compiler/extensions/python/src/zserio/extension/python/EnumerationEmitterTemplateData.java index 02f8b536c..842e12c0f 100644 --- a/compiler/extensions/python/src/zserio/extension/python/EnumerationEmitterTemplateData.java +++ b/compiler/extensions/python/src/zserio/extension/python/EnumerationEmitterTemplateData.java @@ -37,8 +37,8 @@ public EnumerationEmitterTemplateData(TemplateDataContext context, EnumType enum bitSize = createBitSize(enumTypeInstantiation); final ExpressionFormatter pythonExpressionFormatter = context.getPythonExpressionFormatter(this); - runtimeFunction = RuntimeFunctionDataCreator.createData( - enumTypeInstantiation, pythonExpressionFormatter); + runtimeFunction = + RuntimeFunctionDataCreator.createData(enumTypeInstantiation, pythonExpressionFormatter); final List enumItems = enumType.getItems(); items = new ArrayList(enumItems.size()); diff --git a/compiler/extensions/python/src/zserio/extension/python/InitPyEmitter.java b/compiler/extensions/python/src/zserio/extension/python/InitPyEmitter.java index b420b5310..214a2c16f 100644 --- a/compiler/extensions/python/src/zserio/extension/python/InitPyEmitter.java +++ b/compiler/extensions/python/src/zserio/extension/python/InitPyEmitter.java @@ -56,5 +56,5 @@ private void processPackage(PackageName packageName) throws ZserioExtensionExcep private static final String INIT_PY_TEMPLATE = "__init__.py.ftl"; private static final String INIT_PY_FILENAME_ROOT = "__init__"; - private final Set processedPackages= new HashSet(); + private final Set processedPackages = new HashSet(); } diff --git a/compiler/extensions/python/src/zserio/extension/python/NativeTypeInfoTemplateData.java b/compiler/extensions/python/src/zserio/extension/python/NativeTypeInfoTemplateData.java index 7f2642440..55ea178d2 100644 --- a/compiler/extensions/python/src/zserio/extension/python/NativeTypeInfoTemplateData.java +++ b/compiler/extensions/python/src/zserio/extension/python/NativeTypeInfoTemplateData.java @@ -86,8 +86,9 @@ private NativeTypeInfoTemplateData(PythonNativeType pythonNativeType, TypeInstan TypeReference typeReference) throws ZserioExtensionException { typeFullName = PythonFullNameFormatter.getFullName(pythonNativeType); - final PythonNativeType pythonNativeBaseType = (pythonNativeType instanceof NativeSubtype) ? - ((NativeSubtype)pythonNativeType).getNativeTargetBaseType() : pythonNativeType; + final PythonNativeType pythonNativeBaseType = (pythonNativeType instanceof NativeSubtype) + ? ((NativeSubtype)pythonNativeType).getNativeTargetBaseType() + : pythonNativeType; isBuiltin = pythonNativeBaseType instanceof NativeBuiltinType; final ZserioType baseType = typeReference.getBaseTypeReference().getType(); isBytes = baseType instanceof BytesType; @@ -104,9 +105,9 @@ private NativeTypeInfoTemplateData(PythonNativeType pythonNativeType, TypeInstan } else { - hashCodeFunc = (typeInstantiation != null) ? - RuntimeFunctionDataCreator.createHashCodeData(typeInstantiation) : - RuntimeFunctionDataCreator.createHashCodeData(typeReference); + hashCodeFunc = (typeInstantiation != null) + ? RuntimeFunctionDataCreator.createHashCodeData(typeInstantiation) + : RuntimeFunctionDataCreator.createHashCodeData(typeReference); } } diff --git a/compiler/extensions/python/src/zserio/extension/python/PythonApiClashChecker.java b/compiler/extensions/python/src/zserio/extension/python/PythonApiClashChecker.java index b4577ec4f..46404379e 100644 --- a/compiler/extensions/python/src/zserio/extension/python/PythonApiClashChecker.java +++ b/compiler/extensions/python/src/zserio/extension/python/PythonApiClashChecker.java @@ -57,9 +57,10 @@ public void beginPackage(Package pkg) throws ZserioExtensionException if (id.equals(ApiEmitter.API_FILENAME_ROOT)) { ZserioToolPrinter.printError(pkg.getLocation(), - "Cannot generate python package '" + id + "' for package '" + - pkg.getPackageName() + "', since it would clash with auto-generated '" + - API_OUTPUT_FILE_NAME_LOWER_CASE + "'! Please choose different package name."); + "Cannot generate python package '" + id + "' for package '" + pkg.getPackageName() + + "', since it would clash with auto-generated '" + + API_OUTPUT_FILE_NAME_LOWER_CASE + + "'! Please choose different package name."); throw new ZserioExtensionException("Clash in generated code detected!"); } } @@ -157,9 +158,9 @@ private void checkPythonSymbolName(PackageSymbol packageSymbol, PythonNativeSymb if (outputFileName.toLowerCase(Locale.ENGLISH).equals(API_OUTPUT_FILE_NAME_LOWER_CASE)) { ZserioToolPrinter.printError(packageSymbol.getLocation(), - "Cannot generate python source '" + outputFileName + "' for symbol '" + - packageSymbol.getName() + "', since it would clash with auto-generated '" + - API_OUTPUT_FILE_NAME_LOWER_CASE + "'! Please choose different name."); + "Cannot generate python source '" + outputFileName + "' for symbol '" + + packageSymbol.getName() + "', since it would clash with auto-generated '" + + API_OUTPUT_FILE_NAME_LOWER_CASE + "'! Please choose different name."); throw new ZserioExtensionException("Clash in generated code detected!"); } } diff --git a/compiler/extensions/python/src/zserio/extension/python/PythonChoiceExpressionFormattingPolicy.java b/compiler/extensions/python/src/zserio/extension/python/PythonChoiceExpressionFormattingPolicy.java index 1a8c7bcaf..26e1eec88 100644 --- a/compiler/extensions/python/src/zserio/extension/python/PythonChoiceExpressionFormattingPolicy.java +++ b/compiler/extensions/python/src/zserio/extension/python/PythonChoiceExpressionFormattingPolicy.java @@ -8,21 +8,20 @@ */ final class PythonChoiceExpressionFormattingPolicy extends PythonExpressionFormattingPolicy { - public PythonChoiceExpressionFormattingPolicy(TemplateDataContext context, - ImportCollector importCollector) + public PythonChoiceExpressionFormattingPolicy(TemplateDataContext context, ImportCollector importCollector) { super(context, importCollector); } - public PythonChoiceExpressionFormattingPolicy(TemplateDataContext context, - ImportCollector importCollector, String accessPrefix) + public PythonChoiceExpressionFormattingPolicy( + TemplateDataContext context, ImportCollector importCollector, String accessPrefix) { super(context, importCollector, accessPrefix); } @Override - protected void formatFieldAccessor(StringBuilder result, boolean isFirstInDot, Field field, - boolean isSetter) + protected void formatFieldAccessor( + StringBuilder result, boolean isFirstInDot, Field field, boolean isSetter) { if (isFirstInDot && !isSetter) { diff --git a/compiler/extensions/python/src/zserio/extension/python/PythonDefaultEmitter.java b/compiler/extensions/python/src/zserio/extension/python/PythonDefaultEmitter.java index 6d6aab116..654d60cbc 100644 --- a/compiler/extensions/python/src/zserio/extension/python/PythonDefaultEmitter.java +++ b/compiler/extensions/python/src/zserio/extension/python/PythonDefaultEmitter.java @@ -67,8 +67,8 @@ protected void processSourceTemplate(String templateName, Object templateData, P throws ZserioExtensionException { final PythonNativeSymbol nativeSymbol = context.getPythonNativeMapper().getPythonSymbol(packageSymbol); - processTemplate(templateName, templateData, - nativeSymbol.getPackageName(), nativeSymbol.getModuleName()); + processTemplate( + templateName, templateData, nativeSymbol.getPackageName(), nativeSymbol.getModuleName()); } protected void processTemplate(String templateName, Object templateData, PackageName packageName, @@ -77,12 +77,12 @@ protected void processTemplate(String templateName, Object templateData, Package final File outDir = new File(pythonParameters.getOutputDir(), packageName.toFilesystemPath()); final File outputFile = new File(outDir, getOutputFileName(outFileNameRoot)); - final boolean generate = !outputFileManager.checkTimestamps(outputFile) || - !checkGeneratorDescription(outputFile); + final boolean generate = + !outputFileManager.checkTimestamps(outputFile) || !checkGeneratorDescription(outputFile); if (generate) { - FreeMarkerUtil.processTemplate(PYTHON_TEMPLATE_LOCATION + templateName, templateData, outputFile, - false); + FreeMarkerUtil.processTemplate( + PYTHON_TEMPLATE_LOCATION + templateName, templateData, outputFile, false); } outputFileManager.registerOutputFile(outputFile, generate); @@ -103,7 +103,7 @@ private boolean checkGeneratorDescription(File outputFile) try (final Stream lines = Files.lines(outputFile.toPath())) { final String[] generatorDescriptionCandidate = - lines.limit(generatorDescription.length).toArray(String[]::new); + lines.limit(generatorDescription.length).toArray(String[] ::new); return Arrays.equals(generatorDescription, generatorDescriptionCandidate); } catch (IOException e) diff --git a/compiler/extensions/python/src/zserio/extension/python/PythonExpressionFormattingPolicy.java b/compiler/extensions/python/src/zserio/extension/python/PythonExpressionFormattingPolicy.java index b8444bd6f..711c7fad1 100644 --- a/compiler/extensions/python/src/zserio/extension/python/PythonExpressionFormattingPolicy.java +++ b/compiler/extensions/python/src/zserio/extension/python/PythonExpressionFormattingPolicy.java @@ -11,11 +11,11 @@ import zserio.ast.Package; import zserio.ast.Parameter; import zserio.ast.ZserioType; +import zserio.extension.common.DefaultExpressionFormattingPolicy; +import zserio.extension.common.ExpressionFormattingPolicy; import zserio.extension.common.ZserioExtensionException; import zserio.extension.python.symbols.PythonNativeSymbol; import zserio.extension.python.types.PythonNativeType; -import zserio.extension.common.ExpressionFormattingPolicy; -import zserio.extension.common.DefaultExpressionFormattingPolicy; /** * Expression formatting policy for Python generator. @@ -29,8 +29,8 @@ public PythonExpressionFormattingPolicy(TemplateDataContext context, ImportColle this(context, importCollector, PYTHON_SELF_PREFIX); } - public PythonExpressionFormattingPolicy(TemplateDataContext context, ImportCollector importCollector, - String accessPrefix) + public PythonExpressionFormattingPolicy( + TemplateDataContext context, ImportCollector importCollector, String accessPrefix) { this.context = context; this.importCollector = importCollector; @@ -121,8 +121,8 @@ public String getIdentifier(Expression expr, boolean isLastInDot, boolean isSett } else if (!(resolvedSymbol instanceof Package)) { - formatSymbolIdentifier(result, symbol, expr.isMostLeftId(), resolvedSymbol, - expr.getExprZserioType(), isSetter); + formatSymbolIdentifier( + result, symbol, expr.isMostLeftId(), resolvedSymbol, expr.getExprZserioType(), isSetter); } return result.toString(); @@ -355,8 +355,8 @@ protected String getAccessPrefix() return accessPrefix; } - protected void formatFieldAccessor(StringBuilder result, boolean isMostLeftId, Field field, - boolean isSetter) + protected void formatFieldAccessor( + StringBuilder result, boolean isMostLeftId, Field field, boolean isSetter) { if (isMostLeftId) result.append(getAccessPrefix()); @@ -378,7 +378,6 @@ protected void formatParameterAccessor(StringBuilder result, boolean isMostLeftI result.append(getAccessPrefix()); result.append(AccessorNameFormatter.getPropertyName(param)); - } private void formatEnumItem(StringBuilder result, boolean isMostLeftId, EnumItem enumItem, @@ -477,8 +476,8 @@ private void formatConstant(StringBuilder result, Constant constant) throws Zser private static final class TernaryExpressionFormattingPython extends TernaryExpressionFormatting { - public TernaryExpressionFormattingPython(Expression expression, - String beforeOperand1, String afterOperand1, String afterOperand2, String afterOperand3) + public TernaryExpressionFormattingPython(Expression expression, String beforeOperand1, + String afterOperand1, String afterOperand2, String afterOperand3) { super(expression, beforeOperand1, afterOperand1, afterOperand2, afterOperand3); } diff --git a/compiler/extensions/python/src/zserio/extension/python/PythonExtension.java b/compiler/extensions/python/src/zserio/extension/python/PythonExtension.java index de51d928b..a5cd1cda0 100644 --- a/compiler/extensions/python/src/zserio/extension/python/PythonExtension.java +++ b/compiler/extensions/python/src/zserio/extension/python/PythonExtension.java @@ -30,9 +30,9 @@ public String getName() @Override public String getExtensionVersion() { - return PythonExtensionVersion.PYTHON_EXTENSION_VERSION_STRING + - " (BIN " + PythonExtensionVersion.BIN_VERSION_STRING + - ", JSON " + PythonExtensionVersion.JSON_VERSION_STRING + ")"; + return PythonExtensionVersion.PYTHON_EXTENSION_VERSION_STRING + " (BIN " + + PythonExtensionVersion.BIN_VERSION_STRING + ", JSON " + + PythonExtensionVersion.JSON_VERSION_STRING + ")"; } @Override @@ -113,7 +113,7 @@ public void process(Root rootNode, ExtensionParameters parameters) throws Zserio emitters.add(new PubsubEmitter(outputFileManager, pythonParameters, packedTypesCollector)); // emit Python code - for (PythonDefaultEmitter pythonEmitter: emitters) + for (PythonDefaultEmitter pythonEmitter : emitters) rootNode.walk(pythonEmitter); outputFileManager.printReport(); @@ -122,11 +122,8 @@ public void process(Root rootNode, ExtensionParameters parameters) throws Zserio // List of Python keywords, got from Python 3.9 keyword module: // >>> import keyword // >>> keyword.kwlist - private static final String[] PYTHON_KEYWORDS = new String[] - { - "False", "None", "True", "__peg_parser__", "and", "as", "assert", "async", "await", "break", "class", - "continue", "def", "del", "elif", "else", "except", "finally", "for", "from", "global", "if", "import", - "in", "is", "lambda", "nonlocal", "not", "or", "pass", "raise", "return", "try", "while", "with", - "yield" - }; + private static final String[] PYTHON_KEYWORDS = new String[] {"False", "None", "True", "__peg_parser__", + "and", "as", "assert", "async", "await", "break", "class", "continue", "def", "del", "elif", "else", + "except", "finally", "for", "from", "global", "if", "import", "in", "is", "lambda", "nonlocal", + "not", "or", "pass", "raise", "return", "try", "while", "with", "yield"}; } diff --git a/compiler/extensions/python/src/zserio/extension/python/PythonFullNameFormatter.java b/compiler/extensions/python/src/zserio/extension/python/PythonFullNameFormatter.java index 785c34c7b..6d2d63f43 100644 --- a/compiler/extensions/python/src/zserio/extension/python/PythonFullNameFormatter.java +++ b/compiler/extensions/python/src/zserio/extension/python/PythonFullNameFormatter.java @@ -11,8 +11,8 @@ public final class PythonFullNameFormatter { public static String getFullName(PythonNativeSymbol symbol) { - return StringJoinUtil.joinStrings(getFullName(symbol.getPackageName()), - symbol.getModuleName(), symbol.getName(), PYTHON_PACKAGE_SEPARATOR); + return StringJoinUtil.joinStrings(getFullName(symbol.getPackageName()), symbol.getModuleName(), + symbol.getName(), PYTHON_PACKAGE_SEPARATOR); } public static String getModuleFullName(PackageName packageName, String moduleName) diff --git a/compiler/extensions/python/src/zserio/extension/python/PythonGeneratedSymbolsClashChecker.java b/compiler/extensions/python/src/zserio/extension/python/PythonGeneratedSymbolsClashChecker.java index 75d8847ca..e3eb3b499 100644 --- a/compiler/extensions/python/src/zserio/extension/python/PythonGeneratedSymbolsClashChecker.java +++ b/compiler/extensions/python/src/zserio/extension/python/PythonGeneratedSymbolsClashChecker.java @@ -81,8 +81,8 @@ public void beginService(ServiceType serviceType) throws ZserioExtensionExceptio } } - private void checkCompoundType(CompoundType compoundType, - String templateSourceName) throws ZserioExtensionException + private void checkCompoundType(CompoundType compoundType, String templateSourceName) + throws ZserioExtensionException { final CompoundSymbolNameChecker symbolNameChecker = new CompoundSymbolNameChecker(compoundType, templateSourceName); @@ -115,8 +115,8 @@ private void check(ScopeSymbol scopeSymbol, String generatedName, String symbolD { ZserioToolPrinter.printError(scopeSymbol.getLocation(), "Invalid " + symbolDescription.toLowerCase(Locale.ENGLISH) + " name '" + generatedName + - "' generated for symbol '" + scopeSymbol.getName() + "'. " + - symbolDescription + " names cannot start with '_'!"); + "' generated for symbol '" + scopeSymbol.getName() + "'. " + symbolDescription + + " names cannot start with '_'!"); throw new ZserioExtensionException(symbolDescription + " name error detected!"); } } @@ -163,7 +163,7 @@ private void check(ScopeSymbol scopeSymbol, String generatedName, String symbolD { ZserioToolPrinter.printError(scopeSymbol.getLocation(), symbolDescription + " name '" + generatedName + "' generated for symbol '" + - scopeSymbol.getName() + "' clashes with generated API method!"); + scopeSymbol.getName() + "' clashes with generated API method!"); throw new ZserioExtensionException(symbolDescription + " name clash detected!"); } @@ -172,10 +172,11 @@ private void check(ScopeSymbol scopeSymbol, String generatedName, String symbolD { ZserioToolPrinter.printError(scopeSymbol.getLocation(), symbolDescription + " name '" + generatedName + "' generated for symbol '" + - scopeSymbol.getName() + "' clashes with generated indicator for optional field '" + - clashingField.getName() + "' defined at " + - clashingField.getLocation().getLine() + ":" + - clashingField.getLocation().getColumn() + "!"); + scopeSymbol.getName() + + "' clashes with generated indicator for optional field '" + + clashingField.getName() + "' defined at " + + clashingField.getLocation().getLine() + ":" + + clashingField.getLocation().getColumn() + "!"); throw new ZserioExtensionException(symbolDescription + " name clash detected!"); } } diff --git a/compiler/extensions/python/src/zserio/extension/python/PythonInnerClassesClashChecker.java b/compiler/extensions/python/src/zserio/extension/python/PythonInnerClassesClashChecker.java index f74f37e70..03affcfcc 100644 --- a/compiler/extensions/python/src/zserio/extension/python/PythonInnerClassesClashChecker.java +++ b/compiler/extensions/python/src/zserio/extension/python/PythonInnerClassesClashChecker.java @@ -32,8 +32,8 @@ public void beginBitmask(BitmaskType bitmaskType) throws ZserioExtensionExceptio if (BITMASK_INNER_CLASS_NAME.equals(className)) { ZserioToolPrinter.printError(bitmaskType.getLocation(), - "Class name '" + className + "' generated for bitmask clashes with " + - "its inner class '" + className + "' generated in Python code."); + "Class name '" + className + "' generated for bitmask clashes with " + + "its inner class '" + className + "' generated in Python code."); throw new ZserioExtensionException("Class name clash detected!"); } } @@ -45,13 +45,13 @@ public void beginSqlTable(SqlTableType sqlTableType) throws ZserioExtensionExcep if (SQL_TABLE_INNER_CLASSES_NAMES.contains(className)) { ZserioToolPrinter.printError(sqlTableType.getLocation(), - "Class name '" + className + "' generated for SQL table clashes with " + - "its inner class '" + className + "' generated in Python code."); + "Class name '" + className + "' generated for SQL table clashes with " + + "its inner class '" + className + "' generated in Python code."); throw new ZserioExtensionException("Class name clash detected!"); } } private static final String BITMASK_INNER_CLASS_NAME = "Values"; - private static final List SQL_TABLE_INNER_CLASSES_NAMES = Arrays.asList( - "IParameterProvider", "Rows"); + private static final List SQL_TABLE_INNER_CLASSES_NAMES = + Arrays.asList("IParameterProvider", "Rows"); } \ No newline at end of file diff --git a/compiler/extensions/python/src/zserio/extension/python/PythonModuleClashChecker.java b/compiler/extensions/python/src/zserio/extension/python/PythonModuleClashChecker.java index 7aad86b43..d1672c2cd 100644 --- a/compiler/extensions/python/src/zserio/extension/python/PythonModuleClashChecker.java +++ b/compiler/extensions/python/src/zserio/extension/python/PythonModuleClashChecker.java @@ -136,9 +136,10 @@ private void addSymbol(PackageSymbol packageSymbol, PythonNativeSymbol pythonNat ZserioToolPrinter.printError(packageSymbol.getLocation(), "Module '" + moduleName + "' generated for package symbol '" + packageSymbol.getName() + - "' clashes with module generated for package symbol '" + clashingPackageSymbol.getName() + - "' defined at " + clashingPackageSymbol.getLocation().getLine() + ":" + - clashingPackageSymbol.getLocation().getColumn() + "!"); + "' clashes with module generated for package symbol '" + + clashingPackageSymbol.getName() + "' defined at " + + clashingPackageSymbol.getLocation().getLine() + ":" + + clashingPackageSymbol.getLocation().getColumn() + "!"); throw new ZserioExtensionException("Module name clashing detected!"); } } @@ -157,7 +158,7 @@ private static void printErrorContext(PackageSymbol packageSymbol) { ZserioToolPrinter.printError(instantiationReference.getLocation(), " In instantiation of '" + instantiationReference.getReferencedTypeName() + - "' required from here"); + "' required from here"); } } } diff --git a/compiler/extensions/python/src/zserio/extension/python/PythonNativeMapper.java b/compiler/extensions/python/src/zserio/extension/python/PythonNativeMapper.java index 4b1591441..3723086c0 100644 --- a/compiler/extensions/python/src/zserio/extension/python/PythonNativeMapper.java +++ b/compiler/extensions/python/src/zserio/extension/python/PythonNativeMapper.java @@ -97,8 +97,8 @@ public PythonNativeType getPythonType(ZserioType type) throws ZserioExtensionExc final PythonNativeType nativeType = visitor.getPythonType(); if (nativeType == null) - throw new ZserioExtensionException("Unhandled type '" + type.getClass().getName() + - "' in PythonNativeMapper!"); + throw new ZserioExtensionException( + "Unhandled type '" + type.getClass().getName() + "' in PythonNativeMapper!"); return nativeType; } diff --git a/compiler/extensions/python/src/zserio/extension/python/PythonPackageWithModuleClashChecker.java b/compiler/extensions/python/src/zserio/extension/python/PythonPackageWithModuleClashChecker.java index 6ff6dc063..539999bd1 100644 --- a/compiler/extensions/python/src/zserio/extension/python/PythonPackageWithModuleClashChecker.java +++ b/compiler/extensions/python/src/zserio/extension/python/PythonPackageWithModuleClashChecker.java @@ -65,8 +65,8 @@ public void endRoot(Root root) throws ZserioExtensionException printErrorContext(packageSymbol); ZserioToolPrinter.printError(packageSymbol.getLocation(), "Module '" + PythonFullNameFormatter.getModuleFullName(nativeSymbol) + - "' generated for package symbol '" + packageSymbol.getName() + - "' clashes with equally named generated package!"); + "' generated for package symbol '" + packageSymbol.getName() + + "' clashes with equally named generated package!"); throw new ZserioExtensionException("Package with module name clashing detected!"); } @@ -193,7 +193,7 @@ private static void printErrorContext(PackageSymbol packageSymbol) { ZserioToolPrinter.printError(instantiationReference.getLocation(), " In instantiation of '" + instantiationReference.getReferencedTypeName() + - "' required from here"); + "' required from here"); } } } diff --git a/compiler/extensions/python/src/zserio/extension/python/PythonScopeSymbolClashChecker.java b/compiler/extensions/python/src/zserio/extension/python/PythonScopeSymbolClashChecker.java index 0f194c62c..4c822a18e 100644 --- a/compiler/extensions/python/src/zserio/extension/python/PythonScopeSymbolClashChecker.java +++ b/compiler/extensions/python/src/zserio/extension/python/PythonScopeSymbolClashChecker.java @@ -13,8 +13,8 @@ import zserio.ast.Expression; import zserio.ast.Field; import zserio.ast.ParameterizedTypeInstantiation; -import zserio.ast.PubsubType; import zserio.ast.ParameterizedTypeInstantiation.InstantiatedParameter; +import zserio.ast.PubsubType; import zserio.ast.ScopeSymbol; import zserio.ast.ServiceType; import zserio.ast.SqlDatabaseType; @@ -64,7 +64,7 @@ public void beginUnion(UnionType unionType) throws ZserioExtensionException public void beginEnumeration(EnumType enumType) throws ZserioExtensionException { final Map symbolMap = new HashMap(); - for (EnumItem enumItem: enumType.getItems()) + for (EnumItem enumItem : enumType.getItems()) { addSymbol(symbolMap, enumItem, PythonSymbolConverter.enumItemToSymbol(enumItem.getName(), enumItem.isRemoved())); @@ -149,8 +149,8 @@ private void checkExplicitParameters(SqlTableType sqlTableType) throws ZserioExt { ZserioToolPrinter.printError(paramExpression.getLocation(), "Explicit parameter '" + explicitParamName + "' clashes with '" + - prevExplicitParamName + - "' since both are generated as the same getter in Python code!"); + prevExplicitParamName + + "' since both are generated as the same getter in Python code!"); throw new ZserioExtensionException("Explicit parameter name clash detected!"); } } @@ -168,7 +168,7 @@ private void addSymbol(Map symbolMap, ScopeSymbol symbol, String { ZserioToolPrinter.printError(symbol.getLocation(), "Symbol name '" + symbol.getName() + "' clashes with '" + prevSymbolName + - "' since both are generated equally in Python code!"); + "' since both are generated equally in Python code!"); throw new ZserioExtensionException("Symbol name clash detected!"); } } diff --git a/compiler/extensions/python/src/zserio/extension/python/PythonSqlIndirectExpressionFormattingPolicy.java b/compiler/extensions/python/src/zserio/extension/python/PythonSqlIndirectExpressionFormattingPolicy.java index 44076deae..5c0960861 100644 --- a/compiler/extensions/python/src/zserio/extension/python/PythonSqlIndirectExpressionFormattingPolicy.java +++ b/compiler/extensions/python/src/zserio/extension/python/PythonSqlIndirectExpressionFormattingPolicy.java @@ -7,15 +7,15 @@ */ final class PythonSqlIndirectExpressionFormattingPolicy extends PythonExpressionFormattingPolicy { - public PythonSqlIndirectExpressionFormattingPolicy(TemplateDataContext context, - ImportCollector importCollector) + public PythonSqlIndirectExpressionFormattingPolicy( + TemplateDataContext context, ImportCollector importCollector) { super(context, importCollector); } @Override - protected void formatFieldAccessor(StringBuilder result, boolean isFirstInDot, Field field, - boolean isSetter) + protected void formatFieldAccessor( + StringBuilder result, boolean isFirstInDot, Field field, boolean isSetter) { if (isFirstInDot) result.append(AccessorNameFormatter.getSqlColumnName(field)); diff --git a/compiler/extensions/python/src/zserio/extension/python/PythonStructExpressionFormattingPolicy.java b/compiler/extensions/python/src/zserio/extension/python/PythonStructExpressionFormattingPolicy.java index 8301f1359..089031419 100644 --- a/compiler/extensions/python/src/zserio/extension/python/PythonStructExpressionFormattingPolicy.java +++ b/compiler/extensions/python/src/zserio/extension/python/PythonStructExpressionFormattingPolicy.java @@ -8,21 +8,20 @@ */ final class PythonStructExpressionFormattingPolicy extends PythonExpressionFormattingPolicy { - public PythonStructExpressionFormattingPolicy(TemplateDataContext context, - ImportCollector importCollector) + public PythonStructExpressionFormattingPolicy(TemplateDataContext context, ImportCollector importCollector) { super(context, importCollector); } - public PythonStructExpressionFormattingPolicy(TemplateDataContext context, - ImportCollector importCollector, String accessPrefix) + public PythonStructExpressionFormattingPolicy( + TemplateDataContext context, ImportCollector importCollector, String accessPrefix) { super(context, importCollector, accessPrefix); } @Override - protected void formatFieldAccessor(StringBuilder result, boolean isFirstInDot, Field field, - boolean isSetter) + protected void formatFieldAccessor( + StringBuilder result, boolean isFirstInDot, Field field, boolean isSetter) { if (isFirstInDot && !isSetter) { diff --git a/compiler/extensions/python/src/zserio/extension/python/PythonSymbolConverter.java b/compiler/extensions/python/src/zserio/extension/python/PythonSymbolConverter.java index b9fda5e91..73820e8db 100644 --- a/compiler/extensions/python/src/zserio/extension/python/PythonSymbolConverter.java +++ b/compiler/extensions/python/src/zserio/extension/python/PythonSymbolConverter.java @@ -17,7 +17,8 @@ public static String symbolToModule(String pythonSymbolName) public static String enumItemToSymbol(String enumItemName, boolean isRemoved) { - return isRemoved ? REMOVED_ENUMERATOR_PREFIX + toUpperSnakeCase(enumItemName) : toUpperSnakeCase(enumItemName); + return isRemoved ? REMOVED_ENUMERATOR_PREFIX + toUpperSnakeCase(enumItemName) + : toUpperSnakeCase(enumItemName); } public static String bitmaskValueToSymbol(String bitmaskValueName) diff --git a/compiler/extensions/python/src/zserio/extension/python/PythonTopLevelPackageClashChecker.java b/compiler/extensions/python/src/zserio/extension/python/PythonTopLevelPackageClashChecker.java index 20de2fea7..cb1bd4929 100644 --- a/compiler/extensions/python/src/zserio/extension/python/PythonTopLevelPackageClashChecker.java +++ b/compiler/extensions/python/src/zserio/extension/python/PythonTopLevelPackageClashChecker.java @@ -32,7 +32,7 @@ public void beginPackage(Package pkg) throws ZserioExtensionException { ZserioToolPrinter.printError(pkg.getLocation(), "Top level package '" + topLevelId + "' clashes with Python '" + TYPING_MODULE + - "' module which is used by generated code."); + "' module which is used by generated code."); throw new ZserioExtensionException("Top level package clash detected!"); } } diff --git a/compiler/extensions/python/src/zserio/extension/python/RuntimeFunctionDataCreator.java b/compiler/extensions/python/src/zserio/extension/python/RuntimeFunctionDataCreator.java index 02f99f989..c3be15122 100644 --- a/compiler/extensions/python/src/zserio/extension/python/RuntimeFunctionDataCreator.java +++ b/compiler/extensions/python/src/zserio/extension/python/RuntimeFunctionDataCreator.java @@ -72,8 +72,8 @@ public static RuntimeFunctionTemplateData createHashCodeData(TypeReference typeR final RuntimeFunctionTemplateData templateData = visitor.getTemplateData(); if (templateData == null) { - throw new ZserioExtensionException("Cannot map type '" + typeReference.getType().getName() + - "' in createHashCodeData!"); + throw new ZserioExtensionException( + "Cannot map type '" + typeReference.getType().getName() + "' in createHashCodeData!"); } return templateData; diff --git a/compiler/extensions/python/src/zserio/extension/python/SqlDatabaseEmitterTemplateData.java b/compiler/extensions/python/src/zserio/extension/python/SqlDatabaseEmitterTemplateData.java index b1b0d0d2e..fe583b2cd 100644 --- a/compiler/extensions/python/src/zserio/extension/python/SqlDatabaseEmitterTemplateData.java +++ b/compiler/extensions/python/src/zserio/extension/python/SqlDatabaseEmitterTemplateData.java @@ -3,18 +3,18 @@ import java.util.ArrayList; import java.util.List; -import zserio.ast.TypeInstantiation; -import zserio.ast.ZserioType; import zserio.ast.Field; import zserio.ast.SqlDatabaseType; import zserio.ast.SqlTableType; +import zserio.ast.TypeInstantiation; +import zserio.ast.ZserioType; import zserio.extension.common.ZserioExtensionException; import zserio.extension.python.types.PythonNativeType; /** * FreeMarker template data for SqlDatabaseEmitter. */ -public final class SqlDatabaseEmitterTemplateData extends UserTypeTemplateData +public final class SqlDatabaseEmitterTemplateData extends UserTypeTemplateData { public SqlDatabaseEmitterTemplateData(TemplateDataContext context, SqlDatabaseType databaseType) throws ZserioExtensionException @@ -25,7 +25,7 @@ public SqlDatabaseEmitterTemplateData(TemplateDataContext context, SqlDatabaseTy importPackage("apsw"); fields = new ArrayList(); - for (Field field: databaseType.getFields()) + for (Field field : databaseType.getFields()) fields.add(new DatabaseFieldData(context, field, this)); } @@ -36,8 +36,8 @@ public Iterable getFields() public static final class DatabaseFieldData { - public DatabaseFieldData(TemplateDataContext context, Field field, - ImportCollector importCollector) throws ZserioExtensionException + public DatabaseFieldData(TemplateDataContext context, Field field, ImportCollector importCollector) + throws ZserioExtensionException { final TypeInstantiation fieldTypeInstantiation = field.getTypeInstantiation(); final ZserioType fieldBaseType = fieldTypeInstantiation.getBaseType(); @@ -49,8 +49,9 @@ public DatabaseFieldData(TemplateDataContext context, Field field, snakeCaseName = PythonSymbolConverter.toLowerSnakeCase(name); typeInfo = new NativeTypeInfoTemplateData(nativeType, fieldTypeInstantiation); propertyName = AccessorNameFormatter.getPropertyName(field); - isWithoutRowIdTable = (fieldBaseType instanceof SqlTableType) ? - ((SqlTableType)fieldBaseType).isWithoutRowId() : false; + isWithoutRowIdTable = (fieldBaseType instanceof SqlTableType) + ? ((SqlTableType)fieldBaseType).isWithoutRowId() + : false; docComments = DocCommentsDataCreator.createData(context, field); } diff --git a/compiler/extensions/python/src/zserio/extension/python/SqlTableEmitterTemplateData.java b/compiler/extensions/python/src/zserio/extension/python/SqlTableEmitterTemplateData.java index cda61929b..f58cd4c4e 100644 --- a/compiler/extensions/python/src/zserio/extension/python/SqlTableEmitterTemplateData.java +++ b/compiler/extensions/python/src/zserio/extension/python/SqlTableEmitterTemplateData.java @@ -40,13 +40,14 @@ public SqlTableEmitterTemplateData(TemplateDataContext context, SqlTableType tab final SqlConstraint tableSqlConstraint = tableType.getSqlConstraint(); final ExpressionFormatter pythonExpressionFormatter = context.getPythonExpressionFormatter(this); - sqlConstraint = (tableSqlConstraint == null) ? null : - pythonExpressionFormatter.formatGetter(tableSqlConstraint.getConstraintExpr()); + sqlConstraint = (tableSqlConstraint == null) + ? null + : pythonExpressionFormatter.formatGetter(tableSqlConstraint.getConstraintExpr()); virtualTableUsing = tableType.getVirtualTableUsingString(); needsTypesInSchema = tableType.needsTypesInSchema(); isWithoutRowId = tableType.isWithoutRowId(); - for (Field field: tableType.getFields()) + for (Field field : tableType.getFields()) { final FieldTemplateData fieldData = new FieldTemplateData(context, tableType, field, this); fields.add(fieldData); @@ -177,16 +178,17 @@ public FieldTemplateData(TemplateDataContext context, SqlTableType parentType, F for (InstantiatedParameter instantiatedParameter : parameterizedInstantiation.getInstantiatedParameters()) { - parameters.add(new ParameterTemplateData(context, parentType, instantiatedParameter, - importCollector)); + parameters.add(new ParameterTemplateData( + context, parentType, instantiatedParameter, importCollector)); } } final SqlConstraint fieldSqlConstraint = field.getSqlConstraint(); final ExpressionFormatter pythonExpressionFormatter = context.getPythonExpressionFormatter(importCollector); - sqlConstraint = (fieldSqlConstraint == null) ? null : - pythonExpressionFormatter.formatGetter(fieldSqlConstraint.getConstraintExpr()); + sqlConstraint = (fieldSqlConstraint == null) + ? null + : pythonExpressionFormatter.formatGetter(fieldSqlConstraint.getConstraintExpr()); lambdaBitSize = createBitSize(fieldTypeInstantiation, pythonExpressionFormatter); final SqlNativeTypeMapper sqlNativeTypeMapper = new SqlNativeTypeMapper(); @@ -245,8 +247,8 @@ public static final class SqlTypeTemplateData public SqlTypeTemplateData(SqlNativeTypeMapper sqlNativeTypeMapper, Field field) throws ZserioExtensionException { - final SqlNativeType sqlNativeType = sqlNativeTypeMapper.getSqlType( - field.getTypeInstantiation()); + final SqlNativeType sqlNativeType = + sqlNativeTypeMapper.getSqlType(field.getTypeInstantiation()); name = sqlNativeType.getFullName(); isBlob = sqlNativeType instanceof NativeBlobType; } @@ -269,13 +271,12 @@ public static final class ParameterTemplateData { public ParameterTemplateData(TemplateDataContext context, SqlTableType tableType, InstantiatedParameter instantiatedParameter, ImportCollector importCollector) - throws ZserioExtensionException + throws ZserioExtensionException { final Parameter parameter = instantiatedParameter.getParameter(); final TypeReference referencedType = parameter.getTypeReference(); final PythonNativeMapper pythonNativeMapper = context.getPythonNativeMapper(); - final PythonNativeType parameterNativeType = - pythonNativeMapper.getPythonType(referencedType); + final PythonNativeType parameterNativeType = pythonNativeMapper.getPythonType(referencedType); importCollector.importType(parameterNativeType); typeInfo = new NativeTypeInfoTemplateData(parameterNativeType, referencedType); diff --git a/compiler/extensions/python/src/zserio/extension/python/StructTemplateDataContext.java b/compiler/extensions/python/src/zserio/extension/python/StructTemplateDataContext.java index f79638beb..0b888e36b 100644 --- a/compiler/extensions/python/src/zserio/extension/python/StructTemplateDataContext.java +++ b/compiler/extensions/python/src/zserio/extension/python/StructTemplateDataContext.java @@ -9,8 +9,8 @@ */ public final class StructTemplateDataContext extends TemplateDataContext { - public StructTemplateDataContext(PythonExtensionParameters pythonParameters, - PackedTypesCollector packedTypesCollector) + public StructTemplateDataContext( + PythonExtensionParameters pythonParameters, PackedTypesCollector packedTypesCollector) { super(pythonParameters, packedTypesCollector); } @@ -25,8 +25,9 @@ public ExpressionFormatter getPythonExpressionFormatter(ImportCollector importCo public ExpressionFormatter getPythonOwnerIndirectExpressionFormatter(ImportCollector importCollector) { - final ExpressionFormattingPolicy expressionFormattingPolicy = new PythonStructExpressionFormattingPolicy( - this, importCollector, TemplateDataContext.PYTHON_OWNER_PREFIX); + final ExpressionFormattingPolicy expressionFormattingPolicy = + new PythonStructExpressionFormattingPolicy( + this, importCollector, TemplateDataContext.PYTHON_OWNER_PREFIX); return new ExpressionFormatter(expressionFormattingPolicy); } diff --git a/compiler/extensions/python/src/zserio/extension/python/SubtypeEmitterTemplateData.java b/compiler/extensions/python/src/zserio/extension/python/SubtypeEmitterTemplateData.java index b80264726..6bff0f0d6 100644 --- a/compiler/extensions/python/src/zserio/extension/python/SubtypeEmitterTemplateData.java +++ b/compiler/extensions/python/src/zserio/extension/python/SubtypeEmitterTemplateData.java @@ -15,8 +15,7 @@ public SubtypeEmitterTemplateData(TemplateDataContext context, Subtype subtype) super(context, subtype, subtype); final PythonNativeMapper pythonNativeMapper = context.getPythonNativeMapper(); - final PythonNativeType nativeTargetType = - pythonNativeMapper.getPythonType(subtype.getTypeReference()); + final PythonNativeType nativeTargetType = pythonNativeMapper.getPythonType(subtype.getTypeReference()); importType(nativeTargetType); targetTypeName = PythonFullNameFormatter.getFullName(nativeTargetType); } diff --git a/compiler/extensions/python/src/zserio/extension/python/TemplateDataContext.java b/compiler/extensions/python/src/zserio/extension/python/TemplateDataContext.java index f55fe48eb..63e013aba 100644 --- a/compiler/extensions/python/src/zserio/extension/python/TemplateDataContext.java +++ b/compiler/extensions/python/src/zserio/extension/python/TemplateDataContext.java @@ -11,8 +11,8 @@ */ class TemplateDataContext { - public TemplateDataContext(PythonExtensionParameters pythonParameters, - PackedTypesCollector packedTypesCollector) + public TemplateDataContext( + PythonExtensionParameters pythonParameters, PackedTypesCollector packedTypesCollector) { this.packedTypesCollector = packedTypesCollector; pythonNativeMapper = new PythonNativeMapper(); @@ -20,11 +20,10 @@ public TemplateDataContext(PythonExtensionParameters pythonParameters, withRangeCheckCode = pythonParameters.getWithRangeCheckCode(); withTypeInfoCode = pythonParameters.getWithTypeInfoCode(); withCodeComments = pythonParameters.getWithCodeComments(); - generatorDescription = - "# Automatically generated by Zserio Python generator version " + - PythonExtensionVersion.PYTHON_EXTENSION_VERSION_STRING + " using Zserio core " + - pythonParameters.getZserioVersion() + ".\n" + - "# Generator setup: " + pythonParameters.getParametersDescription(); + generatorDescription = "# Automatically generated by Zserio Python generator version " + + PythonExtensionVersion.PYTHON_EXTENSION_VERSION_STRING + " using Zserio core " + + pythonParameters.getZserioVersion() + ".\n" + + "# Generator setup: " + pythonParameters.getParametersDescription(); } public PackedTypesCollector getPackedTypesCollector() diff --git a/compiler/extensions/python/src/zserio/extension/python/TemplateInstantiationTemplateData.java b/compiler/extensions/python/src/zserio/extension/python/TemplateInstantiationTemplateData.java index 30bf5794b..9fac7ba2e 100644 --- a/compiler/extensions/python/src/zserio/extension/python/TemplateInstantiationTemplateData.java +++ b/compiler/extensions/python/src/zserio/extension/python/TemplateInstantiationTemplateData.java @@ -18,7 +18,7 @@ public final class TemplateInstantiationTemplateData { public TemplateInstantiationTemplateData(TemplateDataContext context, ZserioTemplatableType template, List templateArguments, ImportCollector importCollector) - throws ZserioExtensionException + throws ZserioExtensionException { templateName = ZserioTypeUtil.getFullName(template); final PythonNativeMapper pythonNativeMapper = context.getPythonNativeMapper(); @@ -27,8 +27,8 @@ public TemplateInstantiationTemplateData(TemplateDataContext context, ZserioTemp { final TypeReference argumentTypeReference = templateArgument.getTypeReference(); final PythonNativeType argumentNativeType = pythonNativeMapper.getPythonType(argumentTypeReference); - templateArgumentTypeInfos.add(new NativeTypeInfoTemplateData(argumentNativeType, - argumentTypeReference)); + templateArgumentTypeInfos.add( + new NativeTypeInfoTemplateData(argumentNativeType, argumentTypeReference)); if (context.getWithTypeInfoCode()) { // imports of template arguments types are needed only in type_info diff --git a/compiler/extensions/python/src/zserio/extension/python/types/PythonNativeType.java b/compiler/extensions/python/src/zserio/extension/python/types/PythonNativeType.java index 6218b78ef..e8f447925 100644 --- a/compiler/extensions/python/src/zserio/extension/python/types/PythonNativeType.java +++ b/compiler/extensions/python/src/zserio/extension/python/types/PythonNativeType.java @@ -8,8 +8,8 @@ */ public class PythonNativeType extends PythonNativeSymbol { - protected PythonNativeType(PackageName packageName, String moduleName, String name, - NativeArrayTraits arrayTraits) + protected PythonNativeType( + PackageName packageName, String moduleName, String name, NativeArrayTraits arrayTraits) { super(packageName, moduleName, name); diff --git a/compiler/extensions/python/test/zserio/extension/python/PythonSymbolConverterTest.java b/compiler/extensions/python/test/zserio/extension/python/PythonSymbolConverterTest.java index e67d96b86..e8f5049b9 100644 --- a/compiler/extensions/python/test/zserio/extension/python/PythonSymbolConverterTest.java +++ b/compiler/extensions/python/test/zserio/extension/python/PythonSymbolConverterTest.java @@ -1,6 +1,7 @@ package zserio.extension.python; import static org.junit.jupiter.api.Assertions.assertEquals; + import org.junit.jupiter.api.Test; public class PythonSymbolConverterTest @@ -28,8 +29,10 @@ public void enumItemToSymbol() assertEquals("MY_LONG_ENUM_ITEM", PythonSymbolConverter.enumItemToSymbol("MyLongEnumItem", false)); assertEquals("MY_LONG_ENUM_ITEM", PythonSymbolConverter.enumItemToSymbol("my_long_enum_item", false)); assertEquals("MY_LONG6_ENUM_ITEM", PythonSymbolConverter.enumItemToSymbol("MyLong6EnumItem", false)); - assertEquals("MY_LONG6ACD_ENUM_ITEM", PythonSymbolConverter.enumItemToSymbol("MyLong6ACDEnumItem", false)); - assertEquals("MY_LONG_6ACD_ENUM_ITEM", PythonSymbolConverter.enumItemToSymbol("MyLong_6ACD_EnumItem", false)); + assertEquals( + "MY_LONG6ACD_ENUM_ITEM", PythonSymbolConverter.enumItemToSymbol("MyLong6ACDEnumItem", false)); + assertEquals("MY_LONG_6ACD_ENUM_ITEM", + PythonSymbolConverter.enumItemToSymbol("MyLong_6ACD_EnumItem", false)); assertEquals("ZSERIO_REMOVED_MY_LONG_ENUM_ITEM", PythonSymbolConverter.enumItemToSymbol("MY_LONG_ENUM_ITEM", true)); @@ -48,14 +51,13 @@ public void enumItemToSymbol() @Test public void bitmaskValueToSymbol() { - assertEquals("MY_LONG_BITMASK_VALUE", - PythonSymbolConverter.bitmaskValueToSymbol("MY_LONG_BITMASK_VALUE")); - assertEquals("MY_LONG_BITMASK_VALUE", - PythonSymbolConverter.bitmaskValueToSymbol("MyLongBitmaskValue")); - assertEquals("MY_LONG_BITMASK_VALUE", - PythonSymbolConverter.bitmaskValueToSymbol("my_long_bitmask_value")); - assertEquals("MY_LONG6_BITMASK_VALUE", - PythonSymbolConverter.bitmaskValueToSymbol("MyLong6BitmaskValue")); + assertEquals( + "MY_LONG_BITMASK_VALUE", PythonSymbolConverter.bitmaskValueToSymbol("MY_LONG_BITMASK_VALUE")); + assertEquals("MY_LONG_BITMASK_VALUE", PythonSymbolConverter.bitmaskValueToSymbol("MyLongBitmaskValue")); + assertEquals( + "MY_LONG_BITMASK_VALUE", PythonSymbolConverter.bitmaskValueToSymbol("my_long_bitmask_value")); + assertEquals( + "MY_LONG6_BITMASK_VALUE", PythonSymbolConverter.bitmaskValueToSymbol("MyLong6BitmaskValue")); assertEquals("MY_LONG6ACD_BITMASK_VALUE", PythonSymbolConverter.bitmaskValueToSymbol("MyLong6ACDBitmaskValue")); assertEquals("MY_LONG_6ACD_BITMASK_VALUE",