diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/Bug1429.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/Bug1429.txt index c185aa487a..b1a0d5889e 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/Bug1429.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/Bug1429.txt @@ -91,7 +91,7 @@ | +- MethodCall[@CompileTimeConstant = "false", @Image = "concat", @MethodName = "concat", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "result", @Name = "result", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- ArgumentList[@Size = "1"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = ":", @Empty = "false", @Image = "":"", @Length = "1", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = ":", @Empty = "false", @Image = "\":\"", @Length = "1", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | +- ArgumentList[@Size = "1"] | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "value", @Name = "value", @ParenthesisDepth = "0", @Parenthesized = "false"] +- ReturnStatement[] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases.txt index 51a5694e6f..6fc2e4a168 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases.txt @@ -44,7 +44,7 @@ | | | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"] | | +- ArgumentList[@Size = "1"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Outer constructor", @Empty = "false", @Image = ""Outer constructor"", @Length = "17", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Outer constructor", @Empty = "false", @Image = "\"Outer constructor\"", @Length = "17", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | +- ClassOrInterfaceDeclaration[@Abstract = "false", @Annotation = "false", @Anonymous = "false", @BinaryName = "Outer$Inner", @CanonicalName = "Outer.Inner", @EffectiveVisibility = "package", @Enum = "false", @Final = "false", @Interface = "false", @Local = "false", @Nested = "true", @PackageName = "", @PackagePrivate = "true", @Record = "false", @RegularClass = "true", @SimpleName = "Inner", @TopLevel = "false", @Visibility = "package"] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ClassOrInterfaceBody[@Size = "1"] @@ -58,7 +58,7 @@ | | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"] | +- ArgumentList[@Size = "1"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Inner constructor", @Empty = "false", @Image = ""Inner constructor"", @Length = "17", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Inner constructor", @Empty = "false", @Image = "\"Inner constructor\"", @Length = "17", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] +- ClassOrInterfaceDeclaration[@Abstract = "false", @Annotation = "false", @Anonymous = "false", @BinaryName = "Child", @CanonicalName = "Child", @EffectiveVisibility = "package", @Enum = "false", @Final = "false", @Interface = "false", @Local = "false", @Nested = "false", @PackageName = "", @PackagePrivate = "true", @Record = "false", @RegularClass = "true", @SimpleName = "Child", @TopLevel = "true", @Visibility = "package"] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ExtendsList[@Size = "1"] @@ -82,7 +82,7 @@ | | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"] | +- ArgumentList[@Size = "1"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Child constructor", @Empty = "false", @Image = ""Child constructor"", @Length = "17", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Child constructor", @Empty = "false", @Image = "\"Child constructor\"", @Length = "17", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] +- ClassOrInterfaceDeclaration[@Abstract = "false", @Annotation = "false", @Anonymous = "false", @BinaryName = "ParserCornerCases", @CanonicalName = "ParserCornerCases", @EffectiveVisibility = "public", @Enum = "false", @Final = "false", @Interface = "false", @Local = "false", @Nested = "false", @PackageName = "", @PackagePrivate = "false", @Record = "false", @RegularClass = "true", @SimpleName = "ParserCornerCases", @TopLevel = "true", @Visibility = "public"] | +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"] | +- ExtendsList[@Size = "1"] @@ -153,7 +153,7 @@ | | | +- TypeArguments[@Diamond = "false", @Size = "1"] | | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | | | +- ArgumentList[@Size = "1"] - | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "foo", @Empty = "false", @Image = ""foo"", @Length = "3", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "foo", @Empty = "false", @Image = "\"foo\"", @Length = "3", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] @@ -164,7 +164,7 @@ | | +- TypeArguments[@Diamond = "false", @Size = "1"] | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | | +- ArgumentList[@Size = "1"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "bar", @Empty = "false", @Image = ""bar"", @Length = "3", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "bar", @Empty = "false", @Image = "\"bar\"", @Length = "3", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | +- MethodDeclaration[@Abstract = "false", @Arity = "1", @EffectiveVisibility = "package", @Image = "thisGeneric", @Name = "thisGeneric", @Overridden = "false", @Varargs = "false", @Visibility = "package", @Void = "false"] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- TypeParameters[@Size = "1"] @@ -206,7 +206,7 @@ | +- MethodCall[@CompileTimeConstant = "false", @Image = "append", @MethodName = "append", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- AmbiguousName[@CompileTimeConstant = "false", @Image = "buf", @Name = "buf", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- ArgumentList[@Size = "1"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "shift ", @Empty = "false", @Image = ""shift "", @Length = "6", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "shift ", @Empty = "false", @Image = "\"shift \"", @Length = "6", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] +- ClassOrInterfaceDeclaration[@Abstract = "false", @Annotation = "false", @Anonymous = "false", @BinaryName = "PmdTestParent", @CanonicalName = "PmdTestParent", @EffectiveVisibility = "package", @Enum = "false", @Final = "false", @Interface = "false", @Local = "false", @Nested = "false", @PackageName = "", @PackagePrivate = "true", @Record = "false", @RegularClass = "true", @SimpleName = "PmdTestParent", @TopLevel = "true", @Visibility = "package"] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ClassOrInterfaceBody[@Size = "1"] @@ -295,7 +295,7 @@ | +- ExpressionStatement[] | +- AssignmentExpression[@CompileTimeConstant = "false", @Compound = "false", @Operator = "=", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- VariableAccess[@AccessType = "WRITE", @CompileTimeConstant = "false", @Image = "name", @Name = "name", @ParenthesisDepth = "0", @Parenthesized = "false"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "test", @Empty = "false", @Image = ""test"", @Length = "4", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "test", @Empty = "false", @Image = "\"test\"", @Length = "4", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] +- ClassOrInterfaceDeclaration[@Abstract = "false", @Annotation = "false", @Anonymous = "false", @BinaryName = "SimpleBeanUser2", @CanonicalName = "SimpleBeanUser2", @EffectiveVisibility = "package", @Enum = "false", @Final = "false", @Interface = "false", @Local = "false", @Nested = "false", @PackageName = "", @PackagePrivate = "true", @Record = "false", @RegularClass = "true", @SimpleName = "SimpleBeanUser2", @TopLevel = "true", @Visibility = "package"] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ExtendsList[@Size = "1"] @@ -318,7 +318,7 @@ | +- ExpressionStatement[] | +- AssignmentExpression[@CompileTimeConstant = "false", @Compound = "false", @Operator = "=", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- VariableAccess[@AccessType = "WRITE", @CompileTimeConstant = "false", @Image = "name", @Name = "name", @ParenthesisDepth = "0", @Parenthesized = "false"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "test2", @Empty = "false", @Image = ""test2"", @Length = "5", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "test2", @Empty = "false", @Image = "\"test2\"", @Length = "5", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] +- ClassOrInterfaceDeclaration[@Abstract = "false", @Annotation = "false", @Anonymous = "false", @BinaryName = "TestParseAnnototation", @CanonicalName = "TestParseAnnototation", @EffectiveVisibility = "package", @Enum = "false", @Final = "false", @Interface = "false", @Local = "false", @Nested = "false", @PackageName = "", @PackagePrivate = "true", @Record = "false", @RegularClass = "true", @SimpleName = "TestParseAnnototation", @TopLevel = "true", @Visibility = "package"] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ClassOrInterfaceBody[@Size = "1"] @@ -335,7 +335,7 @@ | | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "SuppressWarnings"] | | | | +- AnnotationMemberList[@Size = "1"] | | | | +- MemberValuePair[@Image = "value", @Name = "value", @Shorthand = "true"] - | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "unchecked", @Empty = "false", @Image = ""unchecked"", @Length = "9", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "unchecked", @Empty = "false", @Image = "\"unchecked\"", @Length = "9", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | | +- PrimitiveType[@Kind = "int"] | | | +- VariableDeclarator[@Initializer = "true", @Name = "i"] | | | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "i", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] @@ -356,7 +356,7 @@ | | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "SuppressWarnings"] | | | | +- AnnotationMemberList[@Size = "1"] | | | | +- MemberValuePair[@Image = "value", @Name = "value", @Shorthand = "true"] - | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "unchecked", @Empty = "false", @Image = ""unchecked"", @Length = "9", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "unchecked", @Empty = "false", @Image = "\"unchecked\"", @Length = "9", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "Iterator"] | | | +- VariableDeclarator[@Initializer = "true", @Name = "it"] | | | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "it", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] @@ -388,7 +388,7 @@ | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "SuppressWarnings"] | | | +- AnnotationMemberList[@Size = "1"] | | | +- MemberValuePair[@Image = "value", @Name = "value", @Shorthand = "true"] - | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "unchecked", @Empty = "false", @Image = ""unchecked"", @Length = "9", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "unchecked", @Empty = "false", @Image = "\"unchecked\"", @Length = "9", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | | +- VariableDeclarator[@Initializer = "false", @Name = "s"] | | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "s", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] @@ -439,7 +439,7 @@ | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | | +- VariableDeclarator[@Initializer = "true", @Name = "fish"] | | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "fish", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "salmon", @Empty = "false", @Image = ""salmon"", @Length = "6", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "salmon", @Empty = "false", @Image = "\"salmon\"", @Length = "6", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | +- ReturnStatement[] | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "fish", @Name = "fish", @ParenthesisDepth = "0", @Parenthesized = "false"] +- ClassOrInterfaceDeclaration[@Abstract = "false", @Annotation = "false", @Anonymous = "false", @BinaryName = "SuperTest", @CanonicalName = "SuperTest", @EffectiveVisibility = "package", @Enum = "false", @Final = "false", @Interface = "false", @Local = "false", @Nested = "false", @PackageName = "", @PackagePrivate = "true", @Record = "false", @RegularClass = "true", @SimpleName = "SuperTest", @TopLevel = "true", @Visibility = "package"] @@ -617,7 +617,7 @@ | +- Block[@Size = "0", @containsComment = "false"] +- IfStatement[@Else = "false"] | +- MethodCall[@CompileTimeConstant = "false", @Image = "equals", @MethodName = "equals", @ParenthesisDepth = "0", @Parenthesized = "false"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "a", @Empty = "false", @Image = ""a"", @Length = "1", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "a", @Empty = "false", @Image = "\"a\"", @Length = "1", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- ArgumentList[@Size = "1"] | | +- MethodCall[@CompileTimeConstant = "false", @Image = "getName", @MethodName = "getName", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- ClassLiteral[@CompileTimeConstant = "false", @ParenthesisDepth = "1", @Parenthesized = "true"] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases17.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases17.txt index 968bad85f9..698aeedd4d 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases17.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases17.txt @@ -249,7 +249,7 @@ | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | | +- VariableDeclarator[@Initializer = "true", @Name = "dayOfWeekArg"] | | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "dayOfWeekArg", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Wednesday", @Empty = "false", @Image = ""Wednesday"", @Length = "9", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Wednesday", @Empty = "false", @Image = "\"Wednesday\"", @Length = "9", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] @@ -259,44 +259,44 @@ | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "dayOfWeekArg", @Name = "dayOfWeekArg", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- SwitchFallthroughBranch[@Default = "false"] | | | +- SwitchLabel[@Default = "false"] - | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Monday", @Empty = "false", @Image = ""Monday"", @Length = "6", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Monday", @Empty = "false", @Image = "\"Monday\"", @Length = "6", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | | +- ExpressionStatement[] | | | | +- AssignmentExpression[@CompileTimeConstant = "false", @Compound = "false", @Operator = "=", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | | +- VariableAccess[@AccessType = "WRITE", @CompileTimeConstant = "false", @Image = "typeOfDay", @Name = "typeOfDay", @ParenthesisDepth = "0", @Parenthesized = "false"] - | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Start of work week", @Empty = "false", @Image = ""Start of work week"", @Length = "18", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Start of work week", @Empty = "false", @Image = "\"Start of work week\"", @Length = "18", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | | +- BreakStatement[@Label = null] | | +- SwitchFallthroughBranch[@Default = "false"] | | | +- SwitchLabel[@Default = "false"] - | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Tuesday", @Empty = "false", @Image = ""Tuesday"", @Length = "7", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Tuesday", @Empty = "false", @Image = "\"Tuesday\"", @Length = "7", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- SwitchFallthroughBranch[@Default = "false"] | | | +- SwitchLabel[@Default = "false"] - | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Wednesday", @Empty = "false", @Image = ""Wednesday"", @Length = "9", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Wednesday", @Empty = "false", @Image = "\"Wednesday\"", @Length = "9", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- SwitchFallthroughBranch[@Default = "false"] | | | +- SwitchLabel[@Default = "false"] - | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Thursday", @Empty = "false", @Image = ""Thursday"", @Length = "8", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Thursday", @Empty = "false", @Image = "\"Thursday\"", @Length = "8", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | | +- ExpressionStatement[] | | | | +- AssignmentExpression[@CompileTimeConstant = "false", @Compound = "false", @Operator = "=", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | | +- VariableAccess[@AccessType = "WRITE", @CompileTimeConstant = "false", @Image = "typeOfDay", @Name = "typeOfDay", @ParenthesisDepth = "0", @Parenthesized = "false"] - | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Midweek", @Empty = "false", @Image = ""Midweek"", @Length = "7", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Midweek", @Empty = "false", @Image = "\"Midweek\"", @Length = "7", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | | +- BreakStatement[@Label = null] | | +- SwitchFallthroughBranch[@Default = "false"] | | | +- SwitchLabel[@Default = "false"] - | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Friday", @Empty = "false", @Image = ""Friday"", @Length = "6", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Friday", @Empty = "false", @Image = "\"Friday\"", @Length = "6", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | | +- ExpressionStatement[] | | | | +- AssignmentExpression[@CompileTimeConstant = "false", @Compound = "false", @Operator = "=", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | | +- VariableAccess[@AccessType = "WRITE", @CompileTimeConstant = "false", @Image = "typeOfDay", @Name = "typeOfDay", @ParenthesisDepth = "0", @Parenthesized = "false"] - | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "End of work week", @Empty = "false", @Image = ""End of work week"", @Length = "16", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "End of work week", @Empty = "false", @Image = "\"End of work week\"", @Length = "16", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | | +- BreakStatement[@Label = null] | | +- SwitchFallthroughBranch[@Default = "false"] | | | +- SwitchLabel[@Default = "false"] - | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Saturday", @Empty = "false", @Image = ""Saturday"", @Length = "8", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Saturday", @Empty = "false", @Image = "\"Saturday\"", @Length = "8", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- SwitchFallthroughBranch[@Default = "false"] | | | +- SwitchLabel[@Default = "false"] - | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Sunday", @Empty = "false", @Image = ""Sunday"", @Length = "6", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Sunday", @Empty = "false", @Image = "\"Sunday\"", @Length = "6", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | | +- ExpressionStatement[] | | | | +- AssignmentExpression[@CompileTimeConstant = "false", @Compound = "false", @Operator = "=", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | | +- VariableAccess[@AccessType = "WRITE", @CompileTimeConstant = "false", @Image = "typeOfDay", @Name = "typeOfDay", @ParenthesisDepth = "0", @Parenthesized = "false"] - | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Weekend", @Empty = "false", @Image = ""Weekend"", @Length = "7", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Weekend", @Empty = "false", @Image = "\"Weekend\"", @Length = "7", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | | +- BreakStatement[@Label = null] | | +- SwitchFallthroughBranch[@Default = "true"] | | +- SwitchLabel[@Default = "true"] @@ -305,7 +305,7 @@ | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "IllegalArgumentException"] | | +- ArgumentList[@Size = "1"] | | +- InfixExpression[@CompileTimeConstant = "false", @Operator = "+", @ParenthesisDepth = "0", @Parenthesized = "false"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Invalid day of the week: ", @Empty = "false", @Image = ""Invalid day of the week: "", @Length = "25", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Invalid day of the week: ", @Empty = "false", @Image = "\"Invalid day of the week: \"", @Length = "25", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "dayOfWeekArg", @Name = "dayOfWeekArg", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- ReturnStatement[] | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "typeOfDay", @Name = "typeOfDay", @ParenthesisDepth = "0", @Parenthesized = "false"] @@ -358,7 +358,7 @@ | | +- MethodCall[@CompileTimeConstant = "false", @Image = "add", @MethodName = "add", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "list", @Name = "list", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- ArgumentList[@Size = "1"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "A", @Empty = "false", @Image = ""A"", @Length = "1", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "A", @Empty = "false", @Image = "\"A\"", @Length = "1", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "List"] @@ -387,7 +387,7 @@ | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "MyClass"] | | +- TypeArguments[@Diamond = "true", @Size = "0"] | +- ArgumentList[@Size = "1"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "", @Empty = "true", @Image = """", @Length = "0", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "", @Empty = "true", @Image = "\"\"", @Length = "0", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] +- MethodDeclaration[@Abstract = "false", @Arity = "0", @EffectiveVisibility = "public", @Image = "theTryWithResourcesStatement", @Name = "theTryWithResourcesStatement", @Overridden = "false", @Varargs = "false", @Visibility = "public", @Void = "true"] | +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"] | +- VoidType[] @@ -400,7 +400,7 @@ | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | | +- VariableDeclarator[@Initializer = "true", @Name = "path"] | | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "path", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "/foo", @Empty = "false", @Image = ""/foo"", @Length = "4", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "/foo", @Empty = "false", @Image = "\"/foo\"", @Length = "4", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | +- TryStatement[@TryWithResources = "true"] | | +- ResourceList[@Size = "1", @TrailingSemiColon = "false"] | | | +- Resource[@ConciseResource = "false", @StableName = "br"] @@ -430,13 +430,13 @@ | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | | +- VariableDeclarator[@Initializer = "true", @Name = "outputFileName"] | | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "outputFileName", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "/foo-out", @Empty = "false", @Image = ""/foo-out"", @Length = "8", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "/foo-out", @Empty = "false", @Image = "\"/foo-out\"", @Length = "8", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | | +- VariableDeclarator[@Initializer = "true", @Name = "zipFileName"] | | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "zipFileName", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "/foo.zip", @Empty = "false", @Image = ""/foo.zip"", @Length = "8", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "/foo.zip", @Empty = "false", @Image = "\"/foo.zip\"", @Length = "8", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- ClassOrInterfaceType[@FullyQualified = "true", @SimpleName = "Charset"] @@ -446,7 +446,7 @@ | | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | +- ClassOrInterfaceType[@FullyQualified = "true", @SimpleName = "Charset"] | | +- ArgumentList[@Size = "1"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "US-ASCII", @Empty = "false", @Image = ""US-ASCII"", @Length = "8", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "US-ASCII", @Empty = "false", @Image = "\"US-ASCII\"", @Length = "8", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- ClassOrInterfaceType[@FullyQualified = "true", @SimpleName = "Path"] @@ -508,7 +508,7 @@ | | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"] | | +- ArgumentList[@Size = "1"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "line.separator", @Empty = "false", @Image = ""line.separator"", @Length = "14", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "line.separator", @Empty = "false", @Image = "\"line.separator\"", @Length = "14", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] @@ -547,7 +547,7 @@ | | | +- ConstructorCall[@AnonymousClass = "false", @CompileTimeConstant = "false", @DiamondTypeArgs = "false", @MethodName = "new", @ParenthesisDepth = "0", @Parenthesized = "false", @QualifiedInstanceCreation = "false"] | | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "File"] | | | | +- ArgumentList[@Size = "1"] - | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "foo", @Empty = "false", @Image = ""foo"", @Length = "3", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "foo", @Empty = "false", @Image = "\"foo\"", @Length = "3", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | | +- ArgumentList[@Size = "0"] | | +- Block[@Size = "1", @containsComment = "false"] | | +- ThrowStatement[] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases18.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases18.txt index 00a3930c96..934e32b8a6 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases18.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases18.txt @@ -33,7 +33,7 @@ | | | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "f", @Name = "f", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | | +- ArgumentList[@Size = "0"] | | | +- ArgumentList[@Size = "1"] - | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = ".java", @Empty = "false", @Image = "".java"", @Length = "5", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = ".java", @Empty = "false", @Image = "\".java\"", @Length = "5", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "FileFilter"] @@ -49,7 +49,7 @@ | | | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "f", @Name = "f", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | | +- ArgumentList[@Size = "0"] | | | +- ArgumentList[@Size = "1"] - | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = ".java", @Empty = "false", @Image = "".java"", @Length = "5", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = ".java", @Empty = "false", @Image = "\".java\"", @Length = "5", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "FileFilter"] @@ -65,7 +65,7 @@ | | | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "f", @Name = "f", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | | +- ArgumentList[@Size = "0"] | | | +- ArgumentList[@Size = "1"] - | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = ".java", @Empty = "false", @Image = "".java"", @Length = "5", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = ".java", @Empty = "false", @Image = "\".java\"", @Length = "5", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "FileFilter"] @@ -81,7 +81,7 @@ | | | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "f", @Name = "f", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | | +- ArgumentList[@Size = "0"] | | | +- ArgumentList[@Size = "1"] - | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = ".java", @Empty = "false", @Image = "".java"", @Length = "5", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = ".java", @Empty = "false", @Image = "\".java\"", @Length = "5", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- ExpressionStatement[] | | | +- MethodCall[@CompileTimeConstant = "false", @Image = "forEach", @MethodName = "forEach", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | +- MethodCall[@CompileTimeConstant = "false", @Image = "parallel", @MethodName = "parallel", @ParenthesisDepth = "0", @Parenthesized = "false"] @@ -148,7 +148,7 @@ | | | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "f", @Name = "f", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | | +- ArgumentList[@Size = "0"] | | | +- ArgumentList[@Size = "1"] - | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "q", @Empty = "false", @Image = ""q"", @Length = "1", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "q", @Empty = "false", @Image = "\"q\"", @Length = "1", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- ExpressionStatement[] | | | +- MethodCall[@CompileTimeConstant = "false", @Image = "filterFiles", @MethodName = "filterFiles", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | +- ArgumentList[@Size = "1"] @@ -184,7 +184,7 @@ | | | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "f", @Name = "f", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | | +- ArgumentList[@Size = "0"] | | | +- ArgumentList[@Size = "1"] - | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "q", @Empty = "false", @Image = ""q"", @Length = "1", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "q", @Empty = "false", @Image = "\"q\"", @Length = "1", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] @@ -198,7 +198,7 @@ | | | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"] | | | +- ArgumentList[@Size = "1"] - | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "user.name", @Empty = "false", @Image = ""user.name"", @Length = "9", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "user.name", @Empty = "false", @Image = "\"user.name\"", @Length = "9", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "Callable"] @@ -208,7 +208,7 @@ | | | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "c", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] | | | +- LambdaExpression[@BlockBody = "false", @CompileTimeConstant = "false", @ExpressionBody = "true", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | +- LambdaParameterList[@Size = "0"] - | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "done", @Empty = "false", @Image = ""done"", @Length = "4", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "done", @Empty = "false", @Image = "\"done\"", @Length = "4", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "Runnable"] @@ -223,7 +223,7 @@ | | | | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"] | | | +- ArgumentList[@Size = "1"] - | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "done", @Empty = "false", @Image = ""done"", @Length = "4", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "done", @Empty = "false", @Image = "\"done\"", @Length = "4", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "Supplier"] @@ -242,7 +242,7 @@ | | | | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"] | | | +- ArgumentList[@Size = "1"] - | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "hi", @Empty = "false", @Image = ""hi"", @Length = "2", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "hi", @Empty = "false", @Image = "\"hi\"", @Length = "2", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | +- PrimitiveType[@Kind = "boolean"] @@ -282,7 +282,7 @@ | | | | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"] | | | +- ArgumentList[@Size = "1"] - | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "hi", @Empty = "false", @Image = ""hi"", @Length = "2", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "hi", @Empty = "false", @Image = "\"hi\"", @Length = "2", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- ExpressionStatement[] | | | +- MethodCall[@CompileTimeConstant = "false", @Image = "run", @MethodName = "run", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | +- FieldAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "r1", @Name = "r1", @ParenthesisDepth = "0", @Parenthesized = "false"] @@ -513,7 +513,7 @@ | | | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"] | | +- ArgumentList[@Size = "1"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "later", @Empty = "false", @Image = ""later"", @Length = "5", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "later", @Empty = "false", @Image = "\"later\"", @Length = "5", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | +- MethodDeclaration[@Abstract = "false", @Arity = "1", @EffectiveVisibility = "private", @Image = "doPrivileged", @Name = "doPrivileged", @Overridden = "false", @Varargs = "false", @Visibility = "private", @Void = "false"] | | +- ModifierList[@EffectiveModifiers = "{private}", @ExplicitModifiers = "{private}"] | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] @@ -709,7 +709,7 @@ | | | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"] | | +- ArgumentList[@Size = "1"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "run", @Empty = "false", @Image = ""run"", @Length = "3", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "run", @Empty = "false", @Image = "\"run\"", @Length = "3", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | +- MethodDeclaration[@Abstract = "false", @Arity = "0", @EffectiveVisibility = "public", @Image = "typeAnnotations", @Name = "typeAnnotations", @Overridden = "false", @Varargs = "false", @Visibility = "public", @Void = "true"] | | +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"] | | +- VoidType[] @@ -1092,4 +1092,4 @@ | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"] +- ArgumentList[@Size = "1"] - +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "", @Empty = "true", @Image = """", @Length = "0", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "", @Empty = "true", @Image = "\"\"", @Length = "0", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchStatements.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchStatements.txt index bcba0a3909..1f72870a4c 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchStatements.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchStatements.txt @@ -33,7 +33,7 @@ | | | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"] | | +- ArgumentList[@Size = "1"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "1", @Empty = "false", @Image = ""1"", @Length = "1", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "1", @Empty = "false", @Image = "\"1\"", @Length = "1", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | +- BreakStatement[@Label = null] +- SwitchFallthroughBranch[@Default = "true"] +- SwitchLabel[@Default = "true"] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java15/TextBlocks.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java15/TextBlocks.txt index 364cba52b2..63e3d9eac1 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java15/TextBlocks.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java15/TextBlocks.txt @@ -23,18 +23,7 @@ | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | +- VariableDeclarator[@Initializer = "true", @Name = "html"] | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "html", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = " - -

Hello, world

- - -", @Empty = "false", @Image = """" - - -

Hello, world

- - - """", @Length = "66", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "\n \n

Hello, world

\n \n\n", @Empty = "false", @Image = "\"\"\"\n \n \n

Hello, world

\n \n \n \"\"\"", @Length = "66", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] +- ExpressionStatement[] | +- MethodCall[@CompileTimeConstant = "false", @Image = "println", @MethodName = "println", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- FieldAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "out", @Name = "out", @ParenthesisDepth = "0", @Parenthesized = "false"] @@ -47,14 +36,7 @@ | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | +- VariableDeclarator[@Initializer = "true", @Name = "query"] | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "query", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "SELECT `EMP_ID`, `LAST_NAME` FROM `EMPLOYEE_TB` -WHERE `CITY` = 'INDIANAPOLIS' -ORDER BY `EMP_ID`, `LAST_NAME`; -", @Empty = "false", @Image = """" - SELECT `EMP_ID`, `LAST_NAME` FROM `EMPLOYEE_TB` - WHERE `CITY` = 'INDIANAPOLIS' - ORDER BY `EMP_ID`, `LAST_NAME`; - """", @Length = "110", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "SELECT `EMP_ID`, `LAST_NAME` FROM `EMPLOYEE_TB`\nWHERE `CITY` = \'INDIANAPOLIS\'\nORDER BY `EMP_ID`, `LAST_NAME`;\n", @Empty = "false", @Image = "\"\"\"\n SELECT `EMP_ID`, `LAST_NAME` FROM `EMPLOYEE_TB`\n WHERE `CITY` = \'INDIANAPOLIS\'\n ORDER BY `EMP_ID`, `LAST_NAME`;\n \"\"\"", @Length = "110", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] +- ExpressionStatement[] | +- MethodCall[@CompileTimeConstant = "false", @Image = "println", @MethodName = "println", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- FieldAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "out", @Name = "out", @ParenthesisDepth = "0", @Parenthesized = "false"] @@ -72,7 +54,7 @@ ORDER BY `EMP_ID`, `LAST_NAME`; | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "ScriptEngineManager"] | | +- ArgumentList[@Size = "0"] | +- ArgumentList[@Size = "1"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "js", @Empty = "false", @Image = ""js"", @Length = "2", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "js", @Empty = "false", @Image = "\"js\"", @Length = "2", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "Object"] @@ -81,35 +63,13 @@ ORDER BY `EMP_ID`, `LAST_NAME`; | +- MethodCall[@CompileTimeConstant = "false", @Image = "eval", @MethodName = "eval", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "engine", @Name = "engine", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- ArgumentList[@Size = "1"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "function hello() { - print('"Hello, world"'); -} - -hello(); -", @Empty = "false", @Image = """" - function hello() { - print('"Hello, world"'); - } - - hello(); - """", @Length = "60", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "function hello() {\n print(\'\"Hello, world\"\');\n}\n\nhello();\n", @Empty = "false", @Image = "\"\"\"\n function hello() {\n print(\'\"Hello, world\"\');\n }\n \n hello();\n \"\"\"", @Length = "60", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | +- VariableDeclarator[@Initializer = "true", @Name = "htmlWithEscapes"] | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "htmlWithEscapes", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = " - -

Hello, world

- - -", @Empty = "false", @Image = """" - - -

Hello, world

- - - """", @Length = "71", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "\r\n \r\n

Hello, world

\r\n \r\n\r\n", @Empty = "false", @Image = "\"\"\"\n \\r\n \\r\n

Hello, world

\\r\n \\r\n \\r\n \"\"\"", @Length = "71", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] +- ExpressionStatement[] | +- MethodCall[@CompileTimeConstant = "false", @Image = "println", @MethodName = "println", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- FieldAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "out", @Name = "out", @ParenthesisDepth = "0", @Parenthesized = "false"] @@ -122,91 +82,61 @@ hello(); | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | +- VariableDeclarator[@Initializer = "true", @Name = "season"] | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "season", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "winter", @Empty = "false", @Image = """" - winter"""", @Length = "6", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "winter", @Empty = "false", @Image = "\"\"\"\n winter\"\"\"", @Length = "6", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | +- VariableDeclarator[@Initializer = "true", @Name = "period"] | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "period", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "winter -", @Empty = "false", @Image = """" - winter - """", @Length = "7", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "winter\n", @Empty = "false", @Image = "\"\"\"\n winter\n \"\"\"", @Length = "7", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | +- VariableDeclarator[@Initializer = "true", @Name = "greeting"] | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "greeting", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Hi, "Bob" -", @Empty = "false", @Image = """" - Hi, "Bob" - """", @Length = "10", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Hi, \"Bob\"\n", @Empty = "false", @Image = "\"\"\"\n Hi, \"Bob\"\n \"\"\"", @Length = "10", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | +- VariableDeclarator[@Initializer = "true", @Name = "salutation"] | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "salutation", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Hi, - "Bob" -", @Empty = "false", @Image = """" - Hi, - "Bob" - """", @Length = "11", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Hi,\n \"Bob\"\n", @Empty = "false", @Image = "\"\"\"\n Hi,\n \"Bob\"\n \"\"\"", @Length = "11", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | +- VariableDeclarator[@Initializer = "true", @Name = "empty"] | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "empty", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "", @Empty = "true", @Image = """" - """", @Length = "0", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "", @Empty = "true", @Image = "\"\"\"\n \"\"\"", @Length = "0", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | +- VariableDeclarator[@Initializer = "true", @Name = "quote"] | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "quote", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "" -", @Empty = "false", @Image = """" - " - """", @Length = "2", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "\"\n", @Empty = "false", @Image = "\"\"\"\n \"\n \"\"\"", @Length = "2", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | +- VariableDeclarator[@Initializer = "true", @Name = "backslash"] | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "backslash", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = " -", @Empty = "false", @Image = """" - \ - """", @Length = "2", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "\\\n", @Empty = "false", @Image = "\"\"\"\n \\\\\n \"\"\"", @Length = "2", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | +- VariableDeclarator[@Initializer = "true", @Name = "normalStringLiteral"] | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "normalStringLiteral", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "test", @Empty = "false", @Image = ""test"", @Length = "4", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "test", @Empty = "false", @Image = "\"test\"", @Length = "4", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | +- VariableDeclarator[@Initializer = "true", @Name = "code"] | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "code", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "String text = """ - A text block inside a text block -"""; -", @Empty = "false", @Image = """" - String text = """ - A text block inside a text block - """; - """", @Length = "60", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "String text = \"\"\"\n A text block inside a text block\n\"\"\";\n", @Empty = "false", @Image = "\"\"\"\n String text = \\\"\"\"\n A text block inside a text block\n \\\"\"\";\n \"\"\"", @Length = "60", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | +- VariableDeclarator[@Initializer = "true", @Name = "text"] | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "text", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", @Empty = "false", @Image = """" - Lorem ipsum dolor sit amet, consectetur adipiscing - elit, sed do eiusmod tempor incididunt ut labore - et dolore magna aliqua. - """", @Length = "123", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", @Empty = "false", @Image = "\"\"\"\n Lorem ipsum dolor sit amet, consectetur adipiscing \\\n elit, sed do eiusmod tempor incididunt ut labore \\\n et dolore magna aliqua.\\\n \"\"\"", @Length = "123", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] +- ExpressionStatement[] | +- MethodCall[@CompileTimeConstant = "false", @Image = "println", @MethodName = "println", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- FieldAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "out", @Name = "out", @ParenthesisDepth = "0", @Parenthesized = "false"] @@ -219,14 +149,7 @@ hello(); | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | +- VariableDeclarator[@Initializer = "true", @Name = "colors"] | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "colors", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "red -green -blue -", @Empty = "false", @Image = """" - red s - greens - blue s - """", @Length = "21", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "red \ngreen \nblue \n", @Empty = "false", @Image = "\"\"\"\n red \\s\n green\\s\n blue \\s\n \"\"\"", @Length = "21", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] +- ExpressionStatement[] | +- MethodCall[@CompileTimeConstant = "false", @Image = "println", @MethodName = "println", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- FieldAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "out", @Name = "out", @ParenthesisDepth = "0", @Parenthesized = "false"] @@ -239,12 +162,7 @@ blue | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | +- VariableDeclarator[@Initializer = "true", @Name = "emptyLine"] | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "emptyLine", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = " -test -", @Empty = "false", @Image = """" - -test -"""", @Length = "6", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "\ntest\n", @Empty = "false", @Image = "\"\"\"\n\ntest\n\"\"\"", @Length = "6", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] +- ExpressionStatement[] | +- MethodCall[@CompileTimeConstant = "false", @Image = "println", @MethodName = "println", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- FieldAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "out", @Name = "out", @ParenthesisDepth = "0", @Parenthesized = "false"] @@ -254,19 +172,14 @@ test | +- MethodCall[@CompileTimeConstant = "false", @Image = "replaceAll", @MethodName = "replaceAll", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "emptyLine", @Name = "emptyLine", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- ArgumentList[@Size = "2"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = " -", @Empty = "false", @Image = "" -"", @Length = "1", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "", @Empty = "false", @Image = """", @Length = "4", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "\n", @Empty = "false", @Image = "\"\\n\"", @Length = "1", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "", @Empty = "false", @Image = "\"\"", @Length = "4", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | +- VariableDeclarator[@Initializer = "true", @Name = "bs"] | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "bs", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = " est -", @Empty = "false", @Image = """" - \test - """", @Length = "6", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "\\test\n", @Empty = "false", @Image = "\"\"\"\n \\\\test\n \"\"\"", @Length = "6", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "true"] +- ExpressionStatement[] +- MethodCall[@CompileTimeConstant = "false", @Image = "println", @MethodName = "println", @ParenthesisDepth = "0", @Parenthesized = "false"] +- FieldAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "out", @Name = "out", @ParenthesisDepth = "0", @Parenthesized = "false"] @@ -276,7 +189,5 @@ test +- MethodCall[@CompileTimeConstant = "false", @Image = "replaceAll", @MethodName = "replaceAll", @ParenthesisDepth = "0", @Parenthesized = "false"] +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "bs", @Name = "bs", @ParenthesisDepth = "0", @Parenthesized = "false"] +- ArgumentList[@Size = "2"] - +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = " -", @Empty = "false", @Image = "" -"", @Length = "1", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] - +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "", @Empty = "false", @Image = """", @Length = "4", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "\n", @Empty = "false", @Image = "\"\\n\"", @Length = "1", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "", @Empty = "false", @Image = "\"\"", @Length = "4", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java15p/PatternMatchingInstanceof.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java15p/PatternMatchingInstanceof.txt index 67127598d6..5853cd3aa5 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java15p/PatternMatchingInstanceof.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java15p/PatternMatchingInstanceof.txt @@ -7,7 +7,7 @@ | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | +- VariableDeclarator[@Initializer = "true", @Name = "s"] | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "s", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "other string", @Empty = "false", @Image = ""other string"", @Length = "12", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "other string", @Empty = "false", @Image = "\"other string\"", @Length = "12", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] +- MethodDeclaration[@Abstract = "false", @Arity = "0", @EffectiveVisibility = "public", @Image = "test", @Name = "test", @Overridden = "false", @Varargs = "false", @Visibility = "public", @Void = "true"] | +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"] | +- VoidType[] @@ -18,7 +18,7 @@ | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "Object"] | | +- VariableDeclarator[@Initializer = "true", @Name = "obj"] | | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "obj", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "abc", @Empty = "false", @Image = ""abc"", @Length = "3", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "abc", @Empty = "false", @Image = "\"abc\"", @Length = "3", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | +- IfStatement[@Else = "true"] | | +- InfixExpression[@CompileTimeConstant = "false", @Operator = "instanceof", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "obj", @Name = "obj", @ParenthesisDepth = "0", @Parenthesized = "false"] @@ -35,7 +35,7 @@ | | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"] | | | +- ArgumentList[@Size = "1"] | | | +- InfixExpression[@CompileTimeConstant = "false", @Operator = "+", @ParenthesisDepth = "0", @Parenthesized = "false"] - | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "a) obj == s: ", @Empty = "false", @Image = ""a) obj == s: "", @Length = "13", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "a) obj == s: ", @Empty = "false", @Image = "\"a) obj == s: \"", @Length = "13", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | | +- InfixExpression[@CompileTimeConstant = "false", @Operator = "==", @ParenthesisDepth = "1", @Parenthesized = "true"] | | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "obj", @Name = "obj", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "s", @Name = "s", @ParenthesisDepth = "0", @Parenthesized = "false"] @@ -47,7 +47,7 @@ | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"] | | +- ArgumentList[@Size = "1"] | | +- InfixExpression[@CompileTimeConstant = "false", @Operator = "+", @ParenthesisDepth = "0", @Parenthesized = "false"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "b) obj == s: ", @Empty = "false", @Image = ""b) obj == s: "", @Length = "13", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "b) obj == s: ", @Empty = "false", @Image = "\"b) obj == s: \"", @Length = "13", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- InfixExpression[@CompileTimeConstant = "false", @Operator = "==", @ParenthesisDepth = "1", @Parenthesized = "true"] | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "obj", @Name = "obj", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "s", @Name = "s", @ParenthesisDepth = "0", @Parenthesized = "false"] @@ -68,7 +68,7 @@ | | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"] | | | +- ArgumentList[@Size = "1"] | | | +- InfixExpression[@CompileTimeConstant = "false", @Operator = "+", @ParenthesisDepth = "0", @Parenthesized = "false"] - | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "c) obj == s: ", @Empty = "false", @Image = ""c) obj == s: "", @Length = "13", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "c) obj == s: ", @Empty = "false", @Image = "\"c) obj == s: \"", @Length = "13", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | | +- InfixExpression[@CompileTimeConstant = "false", @Operator = "==", @ParenthesisDepth = "1", @Parenthesized = "true"] | | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "obj", @Name = "obj", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "s", @Name = "s", @ParenthesisDepth = "0", @Parenthesized = "false"] @@ -80,7 +80,7 @@ | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"] | | +- ArgumentList[@Size = "1"] | | +- InfixExpression[@CompileTimeConstant = "false", @Operator = "+", @ParenthesisDepth = "0", @Parenthesized = "false"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "d) obj == s: ", @Empty = "false", @Image = ""d) obj == s: "", @Length = "13", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "d) obj == s: ", @Empty = "false", @Image = "\"d) obj == s: \"", @Length = "13", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- InfixExpression[@CompileTimeConstant = "false", @Operator = "==", @ParenthesisDepth = "1", @Parenthesized = "true"] | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "obj", @Name = "obj", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "s", @Name = "s", @ParenthesisDepth = "0", @Parenthesized = "false"] @@ -106,7 +106,7 @@ | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"] | | +- ArgumentList[@Size = "1"] | | +- InfixExpression[@CompileTimeConstant = "false", @Operator = "+", @ParenthesisDepth = "0", @Parenthesized = "false"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "e) obj == s: ", @Empty = "false", @Image = ""e) obj == s: "", @Length = "13", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "e) obj == s: ", @Empty = "false", @Image = "\"e) obj == s: \"", @Length = "13", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- InfixExpression[@CompileTimeConstant = "false", @Operator = "==", @ParenthesisDepth = "1", @Parenthesized = "true"] | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "obj", @Name = "obj", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "s", @Name = "s", @ParenthesisDepth = "0", @Parenthesized = "false"] @@ -132,7 +132,7 @@ | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"] | +- ArgumentList[@Size = "1"] | +- InfixExpression[@CompileTimeConstant = "false", @Operator = "+", @ParenthesisDepth = "0", @Parenthesized = "false"] - | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "f) obj == s: ", @Empty = "false", @Image = ""f) obj == s: "", @Length = "13", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "f) obj == s: ", @Empty = "false", @Image = "\"f) obj == s: \"", @Length = "13", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | +- InfixExpression[@CompileTimeConstant = "false", @Operator = "==", @ParenthesisDepth = "1", @Parenthesized = "true"] | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "obj", @Name = "obj", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "s", @Name = "s", @ParenthesisDepth = "0", @Parenthesized = "false"] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java15p/Records.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java15p/Records.txt index bad5cddde6..146428c941 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java15p/Records.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java15p/Records.txt @@ -67,7 +67,7 @@ | | | +- ConstructorCall[@AnonymousClass = "false", @CompileTimeConstant = "false", @DiamondTypeArgs = "false", @MethodName = "new", @ParenthesisDepth = "0", @Parenthesized = "false", @QualifiedInstanceCreation = "false"] | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "IllegalArgumentException"] | | | +- ArgumentList[@Size = "1"] - | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "too big", @Empty = "false", @Image = ""too big"", @Length = "7", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "too big", @Empty = "false", @Image = "\"too big\"", @Length = "7", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- ExpressionStatement[] | | | +- AssignmentExpression[@CompileTimeConstant = "false", @Compound = "false", @Operator = "=", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | +- FieldAccess[@AccessType = "WRITE", @CompileTimeConstant = "false", @Image = "real", @Name = "real", @ParenthesisDepth = "0", @Parenthesized = "false"] @@ -118,7 +118,7 @@ | | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"] | | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"] | | +- ArgumentList[@Size = "3"] - | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "(%d,%d)", @Empty = "false", @Image = ""(%d,%d)"", @Length = "7", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] + | | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "(%d,%d)", @Empty = "false", @Image = "\"(%d,%d)\"", @Length = "7", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"] | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "lo", @Name = "lo", @ParenthesisDepth = "0", @Parenthesized = "false"] | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "hi", @Name = "hi", @ParenthesisDepth = "0", @Parenthesized = "false"] | +- MethodDeclaration[@Abstract = "false", @Arity = "0", @EffectiveVisibility = "public", @Image = "foo", @Name = "foo", @Overridden = "false", @Varargs = "false", @Visibility = "public", @Void = "true"] diff --git a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/NodePrinters.kt b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/NodePrinters.kt index 44ce65c6c2..2e1c806cf3 100644 --- a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/NodePrinters.kt +++ b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/NodePrinters.kt @@ -6,8 +6,8 @@ package net.sourceforge.pmd.lang.ast.test import net.sourceforge.pmd.lang.ast.Node import net.sourceforge.pmd.lang.rule.xpath.Attribute +import net.sourceforge.pmd.util.StringUtil import net.sourceforge.pmd.util.treeexport.TextTreeRenderer -import org.apache.commons.lang3.StringEscapeUtils /** * Prints just the structure, like so: @@ -87,7 +87,7 @@ open class BaseNodeAttributePrinter : TextTreeRenderer(true, -1) { protected open fun valueToString(value: Any?): String? { return when (value) { - is String -> "\"" + StringEscapeUtils.unescapeJava(value) + "\"" + is String -> "\"" + StringUtil.escapeJava(value) + "\"" is Char -> '\''.toString() + value.toString().replace("'".toRegex(), "\\'") + '\''.toString() is Enum<*> -> value.enumDeclaringClass.simpleName + "." + value.name is Class<*> -> value.canonicalName?.let { "$it.class" } diff --git a/pmd-modelica/src/test/kotlin/net/sourceforge/pmd/lang/modelica/ast/ModelicaCoordsTest.kt b/pmd-modelica/src/test/kotlin/net/sourceforge/pmd/lang/modelica/ast/ModelicaCoordsTest.kt index bd231d4beb..b1ba99c7de 100644 --- a/pmd-modelica/src/test/kotlin/net/sourceforge/pmd/lang/modelica/ast/ModelicaCoordsTest.kt +++ b/pmd-modelica/src/test/kotlin/net/sourceforge/pmd/lang/modelica/ast/ModelicaCoordsTest.kt @@ -7,8 +7,8 @@ package net.sourceforge.pmd.lang.modelica.ast import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.should import io.kotest.matchers.shouldBe -import net.sourceforge.pmd.lang.ast.Node import net.sourceforge.pmd.lang.ast.test.matchNode +import net.sourceforge.pmd.lang.ast.test.assertPosition import net.sourceforge.pmd.lang.ast.test.shouldBe import net.sourceforge.pmd.lang.modelica.ModelicaParsingHelper @@ -29,22 +29,22 @@ end TestPackage; end EmptyPackage; end TestPackage;""" - it.assertBounds(1, 1, 4, 17) + it.assertPosition(1, 1, 4, 17) child { it::getText shouldBe """package TestPackage package EmptyPackage end EmptyPackage; end TestPackage""" - it.assertBounds(1, 1, 4, 16) + it.assertPosition(1, 1, 4, 16) child { it::getText shouldBe "package" - it.assertBounds(1, 1, 1, 8) + it.assertPosition(1, 1, 1, 8) child { it::getText shouldBe "package" - it.assertBounds(1, 1, 1, 8) + it.assertPosition(1, 1, 1, 8) } } child { @@ -52,7 +52,7 @@ end TestPackage""" package EmptyPackage end EmptyPackage; end TestPackage""" - it.assertBounds(1, 9, 4, 16) + it.assertPosition(1, 9, 4, 16) child { it::getText shouldBe """TestPackage @@ -60,56 +60,56 @@ end TestPackage""" end EmptyPackage; end TestPackage""" - it.assertBounds(1, 9, 4, 16) + it.assertPosition(1, 9, 4, 16) child { it::getText shouldBe "TestPackage" - it.assertBounds(1, 9, 1, 20) + it.assertPosition(1, 9, 1, 20) } child { it::getText shouldBe """package EmptyPackage end EmptyPackage;""" - it.assertBounds(2, 3, 3, 20) + it.assertPosition(2, 3, 3, 20) child { it::getText shouldBe """package EmptyPackage end EmptyPackage;""" - it.assertBounds(2, 3, 3, 20) + it.assertPosition(2, 3, 3, 20) child { it::getText shouldBe """package EmptyPackage end EmptyPackage""" - it.assertBounds(2, 3, 3, 19) + it.assertPosition(2, 3, 3, 19) child { it::getText shouldBe """package EmptyPackage end EmptyPackage""" - it.assertBounds(2, 3, 3, 19) + it.assertPosition(2, 3, 3, 19) it.isPartial shouldBe false child { it::getText shouldBe "package" - it.assertBounds(2, 3, 2, 10) + it.assertPosition(2, 3, 2, 10) child { it::getText shouldBe "package" - it.assertBounds(2, 3, 2, 10) + it.assertPosition(2, 3, 2, 10) } } child { it::getText shouldBe """EmptyPackage end EmptyPackage""" - it.assertBounds(2, 11, 3, 19) + it.assertPosition(2, 11, 3, 19) child { it::getText shouldBe """EmptyPackage end EmptyPackage""" - it.assertBounds(2, 11, 3, 19) + it.assertPosition(2, 11, 3, 19) it.simpleClassName shouldBe "EmptyPackage" child { it::getText shouldBe "EmptyPackage" - it.assertBounds(2, 11, 2, 23) + it.assertPosition(2, 11, 2, 23) } child { @@ -117,20 +117,20 @@ end TestPackage""" it.firstToken::isImplicit shouldBe true it.lastToken shouldBe it.firstToken - it.assertBounds(3, 3, 3, 3) + it.assertPosition(3, 3, 3, 3) child { it::getText shouldBe "" it.firstToken::isImplicit shouldBe true it.lastToken shouldBe it.firstToken - it.assertBounds(3, 3, 3, 3) + it.assertPosition(3, 3, 3, 3) } } child { it::getText shouldBe "EmptyPackage" it::getImage shouldBe "EmptyPackage" - it.assertBounds(3, 7, 3, 19) + it.assertPosition(3, 7, 3, 19) } } } @@ -140,7 +140,7 @@ end TestPackage""" } child { it::getText shouldBe "TestPackage" - it.assertBounds(4, 5, 4, 16) + it.assertPosition(4, 5, 4, 16) } } } @@ -151,10 +151,3 @@ end TestPackage""" fun String.parseModelica(): ASTStoredDefinition = ModelicaParsingHelper.DEFAULT.parse(this) - -fun Node.assertBounds(bline: Int, bcol: Int, eline: Int, ecol: Int) { - this::getBeginLine shouldBe bline - this::getBeginColumn shouldBe bcol - this::getEndLine shouldBe eline - this::getEndColumn shouldBe ecol -} diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/ast/internal/XmlParserImpl.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/ast/internal/XmlParserImpl.java index fe28b9c085..8b3928000b 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/ast/internal/XmlParserImpl.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/ast/internal/XmlParserImpl.java @@ -4,6 +4,7 @@ package net.sourceforge.pmd.lang.xml.ast.internal; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.StringReader; import java.util.HashMap; @@ -14,6 +15,7 @@ import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.w3c.dom.Node; +import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -25,6 +27,8 @@ import net.sourceforge.pmd.lang.xml.ast.XmlNode; public final class XmlParserImpl { + // never throws on unresolved resource + private static final EntityResolver SILENT_ENTITY_RESOLVER = (publicId, systemId) -> new InputSource(new ByteArrayInputStream("".getBytes())); private final Map nodeCache = new HashMap<>(); @@ -44,6 +48,7 @@ public final class XmlParserImpl { dbf.setFeature("http://xml.org/sax/features/external-general-entities", false); dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false); DocumentBuilder documentBuilder = dbf.newDocumentBuilder(); + documentBuilder.setEntityResolver(SILENT_ENTITY_RESOLVER); return documentBuilder.parse(new InputSource(new StringReader(xmlData))); } catch (ParserConfigurationException | SAXException | IOException e) { throw new ParseException(e); diff --git a/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/ast/XmlCoordinatesTest.java b/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/ast/XmlCoordinatesTest.java index 9a7ce14dba..777dc49bd1 100644 --- a/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/ast/XmlCoordinatesTest.java +++ b/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/ast/XmlCoordinatesTest.java @@ -4,14 +4,13 @@ package net.sourceforge.pmd.lang.xml.ast; -import static net.sourceforge.pmd.lang.ast.test.TestUtilsKt.assertPosition; - import org.checkerframework.checker.nullness.qual.NonNull; import org.junit.Test; import net.sourceforge.pmd.lang.ast.test.BaseParsingHelper; import net.sourceforge.pmd.lang.ast.test.BaseTreeDumpTest; import net.sourceforge.pmd.lang.ast.test.CoordinatesPrinter; +import net.sourceforge.pmd.lang.ast.test.TestUtilsKt; import net.sourceforge.pmd.lang.xml.XmlParsingHelper; public class XmlCoordinatesTest extends BaseTreeDumpTest { @@ -37,7 +36,7 @@ public class XmlCoordinatesTest extends BaseTreeDumpTest { @Test public void testAutoclosingElementLength() { final String xml = ""; - assertPosition(XmlParsingHelper.XML.parse(xml), 1, 1, 1, xml.length()); + TestUtilsKt.assertPosition(XmlParsingHelper.XML.parse(xml), 1, 1, 1, xml.length()); } } diff --git a/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/ast/XmlParserTest.java b/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/ast/XmlParserTest.java index c2dc80c646..a44de6da72 100644 --- a/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/ast/XmlParserTest.java +++ b/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/ast/XmlParserTest.java @@ -40,4 +40,29 @@ public class XmlParserTest extends BaseTreeDumpTest { public void testBug1518() { doTest("bug1518"); } + + + @Test + public void dtdIsNotLookedUp() { + // no exception should be thrown + XmlParsingHelper.XML.parse( + "" + + ""); + } + + @Test + public void xsdIsNotLookedUp() { + // no exception should be thrown + XmlParsingHelper.XML.parse( + " " + + "" + + ""); + } + + } diff --git a/pmd-xml/src/test/resources/net/sourceforge/pmd/lang/xml/ast/testdata/bug1518.txt b/pmd-xml/src/test/resources/net/sourceforge/pmd/lang/xml/ast/testdata/bug1518.txt index 238556b80b..cbb8c4a578 100644 --- a/pmd-xml/src/test/resources/net/sourceforge/pmd/lang/xml/ast/testdata/bug1518.txt +++ b/pmd-xml/src/test/resources/net/sourceforge/pmd/lang/xml/ast/testdata/bug1518.txt @@ -1,69 +1,48 @@ +- document[] +- deployment-plan[@global-variables = "false", @xmlns = "http://xmlns.oracle.com/weblogic/deployment-plan", @xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance", @xsi:schemaLocation = "http://xmlns.oracle.com/weblogic/deployment-plan http://xmlns.oracle.com/weblogic/deployment-plan/1.0/deployment-plan.xsd"] - +- text[@Image = " - "] + +- text[@Image = "\n "] +- application-name[] | +- text[@Image = "app"] - +- text[@Image = " - "] + +- text[@Image = "\n "] +- variable-definition[] - | +- text[@Image = " - "] + | +- text[@Image = "\n "] | +- variable[] - | | +- text[@Image = " - "] + | | +- text[@Image = "\n "] | | +- name[] | | | +- text[@Image = "Application_Module_Web_ContextRoot"] - | | +- text[@Image = " - "] + | | +- text[@Image = "\n "] | | +- value[@xsi:nil = "false"] | | | +- text[@Image = "ikb.adf.kreda.abw.webapp-Abnahmetest-ohne-SSO"] - | | +- text[@Image = " - "] - | +- text[@Image = " - "] - +- text[@Image = " - "] + | | +- text[@Image = "\n "] + | +- text[@Image = "\n "] + +- text[@Image = "\n "] +- module-override[] - | +- text[@Image = " - "] + | +- text[@Image = "\n "] | +- module-name[] | | +- text[@Image = "ikb.adf.kreda.abw.ear"] - | +- text[@Image = " - "] + | +- text[@Image = "\n "] | +- module-type[] | | +- text[@Image = "ear"] - | +- text[@Image = " - "] + | +- text[@Image = "\n "] | +- module-descriptor[@external = "false"] - | | +- text[@Image = " - "] + | | +- text[@Image = "\n "] | | +- root-element[] | | | +- text[@Image = "application"] - | | +- text[@Image = " - "] + | | +- text[@Image = "\n "] | | +- uri[] | | | +- text[@Image = "META-INF/application.xml"] - | | +- text[@Image = " - "] + | | +- text[@Image = "\n "] | | +- variable-assignment[] - | | | +- text[@Image = " - "] + | | | +- text[@Image = "\n "] | | | +- name[] | | | | +- text[@Image = "Application_Module_Web_ContextRoot"] - | | | +- text[@Image = " - "] + | | | +- text[@Image = "\n "] | | | +- xpath[] - | | | | +- text[@Image = "/application/module/web/[context-root="ikb.adf.kreda.abw.webapp-Local-ohne-SSO"]"] - | | | +- text[@Image = " - "] + | | | | +- text[@Image = "/application/module/web/[context-root=\"ikb.adf.kreda.abw.webapp-Local-ohne-SSO\"]"] + | | | +- text[@Image = "\n "] | | | +- operation[] | | | | +- text[@Image = "replace"] - | | | +- text[@Image = " - "] - | | +- text[@Image = " - "] - | +- text[@Image = " - "] - +- text[@Image = " -"] + | | | +- text[@Image = "\n "] + | | +- text[@Image = "\n "] + | +- text[@Image = "\n "] + +- text[@Image = "\n"] diff --git a/pmd-xml/src/test/resources/net/sourceforge/pmd/lang/xml/ast/testdata/sampleNs.txt b/pmd-xml/src/test/resources/net/sourceforge/pmd/lang/xml/ast/testdata/sampleNs.txt index 14d8a5cf04..79fe784f37 100644 --- a/pmd-xml/src/test/resources/net/sourceforge/pmd/lang/xml/ast/testdata/sampleNs.txt +++ b/pmd-xml/src/test/resources/net/sourceforge/pmd/lang/xml/ast/testdata/sampleNs.txt @@ -2,21 +2,14 @@ +- comment[] +- rootElement[] +- rootElement[] - +- text[@Image = " - "] + +- text[@Image = "\n "] +- comment[] - +- text[@Image = " - "] + +- text[@Image = "\n "] +- child1[@test = "1"] - | +- text[@Image = "entity: Copyright: PMD - "] - +- text[@Image = " - "] + | +- text[@Image = "entity: Copyright: PMD\n "] + +- text[@Image = "\n "] +- child2[] - | +- text[@Image = " - "] + | +- text[@Image = "\n "] | +- cdata-section[@Image = " cdata section "] - | +- text[@Image = " - "] - +- text[@Image = " -"] + | +- text[@Image = "\n "] + +- text[@Image = "\n"] diff --git a/pmd-xml/src/test/resources/net/sourceforge/pmd/lang/xml/ast/testdata/sampleXml.txt b/pmd-xml/src/test/resources/net/sourceforge/pmd/lang/xml/ast/testdata/sampleXml.txt index 967dc4b8a5..40035dc0ef 100644 --- a/pmd-xml/src/test/resources/net/sourceforge/pmd/lang/xml/ast/testdata/sampleXml.txt +++ b/pmd-xml/src/test/resources/net/sourceforge/pmd/lang/xml/ast/testdata/sampleXml.txt @@ -1,20 +1,13 @@ +- document[] +- pmd:rootElement[@xmlns:pmd = "http://pmd.sf.net"] - +- text[@Image = " - "] + +- text[@Image = "\n "] +- comment[] - +- text[@Image = " - "] + +- text[@Image = "\n "] +- pmd:child1[@test = "1"] - | +- text[@Image = "entity: & - "] - +- text[@Image = " - "] + | +- text[@Image = "entity: &\n "] + +- text[@Image = "\n "] +- pmd:child2[] - | +- text[@Image = " - "] + | +- text[@Image = "\n "] | +- cdata-section[@Image = " cdata section "] - | +- text[@Image = " - "] - +- text[@Image = " -"] + | +- text[@Image = "\n "] + +- text[@Image = "\n"]