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

bug: rename传播问题,xml inner rule加入后,受到间接影响的identifier依然没有被rename #120

Open
TsukimiRini opened this issue May 12, 2022 · 5 comments
Assignees

Comments

@TsukimiRini
Copy link
Collaborator

为了实现对xml文件中并非直接与java元素link的identifier的rename,我加入了以下rule:

r-xml-inner:
#    hidden: true
    def:
      lang: XML
      file: (&layoutName).xml
      identifier: android:id
      inline:
        identifier: '@+id\/(&name)'
    use:
      lang: XML
      file: (&layoutName).xml
      identifier: "*constraint*"
      inline:
        identifier: '*\/(&name)'

根据这条rule可以在某个例子中得到如下的inner link:

r-xml-inner
def://app/src/main/res/layout/fragment_description.xml[language=FILE]//androidx.core.widget.NestedScrollView/androidx.constraintlayout.widget.ConstraintLayout/ImageView/android:id[language=XML]//@+id\\/detail_select_description_button[language=ANY]
def://app/src/main/res/layout/fragment_description.xml[language=FILE]//androidx.core.widget.NestedScrollView/androidx.constraintlayout.widget.ConstraintLayout/TextView/app:layout_constraintEnd_toStartOf[language=XML]//@+id\\/detail_select_description_button[language=ANY]

其中上面xll中的def方(第一条uri)与一个java元素绑定:

r-dataBinding
def://app/src/main/res/layout/fragment_description.xml[language=FILE]//androidx.core.widget.NestedScrollView/androidx.constraintlayout.widget.ConstraintLayout/ImageView/android:id[language=XML]//@+id\\/detail_select_description_button[language=ANY]
use://app/src/main/java/org/schabi/newpipe/fragments/detail/DescriptionFragment.java[language=FILE]//DescriptionFragment/disableDescriptionSelection/TooltipCompat.setTooltipText/binding.detailSelectDescriptionButton[language=JAVA]

以上行为都在预期之中,但是当我rename这个java元素时,预期的行为应该是inner link中的两个uri都被rename,但事实上只有databinding link中的xml uri被rename了:

def://app/src/main/res/layout/fragment_description.xml[language=FILE]//androidx.core.widget.NestedScrollView/androidx.constraintlayout.widget.ConstraintLayout/ImageView/android:id[language=XML]//@+id\\/detail_select_description_button[language=ANY]
def://app/src/main/res/layout/fragment_description.xml[language=FILE]//androidx.core.widget.NestedScrollView/androidx.constraintlayout.widget.ConstraintLayout/ImageView/android:id[language=XML]//@+id\\/detailedSelectDescriptionButton[language=ANY]
shigma added a commit that referenced this issue May 12, 2022
@shigma
Copy link
Collaborator

shigma commented May 12, 2022

我这没有复现: 3d666d3 的测试结果显示产生了两个 rename。

@TsukimiRini
Copy link
Collaborator Author

我这没有复现: 3d666d3 的测试结果显示产生了两个 rename。

有没有可能是存在前置rule的时候会有问题?我跑了测试,也可以通过,但是在rename eva中project.rename就只会返回一个结果。

@TsukimiRini
Copy link
Collaborator Author

TsukimiRini commented May 13, 2022

测试时的flowgraph:

flowgraph:
  r-layout:
    - $
  r-menu:
    - $
  r-dataBindingClassLink:
    - $
  r-id:
    - r-layout
    - r-menu
    - r-dataBindingClassLink
    - $
  r-android-id:
    - r-layout
    - r-menu
    - r-dataBindingClassLink
    - $
  r-dataBindingClass:
    - $
  r-include-layout:
    - r-dataBindingClassLink
    - r-layout
  r-include-id:
    - r-include-layout
  r-include-dataBinding:
    - r-include-layout
  r-dataBinding:
    - r-dataBindingClassLink
    - r-layout
#    - $
  r-xml-inner:
    - r-id
    - r-dataBinding
  r-xml-include-inner:
    - r-include-id
  r-xml-include-inter:
    - r-include-id

@TsukimiRini
Copy link
Collaborator Author

image

证实确实是因为存在前置rule的问题,当r-xml-inner有前置rule(r-id, r-dataBinding)的时候,会出现上述问题。 但实际上单从匹配上(跑xll eva)来说,xml inner是正确匹配的了,问题关键大概还是在传播。 另外一个奇怪的现象是,如果我将r-xml-inner的前置rule替换为($)或(r-id, r-dataBindingClassLink),在test中都是能pass的,但是在实际的rename eva中,相同的case下rename结果为0条(这也是为什么我不直接把r-xml-inner的前置去掉的原因)。

@TsukimiRini
Copy link
Collaborator Author

@shigma 仔细测试了一下,在前置rule替换为($)或(r-id, r-dataBindingClassLink)时,是能找到对应的XLL的(之前说没找到应该是文件太大导致的加载问题)。这个行为是预料内的。
但是在实际的rename eva中,rename结果依然是0条。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants