Skip to content

Example: #2

@andrewt0301

Description

@andrewt0301

Before changes:

import java.util.List;
import java.util.Map;
import java.util.HashMap;

class MyClass {
    Map<String, String> map = new HashMap();
}

After changes:

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

class MyClass {
    Map<String, String> map = new ConcurrentHashMap();
}

JSON with two patterns:

{
  "patterns": {
    "JAVA": {
      "kind": "PATTERNS",
      "language": "JAVA",
      "types": {
        "SimpleName": {
          "name": "SimpleName",
          "strictOrder": false
        },
        "ImportDeclaration": {
          "name": "ImportDeclaration",
          "strictOrder": false
        },
        "ClassOrInterfaceType": {
          "name": "ClassOrInterfaceType",
          "strictOrder": false
        },
        "Name": {
          "name": "Name",
          "strictOrder": false
        }
      },
      "data": [
        {
          "language": "JAVA",
          "meta": {
            "source": "D:\\Src\\Source_1.java",
            "target": "D:\\Src\\Target_1.java"
          },
          "tree": {
            "kind": "ACTION_TREE",
            "root": {
              "type": "ClassOrInterfaceType",
              "fragment": {
                "source": "source",
                "start": {
                  "index": 127,
                  "row": 6,
                  "column": 35
                },
                "end": {
                  "index": 134,
                  "row": 6,
                  "column": 42
                }
              },
              "children": [
                {
                  "type": "Attributes",
                  "fragment": {
                    "start": {
                      "index": 0,
                      "row": 1,
                      "column": 1
                    },
                    "end": {
                      "index": 0,
                      "row": 1,
                      "column": 1
                    }
                  },
                  "children": [
                    {
                      "type": "TypeSignature",
                      "data": "java.util.HashMap",
                      "fragment": {
                        "start": {
                          "index": 0,
                          "row": 1,
                          "column": 1
                        },
                        "end": {
                          "index": 0,
                          "row": 1,
                          "column": 1
                        }
                      }
                    }
                  ]
                },
                {
                  "type": "PropertyName",
                  "data": "name",
                  "fragment": {
                    "start": {
                      "index": 0,
                      "row": 1,
                      "column": 1
                    },
                    "end": {
                      "index": 0,
                      "row": 1,
                      "column": 1
                    }
                  },
                  "children": [
                    {
                      "type": "SimpleName",
                      "data": "HashMap",
                      "fragment": {
                        "source": "source",
                        "start": {
                          "index": 127,
                          "row": 6,
                          "column": 35
                        },
                        "end": {
                          "index": 134,
                          "row": 6,
                          "column": 42
                        }
                      }
                    }
                  ],
                  "actions": [
                    {
                      "type": "UPDATE",
                      "ref": 0,
                      "accept": {
                        "type": "SimpleName",
                        "data": "ConcurrentHashMap",
                        "fragment": {
                          "source": "target",
                          "start": {
                            "index": 148,
                            "row": 6,
                            "column": 35
                          },
                          "end": {
                            "index": 165,
                            "row": 6,
                            "column": 52
                          }
                        }
                      }
                    }
                  ]
                }
              ]
            },
            "sources": {
              "source": {
                "start": {
                  "index": 127,
                  "row": 6,
                  "column": 35
                },
                "end": {
                  "index": 134,
                  "row": 6,
                  "column": 42
                },
                "data": "HashMap"
              },
              "target": {
                "start": {
                  "index": 148,
                  "row": 6,
                  "column": 35
                },
                "end": {
                  "index": 165,
                  "row": 6,
                  "column": 52
                },
                "data": "ConcurrentHashMap"
              }
            }
          }
        },
        {
          "language": "JAVA",
          "meta": {
            "source": "D:\\Src\\Source_1.java",
            "target": "D:\\Src\\Target_1.java"
          },
          "tree": {
            "kind": "ACTION_TREE",
            "root": {
              "type": "ImportDeclaration",
              "fragment": {
                "source": "source",
                "start": {
                  "index": 47,
                  "row": 3,
                  "column": 1
                },
                "end": {
                  "index": 72,
                  "row": 3,
                  "column": 26
                }
              },
              "children": [
                {
                  "type": "Attributes",
                  "fragment": {
                    "start": {
                      "index": 0,
                      "row": 1,
                      "column": 1
                    },
                    "end": {
                      "index": 0,
                      "row": 1,
                      "column": 1
                    }
                  },
                  "children": [
                    {
                      "type": "AttributeName",
                      "data": "isAsterisk",
                      "fragment": {
                        "start": {
                          "index": 0,
                          "row": 1,
                          "column": 1
                        },
                        "end": {
                          "index": 0,
                          "row": 1,
                          "column": 1
                        }
                      },
                      "children": [
                        {
                          "type": "AttributeValue",
                          "data": "false",
                          "fragment": {
                            "start": {
                              "index": 0,
                              "row": 1,
                              "column": 1
                            },
                            "end": {
                              "index": 0,
                              "row": 1,
                              "column": 1
                            }
                          }
                        }
                      ]
                    },
                    {
                      "type": "AttributeName",
                      "data": "isStatic",
                      "fragment": {
                        "start": {
                          "index": 0,
                          "row": 1,
                          "column": 1
                        },
                        "end": {
                          "index": 0,
                          "row": 1,
                          "column": 1
                        }
                      },
                      "children": [
                        {
                          "type": "AttributeValue",
                          "data": "false",
                          "fragment": {
                            "start": {
                              "index": 0,
                              "row": 1,
                              "column": 1
                            },
                            "end": {
                              "index": 0,
                              "row": 1,
                              "column": 1
                            }
                          }
                        }
                      ]
                    }
                  ]
                },
                {
                  "type": "PropertyName",
                  "data": "name",
                  "fragment": {
                    "start": {
                      "index": 0,
                      "row": 1,
                      "column": 1
                    },
                    "end": {
                      "index": 0,
                      "row": 1,
                      "column": 1
                    }
                  },
                  "children": [
                    {
                      "type": "Name",
                      "data": "HashMap",
                      "fragment": {
                        "source": "source",
                        "start": {
                          "index": 54,
                          "row": 3,
                          "column": 8
                        },
                        "end": {
                          "index": 71,
                          "row": 3,
                          "column": 25
                        }
                      },
                      "children": [
                        {
                          "type": "PropertyName",
                          "data": "qualifier",
                          "fragment": {
                            "start": {
                              "index": 0,
                              "row": 1,
                              "column": 1
                            },
                            "end": {
                              "index": 0,
                              "row": 1,
                              "column": 1
                            }
                          },
                          "children": [
                            {
                              "type": "Name",
                              "data": "util",
                              "fragment": {
                                "source": "source",
                                "start": {
                                  "index": 54,
                                  "row": 3,
                                  "column": 8
                                },
                                "end": {
                                  "index": 63,
                                  "row": 3,
                                  "column": 17
                                }
                              },
                              "children": [
                                {
                                  "type": "PropertyName",
                                  "data": "qualifier",
                                  "fragment": {
                                    "start": {
                                      "index": 0,
                                      "row": 1,
                                      "column": 1
                                    },
                                    "end": {
                                      "index": 0,
                                      "row": 1,
                                      "column": 1
                                    }
                                  },
                                  "children": [
                                    {
                                      "type": "Name",
                                      "data": "java",
                                      "fragment": {
                                        "source": "source",
                                        "start": {
                                          "index": 54,
                                          "row": 3,
                                          "column": 8
                                        },
                                        "end": {
                                          "index": 58,
                                          "row": 3,
                                          "column": 12
                                        }
                                      }
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ],
                  "actions": [
                    {
                      "type": "DELETE",
                      "ref": 0
                    },
                    {
                      "type": "INSERT",
                      "ref": -1,
                      "accept": {
                        "type": "Name",
                        "data": "ConcurrentHashMap",
                        "fragment": {
                          "source": "target",
                          "start": {
                            "index": 54,
                            "row": 3,
                            "column": 8
                          },
                          "end": {
                            "index": 92,
                            "row": 3,
                            "column": 46
                          }
                        },
                        "children": [
                          {
                            "type": "PropertyName",
                            "data": "qualifier",
                            "fragment": {
                              "start": {
                                "index": 0,
                                "row": 1,
                                "column": 1
                              },
                              "end": {
                                "index": 0,
                                "row": 1,
                                "column": 1
                              }
                            },
                            "children": [
                              {
                                "type": "Name",
                                "data": "concurrent",
                                "fragment": {
                                  "source": "target",
                                  "start": {
                                    "index": 54,
                                    "row": 3,
                                    "column": 8
                                  },
                                  "end": {
                                    "index": 74,
                                    "row": 3,
                                    "column": 28
                                  }
                                },
                                "children": [
                                  {
                                    "type": "PropertyName",
                                    "data": "qualifier",
                                    "fragment": {
                                      "start": {
                                        "index": 0,
                                        "row": 1,
                                        "column": 1
                                      },
                                      "end": {
                                        "index": 0,
                                        "row": 1,
                                        "column": 1
                                      }
                                    },
                                    "children": [
                                      {
                                        "type": "Name",
                                        "data": "util",
                                        "fragment": {
                                          "source": "target",
                                          "start": {
                                            "index": 54,
                                            "row": 3,
                                            "column": 8
                                          },
                                          "end": {
                                            "index": 63,
                                            "row": 3,
                                            "column": 17
                                          }
                                        },
                                        "children": [
                                          {
                                            "type": "PropertyName",
                                            "data": "qualifier",
                                            "fragment": {
                                              "start": {
                                                "index": 0,
                                                "row": 1,
                                                "column": 1
                                              },
                                              "end": {
                                                "index": 0,
                                                "row": 1,
                                                "column": 1
                                              }
                                            },
                                            "children": [
                                              {
                                                "type": "Name",
                                                "data": "java",
                                                "fragment": {
                                                  "source": "target",
                                                  "start": {
                                                    "index": 54,
                                                    "row": 3,
                                                    "column": 8
                                                  },
                                                  "end": {
                                                    "index": 58,
                                                    "row": 3,
                                                    "column": 12
                                                  }
                                                }
                                              }
                                            ]
                                          }
                                        ]
                                      }
                                    ]
                                  }
                                ]
                              }
                            ]
                          }
                        ]
                      }
                    }
                  ]
                }
              ]
            },
            "sources": {
              "source": {
                "start": {
                  "index": 47,
                  "row": 3,
                  "column": 1
                },
                "end": {
                  "index": 72,
                  "row": 3,
                  "column": 26
                },
                "data": "import java.util.HashMap;"
              },
              "target": {
                "start": {
                  "index": 47,
                  "row": 3,
                  "column": 1
                },
                "end": {
                  "index": 93,
                  "row": 3,
                  "column": 47
                },
                "data": "import java.util.concurrent.ConcurrentHashMap;"
              }
            }
          }
        }
      ]
    }
  },
  "kind": "PATTERNS",
  "version": {
    "major": 0,
    "minor": 0,
    "patch": 0,
    "postfix": ""
  },
  "scenario": {
    "kind": "UNKNOWN",
    "meta": {}
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions