Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: changes explanations on hover over conflicting regions #13

Open
kpatenio opened this issue Nov 16, 2020 · 0 comments
Open

feat: changes explanations on hover over conflicting regions #13

kpatenio opened this issue Nov 16, 2020 · 0 comments
Assignees
Labels
3 way diff Related to the IntelliJ 3 way diff functionality

Comments

@kpatenio
Copy link
Collaborator

kpatenio commented Nov 16, 2020

Description

In the previous version of this project, we relied on a new plugin window that details all merge conflict changes. For this new proposed design, we want to utilize IntelliJ's three-way diff to display these explanations. When viewing the diff while in the merge conflict state, hovering over a conflict region (whether it be in base, OURS, or THEIRS) with our cursor, a pop-up would appear containing pertinent information regarding the merge conflict.

Relevant information

A pop-up window would contain the following:

  • OURS changes that contribute to the conflict
  • THEIRS changes that contribute to the conflict
  • For each change, a link that opens and jumps to the relevant revision number in the IntelliJ git log

Draft design

Open image in new tab for better quality. Current merge conflict in image is after attempting to merge 113d77e5fa711cfcdc50953b70a7df6803a467d8 and 4f62da869d31c7d72144d50ee436378f302b0d45 for Android-Terminal-Emulator:

image

Planned setup

RefactoringMiner

We will need RefactoringMiner to obtain all refactorings throughout the series of commits (from the common ancestor to a merge parent).

Sample output from RefactoringMiner 2.0 for commit 1327b4c3152331e8e376b112c5827072823de7a5 from Android-Terminal-Emulator:

{
        "repository": "https://github.com/jackpal/Android-Terminal-Emulator.git",
        "sha1": "1327b4c3152331e8e376b112c5827072823de7a5",
        "url": "https://github.com/jackpal/Android-Terminal-Emulator/commit/1327b4c3152331e8e376b112c5827072823de7a5",
        "refactorings": [{
        "type": "Move Class",
        "description": "Move Class jackpal.androidterm.emulatorview.TermKeyListener.ModifierKey moved to jackpal.androidterm.emulatorview.ModifierKey",
        "leftSideLocations": [{
                "filePath": "libraries/emulatorview/src/jackpal/androidterm/emulatorview/EmulatorView.java",
                "startLine": 2000,
                "endLine": 2078,
                "startColumn": 5,
                "endColumn": 6,
                "codeElementType": "TYPE_DECLARATION",
                "description": "original type declaration",
                "codeElement": "jackpal.androidterm.emulatorview.TermKeyListener.ModifierKey"
}],
        "rightSideLocations": [{
                "filePath": "libraries/emulatorview/src/jackpal/androidterm/emulatorview/EmulatorView.java",
                "startLine": 2265,
                "endLine": -1,
                "startColumn": 0,
                "endColumn": -1,
                "codeElementType": "TYPE_DECLARATION",
                "description": "moved type declaration",
                "codeElement": "jackpal.androidterm.emulatorview.ModifierKey"
}]
}

The following information from RefactoringMiner will be useful:

  • filepath
  • startLine
  • endLine

From the screenshot above, the THEIRS change Moved private class ModifierKey from class TermKeyListener in EmulatorView.java to ModifierKey in EmulatorView.java would be collected by using RefactoringMiner.

RefactoringMiner also allows us to detect all refactorings within a commit range, which we can use to detecting between a common ancestor and a merge parent.

GumTree (or CLDiff)

GumTree and CLDiff are differencing algorithms that we can use to distinguish changes semantically and syntactically (rather than relying on textual diffs alone). This can help with breaking down our explanations.

Consider the following example:
image

GumTree

This is how GumTree's edit scripts would look like for the method foo(), which is relevant to THEIRS change Moved method public static void foo() from Foo.java to FooHelper.java:

delete-tree
---
MethodDeclaration [24,144]
    Modifier: public [24,30]
    Modifier: static [31,37]
    PrimitiveType: void [38,42]
    SimpleName: foo [43,46]
    Block [49,144]
        VariableDeclarationStatement [59,74]
            PrimitiveType: int [59,62]
            VariableDeclarationFragment [63,73]
                SimpleName: x [63,64]
                MethodInvocation [67,73]
                    SimpleName: getX [67,71]
        ExpressionStatement [83,90]
            Assignment [83,89]
                SimpleName: x [83,84]
                ASSIGNEMENT_OPERATOR: += [85,87]
                NumberLiteral: 2 [88,89]
        VariableDeclarationStatement [99,114]
            PrimitiveType: int [99,102]
            VariableDeclarationFragment [103,113]
                SimpleName: y [103,104]
                MethodInvocation [107,113]
                    SimpleName: getY [107,111]
        ExpressionStatement [123,138]
            MethodInvocation [123,137]
                SimpleName: calcDist [123,131]
                METHOD_INVOCATION_ARGUMENTS [132,136]
                    SimpleName: x [132,133]
                    SimpleName: y [135,136]

CLDiff

This is how CLDiff's edit scripts would look like for the same change:

Foo.java
----pre-processing 518822237
----mapping 86217129
ActionSize:0

Member key size:1
Change entity size:1
Foo. TypeDeclaration: Foo (1,24) listSize:1
0. deleteMethodDeclaration (3,7)

----grouping 9361404
Concise Code Differences:
0. deleteMethodDeclaration
	(3,7)

git4idea

We would have to use IntelliJ's git dependency git4idea for any git functionality, such as parsing through the commit history and the diffs for conflict regions. How we do this requires more investigation. For reference...

@kpatenio kpatenio added the 3 way diff Related to the IntelliJ 3 way diff functionality label Nov 16, 2020
@kpatenio kpatenio self-assigned this Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 way diff Related to the IntelliJ 3 way diff functionality
Projects
None yet
Development

No branches or pull requests

1 participant