1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00

Merge remote-tracking branch 'origin/master' into add-source-spans

This commit is contained in:
joshvera 2016-10-11 10:45:22 -04:00
commit d95283f4a1
11 changed files with 582 additions and 9 deletions

View File

@ -109,6 +109,10 @@ data Category
| MathOperator
-- | A module
| Module
-- | An import
| Import
-- | An export
| Export
deriving (Eq, Generic, Ord, Show)
-- Instances
@ -161,6 +165,8 @@ instance Arbitrary Category where
, pure Class
, pure Method
, pure Module
, pure Import
, pure Export
, Other <$> arbitrary
]

View File

@ -50,6 +50,8 @@ identifiable term = isIdentifiable (unwrap term) term
S.Method{} -> Identifiable
S.Leaf{} -> Identifiable
S.DoWhile{} -> Identifiable
S.Import{} -> Identifiable
S.Export{} -> Identifiable
_ -> Unidentifiable
data JSONSummary summary span = JSONSummary { summary :: summary, span :: span }
@ -138,13 +140,16 @@ determiner (BranchInfo bs _ _) = determiner (last bs)
determiner _ = "the"
toLeafInfos :: DiffInfo -> [JSONSummary Doc SourceSpan]
toLeafInfos (LeafInfo "number" termName sourceSpan) = pure $ JSONSummary (squotes $ toDoc termName) sourceSpan
toLeafInfos (LeafInfo "boolean" termName sourceSpan) = pure $ JSONSummary (squotes $ toDoc termName) sourceSpan
toLeafInfos (LeafInfo "anonymous function" termName sourceSpan) = pure $ JSONSummary (toDoc termName) sourceSpan
toLeafInfos (LeafInfo cName@"string" termName sourceSpan) = pure $ JSONSummary (toDoc termName <+> toDoc cName) sourceSpan
toLeafInfos LeafInfo{..} = pure $ JSONSummary (squotes (toDoc termName) <+> toDoc categoryName) sourceSpan
toLeafInfos BranchInfo{..} = toLeafInfos =<< branches
toLeafInfos err@ErrorInfo{..} = pure $ ErrorSummary (pretty err) errorSpan
toLeafInfos BranchInfo{..} = branches >>= toLeafInfos
toLeafInfos leaf = pure . flip JSONSummary (sourceSpan leaf) $ case leaf of
(LeafInfo "number" termName _) -> squotes $ toDoc termName
(LeafInfo "boolean" termName _) -> squotes $ toDoc termName
(LeafInfo "anonymous function" termName _) -> toDoc termName
(LeafInfo cName@"string" termName _) -> toDoc termName <+> toDoc cName
(LeafInfo cName@"export statement" termName _) -> toDoc termName <+> toDoc cName
LeafInfo{..} -> squotes (toDoc termName) <+> toDoc categoryName
node -> panic $ "Expected a leaf info but got a: " <> show node
-- Returns a text representing a specific term given a source and a term.
toTermName :: forall leaf fields. (HasCategory leaf, HasField fields Category, HasField fields Range) => Source Char -> SyntaxTerm leaf fields -> Text
@ -199,6 +204,10 @@ toTermName source term = case unwrap term of
S.Comment a -> toCategoryName a
S.Commented _ _ -> termNameFromChildren term (toList $ unwrap term)
S.Module identifier _ -> toTermName' identifier
S.Import identifier _ -> toTermName' identifier
S.Export Nothing expr -> intercalate ", " $ termNameFromSource <$> expr
S.Export (Just identifier) [] -> toTermName' identifier
S.Export (Just identifier) expr -> (intercalate ", " $ termNameFromSource <$> expr) <> " from " <> toTermName' identifier
where toTermName' = toTermName source
termNameFromChildren term children = termNameFromRange (unionRangesFrom (range term) (range <$> children))
termNameFromSource term = termNameFromRange (range term)
@ -210,8 +219,6 @@ toTermName source term = case unwrap term of
Identifiable arg -> toTermName' arg
Unidentifiable _ -> ""
parentContexts :: [Either (Category, Text) (Category, Text)] -> Doc
parentContexts contexts = hsep $ either identifiableDoc annotatableDoc <$> contexts
where
@ -317,6 +324,8 @@ instance HasCategory Category where
C.CommaOperator -> "comma operator"
C.Empty -> "empty statement"
C.Module -> "module statement"
C.Import -> "import statement"
C.Export -> "export statement"
instance HasField fields Category => HasCategory (SyntaxTerm leaf fields) where
toCategoryName = toCategoryName . category . extract

View File

@ -66,6 +66,12 @@ termConstructor source sourceSpan name range children
("method_definition", [ identifier, exprs ]) -> S.Method identifier [] (toList (unwrap exprs))
("class", [ identifier, superclass, definitions ]) -> S.Class identifier (Just superclass) (toList (unwrap definitions))
("class", [ identifier, definitions ]) -> S.Class identifier Nothing (toList (unwrap definitions))
("import_statement", [ statements, identifier ] ) -> S.Import identifier (toList (unwrap statements))
("import_statement", [ identifier ] ) -> S.Import identifier []
("export_statement", [ statements, identifier] ) -> S.Export (Just identifier) (toList (unwrap statements))
("export_statement", [ statements ] ) -> case unwrap statements of
S.Indexed _ -> S.Export Nothing (toList (unwrap statements))
_ -> S.Export (Just statements) []
_ | name `elem` forStatements, Just (exprs, body) <- unsnoc children -> S.For exprs body
_ | name `elem` operators -> S.Operator children
_ | name `elem` functions -> case children of
@ -143,6 +149,8 @@ categoryForJavaScriptProductionName name = case name of
"comment" -> Comment
"bitwise_op" -> BitwiseOperator
"rel_op" -> RelationalOperator
"import_statement" -> Import
"export_statement" -> Export
_ -> Other name
toVarDecl :: (HasField fields Category) => Term (S.Syntax Text) (Record fields) -> Term (S.Syntax Text) (Record fields)

View File

@ -101,6 +101,8 @@ termFields info syntax = "range" .= characterRange info : "category" .= category
S.Class identifier superclass definitions -> [ "classIdentifier" .= identifier ] <> [ "superclass" .= superclass ] <> [ "definitions" .= definitions ]
S.Method identifier params definitions -> [ "methodIdentifier" .= identifier ] <> [ "params" .= params ] <> [ "definitions" .= definitions ]
S.Module identifier definitions-> [ "moduleIdentifier" .= identifier ] <> [ "definitions" .= definitions ]
S.Import identifier expr -> [ "importIdentifier" .= identifier ] <> [ "importStatements" .= expr ]
S.Export identifier expr -> [ "exportIdentifier" .= identifier ] <> [ "exportStatements" .= expr ]
where childrenFields c = [ "children" .= c ]
patchFields :: (KeyValue kv, HasField fields Category, HasField fields Range) => SplitPatch (SyntaxTerm leaf fields) -> [kv]

View File

@ -81,6 +81,8 @@ styleName category = "category-" <> case category of
C.CommaOperator -> "comma_operator"
Other string -> string
C.Module -> "module_statement"
C.Import -> "import_statement"
C.Export -> "export_statement"
-- | Pick the class name for a split patch.
splitPatchToClassName :: SplitPatch a -> AttributeValue

View File

@ -73,6 +73,8 @@ data Syntax a f
| If f f (Maybe f)
-- | A module with an identifier, and a list of syntaxes.
| Module { moduleId:: f, moduleBody :: [f] }
| Import f [f]
| Export (Maybe f) [f]
deriving (Eq, Foldable, Functor, Generic, Generic1, Mergeable, Ord, Show, Traversable)

View File

@ -0,0 +1,267 @@
[{
"testCaseDescription": "javascript-export-insert-test",
"expectedResult": {
"changes": {
"export.js": [
"Added the name1, name2, name3, nameN export statement",
"Added the variable1 as name1, variable2 as name2, nameN export statement",
"Added the name1, name2, nameN export statement",
"Added the name1 = value1, name2 = value2, name3, nameN export statement",
"Added the namedFunction export statement",
"Added the anonymous() function export statement",
"Added the name1 export statement",
"Added the name1 as default export statement",
"Added the 'foo' export statement",
"Added the name1, name2, nameN from 'foo' export statement",
"Added the import1 as name1, import2 as name2, nameN from 'bar' export statement",
"Added the 'foo' export statement"
]
},
"errors": {}
},
"filePaths": [
"export.js"
],
"sha1": "fbc5b11fcf02fc81e576ea8ec5d4e590a6a4cf6c",
"gitDir": "test/corpus/repos/javascript",
"sha2": "2a02b3c789985c3d109009301b6b75f7151dfa26"
}
,{
"testCaseDescription": "javascript-export-replacement-insert-test",
"expectedResult": {
"changes": {
"export.js": [
"Added the name4, name5, name6, nameZ export statement",
"Added the variable2 as name2, variable3 as name3, nameY export statement",
"Added the name3, name4, nameT export statement",
"Added the name2 = value2, name3 = value3, name4, nameO export statement",
"Added the otherNamedFunction export statement",
"Added the newName1 export statement",
"Added the anonymous() function export statement",
"Added the name2 as statement export statement",
"Added the 'baz' export statement",
"Added the name7, name8, nameP from 'buzz' export statement",
"Added the import6 as name6, import7 as name7, nameB from 'fizz' export statement",
"Added the 'fuzz' export statement",
"Added the name1, name2, name3, nameN export statement",
"Added the variable1 as name1, variable2 as name2, nameN export statement",
"Added the name1, name2, nameN export statement",
"Added the name1 = value1, name2 = value2, name3, nameN export statement",
"Added the namedFunction export statement",
"Added the anonymous() function export statement",
"Added the name1 export statement",
"Added the name1 as default export statement",
"Added the 'foo' export statement",
"Added the name1, name2, nameN from 'foo' export statement",
"Added the import1 as name1, import2 as name2, nameN from 'bar' export statement",
"Added the 'foo' export statement"
]
},
"errors": {}
},
"filePaths": [
"export.js"
],
"sha1": "2a02b3c789985c3d109009301b6b75f7151dfa26",
"gitDir": "test/corpus/repos/javascript",
"sha2": "a86486153befecb5a8435248342ae9ee5f9bb9fe"
}
,{
"testCaseDescription": "javascript-export-delete-insert-test",
"expectedResult": {
"changes": {
"export.js": [
"Replaced the 'name4' identifier with the 'name1' identifier in the name1, name2, name3, nameN export statement",
"Replaced the 'name5' identifier with the 'name2' identifier in the name1, name2, name3, nameN export statement",
"Replaced the 'name6' identifier with the 'name3' identifier in the name1, name2, name3, nameN export statement",
"Replaced the 'nameZ' identifier with the 'nameN' identifier in the name1, name2, name3, nameN export statement",
"Replaced the 'variable2' identifier with the 'variable1' identifier in the variable1 as name1, variable2 as name2, nameN export statement",
"Replaced the 'name2' identifier with the 'name1' identifier in the variable1 as name1, variable2 as name2, nameN export statement",
"Replaced the 'variable3' identifier with the 'variable2' identifier in the variable1 as name1, variable2 as name2, nameN export statement",
"Replaced the 'name3' identifier with the 'name2' identifier in the variable1 as name1, variable2 as name2, nameN export statement",
"Replaced the 'nameY' identifier with the 'nameN' identifier in the variable1 as name1, variable2 as name2, nameN export statement",
"Replaced the 'name3' identifier with the 'name1' identifier in the name1, name2, nameN export statement",
"Replaced the 'name4' identifier with the 'name2' identifier in the name1, name2, nameN export statement",
"Replaced the 'nameT' identifier with the 'nameN' identifier in the name1, name2, nameN export statement",
"Replaced the 'name2' identifier with the 'name1' identifier in the name1 var assignment",
"Replaced the 'value2' identifier with the 'value1' identifier in the name1 var assignment",
"Replaced the 'name3' identifier with the 'name2' identifier in the name2 var assignment",
"Replaced the 'value3' identifier with the 'value2' identifier in the name2 var assignment",
"Replaced the 'name4' identifier with the 'name3' identifier in the name1 = value1, name2 = value2, name3, nameN export statement",
"Replaced the 'nameO' identifier with the 'nameN' identifier in the name1 = value1, name2 = value2, name3, nameN export statement",
"Added the namedFunction export statement",
"Added the anonymous() function export statement",
"Added the name1 export statement",
"Added the name1 as default export statement",
"Replaced the otherNamedFunction export statement with the 'foo' export statement",
"Added the name1, name2, nameN from 'foo' export statement",
"Added the import1 as name1, import2 as name2, nameN from 'bar' export statement",
"Added the 'foo' export statement",
"Deleted the newName1 export statement",
"Deleted the anonymous() function export statement",
"Deleted the name2 as statement export statement",
"Deleted the 'baz' export statement",
"Deleted the name7, name8, nameP from 'buzz' export statement",
"Deleted the import6 as name6, import7 as name7, nameB from 'fizz' export statement",
"Deleted the 'fuzz' export statement"
]
},
"errors": {}
},
"filePaths": [
"export.js"
],
"sha1": "a86486153befecb5a8435248342ae9ee5f9bb9fe",
"gitDir": "test/corpus/repos/javascript",
"sha2": "7b46f842245529860476386742508d3086628b4b"
}
,{
"testCaseDescription": "javascript-export-replacement-test",
"expectedResult": {
"changes": {
"export.js": [
"Replaced the 'name1' identifier with the 'name4' identifier in the name4, name5, name6, nameZ export statement",
"Replaced the 'name2' identifier with the 'name5' identifier in the name4, name5, name6, nameZ export statement",
"Replaced the 'name3' identifier with the 'name6' identifier in the name4, name5, name6, nameZ export statement",
"Replaced the 'nameN' identifier with the 'nameZ' identifier in the name4, name5, name6, nameZ export statement",
"Added the variable2 as name2, variable3 as name3, nameY export statement",
"Added the name3, name4, nameT export statement",
"Added the name2 = value2, name3 = value3, name4, nameO export statement",
"Added the otherNamedFunction export statement",
"Added the newName1 export statement",
"Added the anonymous() function export statement",
"Added the name2 as statement export statement",
"Added the 'baz' export statement",
"Added the name7, name8, nameP from 'buzz' export statement",
"Added the import6 as name6, import7 as name7, nameB from 'fizz' export statement",
"Added the 'fuzz' export statement",
"Deleted the variable1 as name1, variable2 as name2, nameN export statement",
"Deleted the name1, name2, nameN export statement",
"Deleted the name1 = value1, name2 = value2, name3, nameN export statement",
"Deleted the namedFunction export statement",
"Deleted the anonymous() function export statement",
"Deleted the name1 export statement",
"Deleted the name1 as default export statement",
"Deleted the 'foo' export statement",
"Deleted the name1, name2, nameN from 'foo' export statement",
"Deleted the import1 as name1, import2 as name2, nameN from 'bar' export statement",
"Deleted the 'foo' export statement"
]
},
"errors": {}
},
"filePaths": [
"export.js"
],
"sha1": "7b46f842245529860476386742508d3086628b4b",
"gitDir": "test/corpus/repos/javascript",
"sha2": "1586e1f5d610cc2c194478f3aeec506172299c7b"
}
,{
"testCaseDescription": "javascript-export-delete-replacement-test",
"expectedResult": {
"changes": {
"export.js": [
"Deleted the name4, name5, name6, nameZ export statement",
"Deleted the variable2 as name2, variable3 as name3, nameY export statement",
"Deleted the name3, name4, nameT export statement",
"Deleted the name2 = value2, name3 = value3, name4, nameO export statement",
"Deleted the otherNamedFunction export statement",
"Deleted the newName1 export statement",
"Deleted the anonymous() function export statement",
"Deleted the name2 as statement export statement",
"Deleted the 'baz' export statement",
"Deleted the name7, name8, nameP from 'buzz' export statement",
"Deleted the import6 as name6, import7 as name7, nameB from 'fizz' export statement",
"Deleted the 'fuzz' export statement",
"Deleted the name1, name2, name3, nameN export statement",
"Deleted the variable1 as name1, variable2 as name2, nameN export statement",
"Deleted the name1, name2, nameN export statement",
"Deleted the name1 = value1, name2 = value2, name3, nameN export statement",
"Deleted the namedFunction export statement",
"Deleted the anonymous() function export statement",
"Deleted the name1 export statement",
"Deleted the name1 as default export statement",
"Deleted the 'foo' export statement",
"Deleted the name1, name2, nameN from 'foo' export statement",
"Deleted the import1 as name1, import2 as name2, nameN from 'bar' export statement",
"Deleted the 'foo' export statement",
"Added the name4, name5, name6, nameZ export statement",
"Added the variable2 as name2, variable3 as name3, nameY export statement",
"Added the name3, name4, nameT export statement",
"Added the name2 = value2, name3 = value3, name4, nameO export statement",
"Added the otherNamedFunction export statement",
"Added the newName1 export statement",
"Added the anonymous() function export statement",
"Added the name2 as statement export statement",
"Added the 'baz' export statement",
"Added the name7, name8, nameP from 'buzz' export statement",
"Added the import6 as name6, import7 as name7, nameB from 'fizz' export statement",
"Added the 'fuzz' export statement"
]
},
"errors": {}
},
"filePaths": [
"export.js"
],
"sha1": "1586e1f5d610cc2c194478f3aeec506172299c7b",
"gitDir": "test/corpus/repos/javascript",
"sha2": "8ed6038b2ae6a12b88e6139701f2fc038ee2fe60"
}
,{
"testCaseDescription": "javascript-export-delete-test",
"expectedResult": {
"changes": {
"export.js": [
"Deleted the name1, name2, name3, nameN export statement",
"Deleted the variable1 as name1, variable2 as name2, nameN export statement",
"Deleted the name1, name2, nameN export statement",
"Deleted the name1 = value1, name2 = value2, name3, nameN export statement",
"Deleted the namedFunction export statement",
"Deleted the anonymous() function export statement",
"Deleted the name1 export statement",
"Deleted the name1 as default export statement",
"Deleted the 'foo' export statement",
"Deleted the name1, name2, nameN from 'foo' export statement",
"Deleted the import1 as name1, import2 as name2, nameN from 'bar' export statement",
"Deleted the 'foo' export statement"
]
},
"errors": {}
},
"filePaths": [
"export.js"
],
"sha1": "8ed6038b2ae6a12b88e6139701f2fc038ee2fe60",
"gitDir": "test/corpus/repos/javascript",
"sha2": "5fa5440ad72fb78f66fdb8163b2cb7e669a0c9f7"
}
,{
"testCaseDescription": "javascript-export-delete-rest-test",
"expectedResult": {
"changes": {
"export.js": [
"Deleted the name4, name5, name6, nameZ export statement",
"Deleted the variable2 as name2, variable3 as name3, nameY export statement",
"Deleted the name3, name4, nameT export statement",
"Deleted the name2 = value2, name3 = value3, name4, nameO export statement",
"Deleted the otherNamedFunction export statement",
"Deleted the newName1 export statement",
"Deleted the anonymous() function export statement",
"Deleted the name2 as statement export statement",
"Deleted the 'baz' export statement",
"Deleted the name7, name8, nameP from 'buzz' export statement",
"Deleted the import6 as name6, import7 as name7, nameB from 'fizz' export statement",
"Deleted the 'fuzz' export statement"
]
},
"errors": {}
},
"filePaths": [
"export.js"
],
"sha1": "5fa5440ad72fb78f66fdb8163b2cb7e669a0c9f7",
"gitDir": "test/corpus/repos/javascript",
"sha2": "870c7e629a76e123abf0a4f8095499e596838bfd"
}]

View File

@ -0,0 +1,214 @@
[{
"testCaseDescription": "javascript-import-insert-test",
"expectedResult": {
"changes": {
"import.js": [
"Added the '\"foo\"' import statement",
"Added the '\"aardvark\"' import statement",
"Added the '\"ant\"' import statement",
"Added the '\"antelope\"' import statement",
"Added the '\"ant-eater\"' import statement",
"Added the '\"anaconda\"' import statement",
"Added the '\"alligator\"' import statement",
"Added the '\"arctic-tern\"' import statement"
]
},
"errors": {}
},
"filePaths": [
"import.js"
],
"sha1": "fdbc1266a42600d265109d102da2496e26a9d3f2",
"gitDir": "test/corpus/repos/javascript",
"sha2": "df90633016b5463425deb3d74463cdcc32b76889"
}
,{
"testCaseDescription": "javascript-import-replacement-insert-test",
"expectedResult": {
"changes": {
"import.js": [
"Added the '\"babirusa\"' import statement",
"Added the '\"baboon\"' import statement",
"Added the '\"badger\"' import statement",
"Added the '\"bald-eagle\"' import statement",
"Added the '\"bandicoot\"' import statement",
"Added the '\"banteng\"' import statement",
"Added the '\"barbet\"' import statement",
"Added the '\"basilisk\"' import statement",
"Added the '\"foo\"' import statement",
"Added the '\"aardvark\"' import statement",
"Added the '\"ant\"' import statement",
"Added the '\"antelope\"' import statement",
"Added the '\"ant-eater\"' import statement",
"Added the '\"anaconda\"' import statement",
"Added the '\"alligator\"' import statement",
"Added the '\"arctic-tern\"' import statement"
]
},
"errors": {}
},
"filePaths": [
"import.js"
],
"sha1": "df90633016b5463425deb3d74463cdcc32b76889",
"gitDir": "test/corpus/repos/javascript",
"sha2": "95c90ad1bea428330d0b62f02e607b4509de89d2"
}
,{
"testCaseDescription": "javascript-import-delete-insert-test",
"expectedResult": {
"changes": {
"import.js": [
"Replaced the \"babirusa\" string with the \"foo\" string in the \"foo\" import statement",
"Replaced the \"baboon\" string with the \"aardvark\" string in the \"aardvark\" import statement",
"Replaced the 'otherName' identifier with the 'name' identifier in the \"aardvark\" import statement",
"Replaced the \"badger\" string with the \"ant\" string in the \"ant\" import statement",
"Replaced the 'element' identifier with the 'member' identifier in the \"ant\" import statement",
"Replaced the \"bald-eagle\" string with the \"antelope\" string in the \"antelope\" import statement",
"Replaced the 'element1' identifier with the 'member1' identifier in the \"antelope\" import statement",
"Replaced the 'element2' identifier with the 'member2' identifier in the \"antelope\" import statement",
"Replaced the \"bandicoot\" string with the \"ant-eater\" string in the \"ant-eater\" import statement",
"Replaced the 'element1' identifier with the 'member1' identifier in the \"ant-eater\" import statement",
"Replaced the 'element2' identifier with the 'member2' identifier in the \"ant-eater\" import statement",
"Replaced the 'elementAlias2' identifier with the 'alias2' identifier in the \"ant-eater\" import statement",
"Replaced the \"banteng\" string with the \"anaconda\" string in the \"anaconda\" import statement",
"Replaced the 'element1' identifier with the 'member1' identifier in the \"anaconda\" import statement",
"Replaced the 'element2' identifier with the 'member2' identifier in the \"anaconda\" import statement",
"Replaced the 'elementAlias2' identifier with the 'alias2' identifier in the \"anaconda\" import statement",
"Replaced the \"barbet\" string with the \"alligator\" string in the \"alligator\" import statement",
"Replaced the 'element' identifier with the 'name' identifier in the \"alligator\" import statement",
"Replaced the \"basilisk\" string with the \"arctic-tern\" string in the \"arctic-tern\" import statement"
]
},
"errors": {}
},
"filePaths": [
"import.js"
],
"sha1": "95c90ad1bea428330d0b62f02e607b4509de89d2",
"gitDir": "test/corpus/repos/javascript",
"sha2": "e7a974df1ae0a2993d5eeda4edd1b586adffe84f"
}
,{
"testCaseDescription": "javascript-import-replacement-test",
"expectedResult": {
"changes": {
"import.js": [
"Replaced the \"foo\" string with the \"babirusa\" string in the \"babirusa\" import statement",
"Replaced the \"aardvark\" string with the \"baboon\" string in the \"baboon\" import statement",
"Replaced the 'name' identifier with the 'otherName' identifier in the \"baboon\" import statement",
"Replaced the \"ant\" string with the \"badger\" string in the \"badger\" import statement",
"Replaced the 'member' identifier with the 'element' identifier in the \"badger\" import statement",
"Replaced the \"antelope\" string with the \"bald-eagle\" string in the \"bald-eagle\" import statement",
"Replaced the 'member1' identifier with the 'element1' identifier in the \"bald-eagle\" import statement",
"Replaced the 'member2' identifier with the 'element2' identifier in the \"bald-eagle\" import statement",
"Replaced the \"ant-eater\" string with the \"bandicoot\" string in the \"bandicoot\" import statement",
"Replaced the 'member1' identifier with the 'element1' identifier in the \"bandicoot\" import statement",
"Replaced the 'member2' identifier with the 'element2' identifier in the \"bandicoot\" import statement",
"Replaced the 'alias2' identifier with the 'elementAlias2' identifier in the \"bandicoot\" import statement",
"Replaced the \"anaconda\" string with the \"banteng\" string in the \"banteng\" import statement",
"Replaced the 'member1' identifier with the 'element1' identifier in the \"banteng\" import statement",
"Replaced the 'member2' identifier with the 'element2' identifier in the \"banteng\" import statement",
"Replaced the 'alias2' identifier with the 'elementAlias2' identifier in the \"banteng\" import statement",
"Replaced the \"alligator\" string with the \"barbet\" string in the \"barbet\" import statement",
"Replaced the 'name' identifier with the 'element' identifier in the \"barbet\" import statement",
"Replaced the \"arctic-tern\" string with the \"basilisk\" string in the \"basilisk\" import statement"
]
},
"errors": {}
},
"filePaths": [
"import.js"
],
"sha1": "e7a974df1ae0a2993d5eeda4edd1b586adffe84f",
"gitDir": "test/corpus/repos/javascript",
"sha2": "ab39b6f04b648cbddfd6afa3470995a0cd6fee69"
}
,{
"testCaseDescription": "javascript-import-delete-replacement-test",
"expectedResult": {
"changes": {
"import.js": [
"Deleted the '\"babirusa\"' import statement",
"Deleted the '\"baboon\"' import statement",
"Deleted the '\"badger\"' import statement",
"Deleted the '\"bald-eagle\"' import statement",
"Deleted the '\"bandicoot\"' import statement",
"Deleted the '\"banteng\"' import statement",
"Deleted the '\"barbet\"' import statement",
"Deleted the '\"basilisk\"' import statement",
"Deleted the '\"foo\"' import statement",
"Deleted the '\"aardvark\"' import statement",
"Deleted the '\"ant\"' import statement",
"Deleted the '\"antelope\"' import statement",
"Deleted the '\"ant-eater\"' import statement",
"Deleted the '\"anaconda\"' import statement",
"Deleted the '\"alligator\"' import statement",
"Deleted the '\"arctic-tern\"' import statement",
"Added the '\"babirusa\"' import statement",
"Added the '\"baboon\"' import statement",
"Added the '\"badger\"' import statement",
"Added the '\"bald-eagle\"' import statement",
"Added the '\"bandicoot\"' import statement",
"Added the '\"banteng\"' import statement",
"Added the '\"barbet\"' import statement",
"Added the '\"basilisk\"' import statement"
]
},
"errors": {}
},
"filePaths": [
"import.js"
],
"sha1": "ab39b6f04b648cbddfd6afa3470995a0cd6fee69",
"gitDir": "test/corpus/repos/javascript",
"sha2": "e9b593a62e90802adf1e1c7a91e8299116092602"
}
,{
"testCaseDescription": "javascript-import-delete-test",
"expectedResult": {
"changes": {
"import.js": [
"Deleted the '\"foo\"' import statement",
"Deleted the '\"aardvark\"' import statement",
"Deleted the '\"ant\"' import statement",
"Deleted the '\"antelope\"' import statement",
"Deleted the '\"ant-eater\"' import statement",
"Deleted the '\"anaconda\"' import statement",
"Deleted the '\"alligator\"' import statement",
"Deleted the '\"arctic-tern\"' import statement"
]
},
"errors": {}
},
"filePaths": [
"import.js"
],
"sha1": "e9b593a62e90802adf1e1c7a91e8299116092602",
"gitDir": "test/corpus/repos/javascript",
"sha2": "aca47c2554e1cf1ab3f0864b01040937488a39e5"
}
,{
"testCaseDescription": "javascript-import-delete-rest-test",
"expectedResult": {
"changes": {
"import.js": [
"Deleted the '\"babirusa\"' import statement",
"Deleted the '\"baboon\"' import statement",
"Deleted the '\"badger\"' import statement",
"Deleted the '\"bald-eagle\"' import statement",
"Deleted the '\"bandicoot\"' import statement",
"Deleted the '\"banteng\"' import statement",
"Deleted the '\"barbet\"' import statement",
"Deleted the '\"basilisk\"' import statement"
]
},
"errors": {}
},
"filePaths": [
"import.js"
],
"sha1": "aca47c2554e1cf1ab3f0864b01040937488a39e5",
"gitDir": "test/corpus/repos/javascript",
"sha2": "fbc5b11fcf02fc81e576ea8ec5d4e590a6a4cf6c"
}]

View File

@ -415,6 +415,21 @@
"repoFilePath": "nested-do-while-in-function.js",
"insert": "function f(arg1, arg2) { do { something(arg1); } while (arg2); }",
"replacement": "function f(arg1, arg2) { do { something(arg2); } while (arg1); }",
"testCaseFilePath": "tools/semantic-git-diff/test/corpus/diff-summaries/javascript/nested-do-while-in-function.json"
},
{
"syntax": "import",
"repoFilePath": "import.js",
"insert": "import defaultMember from \"foo\";\nimport * as name from \"aardvark\";\nimport { member } from \"ant\";\nimport { member1 , member2 } from \"antelope\";\nimport { member1 , member2 as alias2 } from \"ant-eater\";\nimport defaultMember, { member1, member2 as alias2 } from \"anaconda\";\nimport defaultMember, * as name from \"alligator\";\nimport \"arctic-tern\";",
"testCaseFilePath": "tools/semantic-git-diff/test/corpus/diff-summaries/javascript/import.json",
"replacement": "import defaultMember from \"babirusa\";\nimport * as otherName from \"baboon\";\nimport { element } from \"badger\";\nimport { element1 , element2 } from \"bald-eagle\";\nimport { element1 , element2 as elementAlias2 } from \"bandicoot\";\nimport defaultMember, { element1, element2 as elementAlias2 } from \"banteng\";\nimport defaultMember, * as element from \"barbet\";\nimport \"basilisk\";"
},
{
"syntax": "export",
"repoFilePath": "export.js",
"insert": "export { name1, name2, name3, nameN };\nexport { variable1 as name1, variable2 as name2, nameN };\nexport let name1, name2, nameN;\nexport let name1 = value1, name2 = value2, name3, nameN;\nexport default namedFunction;\nexport default function () { };\nexport default function name1() { };\nexport { name1 as default };\nexport * from 'foo';\nexport { name1, name2, nameN } from 'foo';\nexport { import1 as name1, import2 as name2, nameN } from 'bar';",
"testCaseFilePath": "tools/semantic-git-diff/test/corpus/diff-summaries/javascript/export.json",
"replacement": "export { name4, name5, name6, nameZ };\nexport { variable2 as name2, variable3 as name3, nameY };\nexport let name3, name4, nameT;\nexport let name2 = value2, name3 = value3, name4, nameO;\nexport default otherNamedFunction;\nexport default function newName1() {};\nexport default function () {};\nexport { name2 as statement };\nexport * from 'baz';\nexport { name7, name8, nameP } from 'buzz';\nexport { import6 as name6, import7 as name7, nameB } from 'fizz';",
"testCaseFilePath": "test/corpus/diff-summaries/javascript/nested-do-while-in-function.json"
}
]

@ -1 +1 @@
Subproject commit 946dc2ba4cf404c4d8e3ca7a23c09e2b14f3e06b
Subproject commit 870c7e629a76e123abf0a4f8095499e596838bfd

48
weekly/2016-10-07.md Normal file
View File

@ -0,0 +1,48 @@
# Oct 7th, 2016
## What went well?
@tclem
- productive week! Fixed lots of little bugs, project reorg finished
- Sorted out a variety of dotcom issues
- Tracking latest tree-sitter again
@rewinfrey
- getting out annotated nested parent context. Thanks @joshvera!
- import/export syntax (new stuff, personally rewarding)
@joshvera
- happy with all the PRs that got merged in this week
- pairing went well this week (time well spent to unblock people)
## What were the challenges?
@tclem
- not getting to do Haskell book (too heads down on other stuff)
- dotcom deploys hard with env var changes (need work here)
@rewinfrey
- translating tree sitter productions for import/export syntax. How to de-structure stuff correctly.
@joshvera
- not a lot to report that didn't go well!
- would like to have more design conversations at beginning of week
- lost track a little bit on where progressive diff and related projects are
all
- a bit hard to track various teams
## What did you learn?
@tclem
- how tree-sitter works. the base library, the node compiler, each of the grammars.
@rewinfrey
- api difference between named nodes in tree-sitter
- better understanding of how we tie into tree-sitter API via the FFI
@joshvera
- tree-sitter APIs that we aren't using
- split diff output is slow!
- about measures of probability distributions that are multi-dimensional
- difference between variance and volatility