From 9f9721c40b78b9e327f509ab3180f529c6897f2b Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Tue, 12 Jun 2018 10:20:51 -0700 Subject: [PATCH 01/62] introduce identifier' to accommodate MemberAccess change --- src/Language/Java/Assignment.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index ae08fd7fc..0149661fa 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -241,6 +241,7 @@ identifier = makeTerm <$> (symbol Identifier <|> symbol TypeIdentifier) <*> (Syn identifier' :: Assignment.Assignment [] Grammar Name identifier' = (symbol Identifier <|> symbol TypeIdentifier) *> (name <$> source) +-- we want a name and not a full term wrapping the same, so we match the same stuff as identifier but we just produce the name scopedIdentifier :: Assignment scopedIdentifier = makeTerm <$> symbol ScopedIdentifier <*> children (Expression.MemberAccess <$> term expression <*> identifier') From ad18271bbc5dfa17f78f4c8f0d9aae2de4c571c4 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Tue, 12 Jun 2018 11:18:52 -0700 Subject: [PATCH 02/62] alter InterfaceDeclaration syntax to accommodate extending superInterfaces --- src/Data/Syntax/Declaration.hs | 2 +- src/Language/Java/Assignment.hs | 13 +++++++++---- src/Language/TypeScript/Assignment.hs | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Data/Syntax/Declaration.hs b/src/Data/Syntax/Declaration.hs index c669a538c..b5ffafe5a 100644 --- a/src/Data/Syntax/Declaration.hs +++ b/src/Data/Syntax/Declaration.hs @@ -108,7 +108,7 @@ instance Declarations a => Declarations (VariableDeclaration a) where -- | A TypeScript/Java style interface declaration to implement. -data InterfaceDeclaration a = InterfaceDeclaration { interfaceDeclarationContext :: ![a], interfaceDeclarationIdentifier :: !a, interfaceDeclarationBody :: !a } +data InterfaceDeclaration a = InterfaceDeclaration { interfaceDeclarationContext :: ![a], interfaceDeclarationIdentifier :: !a, interfaceDeclarationSuperInterfaces :: ![a], interfaceDeclarationBody :: !a } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) instance Eq1 InterfaceDeclaration where liftEq = genericLiftEq diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 0149661fa..093bc598d 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -277,13 +277,14 @@ generic :: Assignment generic = makeTerm <$> symbol Grammar.GenericType <*> children(Java.Syntax.GenericType <$> term type' <*> manyTerm type') methodInvocation :: Assignment -methodInvocation = makeTerm <$> symbol MethodInvocation <*> children (uncurry Expression.Call <$> (callFunction <$> expression <*> optional ((,) <$ token AnonDot <*> manyTerm typeArgument <*> identifier')) <*> (argumentList <|> pure []) <*> emptyTerm) +methodInvocation = makeTerm <$> symbol MethodInvocation <*> children (uncurry Expression.Call <$> (callFunction <$> expression <*> optional ((,) <$ optional (token AnonRParen) <* token AnonDot <*> manyTerm typeArgument <*> identifier')) <*> (argumentList <|> pure []) <*> emptyTerm) where callFunction a (Just (typeArguments, b)) = (typeArguments, makeTerm1 (Expression.MemberAccess a b)) callFunction a Nothing = ([], a) + -- optional produces a Maybe type (takes a Maybe a and returns a rule that produces a Maybe a) explicitConstructorInvocation :: Assignment -explicitConstructorInvocation = makeTerm <$> symbol ExplicitConstructorInvocation <*> children (uncurry Expression.Call <$> (callFunction <$> term expression <*> optional ((,) <$ token AnonDot <*> manyTerm type' <*> identifier')) <*> argumentList <*> emptyTerm) +explicitConstructorInvocation = makeTerm <$> symbol ExplicitConstructorInvocation <*> children (uncurry Expression.Call <$> (callFunction <$> term expression <*> optional ((,) <$ optional (token AnonRParen) <* token AnonDot <*> manyTerm type' <*> identifier')) <*> argumentList <*> emptyTerm) where callFunction a (Just (typeArguments, b)) = (typeArguments, makeTerm1 (Expression.MemberAccess a b)) callFunction a Nothing = ([], a) @@ -299,11 +300,12 @@ interface :: Assignment interface = makeTerm <$> symbol InterfaceDeclaration <*> children (normal <|> annotationType) where interfaceBody = makeTerm <$> symbol InterfaceBody <*> children (manyTerm interfaceMemberDeclaration) - normal = symbol NormalInterfaceDeclaration *> children (makeInterface <$> manyTerm modifier <*> identifier <*> (typeParameters <|> pure []) <*> interfaceBody) + normal = symbol NormalInterfaceDeclaration *> children (makeInterface <$> manyTerm modifier <*> identifier <*> (typeParameters <|> pure []) <*> (extends <|> pure []) <*> interfaceBody) makeInterface modifiers identifier typeParams = Declaration.InterfaceDeclaration (modifiers ++ typeParams) identifier - annotationType = symbol AnnotationTypeDeclaration *> children (Declaration.InterfaceDeclaration [] <$> identifier <*> annotationTypeBody) + annotationType = symbol AnnotationTypeDeclaration *> children (Declaration.InterfaceDeclaration [] <$> identifier <*> pure [] <*> annotationTypeBody) annotationTypeBody = makeTerm <$> symbol AnnotationTypeBody <*> children (many expression) interfaceMemberDeclaration = symbol InterfaceMemberDeclaration *> children (term expression) + extends = symbol ExtendsInterfaces *> children (symbol InterfaceTypeList *> children (manyTerm type')) package :: Assignment package = makeTerm <$> symbol PackageDeclaration <*> children (Java.Syntax.Package <$> someTerm expression) @@ -510,10 +512,13 @@ constructorDeclaration = makeTerm <$> symbol ConstructorDeclaration <*> children typeParameters :: Assignment.Assignment [] Grammar [Term] typeParameters = symbol TypeParameters *> children (manyTerm typeParam) +-- not making a term, just matching children and returning the whole list +-- unpacking the TypeParameters node where typeParam = makeTerm <$> symbol Grammar.TypeParameter <*> children (Java.Syntax.TypeParameter <$> manyTerm annotation <*> term identifier <*> (typeBound <|> pure [])) typeBound = symbol TypeBound *> children (manyTerm type') + annotation :: Assignment annotation = makeTerm <$> symbol NormalAnnotation <*> children (Java.Syntax.Annotation <$> term expression <*> (elementValuePairList <|> pure [])) <|> makeTerm <$> symbol MarkerAnnotation <*> children (Java.Syntax.Annotation <$> term expression <*> pure []) diff --git a/src/Language/TypeScript/Assignment.hs b/src/Language/TypeScript/Assignment.hs index 79a13c9bc..9e3f4d4fd 100644 --- a/src/Language/TypeScript/Assignment.hs +++ b/src/Language/TypeScript/Assignment.hs @@ -718,8 +718,8 @@ enumAssignment :: Assignment enumAssignment = makeTerm <$> symbol Grammar.EnumAssignment <*> children (Statement.Assignment [] <$> term propertyName <*> term expression) interfaceDeclaration :: Assignment -interfaceDeclaration = makeInterfaceDecl <$> symbol Grammar.InterfaceDeclaration <*> children ((,,,) <$> term identifier <*> (term typeParameters <|> emptyTerm) <*> (term extendsClause <|> emptyTerm) <*> term objectType) - where makeInterfaceDecl loc (identifier, typeParams, clause, objectType) = makeTerm loc (Declaration.InterfaceDeclaration [typeParams, clause] identifier objectType) +interfaceDeclaration = makeInterfaceDecl <$> symbol Grammar.InterfaceDeclaration <*> children ((,,,) <$> term identifier <*> (term typeParameters <|> emptyTerm) <*> optional (term extendsClause) <*> term objectType) + where makeInterfaceDecl loc (identifier, typeParams, clause, objectType) = makeTerm loc (Declaration.InterfaceDeclaration [typeParams] identifier (toList clause) objectType) ambientDeclaration :: Assignment ambientDeclaration = makeTerm <$> symbol Grammar.AmbientDeclaration <*> children (TypeScript.Syntax.AmbientDeclaration <$> term (choice [declaration, statementBlock])) From e02cad9ce283ef5eed9d01970658b12e06d8d335 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Tue, 12 Jun 2018 11:46:50 -0700 Subject: [PATCH 03/62] assign nested parentheses :( --- src/Language/Java/Assignment.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 093bc598d..7534739b8 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -403,7 +403,7 @@ enhancedFor = makeTerm <$> symbol EnhancedForStatement <*> children (Statement.F -- TODO: instanceOf binary :: Assignment -binary = makeTerm' <$> symbol BinaryExpression <*> children (infixTerm expression expression +binary = makeTerm' <$> symbol BinaryExpression <*> children (infixTerm expressionAndParens expressionAndParens [ (inject .) . Expression.LessThan <$ symbol AnonLAngle , (inject .) . Expression.GreaterThan <$ symbol AnonRAngle , (inject .) . Expression.Equal <$ symbol AnonEqualEqual @@ -425,7 +425,11 @@ binary = makeTerm' <$> symbol BinaryExpression <*> children (infixTerm expressio , (inject .) . Expression.DividedBy <$ symbol AnonSlash , (inject .) . Expression.InstanceOf <$ symbol AnonInstanceof ]) - where invert cons a b = Expression.Not (makeTerm1 (cons a b)) + where + invert cons a b = Expression.Not (makeTerm1 (cons a b)) + expressionAndParens = token AnonLParen *> expressionAndParens <* token AnonRParen <|> expression + -- TODO: expressionAndParens is a hack that accommodates Java's nested parens case but + -- altering the TreeSitter Java grammar is a better longer term goal. -- | Match infix terms separated by any of a list of operators, assigning any comments following each operand. infixTerm :: HasCallStack From 94038d70a7f9cc092137045ff2fb908143b3302e Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Tue, 26 Jun 2018 14:05:04 -0400 Subject: [PATCH 04/62] add staticInitializer assignment --- src/Language/Java/Assignment.hs | 19 +++++-------------- src/Language/Java/Syntax.hs | 10 ++++++++++ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 7cf24073a..6ecf787b5 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -55,6 +55,7 @@ type Syntax = , Java.Syntax.New , Java.Syntax.Package , Java.Syntax.SpreadParameter + , Java.Syntax.StaticInitializer , Java.Syntax.Synchronized , Java.Syntax.TypeParameter , Java.Syntax.TypeWithModifiers @@ -172,6 +173,7 @@ expressionChoices = , string , super , switch + , staticInitializer , synchronized , ternary , this @@ -256,10 +258,9 @@ class' = makeTerm <$> symbol ClassDeclaration <*> children (makeClass <$> many m makeClass modifiers identifier typeParams superClass superInterfaces = Declaration.Class (modifiers <> typeParams) identifier (maybeToList superClass <> superInterfaces) -- not doing an assignment, just straight up function classBody = makeTerm <$> symbol ClassBody <*> children (manyTerm expression) superClass = symbol Superclass *> children type' --- TODO: superclass --- need to match the superclass node when it exists (which will be a rule, similar to how the type params rule matches the typeparams node when it exists) --- optional, when we have a single term --- superInterfaces is also optional but since it produces a list, lists already have an empty value so we don't need to wrap it up in a maybe to get an empty value + +staticInitializer :: Assignment +staticInitializer = makeTerm <$> symbol Grammar.StaticInitializer <*> children (Java.Syntax.StaticInitializer <$> block) fieldDeclaration :: Assignment fieldDeclaration = makeTerm <$> symbol FieldDeclaration <*> children ((,) <$> manyTerm modifier <*> type' <**> variableDeclaratorList) @@ -300,19 +301,9 @@ interface :: Assignment interface = makeTerm <$> symbol InterfaceDeclaration <*> children (normal <|> annotationType) where interfaceBody = makeTerm <$> symbol InterfaceBody <*> children (manyTerm interfaceMemberDeclaration) -<<<<<<< HEAD normal = symbol NormalInterfaceDeclaration *> children (makeInterface <$> manyTerm modifier <*> identifier <*> (typeParameters <|> pure []) <*> (extends <|> pure []) <*> interfaceBody) makeInterface modifiers identifier typeParams = Declaration.InterfaceDeclaration (modifiers ++ typeParams) identifier annotationType = symbol AnnotationTypeDeclaration *> children (Declaration.InterfaceDeclaration [] <$> identifier <*> pure [] <*> annotationTypeBody) -||||||| merged common ancestors - normal = symbol NormalInterfaceDeclaration *> children (makeInterface <$> manyTerm modifier <*> identifier <*> (typeParameters <|> pure []) <*> interfaceBody) - makeInterface modifiers identifier typeParams = Declaration.InterfaceDeclaration (modifiers ++ typeParams) identifier - annotationType = symbol AnnotationTypeDeclaration *> children (Declaration.InterfaceDeclaration [] <$> identifier <*> annotationTypeBody) -======= - normal = symbol NormalInterfaceDeclaration *> children (makeInterface <$> manyTerm modifier <*> identifier <*> (typeParameters <|> pure []) <*> interfaceBody) - makeInterface modifiers identifier typeParams = Declaration.InterfaceDeclaration (modifiers <> typeParams) identifier - annotationType = symbol AnnotationTypeDeclaration *> children (Declaration.InterfaceDeclaration [] <$> identifier <*> annotationTypeBody) ->>>>>>> master annotationTypeBody = makeTerm <$> symbol AnnotationTypeBody <*> children (many expression) interfaceMemberDeclaration = symbol InterfaceMemberDeclaration *> children (term expression) extends = symbol ExtendsInterfaces *> children (symbol InterfaceTypeList *> children (manyTerm type')) diff --git a/src/Language/Java/Syntax.hs b/src/Language/Java/Syntax.hs index 8ffac8839..f947d771c 100644 --- a/src/Language/Java/Syntax.hs +++ b/src/Language/Java/Syntax.hs @@ -177,3 +177,13 @@ instance Show1 SpreadParameter where liftShowsPrec = genericLiftShowsPrec -- TODO: Implement Eval instance for SpreadParameter instance Evaluatable SpreadParameter + +data StaticInitializer a = StaticInitializer { staticInitializerBlock :: !a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + + +instance Eq1 StaticInitializer where liftEq = genericLiftEq +instance Ord1 StaticInitializer where liftCompare = genericLiftCompare +instance Show1 StaticInitializer where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable StaticInitializer From 0d22d7df1c704715c5716dad8ce58226df91bb2a Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Tue, 26 Jun 2018 14:12:32 -0400 Subject: [PATCH 05/62] Revert "Redefine boolean using toTerm/branchNode/leafNode." This reverts commit 695453169c15b064705e11a5f422f5850a59034b. --- src/Language/Java/Assignment.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 6ecf787b5..7f1e44594 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -217,9 +217,9 @@ variableDeclaratorId = symbol VariableDeclaratorId *> children identifier -- Literals boolean :: Assignment -boolean = toTerm (branchNode BooleanLiteral - ( leafNode Grammar.True $> Literal.true - <|> leafNode Grammar.False $> Literal.false)) +boolean = makeTerm <$> symbol BooleanLiteral <*> children + (token Grammar.True $> Literal.true + <|> token Grammar.False $> Literal.false) null' :: Assignment null' = makeTerm <$> symbol NullLiteral <*> (Literal.Null <$ source) From af2edde7a163f4005775a58c40ae07ba22c3c1a5 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Tue, 26 Jun 2018 14:13:20 -0400 Subject: [PATCH 06/62] Revert "Redefine module' using toTerm/branchNode." This reverts commit 1e0a7c23fa345ee6bfd46cf1e17bcdc244cb10fb. --- src/Language/Java/Assignment.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 7f1e44594..650bdd6f9 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -291,7 +291,7 @@ explicitConstructorInvocation = makeTerm <$> symbol ExplicitConstructorInvocatio callFunction a Nothing = ([], a) module' :: Assignment -module' = toTerm (branchNode ModuleDeclaration (Java.Syntax.Module <$> expression <*> many expression)) +module' = makeTerm <$> symbol ModuleDeclaration <*> children (Java.Syntax.Module <$> expression <*> many expression) import' :: Assignment import' = makeTerm <$> symbol ImportDeclaration <*> children (Java.Syntax.Import <$> someTerm (expression <|> asterisk)) From 76088c54b7ce9b52bf18740b8b88a76c757fb9b3 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Tue, 26 Jun 2018 14:24:15 -0400 Subject: [PATCH 07/62] add scopedTypeIdentifier --- src/Language/Java/Assignment.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 650bdd6f9..f31e6dc1e 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -333,6 +333,7 @@ type' = choice [ , symbol ArrayType *> children (array <$> type' <*> dims) -- type rule recurs into itself , symbol CatchType *> children (term type') , symbol ExceptionType *> children (term type') + , makeTerm <$> symbol ScopedTypeIdentifier <*> children (Expression.MemberAccess <$> term type' <*> identifier') , wildcard , identifier , generic From 809c7b643a5df95699242fcd686e6864de84ee87 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Wed, 27 Jun 2018 16:10:56 -0400 Subject: [PATCH 08/62] assign methodReference and add NewKeyword --- src/Language/Java/Assignment.hs | 13 +++++++++++++ src/Language/Java/Syntax.hs | 21 +++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index f31e6dc1e..d8297ea17 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -51,8 +51,10 @@ type Syntax = , Java.Syntax.EnumDeclaration , Java.Syntax.GenericType , Java.Syntax.Import + , Java.Syntax.MethodReference , Java.Syntax.Module , Java.Syntax.New + , Java.Syntax.NewKeyword , Java.Syntax.Package , Java.Syntax.SpreadParameter , Java.Syntax.StaticInitializer @@ -165,6 +167,7 @@ expressionChoices = , integer , method , methodInvocation + , methodReference , module' , null' , package @@ -284,6 +287,13 @@ methodInvocation = makeTerm <$> symbol MethodInvocation <*> children (uncurry Ex callFunction a Nothing = ([], a) -- optional produces a Maybe type (takes a Maybe a and returns a rule that produces a Maybe a) +methodReference :: Assignment +methodReference = makeTerm <$> symbol Grammar.MethodReference <*> children (Java.Syntax.MethodReference <$> term type' <* token AnonColonColon <*> manyTerm type' <*> (new <|> term identifier)) + where new = makeTerm <$> token AnonNew <*> pure NewKeyword +-- can't do term identifier' because identifier' returns a name, not a term, and we want a term +-- <*> - left assoc +-- manyTerm or alternation with pure + explicitConstructorInvocation :: Assignment explicitConstructorInvocation = makeTerm <$> symbol ExplicitConstructorInvocation <*> children (uncurry Expression.Call <$> (callFunction <$> term expression <*> optional ((,) <$ optional (token AnonRParen) <* token AnonDot <*> manyTerm type' <*> identifier')) <*> argumentList <*> emptyTerm) where @@ -499,6 +509,9 @@ classInstance = makeTerm <$> symbol ClassInstanceCreationExpression <*> children argumentList :: Assignment.Assignment [] Grammar [Term] argumentList = symbol ArgumentList *> children (manyTerm expression) +-- this takes care of expression, expression, ..., expression +-- but does this take care of parenthesized argumentList (it's a separate rule in TS) +-- I think methodReference being a top-level expression now will make manyTerm expression recognize this super :: Assignment super = makeTerm <$> token Super <*> pure Expression.Super diff --git a/src/Language/Java/Syntax.hs b/src/Language/Java/Syntax.hs index f947d771c..428ca508c 100644 --- a/src/Language/Java/Syntax.hs +++ b/src/Language/Java/Syntax.hs @@ -187,3 +187,24 @@ instance Ord1 StaticInitializer where liftCompare = genericLiftCompare instance Show1 StaticInitializer where liftShowsPrec = genericLiftShowsPrec instance Evaluatable StaticInitializer + +-- I think this is wrong because it doesn't acknowledge double colon. +data MethodReference a = MethodReference { methodReferenceType :: !a, methodReferenceTypeArgs :: ![a], methodReferenceIdentifier :: !a} + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 MethodReference where liftEq = genericLiftEq +instance Ord1 MethodReference where liftCompare = genericLiftCompare +instance Show1 MethodReference where liftShowsPrec = genericLiftShowsPrec + +-- TODO: Implement Eval instance for TypeWithModifiers +instance Evaluatable MethodReference + +data NewKeyword a = NewKeyword + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 NewKeyword where liftEq = genericLiftEq +instance Ord1 NewKeyword where liftCompare = genericLiftCompare +instance Show1 NewKeyword where liftShowsPrec = genericLiftShowsPrec + +-- TODO: Implement Eval instance for TypeWithModifiers +instance Evaluatable NewKeyword From 27e1f0a3755bddb41986b9fe5f64bbe8a09183a2 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Wed, 27 Jun 2018 16:21:02 -0400 Subject: [PATCH 09/62] new world order that simplifies assignment type signature --- src/Language/Java/Assignment.hs | 162 ++++++++++++++++---------------- 1 file changed, 81 insertions(+), 81 deletions(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index e1a6db7ea..4871c9648 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -105,37 +105,37 @@ type Syntax = ] type Term = Term.Term (Sum Syntax) (Record Location) -type Assignment = Assignment.Assignment [] Grammar Term +type Assignment = Assignment.Assignment [] Grammar -- | Assignment from AST in Java's grammar onto a program in Java's syntax. -assignment :: Assignment +assignment :: Assignment Term assignment = handleError $ makeTerm <$> symbol Grammar.Program <*> children (Statement.Statements <$> manyTerm expression) <|> parseError -- | Match a term optionally preceded by comment(s), or a sequence of comments if the term is not present. -manyTerm :: Assignment -> Assignment.Assignment [] Grammar [Term] +manyTerm :: Assignment Term -> Assignment [Term] manyTerm term = many (contextualize comment term <|> makeTerm1 <$> (Syntax.Context <$> some1 comment <*> emptyTerm)) -- | Match a series of terms or comments until a delimiter is matched. -manyTermsTill :: Assignment.Assignment [] Grammar Term - -> Assignment.Assignment [] Grammar b - -> Assignment.Assignment [] Grammar [Term] +manyTermsTill :: Assignment Term + -> Assignment b + -> Assignment [Term] manyTermsTill step = manyTill (step <|> comment) -someTerm :: Assignment -> Assignment.Assignment [] Grammar [Term] +someTerm :: Assignment Term -> Assignment [Term] someTerm term = some (contextualize comment term <|> makeTerm1 <$> (Syntax.Context <$> some1 comment <*> emptyTerm)) -- | Match comments before and after the node. -term :: Assignment -> Assignment +term :: Assignment Term -> Assignment Term term term = contextualize comment (postContextualize comment term) -- | Match -expression :: Assignment +expression :: Assignment Term expression = handleError (choice expressionChoices) -expressions :: Assignment +expressions :: Assignment Term expressions = makeTerm'' <$> location <*> many expression -expressionChoices :: [Assignment.Assignment [] Grammar Term] +expressionChoices :: [Assignment Term] expressionChoices = [ arrayInitializer @@ -188,22 +188,22 @@ expressionChoices = , while ] -modifier :: Assignment +modifier :: Assignment Term modifier = make <$> symbol Modifier <*> children(Left <$> annotation <|> Right . Syntax.AccessibilityModifier <$> source) where make loc (Right modifier) = makeTerm loc modifier make _ (Left annotation) = annotation -arrayInitializer :: Assignment +arrayInitializer :: Assignment Term arrayInitializer = makeTerm <$> symbol ArrayInitializer <*> (Literal.Array <$> many expression) -comment :: Assignment +comment :: Assignment Term comment = makeTerm <$> symbol Comment <*> (Comment.Comment <$> source) -localVariableDeclaration :: Assignment +localVariableDeclaration :: Assignment Term localVariableDeclaration = makeTerm <$> symbol LocalVariableDeclaration <*> children ((,) <$> manyTerm modifier <*> type' <**> variableDeclaratorList) -variableDeclaratorList :: Assignment.Assignment [] Grammar (([Term], Term) -> [Term]) +variableDeclaratorList :: Assignment (([Term], Term) -> [Term]) variableDeclaratorList = symbol VariableDeclaratorList *> children (makeDecl <$> some variableDeclarator) where variableDeclarator = symbol VariableDeclarator *> children ((,) <$> variableDeclaratorId <*> optional expression) @@ -211,63 +211,63 @@ variableDeclaratorList = symbol VariableDeclaratorList *> children (makeDecl <$> makeSingleDecl modifiers type' (target, Nothing) = makeTerm1 (Java.Syntax.Variable modifiers type' target) makeSingleDecl modifiers type' (target, Just value) = makeTerm1 (Statement.Assignment [] (makeTerm1 (Java.Syntax.Variable modifiers type' target)) value) -localVariableDeclarationStatement :: Assignment +localVariableDeclarationStatement :: Assignment Term localVariableDeclarationStatement = symbol LocalVariableDeclarationStatement *> children localVariableDeclaration -variableDeclaratorId :: Assignment +variableDeclaratorId :: Assignment Term variableDeclaratorId = symbol VariableDeclaratorId *> children identifier -- Literals -boolean :: Assignment +boolean :: Assignment Term boolean = makeTerm <$> symbol BooleanLiteral <*> children (token Grammar.True $> Literal.true <|> token Grammar.False $> Literal.false) -null' :: Assignment +null' :: Assignment Term null' = makeTerm <$> symbol NullLiteral <*> (Literal.Null <$ source) -- Integer supports all integer and floating point literals (hex, octal, binary) -integer :: Assignment +integer :: Assignment Term integer = makeTerm <$> symbol IntegerLiteral <*> children (Literal.Integer <$> source) -float :: Assignment +float :: Assignment Term float = makeTerm <$> symbol FloatingPointLiteral <*> children (Literal.Float <$> source) -string :: Assignment +string :: Assignment Term string = makeTerm <$> symbol StringLiteral <*> (Literal.TextElement <$> source) -char :: Assignment +char :: Assignment Term char = makeTerm <$> symbol CharacterLiteral <*> (Literal.TextElement <$> source) -- Identifiers -identifier :: Assignment +identifier :: Assignment Term identifier = makeTerm <$> (symbol Identifier <|> symbol TypeIdentifier) <*> (Syntax.Identifier . name <$> source) -identifier' :: Assignment.Assignment [] Grammar Name +identifier' :: Assignment Name identifier' = (symbol Identifier <|> symbol TypeIdentifier) *> (name <$> source) -- we want a name and not a full term wrapping the same, so we match the same stuff as identifier but we just produce the name -scopedIdentifier :: Assignment +scopedIdentifier :: Assignment Term scopedIdentifier = makeTerm <$> symbol ScopedIdentifier <*> children (Expression.MemberAccess <$> term expression <*> identifier') -superInterfaces :: Assignment.Assignment [] Grammar [Term] +superInterfaces :: Assignment [Term] superInterfaces = symbol SuperInterfaces *> children (symbol InterfaceTypeList *> children(manyTerm type')) -- Declarations -class' :: Assignment +class' :: Assignment Term class' = makeTerm <$> symbol ClassDeclaration <*> children (makeClass <$> many modifier <*> term identifier <*> (typeParameters <|> pure []) <*> optional superClass <*> (superInterfaces <|> pure []) <*> classBody) where makeClass modifiers identifier typeParams superClass superInterfaces = Declaration.Class (modifiers <> typeParams) identifier (maybeToList superClass <> superInterfaces) -- not doing an assignment, just straight up function classBody = makeTerm <$> symbol ClassBody <*> children (manyTerm expression) superClass = symbol Superclass *> children type' -staticInitializer :: Assignment +staticInitializer :: Assignment Term staticInitializer = makeTerm <$> symbol Grammar.StaticInitializer <*> children (Java.Syntax.StaticInitializer <$> block) -fieldDeclaration :: Assignment +fieldDeclaration :: Assignment Term fieldDeclaration = makeTerm <$> symbol FieldDeclaration <*> children ((,) <$> manyTerm modifier <*> type' <**> variableDeclaratorList) -method :: Assignment +method :: Assignment Term method = makeTerm <$> symbol MethodDeclaration <*> children (makeMethod <$> many modifier <*> emptyTerm <*> methodHeader <*> methodBody) where methodBody = symbol MethodBody *> children (term expression <|> emptyTerm) @@ -276,37 +276,37 @@ method = makeTerm <$> symbol MethodDeclaration <*> children (makeMethod <$> many makeMethod modifiers receiver (typeParams, annotations, returnType, (name, params), throws) = Declaration.Method (returnType : modifiers <> typeParams <> annotations <> throws) receiver name params -- methodHeader needs to include typeParameters (it does) -generic :: Assignment +generic :: Assignment Term generic = makeTerm <$> symbol Grammar.GenericType <*> children(Java.Syntax.GenericType <$> term type' <*> manyTerm type') -methodInvocation :: Assignment +methodInvocation :: Assignment Term methodInvocation = makeTerm <$> symbol MethodInvocation <*> children (uncurry Expression.Call <$> (callFunction <$> expression <*> optional ((,) <$ optional (token AnonRParen) <* token AnonDot <*> manyTerm typeArgument <*> identifier')) <*> (argumentList <|> pure []) <*> emptyTerm) where callFunction a (Just (typeArguments, b)) = (typeArguments, makeTerm1 (Expression.MemberAccess a b)) callFunction a Nothing = ([], a) -- optional produces a Maybe type (takes a Maybe a and returns a rule that produces a Maybe a) -methodReference :: Assignment +methodReference :: Assignment Term methodReference = makeTerm <$> symbol Grammar.MethodReference <*> children (Java.Syntax.MethodReference <$> term type' <* token AnonColonColon <*> manyTerm type' <*> (new <|> term identifier)) where new = makeTerm <$> token AnonNew <*> pure NewKeyword -- can't do term identifier' because identifier' returns a name, not a term, and we want a term -- <*> - left assoc -- manyTerm or alternation with pure -explicitConstructorInvocation :: Assignment +explicitConstructorInvocation :: Assignment Term explicitConstructorInvocation = makeTerm <$> symbol ExplicitConstructorInvocation <*> children (uncurry Expression.Call <$> (callFunction <$> term expression <*> optional ((,) <$ optional (token AnonRParen) <* token AnonDot <*> manyTerm type' <*> identifier')) <*> argumentList <*> emptyTerm) where callFunction a (Just (typeArguments, b)) = (typeArguments, makeTerm1 (Expression.MemberAccess a b)) callFunction a Nothing = ([], a) -module' :: Assignment +module' :: Assignment Term module' = makeTerm <$> symbol ModuleDeclaration <*> children (Java.Syntax.Module <$> expression <*> many expression) -import' :: Assignment +import' :: Assignment Term import' = makeTerm <$> symbol ImportDeclaration <*> children (Java.Syntax.Import <$> someTerm (expression <|> asterisk)) where asterisk = makeTerm <$> token Grammar.Asterisk <*> pure Java.Syntax.Asterisk -interface :: Assignment +interface :: Assignment Term interface = makeTerm <$> symbol InterfaceDeclaration <*> children (normal <|> annotationType) where interfaceBody = makeTerm <$> symbol InterfaceBody <*> children (manyTerm interfaceMemberDeclaration) @@ -317,23 +317,23 @@ interface = makeTerm <$> symbol InterfaceDeclaration <*> children (normal <|> an interfaceMemberDeclaration = symbol InterfaceMemberDeclaration *> children (term expression) extends = symbol ExtendsInterfaces *> children (symbol InterfaceTypeList *> children (manyTerm type')) -package :: Assignment +package :: Assignment Term package = makeTerm <$> symbol PackageDeclaration <*> children (Java.Syntax.Package <$> someTerm expression) -enum :: Assignment +enum :: Assignment Term enum = makeTerm <$> symbol Grammar.EnumDeclaration <*> children (Java.Syntax.EnumDeclaration <$> manyTerm modifier <*> term identifier <*> (superInterfaces <|> pure []) <*> manyTerm enumConstant <*> (enumBodyDeclarations <|> pure [])) where enumConstant = symbol EnumConstant *> children (term identifier) enumBodyDeclarations = symbol EnumBodyDeclarations *> children (manyTerm expression) -return' :: Assignment +return' :: Assignment Term return' = makeTerm <$> symbol ReturnStatement <*> (Statement.Return <$> children (expression <|> emptyTerm)) -- method expressions -dims :: Assignment.Assignment [] Grammar [Term] +dims :: Assignment [Term] dims = symbol Dims *> children (many (emptyTerm <* token AnonLBracket <* token AnonRBracket)) -type' :: Assignment +type' :: Assignment Term type' = choice [ makeTerm <$> token VoidType <*> pure Type.Void , makeTerm <$> token IntegralType <*> pure Type.Int @@ -350,43 +350,43 @@ type' = choice [ ] where array = foldl (\into each -> makeTerm1 (Type.Array (Just each) into)) -typeArgument :: Assignment +typeArgument :: Assignment Term typeArgument = symbol TypeArgument *> children (term type') -wildcard :: Assignment +wildcard :: Assignment Term wildcard = makeTerm <$> symbol Grammar.Wildcard <*> children (Java.Syntax.Wildcard <$> manyTerm annotation <*> optional (super <|> extends)) where super = makeTerm <$> token Super <*> (Java.Syntax.WildcardBoundSuper <$> type') extends = makeTerm1 <$> (Java.Syntax.WildcardBoundExtends <$> type') -if' :: Assignment +if' :: Assignment Term if' = makeTerm <$> symbol IfThenElseStatement <*> children (Statement.If <$> term expression <*> term expression <*> (term expression <|> emptyTerm)) -block :: Assignment +block :: Assignment Term block = makeTerm <$> symbol Block <*> children (manyTerm expression) -while :: Assignment +while :: Assignment Term while = makeTerm <$> symbol WhileStatement <*> children (Statement.While <$> term expression <*> term expression) -doWhile :: Assignment +doWhile :: Assignment Term doWhile = makeTerm <$> symbol DoStatement <*> children (flip Statement.DoWhile <$> term expression <*> term expression) -switch :: Assignment +switch :: Assignment Term switch = makeTerm <$> symbol SwitchStatement <*> children (Statement.Match <$> term expression <*> switchBlock) where switchBlock = makeTerm <$> symbol SwitchBlock <*> children (manyTerm switchLabel) switchLabel = makeTerm <$> symbol SwitchLabel <*> (Statement.Pattern <$> children (term expression <|> emptyTerm) <*> expressions) -break :: Assignment +break :: Assignment Term break = makeTerm <$> symbol BreakStatement <*> children (Statement.Break <$> (term expression <|> emptyTerm)) -continue :: Assignment +continue :: Assignment Term continue = makeTerm <$> symbol ContinueStatement <*> children (Statement.Continue <$> (term expression <|> emptyTerm)) -throw :: Assignment +throw :: Assignment Term throw = makeTerm <$> symbol ThrowStatement <*> children (Statement.Throw <$> term expression) -try :: Assignment +try :: Assignment Term try = makeTerm <$> symbol TryStatement <*> children (Statement.Try <$> term expression <*> (append <$> optional catches <*> optional finally)) where catches = symbol Catches *> children (manyTerm catch) @@ -399,21 +399,21 @@ try = makeTerm <$> symbol TryStatement <*> children (Statement.Try <$> term expr append (Just a) Nothing = a append (Just a) (Just b) = a <> [b] -for :: Assignment +for :: Assignment Term for = symbol ForStatement *> children (basicFor <|> enhancedFor) -basicFor :: Assignment +basicFor :: Assignment Term basicFor = makeTerm <$> symbol BasicForStatement <*> children (Statement.For <$ token AnonFor <* token AnonLParen <*> (token AnonSemicolon *> emptyTerm <|> forInit <* token AnonSemicolon) <*> (token AnonSemicolon *> emptyTerm <|> term expression <* token AnonSemicolon) <*> forStep <*> term expression) where forInit = symbol ForInit *> children (term expression) forStep = makeTerm <$> location <*> manyTermsTill expression (token AnonRParen) -enhancedFor :: Assignment +enhancedFor :: Assignment Term enhancedFor = makeTerm <$> symbol EnhancedForStatement <*> children (Statement.ForEach <$> (variable <$> manyTerm modifier <*> type' <*> variableDeclaratorId) <*> term expression <*> term expression) where variable modifiers type' variableDeclaratorId = makeTerm1 (Java.Syntax.Variable modifiers type' variableDeclaratorId) -- TODO: instanceOf -binary :: Assignment +binary :: Assignment Term binary = makeTerm' <$> symbol BinaryExpression <*> children (infixTerm expressionAndParens expressionAndParens [ (inject .) . Expression.LessThan <$ symbol AnonLAngle , (inject .) . Expression.GreaterThan <$ symbol AnonRAngle @@ -443,13 +443,13 @@ binary = makeTerm' <$> symbol BinaryExpression <*> children (infixTerm expressio -- altering the TreeSitter Java grammar is a better longer term goal. -- | Match infix terms separated by any of a list of operators, assigning any comments following each operand. -infixTerm :: Assignment - -> Assignment - -> [Assignment.Assignment [] Grammar (Term -> Term -> Sum Syntax Term)] - -> Assignment.Assignment [] Grammar (Sum Syntax Term) +infixTerm :: Assignment Term + -> Assignment Term + -> [Assignment (Term -> Term -> Sum Syntax Term)] + -> Assignment (Sum Syntax Term) infixTerm = infixContext comment -assignment' :: Assignment +assignment' :: Assignment Term assignment' = makeTerm' <$> symbol AssignmentExpression <*> children (infixTerm lhs expression [ (inject .) . Statement.Assignment [] <$ symbol AnonEqual , assign Expression.Plus <$ symbol AnonPlusEqual @@ -475,7 +475,7 @@ data UnaryType | UBang | UTilde -unary :: Assignment +unary :: Assignment Term unary = make <$> symbol UnaryExpression <*> children ((,) <$> operator <*> term expression) where make _ (UPlus, operand) = operand @@ -487,39 +487,39 @@ unary = make <$> symbol UnaryExpression <*> children ((,) <$> operator <*> term <|> token AnonBang $> UBang <|> token AnonTilde $> UTilde -update :: Assignment +update :: Assignment Term update = makeTerm' <$> symbol UpdateExpression <*> children ( inject . Statement.PreIncrement <$ token AnonPlusPlus <*> term expression <|> inject . Statement.PreDecrement <$ token AnonMinusMinus <*> term expression <|> inject . Statement.PostIncrement <$> term expression <* token AnonPlusPlus <|> inject . Statement.PostDecrement <$> term expression <* token AnonMinusMinus) -ternary :: Assignment +ternary :: Assignment Term ternary = makeTerm <$> symbol TernaryExpression <*> children (Statement.If <$> term expression <*> term expression <*> term expression) -synchronized :: Assignment +synchronized :: Assignment Term synchronized = makeTerm <$> symbol SynchronizedStatement <*> children (Java.Syntax.Synchronized <$> term expression <*> term expression) -classInstance :: Assignment +classInstance :: Assignment Term classInstance = makeTerm <$> symbol ClassInstanceCreationExpression <*> children unqualified where unqualified = symbol UnqualifiedClassInstanceCreationExpression *> children (Java.Syntax.New <$> type' <*> (argumentList <|> pure [])) -argumentList :: Assignment.Assignment [] Grammar [Term] +argumentList :: Assignment [Term] argumentList = symbol ArgumentList *> children (manyTerm expression) -- this takes care of expression, expression, ..., expression -- but does this take care of parenthesized argumentList (it's a separate rule in TS) -- I think methodReference being a top-level expression now will make manyTerm expression recognize this -super :: Assignment +super :: Assignment Term super = makeTerm <$> token Super <*> pure Expression.Super -- INCORRECT: super = makeTerm <$> token Super $> Expression.Super -- Take partially applied function and replace it instead of applying -this :: Assignment +this :: Assignment Term this = makeTerm <$> token This <*> pure Expression.This -constructorDeclaration :: Assignment +constructorDeclaration :: Assignment Term constructorDeclaration = makeTerm <$> symbol ConstructorDeclaration <*> children ( constructor <$> manyTerm modifier <*> constructorDeclarator <*> (throws <|> pure []) <*> constructorBody) where @@ -527,7 +527,7 @@ constructorDeclaration = makeTerm <$> symbol ConstructorDeclaration <*> children constructorBody = makeTerm <$> symbol ConstructorBody <*> children (manyTerm expression) -- wrapping list of terms up in single node constructor modifiers (typeParameters, identifier, formalParameters) = Java.Syntax.Constructor modifiers typeParameters identifier formalParameters -- let partial application do its thing -typeParameters :: Assignment.Assignment [] Grammar [Term] +typeParameters :: Assignment [Term] typeParameters = symbol TypeParameters *> children (manyTerm typeParam) -- not making a term, just matching children and returning the whole list -- unpacking the TypeParameters node @@ -536,7 +536,7 @@ typeParameters = symbol TypeParameters *> children (manyTerm typeParam) typeBound = symbol TypeBound *> children (manyTerm type') -annotation :: Assignment +annotation :: Assignment Term annotation = makeTerm <$> symbol NormalAnnotation <*> children (Java.Syntax.Annotation <$> term expression <*> (elementValuePairList <|> pure [])) <|> makeTerm <$> symbol MarkerAnnotation <*> children (Java.Syntax.Annotation <$> term expression <*> pure []) <|> makeTerm <$> symbol SingleElementAnnotation <*> children (Java.Syntax.Annotation <$> term expression <*> (pure <$> term elementValue)) @@ -545,28 +545,28 @@ annotation = makeTerm <$> symbol NormalAnnotation <*> children (Java.Syntax.Anno elementValuePair = makeTerm <$> symbol ElementValuePair <*> children (Java.Syntax.AnnotationField <$> term expression <*> term elementValue) elementValue = symbol ElementValue *> children (term expression) -throws :: Assignment.Assignment [] Grammar [Term] +throws :: Assignment [Term] throws = symbol Throws *> children (symbol ExceptionTypeList *> children(manyTerm type')) -formalParameters :: Assignment.Assignment [] Grammar [Term] +formalParameters :: Assignment [Term] formalParameters = manyTerm (parameter <|> spreadParameter) where parameter = makeTerm <$> symbol FormalParameter <*> children (makeAnnotation <$> manyTerm modifier <*> type' <* symbol VariableDeclaratorId <*> children identifier) makeAnnotation [] type' variableName = Type.Annotation variableName type' makeAnnotation modifiers type' variableName = Type.Annotation variableName (makeTerm1 (Java.Syntax.TypeWithModifiers modifiers type')) -castExpression :: Assignment +castExpression :: Assignment Term castExpression = makeTerm <$> symbol CastExpression <*> children (flip Type.Annotation <$> type' <*> term expression) -fieldAccess :: Assignment +fieldAccess :: Assignment Term fieldAccess = makeTerm <$> symbol FieldAccess <*> children (Expression.MemberAccess <$> term expression <*> identifier') -spreadParameter :: Assignment +spreadParameter :: Assignment Term spreadParameter = makeTerm <$> symbol Grammar.SpreadParameter <*> children (Java.Syntax.SpreadParameter <$> (makeSingleDecl <$> manyTerm modifier <*> type' <*> variableDeclarator)) where variableDeclarator = symbol VariableDeclarator *> children ((,) <$> variableDeclaratorId <*> optional expression) makeSingleDecl modifiers type' (target, Nothing) = makeTerm1 (Java.Syntax.Variable modifiers type' target) makeSingleDecl modifiers type' (target, Just value) = makeTerm1 (Statement.Assignment [] (makeTerm1 (Java.Syntax.Variable modifiers type' target)) value) -arrayAccess :: Assignment +arrayAccess :: Assignment Term arrayAccess = makeTerm <$> symbol ArrayAccess <*> children (Expression.Subscript <$> term expression <*> manyTerm expression) From 81ce713c200de3188e96c8ce744cd88da027fd0e Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Wed, 27 Jun 2018 17:18:36 -0400 Subject: [PATCH 10/62] methodReference test --- test/fixtures/java/corpus/methodReference.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 test/fixtures/java/corpus/methodReference.java diff --git a/test/fixtures/java/corpus/methodReference.java b/test/fixtures/java/corpus/methodReference.java new file mode 100644 index 000000000..2f104cbd4 --- /dev/null +++ b/test/fixtures/java/corpus/methodReference.java @@ -0,0 +1,11 @@ +class TermsSetQueryBuilder { + void Terms() { + min = read(Script::new); + } +} + +class TermsSetQueryBuilder { + void Terms() { + min = read(Script::yodawg); + } +} From 2880d01e5b1a8756e192764197480e73cf9ad41c Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Wed, 27 Jun 2018 17:26:12 -0400 Subject: [PATCH 11/62] type arg test --- test/fixtures/java/corpus/type-argument.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 test/fixtures/java/corpus/type-argument.java diff --git a/test/fixtures/java/corpus/type-argument.java b/test/fixtures/java/corpus/type-argument.java new file mode 100644 index 000000000..10b339657 --- /dev/null +++ b/test/fixtures/java/corpus/type-argument.java @@ -0,0 +1,5 @@ +class Dinosaur { + void apply() { + (T1)a[0]; + } +} From 1fbe1ad77d980b7cedad90206f641e6293491699 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Wed, 27 Jun 2018 17:26:38 -0400 Subject: [PATCH 12/62] add scopedIdentifier test --- test/fixtures/java/corpus/scoped-identifier.java | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 test/fixtures/java/corpus/scoped-identifier.java diff --git a/test/fixtures/java/corpus/scoped-identifier.java b/test/fixtures/java/corpus/scoped-identifier.java new file mode 100644 index 000000000..cd3bf1f04 --- /dev/null +++ b/test/fixtures/java/corpus/scoped-identifier.java @@ -0,0 +1,3 @@ +static final class EventLoopWorker extends Scheduler.Worker { + + } From 290f5f0a6df6f64e9fd1af5bd47d299c8c2ca636 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Wed, 27 Jun 2018 17:26:58 -0400 Subject: [PATCH 13/62] add memberAccess test --- test/fixtures/java/corpus/member-access.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 test/fixtures/java/corpus/member-access.java diff --git a/test/fixtures/java/corpus/member-access.java b/test/fixtures/java/corpus/member-access.java new file mode 100644 index 000000000..16946a2d6 --- /dev/null +++ b/test/fixtures/java/corpus/member-access.java @@ -0,0 +1,5 @@ +class Natural { + int compare(Object a, Object b) { + (a).compareTo(b); + } +} From e5c9be8648ef7f6b48bbee85a4c7b4b1c2aae1a5 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Mon, 9 Jul 2018 18:49:56 -0400 Subject: [PATCH 14/62] syntax data type for lambda expression --- src/Language/Java/Assignment.hs | 11 +++++++++-- src/Language/Java/Syntax.hs | 9 +++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 980c337e1..51bd53ee7 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -73,6 +73,7 @@ type Syntax = , Java.Syntax.EnumDeclaration , Java.Syntax.GenericType , Java.Syntax.Import + , Java.Syntax.Lambda , Java.Syntax.MethodReference , Java.Syntax.Module , Java.Syntax.New @@ -187,6 +188,7 @@ expressionChoices = , identifier , import' , integer + , lambda , method , methodInvocation , methodReference @@ -313,8 +315,8 @@ methodReference :: Assignment Term methodReference = makeTerm <$> symbol Grammar.MethodReference <*> children (Java.Syntax.MethodReference <$> term type' <* token AnonColonColon <*> manyTerm type' <*> (new <|> term identifier)) where new = makeTerm <$> token AnonNew <*> pure NewKeyword -- can't do term identifier' because identifier' returns a name, not a term, and we want a term --- <*> - left assoc --- manyTerm or alternation with pure +-- <*> - left assoc so when you have a token that you need to match but not retain, +-- manyTerm or alternation with pure, but not bowf explicitConstructorInvocation :: Assignment Term explicitConstructorInvocation = makeTerm <$> symbol ExplicitConstructorInvocation <*> children (uncurry Expression.Call <$> (callFunction <$> term expression <*> optional ((,) <$ optional (token AnonRParen) <* token AnonDot <*> manyTerm type' <*> identifier')) <*> argumentList <*> emptyTerm) @@ -593,3 +595,8 @@ spreadParameter = makeTerm <$> symbol Grammar.SpreadParameter <*> children (Java arrayAccess :: Assignment Term arrayAccess = makeTerm <$> symbol ArrayAccess <*> children (Expression.Subscript <$> term expression <*> manyTerm expression) + +lambda :: Assignment Term +lambda = makeTerm <$> symbol LambdaExpression <*> children (Java.Syntax.Lambda <$> term expression <* token AnonMinusRAngle <*> term expression) +-- The current error occurs when a lambda expression is the argument in the argument for a method; +-- If it is exposed at the top-level, lambdas will be referenced in expressionChoices diff --git a/src/Language/Java/Syntax.hs b/src/Language/Java/Syntax.hs index 428ca508c..7211a8ef8 100644 --- a/src/Language/Java/Syntax.hs +++ b/src/Language/Java/Syntax.hs @@ -208,3 +208,12 @@ instance Show1 NewKeyword where liftShowsPrec = genericLiftShowsPrec -- TODO: Implement Eval instance for TypeWithModifiers instance Evaluatable NewKeyword + +data Lambda a = Lambda { lambdaHead :: !a, lambdaBody :: !a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 Lambda where liftEq = genericLiftEq +instance Ord1 Lambda where liftCompare = genericLiftCompare +instance Show1 Lambda where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable Lambda From 15514a8ebb4554ac9d431b5595acd6906eb7609a Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Wed, 11 Jul 2018 16:57:21 -0400 Subject: [PATCH 15/62] back to master's vendor effects --- vendor/effects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/effects b/vendor/effects index 8181375d6..105a543cc 160000 --- a/vendor/effects +++ b/vendor/effects @@ -1 +1 @@ -Subproject commit 8181375d6386de302a8c9807dad2f096e8d490aa +Subproject commit 105a543ccc98f2929cf0b1f1e97bcc48dfb8f718 From 7a7f197caa069a4d56ec494a6786b2bcc06f10c4 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Wed, 11 Jul 2018 17:12:56 -0400 Subject: [PATCH 16/62] back to master's version of haskell-tree-sitter --- vendor/haskell-tree-sitter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/haskell-tree-sitter b/vendor/haskell-tree-sitter index 6176c8c8e..9ada8cc48 160000 --- a/vendor/haskell-tree-sitter +++ b/vendor/haskell-tree-sitter @@ -1 +1 @@ -Subproject commit 6176c8c8e7c59760a881a2487d81bcbdb26efe9c +Subproject commit 9ada8cc48be1a25b971aca1a49c0963897c09d7c From 6ac04c9589a554b9a9d76b15a6c7814f876cca76 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Thu, 12 Jul 2018 12:29:40 -0400 Subject: [PATCH 17/62] parse lambda expressions --- src/Language/Java/Assignment.hs | 7 ++++--- src/Language/Java/Syntax.hs | 11 ++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 51bd53ee7..344d657bc 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -74,6 +74,7 @@ type Syntax = , Java.Syntax.GenericType , Java.Syntax.Import , Java.Syntax.Lambda + , Java.Syntax.LambdaBody , Java.Syntax.MethodReference , Java.Syntax.Module , Java.Syntax.New @@ -597,6 +598,6 @@ arrayAccess :: Assignment Term arrayAccess = makeTerm <$> symbol ArrayAccess <*> children (Expression.Subscript <$> term expression <*> manyTerm expression) lambda :: Assignment Term -lambda = makeTerm <$> symbol LambdaExpression <*> children (Java.Syntax.Lambda <$> term expression <* token AnonMinusRAngle <*> term expression) --- The current error occurs when a lambda expression is the argument in the argument for a method; --- If it is exposed at the top-level, lambdas will be referenced in expressionChoices +lambda = makeTerm <$> symbol LambdaExpression <*> children (Java.Syntax.Lambda <$> manyTerm expression <* token AnonMinusRAngle <*> lambdaBody) + where + lambdaBody = makeTerm <$> symbol Grammar.LambdaBody <*> children (Java.Syntax.LambdaBody <$> manyTerm expression) diff --git a/src/Language/Java/Syntax.hs b/src/Language/Java/Syntax.hs index 7211a8ef8..ac6793cfe 100644 --- a/src/Language/Java/Syntax.hs +++ b/src/Language/Java/Syntax.hs @@ -209,7 +209,7 @@ instance Show1 NewKeyword where liftShowsPrec = genericLiftShowsPrec -- TODO: Implement Eval instance for TypeWithModifiers instance Evaluatable NewKeyword -data Lambda a = Lambda { lambdaHead :: !a, lambdaBody :: !a } +data Lambda a = Lambda { lambdaParams :: ![a], lambdaBody :: !a } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) instance Eq1 Lambda where liftEq = genericLiftEq @@ -217,3 +217,12 @@ instance Ord1 Lambda where liftCompare = genericLiftCompare instance Show1 Lambda where liftShowsPrec = genericLiftShowsPrec instance Evaluatable Lambda + +data LambdaBody a = LambdaBody { lambdaBodyExpression :: ![a] } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 LambdaBody where liftEq = genericLiftEq +instance Ord1 LambdaBody where liftCompare = genericLiftCompare +instance Show1 LambdaBody where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable LambdaBody From 5329894a485c54ea33ac3a37bfefac717c784b7e Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Thu, 12 Jul 2018 12:30:39 -0400 Subject: [PATCH 18/62] test lambda --- test/fixtures/java/corpus/lambda.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 test/fixtures/java/corpus/lambda.java diff --git a/test/fixtures/java/corpus/lambda.java b/test/fixtures/java/corpus/lambda.java new file mode 100644 index 000000000..1ba8c84cc --- /dev/null +++ b/test/fixtures/java/corpus/lambda.java @@ -0,0 +1,5 @@ +class LambdaTest { + void singleton() { + version -> create; + } +} From 495d44cfbdf3db1b08b39d30083dda83d473c1d9 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Thu, 12 Jul 2018 15:28:55 -0400 Subject: [PATCH 19/62] remove token because it's skipped automatically --- src/Language/Java/Assignment.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 344d657bc..57d8fcbfa 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -598,6 +598,6 @@ arrayAccess :: Assignment Term arrayAccess = makeTerm <$> symbol ArrayAccess <*> children (Expression.Subscript <$> term expression <*> manyTerm expression) lambda :: Assignment Term -lambda = makeTerm <$> symbol LambdaExpression <*> children (Java.Syntax.Lambda <$> manyTerm expression <* token AnonMinusRAngle <*> lambdaBody) +lambda = makeTerm <$> symbol LambdaExpression <*> children (Java.Syntax.Lambda <$> manyTerm expression <*> lambdaBody) where lambdaBody = makeTerm <$> symbol Grammar.LambdaBody <*> children (Java.Syntax.LambdaBody <$> manyTerm expression) From 90705f1658e1519804c7b1e1c005b62e7bce5e4e Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Thu, 12 Jul 2018 17:06:50 -0400 Subject: [PATCH 20/62] replace type' with typeArgument in methodReference --- src/Language/Java/Assignment.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 57d8fcbfa..44792e185 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -313,7 +313,7 @@ methodInvocation = makeTerm <$> symbol MethodInvocation <*> children (uncurry Ex -- optional produces a Maybe type (takes a Maybe a and returns a rule that produces a Maybe a) methodReference :: Assignment Term -methodReference = makeTerm <$> symbol Grammar.MethodReference <*> children (Java.Syntax.MethodReference <$> term type' <* token AnonColonColon <*> manyTerm type' <*> (new <|> term identifier)) +methodReference = makeTerm <$> symbol Grammar.MethodReference <*> children (Java.Syntax.MethodReference <$> term type' <*> manyTerm typeArgument <*> (new <|> term identifier)) where new = makeTerm <$> token AnonNew <*> pure NewKeyword -- can't do term identifier' because identifier' returns a name, not a term, and we want a term -- <*> - left assoc so when you have a token that you need to match but not retain, From 7fec77cc305eeead090f6fef2059146a50a401ce Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Fri, 13 Jul 2018 16:21:34 -0400 Subject: [PATCH 21/62] add dimsExpr and arrayCreationExpression assignments and syntaxes --- src/Data/Syntax.hs | 1 - src/Language/Java/Assignment.hs | 18 ++++++++++++++++-- src/Language/Java/Syntax.hs | 18 ++++++++++++++++++ vendor/effects | 2 +- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/Data/Syntax.hs b/src/Data/Syntax.hs index f2e1a40fd..3e6b7f4d4 100644 --- a/src/Data/Syntax.hs +++ b/src/Data/Syntax.hs @@ -64,7 +64,6 @@ handleError = flip Assignment.catchError (\ err -> makeTerm <$> Assignment.locat parseError :: (HasCallStack, Error :< syntaxes, Bounded grammar, Enum grammar, Ix grammar, Apply Foldable syntaxes) => Assignment.Assignment ast grammar (Term (Sum syntaxes) (Record Location)) parseError = makeTerm <$> Assignment.token maxBound <*> pure (Error (ErrorStack $ errorSite <$> getCallStack (freezeCallStack callStack)) [] (Just "ParseError") []) - -- | Match context terms before a subject term, wrapping both up in a Context term if any context terms matched, or otherwise returning the subject term. contextualize :: (HasCallStack, Context :< syntaxes, Alternative m, Semigroup ann, Apply Foldable syntaxes) => m (Term (Sum syntaxes) ann) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 44792e185..464383cb9 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -68,8 +68,10 @@ type Syntax = , Expression.This , Java.Syntax.Annotation , Java.Syntax.AnnotationField + , Java.Syntax.ArrayCreationExpression , Java.Syntax.Asterisk , Java.Syntax.Constructor + , Java.Syntax.DimsExpr , Java.Syntax.EnumDeclaration , Java.Syntax.GenericType , Java.Syntax.Import @@ -163,8 +165,9 @@ expressions = makeTerm'' <$> location <*> many expression expressionChoices :: [Assignment Term] expressionChoices = [ - arrayInitializer - , arrayAccess + arrayAccess + , arrayCreationExpression + , arrayInitializer , assignment' , block , binary @@ -176,6 +179,7 @@ expressionChoices = , classInstance , continue , constructorDeclaration + , dimsExpr , explicitConstructorInvocation -- , TODO: constantDeclaration , doWhile @@ -237,6 +241,11 @@ variableDeclaratorList = symbol VariableDeclaratorList *> children (makeDecl <$> makeSingleDecl modifiers type' (target, Nothing) = makeTerm1 (Java.Syntax.Variable modifiers type' target) makeSingleDecl modifiers type' (target, Just value) = makeTerm1 (Statement.Assignment [] (makeTerm1 (Java.Syntax.Variable modifiers type' target)) value) +-- variable declarator -> variable initializer -> expression -> primary -> array creation expression +arrayCreationExpression :: Assignment Term +arrayCreationExpression = symbol Grammar.ArrayCreationExpression *> children (makeTerm1 <$> (Java.Syntax.ArrayCreationExpression <$> (new *> type') <*> many dimsExpr)) + where new = token AnonNew *> pure NewKeyword + localVariableDeclarationStatement :: Assignment Term localVariableDeclarationStatement = symbol LocalVariableDeclarationStatement *> children localVariableDeclaration @@ -359,6 +368,11 @@ return' = makeTerm <$> symbol ReturnStatement <*> (Statement.Return <$> children dims :: Assignment [Term] dims = symbol Dims *> children (many (emptyTerm <* token AnonLBracket <* token AnonRBracket)) +-- not sure why we did <* token with the dims (possibly because it's the only thing happening?) +-- will define with manyTerm annotation <*> manyTerm expression and then revisit whether or not I need brackets +dimsExpr :: Assignment Term +dimsExpr = makeTerm <$> symbol Grammar.DimsExpr <*> children (Java.Syntax.DimsExpr <$> manyTerm annotation <*> manyTerm expression) + type' :: Assignment Term type' = choice [ makeTerm <$> token VoidType <*> pure Type.Void diff --git a/src/Language/Java/Syntax.hs b/src/Language/Java/Syntax.hs index ac6793cfe..d8f6ce1b3 100644 --- a/src/Language/Java/Syntax.hs +++ b/src/Language/Java/Syntax.hs @@ -226,3 +226,21 @@ instance Ord1 LambdaBody where liftCompare = genericLiftCompare instance Show1 LambdaBody where liftShowsPrec = genericLiftShowsPrec instance Evaluatable LambdaBody + +data ArrayCreationExpression a = ArrayCreationExpression { arrayCreationExpressionType :: !a, arrayCreationExpressionDims :: ![a] } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 ArrayCreationExpression where liftEq = genericLiftEq +instance Ord1 ArrayCreationExpression where liftCompare = genericLiftCompare +instance Show1 ArrayCreationExpression where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable ArrayCreationExpression + +data DimsExpr a = DimsExpr { dimsExprAnnotation :: ![a], dimsExprExpression :: ![a] } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 DimsExpr where liftEq = genericLiftEq +instance Ord1 DimsExpr where liftCompare = genericLiftCompare +instance Show1 DimsExpr where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable DimsExpr diff --git a/vendor/effects b/vendor/effects index 0b6d04713..105a543cc 160000 --- a/vendor/effects +++ b/vendor/effects @@ -1 +1 @@ -Subproject commit 0b6d04713b70e6b0551b841304fb44c9b1564e9b +Subproject commit 105a543ccc98f2929cf0b1f1e97bcc48dfb8f718 From 3272e49d97b1923394092f8dc1d5c1a5c26fa6cf Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Mon, 16 Jul 2018 17:23:37 -0400 Subject: [PATCH 22/62] bump haskell-tree-sitter --- vendor/haskell-tree-sitter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/haskell-tree-sitter b/vendor/haskell-tree-sitter index 9ada8cc48..27e75c07b 160000 --- a/vendor/haskell-tree-sitter +++ b/vendor/haskell-tree-sitter @@ -1 +1 @@ -Subproject commit 9ada8cc48be1a25b971aca1a49c0963897c09d7c +Subproject commit 27e75c07b7835766d06a023c63c64cae15a6d367 From 34dfc4f8d90d0711b44be32cc27697ea97de2f5d Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Tue, 17 Jul 2018 12:05:26 -0400 Subject: [PATCH 23/62] add classBody and classLiteral assignments --- src/Language/Java/Assignment.hs | 16 +++++++++++++--- src/Language/Java/Syntax.hs | 20 +++++++++++++++++++- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 464383cb9..366ee653e 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -71,6 +71,8 @@ type Syntax = , Java.Syntax.ArrayCreationExpression , Java.Syntax.Asterisk , Java.Syntax.Constructor + , Java.Syntax.ClassBody + , Java.Syntax.ClassLiteral , Java.Syntax.DimsExpr , Java.Syntax.EnumDeclaration , Java.Syntax.GenericType @@ -176,7 +178,9 @@ expressionChoices = , castExpression , char , class' + , classBody , classInstance + , classLiteral , continue , constructorDeclaration , dimsExpr @@ -243,7 +247,7 @@ variableDeclaratorList = symbol VariableDeclaratorList *> children (makeDecl <$> -- variable declarator -> variable initializer -> expression -> primary -> array creation expression arrayCreationExpression :: Assignment Term -arrayCreationExpression = symbol Grammar.ArrayCreationExpression *> children (makeTerm1 <$> (Java.Syntax.ArrayCreationExpression <$> (new *> type') <*> many dimsExpr)) +arrayCreationExpression = makeTerm <$> symbol Grammar.ArrayCreationExpression <*> children (Java.Syntax.ArrayCreationExpression <$> (new *> type') <*> many dimsExpr) where new = token AnonNew *> pure NewKeyword localVariableDeclarationStatement :: Assignment Term @@ -293,9 +297,12 @@ class' :: Assignment Term class' = makeTerm <$> symbol ClassDeclaration <*> children (makeClass <$> many modifier <*> term identifier <*> (typeParameters <|> pure []) <*> optional superClass <*> (superInterfaces <|> pure []) <*> classBody) where makeClass modifiers identifier typeParams superClass superInterfaces = Declaration.Class (modifiers <> typeParams) identifier (maybeToList superClass <> superInterfaces) -- not doing an assignment, just straight up function - classBody = makeTerm <$> symbol ClassBody <*> children (manyTerm expression) + -- classBody = makeTerm <$> symbol ClassBody <*> children (manyTerm expression) superClass = symbol Superclass *> children type' +classBody :: Assignment Term +classBody = makeTerm <$> symbol Grammar.ClassBody <*> children (manyTerm expression) + staticInitializer :: Assignment Term staticInitializer = makeTerm <$> symbol Grammar.StaticInitializer <*> children (Java.Syntax.StaticInitializer <$> block) @@ -543,7 +550,10 @@ synchronized = makeTerm <$> symbol SynchronizedStatement <*> children (Java.Synt classInstance :: Assignment Term classInstance = makeTerm <$> symbol ClassInstanceCreationExpression <*> children unqualified where - unqualified = symbol UnqualifiedClassInstanceCreationExpression *> children (Java.Syntax.New <$> type' <*> (argumentList <|> pure [])) + unqualified = symbol UnqualifiedClassInstanceCreationExpression *> children (Java.Syntax.New <$> type' <*> (argumentList <|> pure []) <*> optional classBody) + +classLiteral :: Assignment Term +classLiteral = makeTerm <$> symbol Grammar.ClassLiteral <*> children (Java.Syntax.ClassLiteral <$> type') argumentList :: Assignment [Term] argumentList = symbol ArgumentList *> children (manyTerm expression) diff --git a/src/Language/Java/Syntax.hs b/src/Language/Java/Syntax.hs index d8f6ce1b3..bba7ae005 100644 --- a/src/Language/Java/Syntax.hs +++ b/src/Language/Java/Syntax.hs @@ -67,7 +67,7 @@ instance Show1 Synchronized where liftShowsPrec = genericLiftShowsPrec -- TODO: Implement Eval instance for Synchronized instance Evaluatable Synchronized -data New a = New { newType :: !a, newArgs :: ![a] } +data New a = New { newType :: !a, newArgs :: ![a], newClassBody :: Maybe a } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) instance Eq1 New where liftEq = genericLiftEq @@ -244,3 +244,21 @@ instance Ord1 DimsExpr where liftCompare = genericLiftCompare instance Show1 DimsExpr where liftShowsPrec = genericLiftShowsPrec instance Evaluatable DimsExpr + +newtype ClassBody a = ClassBody { classBodyExpression :: [a] } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 ClassBody where liftEq = genericLiftEq +instance Ord1 ClassBody where liftCompare = genericLiftCompare +instance Show1 ClassBody where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable ClassBody + +newtype ClassLiteral a = ClassLiteral { classLiteralType :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 ClassLiteral where liftEq = genericLiftEq +instance Ord1 ClassLiteral where liftCompare = genericLiftCompare +instance Show1 ClassLiteral where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable ClassLiteral From f6dab65ac713cd6de5c63a61c27e5fcfbcc92195 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Tue, 17 Jul 2018 12:59:15 -0400 Subject: [PATCH 24/62] assign tryWithResourcesStatement --- src/Language/Java/Assignment.hs | 32 +++++++++++++++++++++++--------- src/Language/Java/Syntax.hs | 10 ++++++++++ 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 366ee653e..ddd35f3d4 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -25,7 +25,7 @@ import qualified Data.Syntax.Statement as Statement import qualified Data.Syntax.Type as Type import qualified Data.Term as Term import Prelude hiding (break) -import Prologue hiding (for, try, This) +import Prologue hiding (for, try, This, catches, finally) type Syntax = '[ Comment.Comment @@ -87,6 +87,7 @@ type Syntax = , Java.Syntax.SpreadParameter , Java.Syntax.StaticInitializer , Java.Syntax.Synchronized + , Java.Syntax.TryWithResources , Java.Syntax.TypeParameter , Java.Syntax.TypeWithModifiers , Java.Syntax.Variable @@ -434,17 +435,30 @@ throw :: Assignment Term throw = makeTerm <$> symbol ThrowStatement <*> children (Statement.Throw <$> term expression) try :: Assignment Term -try = makeTerm <$> symbol TryStatement <*> children (Statement.Try <$> term expression <*> (append <$> optional catches <*> optional finally)) +try = symbol TryStatement *> children tryWithResources <|> makeTerm <$> symbol TryStatement <*> children (Statement.Try <$> term expression <*> (append <$> optional catches <*> optional finally)) + +catches :: Assignment [Term] +catches = symbol Catches *> children (manyTerm catch) where - catches = symbol Catches *> children (manyTerm catch) catch = makeTerm <$> symbol CatchClause <*> children (Statement.Catch <$> catchFormalParameter <*> term expression) catchFormalParameter = makeTerm <$> symbol CatchFormalParameter <*> children (flip Type.Annotation <$> type' <* symbol VariableDeclaratorId <*> children identifier) - finally = makeTerm <$> symbol Finally <*> children (Statement.Finally <$> term expression) - -- append catches finally = - append Nothing Nothing = [] - append Nothing (Just a) = [a] - append (Just a) Nothing = a - append (Just a) (Just b) = a <> [b] + +finally :: Assignment Term +finally = makeTerm <$> symbol Finally <*> children (Statement.Finally <$> term expression) + +append :: Maybe [a] -> Maybe a -> [a] +append Nothing Nothing = [] +append Nothing (Just a) = [a] +append (Just a) Nothing = a +append (Just a) (Just b) = a <> [b] + +tryWithResources :: Assignment Term +tryWithResources = makeTerm <$> symbol TryWithResourcesStatement <*> children (Java.Syntax.TryWithResources <$> resourceSpecification <*> block <*> (append <$> optional catches <*> optional finally)) + where + resourceSpecification = symbol ResourceSpecification *> children (manyTerm resource) + resource = symbol Resource *> children variableAccess <|> makeTerm <$> symbol Resource <*> children (makeSingleDecl <$> many modifier <*> type' <*> variableDeclaratorId <*> term expression) + variableAccess = symbol VariableAccess *> children (identifier <|> fieldAccess) + makeSingleDecl modifiers type' target value = Statement.Assignment [] (makeTerm1 (Java.Syntax.Variable modifiers type' target)) value for :: Assignment Term for = symbol ForStatement *> children (basicFor <|> enhancedFor) diff --git a/src/Language/Java/Syntax.hs b/src/Language/Java/Syntax.hs index bba7ae005..4e6672f3c 100644 --- a/src/Language/Java/Syntax.hs +++ b/src/Language/Java/Syntax.hs @@ -262,3 +262,13 @@ instance Ord1 ClassLiteral where liftCompare = genericLiftCompare instance Show1 ClassLiteral where liftShowsPrec = genericLiftShowsPrec instance Evaluatable ClassLiteral + +data TryWithResources a = TryWithResources { tryResources :: ![a], tryBody :: !a, tryCatch :: ![a] } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 TryWithResources where liftEq = genericLiftEq +instance Ord1 TryWithResources where liftCompare = genericLiftCompare +instance Show1 TryWithResources where liftShowsPrec = genericLiftShowsPrec + +-- TODO: Implement Eval instance for TryWithResources +instance Evaluatable TryWithResources From 3d61ea9368c207ee11d61a3c2dd1304780335853 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Tue, 17 Jul 2018 15:51:24 -0400 Subject: [PATCH 25/62] add test fixtures --- test/fixtures/java/classLiteral.java | 5 +++++ test/fixtures/java/corpus/classBody.java | 6 ++++++ test/fixtures/java/corpus/tryWithResourcesStatement.java | 6 ++++++ 3 files changed, 17 insertions(+) create mode 100644 test/fixtures/java/classLiteral.java create mode 100644 test/fixtures/java/corpus/classBody.java create mode 100644 test/fixtures/java/corpus/tryWithResourcesStatement.java diff --git a/test/fixtures/java/classLiteral.java b/test/fixtures/java/classLiteral.java new file mode 100644 index 000000000..a4381fdf3 --- /dev/null +++ b/test/fixtures/java/classLiteral.java @@ -0,0 +1,5 @@ +class Dino { + void normalError() { + error(TestException.class); + } +} diff --git a/test/fixtures/java/corpus/classBody.java b/test/fixtures/java/corpus/classBody.java new file mode 100644 index 000000000..75d7b610b --- /dev/null +++ b/test/fixtures/java/corpus/classBody.java @@ -0,0 +1,6 @@ +class Dino { + public void dispose() { + Test.flat(new Function() { + }); + } +} diff --git a/test/fixtures/java/corpus/tryWithResourcesStatement.java b/test/fixtures/java/corpus/tryWithResourcesStatement.java new file mode 100644 index 000000000..f6ef073a6 --- /dev/null +++ b/test/fixtures/java/corpus/tryWithResourcesStatement.java @@ -0,0 +1,6 @@ +class Dino { + void hi() { + try (CustomAnalyzer analyzer = new CustomAnalyzer()){ + } + } +} From 3c0e4c7d3dc5dfb89e4237e7f46fca287b273f6b Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Wed, 18 Jul 2018 08:44:18 -0700 Subject: [PATCH 26/62] Back to master's vendor/effects --- vendor/effects | 2 +- vendor/haskell-tree-sitter | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vendor/effects b/vendor/effects index 105a543cc..0b6d04713 160000 --- a/vendor/effects +++ b/vendor/effects @@ -1 +1 @@ -Subproject commit 105a543ccc98f2929cf0b1f1e97bcc48dfb8f718 +Subproject commit 0b6d04713b70e6b0551b841304fb44c9b1564e9b diff --git a/vendor/haskell-tree-sitter b/vendor/haskell-tree-sitter index 27e75c07b..9ada8cc48 160000 --- a/vendor/haskell-tree-sitter +++ b/vendor/haskell-tree-sitter @@ -1 +1 @@ -Subproject commit 27e75c07b7835766d06a023c63c64cae15a6d367 +Subproject commit 9ada8cc48be1a25b971aca1a49c0963897c09d7c From 45bee052ab6354a1e8e0b8439116be3ea94fba89 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Wed, 18 Jul 2018 08:48:33 -0700 Subject: [PATCH 27/62] ++haskell-tree-sitter with tree-sitter-java --- vendor/haskell-tree-sitter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/haskell-tree-sitter b/vendor/haskell-tree-sitter index 9ada8cc48..4a3e8b8bc 160000 --- a/vendor/haskell-tree-sitter +++ b/vendor/haskell-tree-sitter @@ -1 +1 @@ -Subproject commit 9ada8cc48be1a25b971aca1a49c0963897c09d7c +Subproject commit 4a3e8b8bc08a10a0ec5b5d503a92757970672b2a From dead9debb01f6a74838406100848224ace05798c Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Wed, 18 Jul 2018 15:36:35 -0400 Subject: [PATCH 28/62] assign assertStatement --- src/Language/Java/Assignment.hs | 5 +++++ src/Language/Java/Syntax.hs | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index ddd35f3d4..d9d8e67a0 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -69,6 +69,7 @@ type Syntax = , Java.Syntax.Annotation , Java.Syntax.AnnotationField , Java.Syntax.ArrayCreationExpression + , Java.Syntax.AssertStatement , Java.Syntax.Asterisk , Java.Syntax.Constructor , Java.Syntax.ClassBody @@ -171,6 +172,7 @@ expressionChoices = arrayAccess , arrayCreationExpression , arrayInitializer + , assert , assignment' , block , binary @@ -473,6 +475,9 @@ enhancedFor :: Assignment Term enhancedFor = makeTerm <$> symbol EnhancedForStatement <*> children (Statement.ForEach <$> (variable <$> manyTerm modifier <*> type' <*> variableDeclaratorId) <*> term expression <*> term expression) where variable modifiers type' variableDeclaratorId = makeTerm1 (Java.Syntax.Variable modifiers type' variableDeclaratorId) +assert :: Assignment Term +assert = makeTerm <$> symbol Grammar.AssertStatement <*> children (Java.Syntax.AssertStatement <$> term expression) + -- TODO: instanceOf binary :: Assignment Term binary = makeTerm' <$> symbol BinaryExpression <*> children (infixTerm expressionAndParens expressionAndParens diff --git a/src/Language/Java/Syntax.hs b/src/Language/Java/Syntax.hs index 4e6672f3c..59771e595 100644 --- a/src/Language/Java/Syntax.hs +++ b/src/Language/Java/Syntax.hs @@ -272,3 +272,13 @@ instance Show1 TryWithResources where liftShowsPrec = genericLiftShowsPrec -- TODO: Implement Eval instance for TryWithResources instance Evaluatable TryWithResources + +newtype AssertStatement a = AssertStatement { assertStatementExpression :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 AssertStatement where liftEq = genericLiftEq +instance Ord1 AssertStatement where liftCompare = genericLiftCompare +instance Show1 AssertStatement where liftShowsPrec = genericLiftShowsPrec + +-- TODO: Implement Eval instance for AssertStatement +instance Evaluatable AssertStatement From 01c5872a547a3076eaff732c28983d33ce19f980 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Wed, 18 Jul 2018 15:39:17 -0400 Subject: [PATCH 29/62] assertStatement fixture --- test/fixtures/java/corpus/assertStatement.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 test/fixtures/java/corpus/assertStatement.java diff --git a/test/fixtures/java/corpus/assertStatement.java b/test/fixtures/java/corpus/assertStatement.java new file mode 100644 index 000000000..ea8131067 --- /dev/null +++ b/test/fixtures/java/corpus/assertStatement.java @@ -0,0 +1,7 @@ +class Dino { + void fn() { + for (File file : snap.index()) { + assert oldFile == null; + } + } +} From 105d1a6ecea9c3b66bf2dacde9440292aa4b9a9a Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Wed, 18 Jul 2018 17:22:06 -0400 Subject: [PATCH 30/62] fix assert statement error --- src/Language/Java/Assignment.hs | 2 +- src/Language/Java/Syntax.hs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index d9d8e67a0..1ee21554e 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -476,7 +476,7 @@ enhancedFor = makeTerm <$> symbol EnhancedForStatement <*> children (Statement.F where variable modifiers type' variableDeclaratorId = makeTerm1 (Java.Syntax.Variable modifiers type' variableDeclaratorId) assert :: Assignment Term -assert = makeTerm <$> symbol Grammar.AssertStatement <*> children (Java.Syntax.AssertStatement <$> term expression) +assert = makeTerm <$> symbol Grammar.AssertStatement <*> children (Java.Syntax.AssertStatement <$> term expression <*> term expression) -- TODO: instanceOf binary :: Assignment Term diff --git a/src/Language/Java/Syntax.hs b/src/Language/Java/Syntax.hs index 59771e595..87031a608 100644 --- a/src/Language/Java/Syntax.hs +++ b/src/Language/Java/Syntax.hs @@ -273,7 +273,7 @@ instance Show1 TryWithResources where liftShowsPrec = genericLiftShowsPrec -- TODO: Implement Eval instance for TryWithResources instance Evaluatable TryWithResources -newtype AssertStatement a = AssertStatement { assertStatementExpression :: a } +data AssertStatement a = AssertStatement { assertLHS :: !a, assertRHS :: !a } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) instance Eq1 AssertStatement where liftEq = genericLiftEq From 9cb3a059c0623f1e90d34eb3893c0b75261fc024 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Thu, 19 Jul 2018 16:56:03 -0400 Subject: [PATCH 31/62] assert statement modification --- src/Language/Java/Assignment.hs | 4 ++-- src/Language/Java/Syntax.hs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 1ee21554e..fc93c2f62 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -357,7 +357,7 @@ interface = makeTerm <$> symbol InterfaceDeclaration <*> children (normal <|> an interfaceBody = makeTerm <$> symbol InterfaceBody <*> children (manyTerm interfaceMemberDeclaration) normal = symbol NormalInterfaceDeclaration *> children (makeInterface <$> manyTerm modifier <*> identifier <*> (typeParameters <|> pure []) <*> (extends <|> pure []) <*> interfaceBody) makeInterface modifiers identifier typeParams = Declaration.InterfaceDeclaration (modifiers ++ typeParams) identifier - annotationType = symbol AnnotationTypeDeclaration *> children (Declaration.InterfaceDeclaration [] <$> identifier <*> pure [] <*> annotationTypeBody) + annotationType = symbol AnnotationTypeDeclaration *> children (Declaration.InterfaceDeclaration [] <$> AnonAt *> identifier <*> pure [] <*> annotationTypeBody) annotationTypeBody = makeTerm <$> symbol AnnotationTypeBody <*> children (many expression) interfaceMemberDeclaration = symbol InterfaceMemberDeclaration *> children (term expression) extends = symbol ExtendsInterfaces *> children (symbol InterfaceTypeList *> children (manyTerm type')) @@ -476,7 +476,7 @@ enhancedFor = makeTerm <$> symbol EnhancedForStatement <*> children (Statement.F where variable modifiers type' variableDeclaratorId = makeTerm1 (Java.Syntax.Variable modifiers type' variableDeclaratorId) assert :: Assignment Term -assert = makeTerm <$> symbol Grammar.AssertStatement <*> children (Java.Syntax.AssertStatement <$> term expression <*> term expression) +assert = makeTerm <$> symbol Grammar.AssertStatement <*> children (Java.Syntax.AssertStatement <$> term expression <*> optional (term expression)) -- TODO: instanceOf binary :: Assignment Term diff --git a/src/Language/Java/Syntax.hs b/src/Language/Java/Syntax.hs index 87031a608..1d17d0edf 100644 --- a/src/Language/Java/Syntax.hs +++ b/src/Language/Java/Syntax.hs @@ -273,7 +273,7 @@ instance Show1 TryWithResources where liftShowsPrec = genericLiftShowsPrec -- TODO: Implement Eval instance for TryWithResources instance Evaluatable TryWithResources -data AssertStatement a = AssertStatement { assertLHS :: !a, assertRHS :: !a } +data AssertStatement a = AssertStatement { assertLHS :: !a, assertRHS :: !(Maybe a) } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) instance Eq1 AssertStatement where liftEq = genericLiftEq From 536d3b2835d197a1427ab636a951fca68c5f2d33 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Fri, 20 Jul 2018 12:44:51 -0400 Subject: [PATCH 32/62] stubbing in AnnotationType --- src/Language/Java/Assignment.hs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index fc93c2f62..fbe2537ea 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -14,7 +14,7 @@ import Data.Record import Data.Syntax (contextualize, emptyTerm, handleError, infixContext, makeTerm, makeTerm', makeTerm'', makeTerm1, parseError, postContextualize) import Data.Sum import Language.Java.Grammar as Grammar -import Language.Java.Syntax as Java.Syntax +import qualified Language.Java.Syntax as Java.Syntax import qualified Assigning.Assignment as Assignment import qualified Data.Syntax as Syntax import qualified Data.Syntax.Comment as Comment @@ -68,12 +68,14 @@ type Syntax = , Expression.This , Java.Syntax.Annotation , Java.Syntax.AnnotationField + , Java.Syntax.AnnotationTypeElement , Java.Syntax.ArrayCreationExpression , Java.Syntax.AssertStatement , Java.Syntax.Asterisk , Java.Syntax.Constructor , Java.Syntax.ClassBody , Java.Syntax.ClassLiteral + , Java.Syntax.DefaultValue , Java.Syntax.DimsExpr , Java.Syntax.EnumDeclaration , Java.Syntax.GenericType @@ -251,7 +253,7 @@ variableDeclaratorList = symbol VariableDeclaratorList *> children (makeDecl <$> -- variable declarator -> variable initializer -> expression -> primary -> array creation expression arrayCreationExpression :: Assignment Term arrayCreationExpression = makeTerm <$> symbol Grammar.ArrayCreationExpression <*> children (Java.Syntax.ArrayCreationExpression <$> (new *> type') <*> many dimsExpr) - where new = token AnonNew *> pure NewKeyword + where new = token AnonNew *> pure Java.Syntax.NewKeyword localVariableDeclarationStatement :: Assignment Term localVariableDeclarationStatement = symbol LocalVariableDeclarationStatement *> children localVariableDeclaration @@ -285,8 +287,11 @@ char = makeTerm <$> symbol CharacterLiteral <*> (Literal.TextElement <$> source) identifier :: Assignment Term identifier = makeTerm <$> (symbol Identifier <|> symbol TypeIdentifier) <*> (Syntax.Identifier . name <$> source) +typeIdentifier :: Assignment Term +typeIdentifier = makeTerm <$> (symbol Identifier) <*> (Syntax.Identifier . name <$> source) + identifier' :: Assignment Name -identifier' = (symbol Identifier <|> symbol TypeIdentifier) *> (name <$> source) +identifier' = (symbol Identifier <|> symbol TypeIdentifier <|> symbol Identifier') *> (name <$> source) -- we want a name and not a full term wrapping the same, so we match the same stuff as identifier but we just produce the name scopedIdentifier :: Assignment Term @@ -333,7 +338,7 @@ methodInvocation = makeTerm <$> symbol MethodInvocation <*> children (uncurry Ex methodReference :: Assignment Term methodReference = makeTerm <$> symbol Grammar.MethodReference <*> children (Java.Syntax.MethodReference <$> term type' <*> manyTerm typeArgument <*> (new <|> term identifier)) - where new = makeTerm <$> token AnonNew <*> pure NewKeyword + where new = makeTerm <$> token AnonNew <*> pure Java.Syntax.NewKeyword -- can't do term identifier' because identifier' returns a name, not a term, and we want a term -- <*> - left assoc so when you have a token that you need to match but not retain, -- manyTerm or alternation with pure, but not bowf @@ -357,11 +362,18 @@ interface = makeTerm <$> symbol InterfaceDeclaration <*> children (normal <|> an interfaceBody = makeTerm <$> symbol InterfaceBody <*> children (manyTerm interfaceMemberDeclaration) normal = symbol NormalInterfaceDeclaration *> children (makeInterface <$> manyTerm modifier <*> identifier <*> (typeParameters <|> pure []) <*> (extends <|> pure []) <*> interfaceBody) makeInterface modifiers identifier typeParams = Declaration.InterfaceDeclaration (modifiers ++ typeParams) identifier - annotationType = symbol AnnotationTypeDeclaration *> children (Declaration.InterfaceDeclaration [] <$> AnonAt *> identifier <*> pure [] <*> annotationTypeBody) - annotationTypeBody = makeTerm <$> symbol AnnotationTypeBody <*> children (many expression) + annotationType = symbol AnnotationTypeDeclaration *> children (Declaration.InterfaceDeclaration [] <$> identifier <*> pure [] <*> annotationTypeBody) + annotationTypeBody = makeTerm <$> symbol AnnotationTypeBody <*> children (manyTerm annotationTypeMember) + annotationTypeMember = symbol AnnotationTypeMemberDeclaration *> children (class' <|> interface <|> constant) + annotationTypeElement = makeTerm <$> symbol AnnotationTypeElementDeclaration <*> children (Java.Syntax.AnnotationTypeElement <$> many modifier <*> identifier <*> (dims <|> pure []) <*> (defaultValue <|> emptyTerm)) + defaultValue = makeTerm <$> symbol DefaultValue <*> children (Java.Syntax.DefaultValue <$> elementValue) + elementValue = symbol ElementValue *> children (term expression) -- pull this to top level l8r interfaceMemberDeclaration = symbol InterfaceMemberDeclaration *> children (term expression) extends = symbol ExtendsInterfaces *> children (symbol InterfaceTypeList *> children (manyTerm type')) +constant :: Assignment Term +constant = makeTerm <$> symbol ConstantDeclaration <*> ((,) <$> pure [] <*> typeIdentifier <**> variableDeclaratorList) + package :: Assignment Term package = makeTerm <$> symbol PackageDeclaration <*> children (Java.Syntax.Package <$> someTerm expression) @@ -395,6 +407,7 @@ type' = choice [ , makeTerm <$> symbol ScopedTypeIdentifier <*> children (Expression.MemberAccess <$> term type' <*> identifier') , wildcard , identifier + , typeIdentifier , generic , typeArgument ] From 580efad636b1c73a0cd64c80435c75edac4bd179 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Fri, 20 Jul 2018 12:45:36 -0400 Subject: [PATCH 33/62] stubbing in annotationType stuff --- src/Language/Java/Assignment.hs | 2 +- src/Language/Java/Syntax.hs | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index fbe2537ea..43d166bd0 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -285,7 +285,7 @@ char = makeTerm <$> symbol CharacterLiteral <*> (Literal.TextElement <$> source) -- Identifiers identifier :: Assignment Term -identifier = makeTerm <$> (symbol Identifier <|> symbol TypeIdentifier) <*> (Syntax.Identifier . name <$> source) +identifier = makeTerm <$> (symbol Identifier) <*> (Syntax.Identifier . name <$> source) typeIdentifier :: Assignment Term typeIdentifier = makeTerm <$> (symbol Identifier) <*> (Syntax.Identifier . name <$> source) diff --git a/src/Language/Java/Syntax.hs b/src/Language/Java/Syntax.hs index e6d2c35d6..90291a02b 100644 --- a/src/Language/Java/Syntax.hs +++ b/src/Language/Java/Syntax.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE DeriveAnyClass, DuplicateRecordFields #-} {-# OPTIONS_GHC -Wno-missing-export-lists #-} module Language.Java.Syntax where @@ -283,3 +283,22 @@ instance Show1 AssertStatement where liftShowsPrec = genericLiftShowsPrec -- TODO: Implement Eval instance for AssertStatement instance Evaluatable AssertStatement + +newtype DefaultValue a = DefaultValue { defaultValueElement :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 DefaultValue where liftEq = genericLiftEq +instance Ord1 DefaultValue where liftCompare = genericLiftCompare +instance Show1 DefaultValue where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable DefaultValue + +data AnnotationTypeElement a = AnnotationTypeElement { modifiers :: ![a], identifier :: !a, dims :: ![a], defaultValue :: !a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 AnnotationTypeElement where liftEq = genericLiftEq +instance Ord1 AnnotationTypeElement where liftCompare = genericLiftCompare +instance Show1 AnnotationTypeElement where liftShowsPrec = genericLiftShowsPrec + +-- TODO: Implement Eval instance for AnnotationTypeElement +instance Evaluatable AnnotationTypeElement From 1f52d52eb78b4a31485c572fc7054e88670845fb Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Fri, 20 Jul 2018 13:10:42 -0400 Subject: [PATCH 34/62] WIP normalInterfaceDeclaration error fix --- src/Language/Java/Assignment.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 43d166bd0..f442dc674 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -363,7 +363,7 @@ interface = makeTerm <$> symbol InterfaceDeclaration <*> children (normal <|> an normal = symbol NormalInterfaceDeclaration *> children (makeInterface <$> manyTerm modifier <*> identifier <*> (typeParameters <|> pure []) <*> (extends <|> pure []) <*> interfaceBody) makeInterface modifiers identifier typeParams = Declaration.InterfaceDeclaration (modifiers ++ typeParams) identifier annotationType = symbol AnnotationTypeDeclaration *> children (Declaration.InterfaceDeclaration [] <$> identifier <*> pure [] <*> annotationTypeBody) - annotationTypeBody = makeTerm <$> symbol AnnotationTypeBody <*> children (manyTerm annotationTypeMember) + annotationTypeBody = symbol AnnotationTypeBody *> children (annotationTypeMember) annotationTypeMember = symbol AnnotationTypeMemberDeclaration *> children (class' <|> interface <|> constant) annotationTypeElement = makeTerm <$> symbol AnnotationTypeElementDeclaration <*> children (Java.Syntax.AnnotationTypeElement <$> many modifier <*> identifier <*> (dims <|> pure []) <*> (defaultValue <|> emptyTerm)) defaultValue = makeTerm <$> symbol DefaultValue <*> children (Java.Syntax.DefaultValue <$> elementValue) @@ -397,10 +397,10 @@ dimsExpr = makeTerm <$> symbol Grammar.DimsExpr <*> children (Java.Syntax.DimsEx type' :: Assignment Term type' = choice [ - makeTerm <$> token VoidType <*> pure Type.Void - , makeTerm <$> token IntegralType <*> pure Type.Int - , makeTerm <$> token FloatingPointType <*> pure Type.Float - , makeTerm <$> token BooleanType <*> pure Type.Bool + makeTerm <$> symbol VoidType <*> pure Type.Void + , makeTerm <$> symbol IntegralType <*> children (token AnonInt *> pure Type.Int) + , makeTerm <$> symbol FloatingPointType <*> pure Type.Float + , makeTerm <$> symbol BooleanType <*> pure Type.Bool , symbol ArrayType *> children (array <$> type' <*> dims) -- type rule recurs into itself , symbol CatchType *> children (term type') , symbol ExceptionType *> children (term type') From c9c7e43078f2c26a44a2d9b43eecbaa01077c631 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 20 Jul 2018 14:49:09 -0400 Subject: [PATCH 35/62] ++haskell-tree-sitter --- vendor/haskell-tree-sitter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/haskell-tree-sitter b/vendor/haskell-tree-sitter index 4a3e8b8bc..9960a2f94 160000 --- a/vendor/haskell-tree-sitter +++ b/vendor/haskell-tree-sitter @@ -1 +1 @@ -Subproject commit 4a3e8b8bc08a10a0ec5b5d503a92757970672b2a +Subproject commit 9960a2f9463ae44cc2067713454dc359b56d82a1 From 4ffe88e4b98078bddd6359bec2dba93453246b3a Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 20 Jul 2018 15:19:35 -0400 Subject: [PATCH 36/62] Consume a TypeIdentifier Co-Authored-By: Ayman Nadeem --- src/Language/Java/Assignment.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index f442dc674..9399f7633 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -288,7 +288,7 @@ identifier :: Assignment Term identifier = makeTerm <$> (symbol Identifier) <*> (Syntax.Identifier . name <$> source) typeIdentifier :: Assignment Term -typeIdentifier = makeTerm <$> (symbol Identifier) <*> (Syntax.Identifier . name <$> source) +typeIdentifier = makeTerm <$> symbol TypeIdentifier <*> (Syntax.Identifier . name <$> source) identifier' :: Assignment Name identifier' = (symbol Identifier <|> symbol TypeIdentifier <|> symbol Identifier') *> (name <$> source) From 1a8941fc7c35401977e0be439bf857ae01f8c4b2 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 20 Jul 2018 15:19:57 -0400 Subject: [PATCH 37/62] Dive in to constant's children Co-Authored-By: Ayman Nadeem --- src/Language/Java/Assignment.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 9399f7633..d8b78041a 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -372,7 +372,7 @@ interface = makeTerm <$> symbol InterfaceDeclaration <*> children (normal <|> an extends = symbol ExtendsInterfaces *> children (symbol InterfaceTypeList *> children (manyTerm type')) constant :: Assignment Term -constant = makeTerm <$> symbol ConstantDeclaration <*> ((,) <$> pure [] <*> typeIdentifier <**> variableDeclaratorList) +constant = makeTerm <$> symbol ConstantDeclaration <*> children ((,) <$> pure [] <*> typeIdentifier <**> variableDeclaratorList) package :: Assignment Term package = makeTerm <$> symbol PackageDeclaration <*> children (Java.Syntax.Package <$> someTerm expression) From 3dfc9ecdb7ab3ca8f9b03bd480f60e10dbb2c6a3 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 20 Jul 2018 15:36:31 -0400 Subject: [PATCH 38/62] Use a type' in constant Co-Authored-By: Ayman Nadeem --- src/Language/Java/Assignment.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index d8b78041a..d9fcee4ee 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -372,7 +372,7 @@ interface = makeTerm <$> symbol InterfaceDeclaration <*> children (normal <|> an extends = symbol ExtendsInterfaces *> children (symbol InterfaceTypeList *> children (manyTerm type')) constant :: Assignment Term -constant = makeTerm <$> symbol ConstantDeclaration <*> children ((,) <$> pure [] <*> typeIdentifier <**> variableDeclaratorList) +constant = makeTerm <$> symbol ConstantDeclaration <*> children ((,) <$> pure [] <*> type' <**> variableDeclaratorList) package :: Assignment Term package = makeTerm <$> symbol PackageDeclaration <*> children (Java.Syntax.Package <$> someTerm expression) From ce56302b4d9599ee4385f226efdd22483d15df2b Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 20 Jul 2018 15:36:51 -0400 Subject: [PATCH 39/62] Dive into children for simple types Co-Authored-By: Ayman Nadeem --- src/Language/Java/Assignment.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index d9fcee4ee..6156bbb52 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -397,10 +397,10 @@ dimsExpr = makeTerm <$> symbol Grammar.DimsExpr <*> children (Java.Syntax.DimsEx type' :: Assignment Term type' = choice [ - makeTerm <$> symbol VoidType <*> pure Type.Void - , makeTerm <$> symbol IntegralType <*> children (token AnonInt *> pure Type.Int) - , makeTerm <$> symbol FloatingPointType <*> pure Type.Float - , makeTerm <$> symbol BooleanType <*> pure Type.Bool + makeTerm <$> symbol VoidType <*> children (pure Type.Void) + , makeTerm <$> symbol IntegralType <*> children (pure Type.Int) + , makeTerm <$> symbol FloatingPointType <*> children (pure Type.Float) + , makeTerm <$> symbol BooleanType <*> children (pure Type.Bool) , symbol ArrayType *> children (array <$> type' <*> dims) -- type rule recurs into itself , symbol CatchType *> children (term type') , symbol ExceptionType *> children (term type') From 0c97d05d487b23faacf66cbe9d87d395ba8edd20 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 20 Jul 2018 15:36:59 -0400 Subject: [PATCH 40/62] Remove Catch and Exception types Co-Authored-By: Ayman Nadeem --- src/Language/Java/Assignment.hs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 6156bbb52..4977afff2 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -402,8 +402,6 @@ type' = choice [ , makeTerm <$> symbol FloatingPointType <*> children (pure Type.Float) , makeTerm <$> symbol BooleanType <*> children (pure Type.Bool) , symbol ArrayType *> children (array <$> type' <*> dims) -- type rule recurs into itself - , symbol CatchType *> children (term type') - , symbol ExceptionType *> children (term type') , makeTerm <$> symbol ScopedTypeIdentifier <*> children (Expression.MemberAccess <$> term type' <*> identifier') , wildcard , identifier From a3679cfd8b47140307abc5c2f36b5e454292ad20 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 20 Jul 2018 15:46:03 -0400 Subject: [PATCH 41/62] AnnotatedType CatchType data types Co-Authored-By: Ayman Nadeem --- src/Language/Java/Syntax.hs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Language/Java/Syntax.hs b/src/Language/Java/Syntax.hs index 90291a02b..7383c6421 100644 --- a/src/Language/Java/Syntax.hs +++ b/src/Language/Java/Syntax.hs @@ -139,6 +139,26 @@ instance Show1 GenericType where liftShowsPrec = genericLiftShowsPrec -- TODO: Implement Eval instance for GenericType instance Evaluatable GenericType +data AnnotatedType a = AnnotatedType { annotationes :: [a], annotatedType :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 AnnotatedType where liftEq = genericLiftEq +instance Ord1 AnnotatedType where liftCompare = genericLiftCompare +instance Show1 AnnotatedType where liftShowsPrec = genericLiftShowsPrec + +-- TODO: Implement Eval instance for AnnotatedType +instance Evaluatable AnnotatedType + +data CatchType a = CatchType { types :: [a] } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 CatchType where liftEq = genericLiftEq +instance Ord1 CatchType where liftCompare = genericLiftCompare +instance Show1 CatchType where liftShowsPrec = genericLiftShowsPrec + +-- TODO: Implement Eval instance for CatchType +instance Evaluatable CatchType + data TypeWithModifiers a = TypeWithModifiers [a] a deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) From bc8e1ff1ec1d6279f04c86609178a3365b1cf3b8 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 20 Jul 2018 15:46:33 -0400 Subject: [PATCH 42/62] Add annotatedType and add back catchType to catchFormalParameter Co-Authored-By: Ayman Nadeem --- src/Language/Java/Assignment.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 4977afff2..d07742553 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -66,12 +66,14 @@ type Syntax = , Expression.Member , Expression.Super , Expression.This + , Java.Syntax.AnnotatedType , Java.Syntax.Annotation , Java.Syntax.AnnotationField , Java.Syntax.AnnotationTypeElement , Java.Syntax.ArrayCreationExpression , Java.Syntax.AssertStatement , Java.Syntax.Asterisk + , Java.Syntax.CatchType , Java.Syntax.Constructor , Java.Syntax.ClassBody , Java.Syntax.ClassLiteral @@ -408,9 +410,13 @@ type' = choice [ , typeIdentifier , generic , typeArgument + , annotatedType ] where array = foldl (\into each -> makeTerm1 (Type.Array (Just each) into)) +annotatedType :: Assignment Term +annotatedType = makeTerm <$> symbol AnnotatedType <*> children (Java.Syntax.AnnotatedType <$> many annotation <*> type') + typeArgument :: Assignment Term typeArgument = symbol TypeArgument *> children (term type') @@ -454,7 +460,10 @@ catches :: Assignment [Term] catches = symbol Catches *> children (manyTerm catch) where catch = makeTerm <$> symbol CatchClause <*> children (Statement.Catch <$> catchFormalParameter <*> term expression) - catchFormalParameter = makeTerm <$> symbol CatchFormalParameter <*> children (flip Type.Annotation <$> type' <* symbol VariableDeclaratorId <*> children identifier) + catchFormalParameter = makeTerm <$> symbol CatchFormalParameter <*> children (flip Type.Annotation <$> catchType <* symbol VariableDeclaratorId <*> children identifier) + +catchType :: Assignment Term +catchType = makeTerm <$> symbol CatchType <*> (Java.Syntax.CatchType <$> many type') finally :: Assignment Term finally = makeTerm <$> symbol Finally <*> children (Statement.Finally <$> term expression) From fb56ac59d026b302e0f7aa3fefbe466be4902bcd Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 20 Jul 2018 15:56:13 -0400 Subject: [PATCH 43/62] Add types to AnnotationTypeElement Co-Authored-By: Ayman Nadeem --- src/Language/Java/Assignment.hs | 2 +- src/Language/Java/Syntax.hs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index d07742553..65fd13095 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -367,7 +367,7 @@ interface = makeTerm <$> symbol InterfaceDeclaration <*> children (normal <|> an annotationType = symbol AnnotationTypeDeclaration *> children (Declaration.InterfaceDeclaration [] <$> identifier <*> pure [] <*> annotationTypeBody) annotationTypeBody = symbol AnnotationTypeBody *> children (annotationTypeMember) annotationTypeMember = symbol AnnotationTypeMemberDeclaration *> children (class' <|> interface <|> constant) - annotationTypeElement = makeTerm <$> symbol AnnotationTypeElementDeclaration <*> children (Java.Syntax.AnnotationTypeElement <$> many modifier <*> identifier <*> (dims <|> pure []) <*> (defaultValue <|> emptyTerm)) + annotationTypeElement = makeTerm <$> symbol AnnotationTypeElementDeclaration <*> children (Java.Syntax.AnnotationTypeElement <$> many modifier <*> type' <*> identifier <*> (dims <|> pure []) <*> (defaultValue <|> emptyTerm)) defaultValue = makeTerm <$> symbol DefaultValue <*> children (Java.Syntax.DefaultValue <$> elementValue) elementValue = symbol ElementValue *> children (term expression) -- pull this to top level l8r interfaceMemberDeclaration = symbol InterfaceMemberDeclaration *> children (term expression) diff --git a/src/Language/Java/Syntax.hs b/src/Language/Java/Syntax.hs index 7383c6421..6a7f98c75 100644 --- a/src/Language/Java/Syntax.hs +++ b/src/Language/Java/Syntax.hs @@ -313,7 +313,7 @@ instance Show1 DefaultValue where liftShowsPrec = genericLiftShowsPrec instance Evaluatable DefaultValue -data AnnotationTypeElement a = AnnotationTypeElement { modifiers :: ![a], identifier :: !a, dims :: ![a], defaultValue :: !a } +data AnnotationTypeElement a = AnnotationTypeElement { modifiers :: ![a], annotationType :: a, identifier :: !a, dims :: ![a], defaultValue :: !a } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) instance Eq1 AnnotationTypeElement where liftEq = genericLiftEq From 1fc2059cf1f11b3ec5ac12ef1e990dab42128fdd Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 20 Jul 2018 15:56:20 -0400 Subject: [PATCH 44/62] spaces Co-Authored-By: Ayman Nadeem --- src/Language/Java/Assignment.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 65fd13095..e29787a08 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -635,7 +635,7 @@ annotation = makeTerm <$> symbol NormalAnnotation <*> children (Java.Syntax.Anno elementValue = symbol ElementValue *> children (term expression) throws :: Assignment [Term] -throws = symbol Throws *> children (symbol ExceptionTypeList *> children(manyTerm type')) +throws = symbol Throws *> children (symbol ExceptionTypeList *> children (manyTerm type')) formalParameters :: Assignment [Term] formalParameters = manyTerm (parameter <|> spreadParameter) From 5edd10b9a0f8a26660777fdae4ae5f0ee93fc76b Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 20 Jul 2018 15:57:27 -0400 Subject: [PATCH 45/62] Added annotationTypeElement Co-Authored-By: Ayman Nadeem --- src/Language/Java/Assignment.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index e29787a08..39ed656f2 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -365,8 +365,8 @@ interface = makeTerm <$> symbol InterfaceDeclaration <*> children (normal <|> an normal = symbol NormalInterfaceDeclaration *> children (makeInterface <$> manyTerm modifier <*> identifier <*> (typeParameters <|> pure []) <*> (extends <|> pure []) <*> interfaceBody) makeInterface modifiers identifier typeParams = Declaration.InterfaceDeclaration (modifiers ++ typeParams) identifier annotationType = symbol AnnotationTypeDeclaration *> children (Declaration.InterfaceDeclaration [] <$> identifier <*> pure [] <*> annotationTypeBody) - annotationTypeBody = symbol AnnotationTypeBody *> children (annotationTypeMember) - annotationTypeMember = symbol AnnotationTypeMemberDeclaration *> children (class' <|> interface <|> constant) + annotationTypeBody = makeTerm <$> symbol AnnotationTypeBody <*> children (manyTerm annotationTypeMember) + annotationTypeMember = symbol AnnotationTypeMemberDeclaration *> children (class' <|> interface <|> constant <|> annotationTypeElement) annotationTypeElement = makeTerm <$> symbol AnnotationTypeElementDeclaration <*> children (Java.Syntax.AnnotationTypeElement <$> many modifier <*> type' <*> identifier <*> (dims <|> pure []) <*> (defaultValue <|> emptyTerm)) defaultValue = makeTerm <$> symbol DefaultValue <*> children (Java.Syntax.DefaultValue <$> elementValue) elementValue = symbol ElementValue *> children (term expression) -- pull this to top level l8r From fa9a060d09d3e97c279e3219c7dda6ea417d8cfc Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 20 Jul 2018 16:03:48 -0400 Subject: [PATCH 46/62] Consume constant method class and interfaces in normal interfaces Co-Authored-By: Ayman Nadeem --- src/Language/Java/Assignment.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 39ed656f2..18a8f2885 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -370,7 +370,7 @@ interface = makeTerm <$> symbol InterfaceDeclaration <*> children (normal <|> an annotationTypeElement = makeTerm <$> symbol AnnotationTypeElementDeclaration <*> children (Java.Syntax.AnnotationTypeElement <$> many modifier <*> type' <*> identifier <*> (dims <|> pure []) <*> (defaultValue <|> emptyTerm)) defaultValue = makeTerm <$> symbol DefaultValue <*> children (Java.Syntax.DefaultValue <$> elementValue) elementValue = symbol ElementValue *> children (term expression) -- pull this to top level l8r - interfaceMemberDeclaration = symbol InterfaceMemberDeclaration *> children (term expression) + interfaceMemberDeclaration = symbol InterfaceMemberDeclaration *> children (constant <|> method <|> class' <|> interface) extends = symbol ExtendsInterfaces *> children (symbol InterfaceTypeList *> children (manyTerm type')) constant :: Assignment Term From f09f2ce26abe7bdf848ff237ae5f8af910f5f0f1 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Mon, 23 Jul 2018 09:26:02 -0400 Subject: [PATCH 47/62] add tests for normalInterfaceDeclaration and assertStatements in stringLiteral --- test/fixtures/java/corpus/assertStringLiteral.java | 5 +++++ test/fixtures/java/corpus/normalInterfaceDeclaration.java | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 test/fixtures/java/corpus/assertStringLiteral.java create mode 100644 test/fixtures/java/corpus/normalInterfaceDeclaration.java diff --git a/test/fixtures/java/corpus/assertStringLiteral.java b/test/fixtures/java/corpus/assertStringLiteral.java new file mode 100644 index 000000000..201804ee1 --- /dev/null +++ b/test/fixtures/java/corpus/assertStringLiteral.java @@ -0,0 +1,5 @@ +class Dino { + void hi() { + assert failure : "expecting non null"; + } +} diff --git a/test/fixtures/java/corpus/normalInterfaceDeclaration.java b/test/fixtures/java/corpus/normalInterfaceDeclaration.java new file mode 100644 index 000000000..a2410e1ad --- /dev/null +++ b/test/fixtures/java/corpus/normalInterfaceDeclaration.java @@ -0,0 +1,3 @@ +@interface TerminationHandle { + Bar foo = 1; +} From 3139301e7beec0f628ecbbd3e94520f8297dfc3c Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Mon, 23 Jul 2018 11:08:25 -0400 Subject: [PATCH 48/62] add Named1 and Message1 --- src/Data/Syntax/Declaration.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/Syntax/Declaration.hs b/src/Data/Syntax/Declaration.hs index 5111823c9..0ed6c2fdf 100644 --- a/src/Data/Syntax/Declaration.hs +++ b/src/Data/Syntax/Declaration.hs @@ -122,7 +122,7 @@ instance Declarations a => Declarations (VariableDeclaration a) where -- | A TypeScript/Java style interface declaration to implement. data InterfaceDeclaration a = InterfaceDeclaration { interfaceDeclarationContext :: ![a], interfaceDeclarationIdentifier :: !a, interfaceDeclarationSuperInterfaces :: ![a], interfaceDeclarationBody :: !a } - deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable, Named1, Message1) instance Eq1 InterfaceDeclaration where liftEq = genericLiftEq instance Ord1 InterfaceDeclaration where liftCompare = genericLiftCompare From f9474e633cd8cddb1676099faa97c1016d304fbd Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Mon, 23 Jul 2018 11:09:19 -0400 Subject: [PATCH 49/62] cleanup comments in assignment --- src/Language/Java/Assignment.hs | 34 +++++++-------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 18a8f2885..36972e33c 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -192,7 +192,6 @@ expressionChoices = , constructorDeclaration , dimsExpr , explicitConstructorInvocation - -- , TODO: constantDeclaration , doWhile , fieldAccess , fieldDeclaration @@ -252,7 +251,6 @@ variableDeclaratorList = symbol VariableDeclaratorList *> children (makeDecl <$> makeSingleDecl modifiers type' (target, Nothing) = makeTerm1 (Java.Syntax.Variable modifiers type' target) makeSingleDecl modifiers type' (target, Just value) = makeTerm1 (Statement.Assignment [] (makeTerm1 (Java.Syntax.Variable modifiers type' target)) value) --- variable declarator -> variable initializer -> expression -> primary -> array creation expression arrayCreationExpression :: Assignment Term arrayCreationExpression = makeTerm <$> symbol Grammar.ArrayCreationExpression <*> children (Java.Syntax.ArrayCreationExpression <$> (new *> type') <*> many dimsExpr) where new = token AnonNew *> pure Java.Syntax.NewKeyword @@ -294,7 +292,6 @@ typeIdentifier = makeTerm <$> symbol TypeIdentifier <*> (Syntax.Identifier . nam identifier' :: Assignment Name identifier' = (symbol Identifier <|> symbol TypeIdentifier <|> symbol Identifier') *> (name <$> source) --- we want a name and not a full term wrapping the same, so we match the same stuff as identifier but we just produce the name scopedIdentifier :: Assignment Term scopedIdentifier = makeTerm <$> symbol ScopedIdentifier <*> children (Expression.MemberAccess <$> term expression <*> identifier') @@ -306,8 +303,7 @@ superInterfaces = symbol SuperInterfaces *> children (symbol InterfaceTypeList * class' :: Assignment Term class' = makeTerm <$> symbol ClassDeclaration <*> children (makeClass <$> many modifier <*> term identifier <*> (typeParameters <|> pure []) <*> optional superClass <*> (superInterfaces <|> pure []) <*> classBody) where - makeClass modifiers identifier typeParams superClass superInterfaces = Declaration.Class (modifiers <> typeParams) identifier (maybeToList superClass <> superInterfaces) -- not doing an assignment, just straight up function - -- classBody = makeTerm <$> symbol ClassBody <*> children (manyTerm expression) + makeClass modifiers identifier typeParams superClass superInterfaces = Declaration.Class (modifiers <> typeParams) identifier (maybeToList superClass <> superInterfaces) superClass = symbol Superclass *> children type' classBody :: Assignment Term @@ -326,7 +322,6 @@ method = makeTerm <$> symbol MethodDeclaration <*> children (makeMethod <$> many methodDeclarator = symbol MethodDeclarator *> children ( (,) <$> identifier <*> formalParameters) methodHeader = symbol MethodHeader *> children ((,,,,) <$> (typeParameters <|> pure []) <*> manyTerm annotation <*> type' <*> methodDeclarator <*> (throws <|> pure [])) makeMethod modifiers receiver (typeParams, annotations, returnType, (name, params), throws) = Declaration.Method (returnType : modifiers <> typeParams <> annotations <> throws) receiver name params --- methodHeader needs to include typeParameters (it does) generic :: Assignment Term generic = makeTerm <$> symbol Grammar.GenericType <*> children(Java.Syntax.GenericType <$> term type' <*> manyTerm type') @@ -336,14 +331,10 @@ methodInvocation = makeTerm <$> symbol MethodInvocation <*> children (uncurry Ex where callFunction a (Just (typeArguments, b)) = (typeArguments, makeTerm1 (Expression.MemberAccess a b)) callFunction a Nothing = ([], a) - -- optional produces a Maybe type (takes a Maybe a and returns a rule that produces a Maybe a) methodReference :: Assignment Term methodReference = makeTerm <$> symbol Grammar.MethodReference <*> children (Java.Syntax.MethodReference <$> term type' <*> manyTerm typeArgument <*> (new <|> term identifier)) where new = makeTerm <$> token AnonNew <*> pure Java.Syntax.NewKeyword --- can't do term identifier' because identifier' returns a name, not a term, and we want a term --- <*> - left assoc so when you have a token that you need to match but not retain, --- manyTerm or alternation with pure, but not bowf explicitConstructorInvocation :: Assignment Term explicitConstructorInvocation = makeTerm <$> symbol ExplicitConstructorInvocation <*> children (uncurry Expression.Call <$> (callFunction <$> term expression <*> optional ((,) <$ optional (token AnonRParen) <* token AnonDot <*> manyTerm type' <*> identifier')) <*> argumentList <*> emptyTerm) @@ -363,18 +354,18 @@ interface = makeTerm <$> symbol InterfaceDeclaration <*> children (normal <|> an where interfaceBody = makeTerm <$> symbol InterfaceBody <*> children (manyTerm interfaceMemberDeclaration) normal = symbol NormalInterfaceDeclaration *> children (makeInterface <$> manyTerm modifier <*> identifier <*> (typeParameters <|> pure []) <*> (extends <|> pure []) <*> interfaceBody) - makeInterface modifiers identifier typeParams = Declaration.InterfaceDeclaration (modifiers ++ typeParams) identifier + makeInterface modifiers identifier typeParams = Declaration.InterfaceDeclaration (modifiers <> typeParams) identifier annotationType = symbol AnnotationTypeDeclaration *> children (Declaration.InterfaceDeclaration [] <$> identifier <*> pure [] <*> annotationTypeBody) annotationTypeBody = makeTerm <$> symbol AnnotationTypeBody <*> children (manyTerm annotationTypeMember) annotationTypeMember = symbol AnnotationTypeMemberDeclaration *> children (class' <|> interface <|> constant <|> annotationTypeElement) annotationTypeElement = makeTerm <$> symbol AnnotationTypeElementDeclaration <*> children (Java.Syntax.AnnotationTypeElement <$> many modifier <*> type' <*> identifier <*> (dims <|> pure []) <*> (defaultValue <|> emptyTerm)) defaultValue = makeTerm <$> symbol DefaultValue <*> children (Java.Syntax.DefaultValue <$> elementValue) - elementValue = symbol ElementValue *> children (term expression) -- pull this to top level l8r + elementValue = symbol ElementValue *> children (term expression) interfaceMemberDeclaration = symbol InterfaceMemberDeclaration *> children (constant <|> method <|> class' <|> interface) extends = symbol ExtendsInterfaces *> children (symbol InterfaceTypeList *> children (manyTerm type')) constant :: Assignment Term -constant = makeTerm <$> symbol ConstantDeclaration <*> children ((,) <$> pure [] <*> type' <**> variableDeclaratorList) +constant = makeTerm <$> symbol ConstantDeclaration <*> children ((,) [] <$> type' <**> variableDeclaratorList) package :: Assignment Term package = makeTerm <$> symbol PackageDeclaration <*> children (Java.Syntax.Package <$> someTerm expression) @@ -388,12 +379,9 @@ enum = makeTerm <$> symbol Grammar.EnumDeclaration <*> children (Java.Syntax.Enu return' :: Assignment Term return' = makeTerm <$> symbol ReturnStatement <*> (Statement.Return <$> children (expression <|> emptyTerm)) --- method expressions dims :: Assignment [Term] dims = symbol Dims *> children (many (emptyTerm <* token AnonLBracket <* token AnonRBracket)) --- not sure why we did <* token with the dims (possibly because it's the only thing happening?) --- will define with manyTerm annotation <*> manyTerm expression and then revisit whether or not I need brackets dimsExpr :: Assignment Term dimsExpr = makeTerm <$> symbol Grammar.DimsExpr <*> children (Java.Syntax.DimsExpr <$> manyTerm annotation <*> manyTerm expression) @@ -480,7 +468,7 @@ tryWithResources = makeTerm <$> symbol TryWithResourcesStatement <*> children (J resourceSpecification = symbol ResourceSpecification *> children (manyTerm resource) resource = symbol Resource *> children variableAccess <|> makeTerm <$> symbol Resource <*> children (makeSingleDecl <$> many modifier <*> type' <*> variableDeclaratorId <*> term expression) variableAccess = symbol VariableAccess *> children (identifier <|> fieldAccess) - makeSingleDecl modifiers type' target value = Statement.Assignment [] (makeTerm1 (Java.Syntax.Variable modifiers type' target)) value + makeSingleDecl modifiers type' target = Statement.Assignment [] (makeTerm1 (Java.Syntax.Variable modifiers type' target)) for :: Assignment Term for = symbol ForStatement *> children (basicFor <|> enhancedFor) @@ -498,7 +486,6 @@ enhancedFor = makeTerm <$> symbol EnhancedForStatement <*> children (Statement.F assert :: Assignment Term assert = makeTerm <$> symbol Grammar.AssertStatement <*> children (Java.Syntax.AssertStatement <$> term expression <*> optional (term expression)) --- TODO: instanceOf binary :: Assignment Term binary = makeTerm' <$> symbol BinaryExpression <*> children (infixTerm expressionAndParens expressionAndParens [ (inject .) . Expression.LessThan <$ symbol AnonLAngle @@ -525,8 +512,8 @@ binary = makeTerm' <$> symbol BinaryExpression <*> children (infixTerm expressio where invert cons a b = Expression.Not (makeTerm1 (cons a b)) expressionAndParens = token AnonLParen *> expressionAndParens <* token AnonRParen <|> expression - -- TODO: expressionAndParens is a hack that accommodates Java's nested parens case but - -- altering the TreeSitter Java grammar is a better longer term goal. + -- TODO: expressionAndParens is a hack that accommodates Java's nested parens + -- but altering the TreeSitter Java grammar is a better longer term goal. -- | Match infix terms separated by any of a list of operators, assigning any comments following each operand. infixTerm :: Assignment Term @@ -596,14 +583,9 @@ classLiteral = makeTerm <$> symbol Grammar.ClassLiteral <*> children (Java.Synta argumentList :: Assignment [Term] argumentList = symbol ArgumentList *> children (manyTerm expression) --- this takes care of expression, expression, ..., expression --- but does this take care of parenthesized argumentList (it's a separate rule in TS) --- I think methodReference being a top-level expression now will make manyTerm expression recognize this super :: Assignment Term super = makeTerm <$> token Super <*> pure Expression.Super --- INCORRECT: super = makeTerm <$> token Super $> Expression.Super --- Take partially applied function and replace it instead of applying this :: Assignment Term this = makeTerm <$> token This <*> pure Expression.This @@ -618,8 +600,6 @@ constructorDeclaration = makeTerm <$> symbol ConstructorDeclaration <*> children typeParameters :: Assignment [Term] typeParameters = symbol TypeParameters *> children (manyTerm typeParam) --- not making a term, just matching children and returning the whole list --- unpacking the TypeParameters node where typeParam = makeTerm <$> symbol Grammar.TypeParameter <*> children (Java.Syntax.TypeParameter <$> manyTerm annotation <*> term identifier <*> (typeBound <|> pure [])) typeBound = symbol TypeBound *> children (manyTerm type') From cb032b8229cabb36ed7513317a4d429eb3f00f68 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Mon, 23 Jul 2018 11:09:46 -0400 Subject: [PATCH 50/62] change to newtype --- src/Language/Java/Syntax.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Language/Java/Syntax.hs b/src/Language/Java/Syntax.hs index 6a7f98c75..a0c63bf77 100644 --- a/src/Language/Java/Syntax.hs +++ b/src/Language/Java/Syntax.hs @@ -199,7 +199,7 @@ instance Show1 SpreadParameter where liftShowsPrec = genericLiftShowsPrec -- TODO: Implement Eval instance for SpreadParameter instance Evaluatable SpreadParameter -data StaticInitializer a = StaticInitializer { staticInitializerBlock :: !a } +newtype StaticInitializer a = StaticInitializer { staticInitializerBlock :: a } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) From 6e0d69133e4f8fc797f61abc2b7fb0f1c5f71d30 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Mon, 23 Jul 2018 12:16:05 -0400 Subject: [PATCH 51/62] remove mergeable from Java.Syntax --- src/Language/Java/Syntax.hs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Language/Java/Syntax.hs b/src/Language/Java/Syntax.hs index 3b60aa89d..1908eed56 100644 --- a/src/Language/Java/Syntax.hs +++ b/src/Language/Java/Syntax.hs @@ -69,7 +69,7 @@ instance Show1 Synchronized where liftShowsPrec = genericLiftShowsPrec instance Evaluatable Synchronized data New a = New { newType :: !a, newArgs :: ![a], newClassBody :: Maybe a } - deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) instance Eq1 New where liftEq = genericLiftEq instance Ord1 New where liftCompare = genericLiftCompare @@ -140,7 +140,7 @@ instance Show1 GenericType where liftShowsPrec = genericLiftShowsPrec instance Evaluatable GenericType data AnnotatedType a = AnnotatedType { annotationes :: [a], annotatedType :: a } - deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) instance Eq1 AnnotatedType where liftEq = genericLiftEq instance Ord1 AnnotatedType where liftCompare = genericLiftCompare @@ -150,7 +150,7 @@ instance Show1 AnnotatedType where liftShowsPrec = genericLiftShowsPrec instance Evaluatable AnnotatedType data CatchType a = CatchType { types :: [a] } - deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) instance Eq1 CatchType where liftEq = genericLiftEq instance Ord1 CatchType where liftCompare = genericLiftCompare @@ -200,7 +200,7 @@ instance Show1 SpreadParameter where liftShowsPrec = genericLiftShowsPrec instance Evaluatable SpreadParameter newtype StaticInitializer a = StaticInitializer { staticInitializerBlock :: a } - deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) instance Eq1 StaticInitializer where liftEq = genericLiftEq @@ -211,7 +211,7 @@ instance Evaluatable StaticInitializer -- I think this is wrong because it doesn't acknowledge double colon. data MethodReference a = MethodReference { methodReferenceType :: !a, methodReferenceTypeArgs :: ![a], methodReferenceIdentifier :: !a} - deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) instance Eq1 MethodReference where liftEq = genericLiftEq instance Ord1 MethodReference where liftCompare = genericLiftCompare @@ -221,7 +221,7 @@ instance Show1 MethodReference where liftShowsPrec = genericLiftShowsPrec instance Evaluatable MethodReference data NewKeyword a = NewKeyword - deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) instance Eq1 NewKeyword where liftEq = genericLiftEq instance Ord1 NewKeyword where liftCompare = genericLiftCompare @@ -231,7 +231,7 @@ instance Show1 NewKeyword where liftShowsPrec = genericLiftShowsPrec instance Evaluatable NewKeyword data Lambda a = Lambda { lambdaParams :: ![a], lambdaBody :: !a } - deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) instance Eq1 Lambda where liftEq = genericLiftEq instance Ord1 Lambda where liftCompare = genericLiftCompare @@ -240,7 +240,7 @@ instance Show1 Lambda where liftShowsPrec = genericLiftShowsPrec instance Evaluatable Lambda data LambdaBody a = LambdaBody { lambdaBodyExpression :: ![a] } - deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) instance Eq1 LambdaBody where liftEq = genericLiftEq instance Ord1 LambdaBody where liftCompare = genericLiftCompare @@ -249,7 +249,7 @@ instance Show1 LambdaBody where liftShowsPrec = genericLiftShowsPrec instance Evaluatable LambdaBody data ArrayCreationExpression a = ArrayCreationExpression { arrayCreationExpressionType :: !a, arrayCreationExpressionDims :: ![a] } - deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) instance Eq1 ArrayCreationExpression where liftEq = genericLiftEq instance Ord1 ArrayCreationExpression where liftCompare = genericLiftCompare @@ -258,7 +258,7 @@ instance Show1 ArrayCreationExpression where liftShowsPrec = genericLiftShowsPre instance Evaluatable ArrayCreationExpression data DimsExpr a = DimsExpr { dimsExprAnnotation :: ![a], dimsExprExpression :: ![a] } - deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) instance Eq1 DimsExpr where liftEq = genericLiftEq instance Ord1 DimsExpr where liftCompare = genericLiftCompare @@ -267,7 +267,7 @@ instance Show1 DimsExpr where liftShowsPrec = genericLiftShowsPrec instance Evaluatable DimsExpr newtype ClassBody a = ClassBody { classBodyExpression :: [a] } - deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) instance Eq1 ClassBody where liftEq = genericLiftEq instance Ord1 ClassBody where liftCompare = genericLiftCompare @@ -276,7 +276,7 @@ instance Show1 ClassBody where liftShowsPrec = genericLiftShowsPrec instance Evaluatable ClassBody newtype ClassLiteral a = ClassLiteral { classLiteralType :: a } - deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) instance Eq1 ClassLiteral where liftEq = genericLiftEq instance Ord1 ClassLiteral where liftCompare = genericLiftCompare @@ -285,7 +285,7 @@ instance Show1 ClassLiteral where liftShowsPrec = genericLiftShowsPrec instance Evaluatable ClassLiteral data TryWithResources a = TryWithResources { tryResources :: ![a], tryBody :: !a, tryCatch :: ![a] } - deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) instance Eq1 TryWithResources where liftEq = genericLiftEq instance Ord1 TryWithResources where liftCompare = genericLiftCompare @@ -295,7 +295,7 @@ instance Show1 TryWithResources where liftShowsPrec = genericLiftShowsPrec instance Evaluatable TryWithResources data AssertStatement a = AssertStatement { assertLHS :: !a, assertRHS :: !(Maybe a) } - deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) instance Eq1 AssertStatement where liftEq = genericLiftEq instance Ord1 AssertStatement where liftCompare = genericLiftCompare @@ -305,7 +305,7 @@ instance Show1 AssertStatement where liftShowsPrec = genericLiftShowsPrec instance Evaluatable AssertStatement newtype DefaultValue a = DefaultValue { defaultValueElement :: a } - deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) instance Eq1 DefaultValue where liftEq = genericLiftEq instance Ord1 DefaultValue where liftCompare = genericLiftCompare @@ -314,7 +314,7 @@ instance Show1 DefaultValue where liftShowsPrec = genericLiftShowsPrec instance Evaluatable DefaultValue data AnnotationTypeElement a = AnnotationTypeElement { modifiers :: ![a], annotationType :: a, identifier :: !a, dims :: ![a], defaultValue :: !a } - deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) instance Eq1 AnnotationTypeElement where liftEq = genericLiftEq instance Ord1 AnnotationTypeElement where liftCompare = genericLiftCompare From ccd788357486972b89b2938ace712286377f316b Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Mon, 23 Jul 2018 12:33:18 -0400 Subject: [PATCH 52/62] remove comment --- src/Language/Java/Syntax.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Language/Java/Syntax.hs b/src/Language/Java/Syntax.hs index 1908eed56..2ae1740c5 100644 --- a/src/Language/Java/Syntax.hs +++ b/src/Language/Java/Syntax.hs @@ -209,7 +209,6 @@ instance Show1 StaticInitializer where liftShowsPrec = genericLiftShowsPrec instance Evaluatable StaticInitializer --- I think this is wrong because it doesn't acknowledge double colon. data MethodReference a = MethodReference { methodReferenceType :: !a, methodReferenceTypeArgs :: ![a], methodReferenceIdentifier :: !a} deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) From f773cc7de0a2a0f8895c4651a40b771e88655e1c Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Mon, 23 Jul 2018 12:35:49 -0400 Subject: [PATCH 53/62] turn LambdaBody into a newtype --- src/Language/Java/Syntax.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Language/Java/Syntax.hs b/src/Language/Java/Syntax.hs index 2ae1740c5..9fc35a8f1 100644 --- a/src/Language/Java/Syntax.hs +++ b/src/Language/Java/Syntax.hs @@ -238,7 +238,7 @@ instance Show1 Lambda where liftShowsPrec = genericLiftShowsPrec instance Evaluatable Lambda -data LambdaBody a = LambdaBody { lambdaBodyExpression :: ![a] } +newtype LambdaBody a = LambdaBody { lambdaBodyExpression :: ![a] } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) instance Eq1 LambdaBody where liftEq = genericLiftEq From 6ba948f42bcf43b56b9b1332f6694783e8f3df39 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Mon, 23 Jul 2018 12:39:11 -0400 Subject: [PATCH 54/62] remove strict type --- src/Language/Java/Syntax.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Language/Java/Syntax.hs b/src/Language/Java/Syntax.hs index 9fc35a8f1..89da0115f 100644 --- a/src/Language/Java/Syntax.hs +++ b/src/Language/Java/Syntax.hs @@ -238,7 +238,7 @@ instance Show1 Lambda where liftShowsPrec = genericLiftShowsPrec instance Evaluatable Lambda -newtype LambdaBody a = LambdaBody { lambdaBodyExpression :: ![a] } +newtype LambdaBody a = LambdaBody { lambdaBodyExpression :: [a] } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) instance Eq1 LambdaBody where liftEq = genericLiftEq From b8317c8586fd1b7a83ec07c253919d25df8b421f Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Mon, 23 Jul 2018 12:39:46 -0400 Subject: [PATCH 55/62] remove mergeable --- src/Data/Syntax/Declaration.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/Syntax/Declaration.hs b/src/Data/Syntax/Declaration.hs index 0cb516292..e81c0b53f 100644 --- a/src/Data/Syntax/Declaration.hs +++ b/src/Data/Syntax/Declaration.hs @@ -122,7 +122,7 @@ instance Declarations a => Declarations (VariableDeclaration a) where -- | A TypeScript/Java style interface declaration to implement. data InterfaceDeclaration a = InterfaceDeclaration { interfaceDeclarationContext :: ![a], interfaceDeclarationIdentifier :: !a, interfaceDeclarationBody :: !a } - deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable, Named1, Message1) + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable, Named1, Message1) instance Eq1 InterfaceDeclaration where liftEq = genericLiftEq instance Ord1 InterfaceDeclaration where liftCompare = genericLiftCompare From d449218ea34235d385208b585f3043c57afdc15c Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Mon, 23 Jul 2018 13:21:28 -0400 Subject: [PATCH 56/62] fix InterfaceDeclaration syntax --- src/Data/Syntax/Declaration.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Data/Syntax/Declaration.hs b/src/Data/Syntax/Declaration.hs index e81c0b53f..8a7a1dc20 100644 --- a/src/Data/Syntax/Declaration.hs +++ b/src/Data/Syntax/Declaration.hs @@ -121,7 +121,8 @@ instance Declarations a => Declarations (VariableDeclaration a) where -- | A TypeScript/Java style interface declaration to implement. -data InterfaceDeclaration a = InterfaceDeclaration { interfaceDeclarationContext :: ![a], interfaceDeclarationIdentifier :: !a, interfaceDeclarationBody :: !a } + +data InterfaceDeclaration a = InterfaceDeclaration { interfaceDeclarationContext :: ![a], interfaceDeclarationIdentifier :: !a, interfaceDeclarationSuperInterfaces :: ![a], interfaceDeclarationBody :: !a } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable, Named1, Message1) instance Eq1 InterfaceDeclaration where liftEq = genericLiftEq From 3ba39b9bc7c928e0324eea7ffb43f37fb78caa8f Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Mon, 23 Jul 2018 13:34:31 -0400 Subject: [PATCH 57/62] use newtype --- src/Language/Java/Syntax.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Language/Java/Syntax.hs b/src/Language/Java/Syntax.hs index 89da0115f..3cecf9cac 100644 --- a/src/Language/Java/Syntax.hs +++ b/src/Language/Java/Syntax.hs @@ -149,7 +149,7 @@ instance Show1 AnnotatedType where liftShowsPrec = genericLiftShowsPrec -- TODO: Implement Eval instance for AnnotatedType instance Evaluatable AnnotatedType -data CatchType a = CatchType { types :: [a] } +newtype CatchType a = CatchType { types :: [a] } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) instance Eq1 CatchType where liftEq = genericLiftEq From 913ba4c315bd22b07d98419b94294b514da78979 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Mon, 23 Jul 2018 13:49:10 -0400 Subject: [PATCH 58/62] fix hlint errors and add java to integration spec --- src/Language/Java/Assignment.hs | 4 ++-- test/Integration/Spec.hs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 36972e33c..2e721d2e6 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -253,7 +253,7 @@ variableDeclaratorList = symbol VariableDeclaratorList *> children (makeDecl <$> arrayCreationExpression :: Assignment Term arrayCreationExpression = makeTerm <$> symbol Grammar.ArrayCreationExpression <*> children (Java.Syntax.ArrayCreationExpression <$> (new *> type') <*> many dimsExpr) - where new = token AnonNew *> pure Java.Syntax.NewKeyword + where new = token AnonNew $> pure Java.Syntax.NewKeyword localVariableDeclarationStatement :: Assignment Term localVariableDeclarationStatement = symbol LocalVariableDeclarationStatement *> children localVariableDeclaration @@ -285,7 +285,7 @@ char = makeTerm <$> symbol CharacterLiteral <*> (Literal.TextElement <$> source) -- Identifiers identifier :: Assignment Term -identifier = makeTerm <$> (symbol Identifier) <*> (Syntax.Identifier . name <$> source) +identifier = makeTerm <$> symbol Identifier <*> (Syntax.Identifier . name <$> source) typeIdentifier :: Assignment Term typeIdentifier = makeTerm <$> symbol TypeIdentifier <*> (Syntax.Identifier . name <$> source) diff --git a/test/Integration/Spec.hs b/test/Integration/Spec.hs index 463f75f8e..6e804f6a5 100644 --- a/test/Integration/Spec.hs +++ b/test/Integration/Spec.hs @@ -9,7 +9,7 @@ import System.FilePath.Posix import SpecHelpers languages :: [FilePath] -languages = ["go", "javascript", "json", "python", "ruby", "typescript"] +languages = ["go", "javascript", "json", "python", "ruby", "typescript", "java"] spec :: TaskConfig -> Spec spec config = parallel $ do From 7d468d482379fbae53d005348c290caf81826c7c Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Mon, 23 Jul 2018 13:58:12 -0400 Subject: [PATCH 59/62] address ambiguous type variable f0 arising from a use of pure --- src/Language/Java/Assignment.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 2e721d2e6..4b6f02276 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -253,7 +253,7 @@ variableDeclaratorList = symbol VariableDeclaratorList *> children (makeDecl <$> arrayCreationExpression :: Assignment Term arrayCreationExpression = makeTerm <$> symbol Grammar.ArrayCreationExpression <*> children (Java.Syntax.ArrayCreationExpression <$> (new *> type') <*> many dimsExpr) - where new = token AnonNew $> pure Java.Syntax.NewKeyword + where new = token AnonNew $> Java.Syntax.NewKeyword localVariableDeclarationStatement :: Assignment Term localVariableDeclarationStatement = symbol LocalVariableDeclarationStatement *> children localVariableDeclaration From 6713fdde39c99eea2391a76915ecb96631e43ff4 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Mon, 23 Jul 2018 14:22:21 -0400 Subject: [PATCH 60/62] re-generate ambient-declarations and interface typescript tests --- .../corpus/ambient-declarations.diffA-B.txt | 3 --- .../corpus/ambient-declarations.diffB-A.txt | 3 --- .../corpus/ambient-declarations.parseA.txt | 2 -- .../corpus/ambient-declarations.parseB.txt | 1 - .../typescript/corpus/interface.parseA.txt | 23 ------------------- .../typescript/corpus/interface.parseB.txt | 7 ++++-- 6 files changed, 5 insertions(+), 34 deletions(-) diff --git a/test/fixtures/typescript/corpus/ambient-declarations.diffA-B.txt b/test/fixtures/typescript/corpus/ambient-declarations.diffA-B.txt index 19766d866..e1e3f0fd6 100644 --- a/test/fixtures/typescript/corpus/ambient-declarations.diffA-B.txt +++ b/test/fixtures/typescript/corpus/ambient-declarations.diffA-B.txt @@ -22,7 +22,6 @@ {-(Identifier)-} {-(Empty)-})-}) ->(InterfaceDeclaration - {+(Empty)+} {+(Empty)+} {+(Identifier)+} {+(ObjectType)+}) }) @@ -63,7 +62,6 @@ {-(Identifier)-} {-(Empty)-})-})-} {-(InterfaceDeclaration - {-(Empty)-} {-(Empty)-} {-(Identifier)-} {-(ObjectType @@ -74,7 +72,6 @@ {-(PredefinedType)-})-} {-(Identifier)-})-})-})-} {-(InterfaceDeclaration - {-(Empty)-} {-(Empty)-} {-(Identifier)-} {-(ObjectType diff --git a/test/fixtures/typescript/corpus/ambient-declarations.diffB-A.txt b/test/fixtures/typescript/corpus/ambient-declarations.diffB-A.txt index 1e283e178..5cbf08214 100644 --- a/test/fixtures/typescript/corpus/ambient-declarations.diffB-A.txt +++ b/test/fixtures/typescript/corpus/ambient-declarations.diffB-A.txt @@ -53,7 +53,6 @@ {+(Identifier)+} {+(Empty)+})+})+} {+(InterfaceDeclaration - {+(Empty)+} {+(Empty)+} {+(Identifier)+} {+(ObjectType @@ -64,7 +63,6 @@ {+(PredefinedType)+})+} {+(Identifier)+})+})+})+} {+(InterfaceDeclaration - {+(Empty)+} {+(Empty)+} {+(Identifier)+} {+(ObjectType @@ -95,7 +93,6 @@ {-(Statements)-})-})-} {-(AmbientDeclaration {-(InterfaceDeclaration - {-(Empty)-} {-(Empty)-} {-(Identifier)-} {-(ObjectType)-})-})-} diff --git a/test/fixtures/typescript/corpus/ambient-declarations.parseA.txt b/test/fixtures/typescript/corpus/ambient-declarations.parseA.txt index 40133edb5..e16ff63f6 100644 --- a/test/fixtures/typescript/corpus/ambient-declarations.parseA.txt +++ b/test/fixtures/typescript/corpus/ambient-declarations.parseA.txt @@ -53,7 +53,6 @@ (Identifier) (Empty))) (InterfaceDeclaration - (Empty) (Empty) (Identifier) (ObjectType @@ -64,7 +63,6 @@ (PredefinedType)) (Identifier)))) (InterfaceDeclaration - (Empty) (Empty) (Identifier) (ObjectType diff --git a/test/fixtures/typescript/corpus/ambient-declarations.parseB.txt b/test/fixtures/typescript/corpus/ambient-declarations.parseB.txt index 60a04c19c..80110f215 100644 --- a/test/fixtures/typescript/corpus/ambient-declarations.parseB.txt +++ b/test/fixtures/typescript/corpus/ambient-declarations.parseB.txt @@ -8,7 +8,6 @@ (Statements))) (AmbientDeclaration (InterfaceDeclaration - (Empty) (Empty) (Identifier) (ObjectType))) diff --git a/test/fixtures/typescript/corpus/interface.parseA.txt b/test/fixtures/typescript/corpus/interface.parseA.txt index 9cb98a509..e69de29bb 100644 --- a/test/fixtures/typescript/corpus/interface.parseA.txt +++ b/test/fixtures/typescript/corpus/interface.parseA.txt @@ -1,23 +0,0 @@ -(Statements - (InterfaceDeclaration - (TypeParameters - (TypeParameter - (Identifier) - (Empty) - (Empty))) - (Empty) - (Identifier) - (ObjectType - (PropertySignature - (Empty) - (Empty) - (Annotation - (LiteralType - (TextElement))) - (Identifier)) - (PropertySignature - (Empty) - (Readonly) - (Annotation - (TypeIdentifier)) - (Identifier))))) diff --git a/test/fixtures/typescript/corpus/interface.parseB.txt b/test/fixtures/typescript/corpus/interface.parseB.txt index d08c9ddce..a0ac0a3fb 100644 --- a/test/fixtures/typescript/corpus/interface.parseB.txt +++ b/test/fixtures/typescript/corpus/interface.parseB.txt @@ -1,7 +1,10 @@ (Statements (InterfaceDeclaration - (Empty) - (Empty) + (TypeParameters + (TypeParameter + (Identifier) + (Empty) + (Empty))) (Identifier) (ObjectType (PropertySignature From ea869927214ef20277291e3e8d55a04cf1a2496d Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Mon, 23 Jul 2018 15:04:07 -0400 Subject: [PATCH 61/62] regenerate interface tests --- .../typescript/corpus/interface.diffA-B.txt | 3 +-- .../typescript/corpus/interface.diffB-A.txt | 1 - .../typescript/corpus/interface.parseA.txt | 22 +++++++++++++++++++ .../typescript/corpus/interface.parseB.txt | 6 +---- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/test/fixtures/typescript/corpus/interface.diffA-B.txt b/test/fixtures/typescript/corpus/interface.diffA-B.txt index 5010c4149..6a5ffe86b 100644 --- a/test/fixtures/typescript/corpus/interface.diffA-B.txt +++ b/test/fixtures/typescript/corpus/interface.diffA-B.txt @@ -1,12 +1,11 @@ (Statements (InterfaceDeclaration + {+(Empty)+} {-(TypeParameters {-(TypeParameter {-(Identifier)-} {-(Empty)-} {-(Empty)-})-})-} - (Empty) - {+(Empty)+} { (Identifier) ->(Identifier) } (ObjectType diff --git a/test/fixtures/typescript/corpus/interface.diffB-A.txt b/test/fixtures/typescript/corpus/interface.diffB-A.txt index 09d1a01c7..2c44f0f48 100644 --- a/test/fixtures/typescript/corpus/interface.diffB-A.txt +++ b/test/fixtures/typescript/corpus/interface.diffB-A.txt @@ -5,7 +5,6 @@ {+(Identifier)+} {+(Empty)+} {+(Empty)+})+})+} - (Empty) {-(Empty)-} { (Identifier) ->(Identifier) } diff --git a/test/fixtures/typescript/corpus/interface.parseA.txt b/test/fixtures/typescript/corpus/interface.parseA.txt index e69de29bb..a0ac0a3fb 100644 --- a/test/fixtures/typescript/corpus/interface.parseA.txt +++ b/test/fixtures/typescript/corpus/interface.parseA.txt @@ -0,0 +1,22 @@ +(Statements + (InterfaceDeclaration + (TypeParameters + (TypeParameter + (Identifier) + (Empty) + (Empty))) + (Identifier) + (ObjectType + (PropertySignature + (Empty) + (Empty) + (Annotation + (LiteralType + (TextElement))) + (Identifier)) + (PropertySignature + (Empty) + (Readonly) + (Annotation + (TypeIdentifier)) + (Identifier))))) diff --git a/test/fixtures/typescript/corpus/interface.parseB.txt b/test/fixtures/typescript/corpus/interface.parseB.txt index a0ac0a3fb..fd9d86c04 100644 --- a/test/fixtures/typescript/corpus/interface.parseB.txt +++ b/test/fixtures/typescript/corpus/interface.parseB.txt @@ -1,10 +1,6 @@ (Statements (InterfaceDeclaration - (TypeParameters - (TypeParameter - (Identifier) - (Empty) - (Empty))) + (Empty) (Identifier) (ObjectType (PropertySignature From c30298f528be7c8f47b74071237110ff66c387cc Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Mon, 23 Jul 2018 15:22:44 -0400 Subject: [PATCH 62/62] remove java from integration spec --- test/Integration/Spec.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Integration/Spec.hs b/test/Integration/Spec.hs index 6e804f6a5..463f75f8e 100644 --- a/test/Integration/Spec.hs +++ b/test/Integration/Spec.hs @@ -9,7 +9,7 @@ import System.FilePath.Posix import SpecHelpers languages :: [FilePath] -languages = ["go", "javascript", "json", "python", "ruby", "typescript", "java"] +languages = ["go", "javascript", "json", "python", "ruby", "typescript"] spec :: TaskConfig -> Spec spec config = parallel $ do