cagdasgerede / Veysel

2 stars 3 forks source link

Demo of pattern matcher #4

Closed cagdasgerede closed 7 years ago

cagdasgerede commented 7 years ago
  1. Add new method to MappingUtil so that it returns

<Type, src position, target position, source label, target label> where type is enum {insert, delete, change, no change}

  1. Get a list of mappings as above

  2. Build mappings by hand 1->1, 2->2,..., 37->37 : No change 32 -> 32: change from param to paramNew

  3. Build ParseCaches from source code, target code (use Demo2 as reference)

  4. Implement Pattern and PatternMatcher

  5. Write test that gives 2 caches, difference mapping, pattern registry to pattern matcher so that the matcher produces the desired view.

cagdasgerede commented 7 years ago

Extend Demo2.java with

    // Get Result.mapping -> int pairs
    // Convert those pairs to (via MappingUtil):
    //      <Type, src position, target position,
    //       source label, target label>
    //    where type is enum {insert, delete, change, no change} 
    // For each tuple:
    //   ParseTreeWrapper nodeInOriginal = sourceParseTree.nodeAt(srcPos)
    //   ParseTreeWrapper nodeInUpdated = targetParseTree.nodeAt(targetPos)
    //   dataExtractionContext.sourceParser(sourceParseTree.parser())
    //                        .targetParser(targetParseTree.parser())
    //   Pattern pattern = PatternRegistry.match(dataExtractionContext,
    //                                           nodeInOriginal,
    //                                           nodeInUpdated)
    //   assertNotNull(pattern)
    //   view = pattern.viewTemplate().generateView(dataExtractionContext,
    //                                              nodeInOrigianl,
    //                                              nodeInUpdated)
    //   System.out.println(view)