Improvements in Find References #166

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
3 participants
@dragos
Owner

dragos commented Jul 28, 2012

This is a bunch of commits that need more work, but I think they're important and improve at least some cases.

  • ScalaMatchLocator should recurse into trees with transparent positions.
  • better matching of parameter names in ScalaJavaMapper. This one I am not sure is correct, it would be good to get a second opinion. My fix allows finding methods that take parameters with an Array type (that were not found before).
  • a few test cases would help.

It would be cool if someone took this over. Help? :)

dragos added some commits Jul 28, 2012

Recurse down into trees with transparent positions.
`ScalaMatchLocator` should continue to look for matches in subtrees of trees with
transparent positions. 

Better logging in case matches are skipped.
Remove call to flatten array parameters.
getElementType of an array is returning the element type of the array. So any
method that takes Array as a parameter would never pass the `sameParams` test
(such as `main`). 

May not be a full-solution, someone needs to write a test and make sure I don't break something else.
Remove `lazy` local variables.
They seem to exist only for debugging, but they're useless unless they're strict. When
sitting on a breakpoint on the last line of the method, all of those lazy values are not
yet evaluated. Once you step, you're out of the method.
@scala-jenkins

This comment has been minimized.

Show comment Hide comment
@scala-jenkins

scala-jenkins Jul 28, 2012

Started jenkins job pr-validator-master-2.9.x at https://jenkins.scala-ide.org:8496/jenkins/job/pr-validator-master-2.9.x/96/

@scala-jenkins

This comment has been minimized.

Show comment Hide comment
@scala-jenkins

scala-jenkins Jul 28, 2012

Started jenkins job pr-validator-master-trunk at https://jenkins.scala-ide.org:8496/jenkins/job/pr-validator-master-trunk/78/

@scala-jenkins

This comment has been minimized.

Show comment Hide comment
@scala-jenkins

scala-jenkins Jul 28, 2012

jenkins job pr-validator-master-2.9.x: Success - https://jenkins.scala-ide.org:8496/jenkins/job/pr-validator-master-2.9.x/96/

@scala-jenkins

This comment has been minimized.

Show comment Hide comment
@scala-jenkins

scala-jenkins Jul 28, 2012

jenkins job pr-validator-master-trunk: Success - https://jenkins.scala-ide.org:8496/jenkins/job/pr-validator-master-trunk/78/

@@ -220,7 +221,9 @@ trait ScalaMatchLocator { self: ScalaPresentationCompiler =>
}
if (hit) {
- getJavaElement(enclosingDeclaration, scu.project.javaProject).foreach { element =>
+ val javaElem = getJavaElement(enclosingDeclaration, scu.project.javaProject)
+ if (javaElem.isEmpty) logger.info("DROPPED MATCH: Couldn't find enclosing element for matched pattern: " + sym.fullName)

This comment has been minimized.

Show comment Hide comment
@dragos

dragos Jul 29, 2012

Owner

We should never silently drop results just because we couldn't find a corresponding java element. This has to be investigated, but AFAIK the element is used only for displaying the match under the 'logical' enclosing entity. It is nice to be precise (and report it against the innermost element), but anything (including the project itself, worst case) might work. We can:

  • look up repeatedly, from the innermost symbol, through the owner chain, the first Java Element we can find
  • a totally different approach: java elements are handle only: they are more or less paths, and they need not exist in the workspace. We can try to create a JavaElement for the symbol, without looking it up in the existing structure.
@dragos

dragos Jul 29, 2012

Owner

We should never silently drop results just because we couldn't find a corresponding java element. This has to be investigated, but AFAIK the element is used only for displaying the match under the 'logical' enclosing entity. It is nice to be precise (and report it against the innermost element), but anything (including the project itself, worst case) might work. We can:

  • look up repeatedly, from the innermost symbol, through the owner chain, the first Java Element we can find
  • a totally different approach: java elements are handle only: they are more or less paths, and they need not exist in the workspace. We can try to create a JavaElement for the symbol, without looking it up in the existing structure.
@dotta

This comment has been minimized.

Show comment Hide comment
@dotta

dotta Jul 30, 2012

Owner

Alright, I'll keep it from here. Basically, we need:

  • Tests for find references of method that takes array arguments.
  • Tests find references inside for-comprehension (related to transparent positions).
  • When getJavaElement cannot find a matching javaelement for the current enclosingDeclaration, we should try convert its parent (and so on...)
Owner

dotta commented Jul 30, 2012

Alright, I'll keep it from here. Basically, we need:

  • Tests for find references of method that takes array arguments.
  • Tests find references inside for-comprehension (related to transparent positions).
  • When getJavaElement cannot find a matching javaelement for the current enclosingDeclaration, we should try convert its parent (and so on...)
@dragos

This comment has been minimized.

Show comment Hide comment
@dragos

dragos Jul 30, 2012

Owner

Thanks Mirco!

Owner

dragos commented Jul 30, 2012

Thanks Mirco!

@scala-jenkins

This comment has been minimized.

Show comment Hide comment
@scala-jenkins

scala-jenkins Oct 19, 2012

Started jenkins job worksheet-2.1-2.10-pr-validator at https://jenkins.scala-ide.org:8496/jenkins/job/worksheet-2.1-2.10-pr-validator/2/

@scala-jenkins

This comment has been minimized.

Show comment Hide comment
@scala-jenkins

scala-jenkins Oct 19, 2012

Started jenkins job worksheet-2.1-2.9-pr-validator at https://jenkins.scala-ide.org:8496/jenkins/job/worksheet-2.1-2.9-pr-validator/2/

@scala-jenkins

This comment has been minimized.

Show comment Hide comment
@scala-jenkins

scala-jenkins Oct 19, 2012

jenkins job worksheet-2.1-2.9-pr-validator: Failed - https://jenkins.scala-ide.org:8496/jenkins/job/worksheet-2.1-2.9-pr-validator/2/

@scala-jenkins

This comment has been minimized.

Show comment Hide comment
@scala-jenkins

scala-jenkins Oct 19, 2012

jenkins job worksheet-2.1-2.10-pr-validator: Failed - https://jenkins.scala-ide.org:8496/jenkins/job/worksheet-2.1-2.10-pr-validator/2/

@scala-jenkins

This comment has been minimized.

Show comment Hide comment
@scala-jenkins

scala-jenkins Apr 17, 2013

Started jenkins job pr-validator-master-2.10.x at https://jenkins.scala-ide.org:8496/jenkins/job/pr-validator-master-2.10.x/4/

@scala-jenkins

This comment has been minimized.

Show comment Hide comment
@scala-jenkins

scala-jenkins Apr 17, 2013

jenkins job pr-validator-master-2.10.x: Failed - https://jenkins.scala-ide.org:8496/jenkins/job/pr-validator-master-2.10.x/4/
sad kitty

@scala-jenkins

This comment has been minimized.

Show comment Hide comment
@scala-jenkins

scala-jenkins Apr 26, 2013

Job pr-validator-master-trunk failed for b3ba6f7 (results):


Took 5 s.
to rebuild, comment "PLS REBUILD/pr-validator-master-trunk@b3ba6f79c27320fcb1aefb68fcf967983d364dca" on PR 166

Job pr-validator-master-trunk failed for b3ba6f7 (results):


Took 5 s.
to rebuild, comment "PLS REBUILD/pr-validator-master-trunk@b3ba6f79c27320fcb1aefb68fcf967983d364dca" on PR 166

This comment has been minimized.

Show comment Hide comment
@scala-jenkins

scala-jenkins Apr 27, 2013

Job pr-validator-master-2.10.x failed for b3ba6f7 (results):


Took 31 s.
to rebuild, comment "PLS REBUILD/pr-validator-master-2.10.x@b3ba6f79c27320fcb1aefb68fcf967983d364dca" on PR 166

Job pr-validator-master-2.10.x failed for b3ba6f7 (results):


Took 31 s.
to rebuild, comment "PLS REBUILD/pr-validator-master-2.10.x@b3ba6f79c27320fcb1aefb68fcf967983d364dca" on PR 166

@scala-jenkins

This comment has been minimized.

Show comment Hide comment
@scala-jenkins

scala-jenkins Apr 26, 2013

Job pr-validator-master-trunk failed for 0f9fd2c (results):


Took 10 s.
to rebuild, comment "PLS REBUILD/pr-validator-master-trunk@0f9fd2ca4f5ffa1b748fd49d33d569a8932d66f9" on PR 166

Job pr-validator-master-trunk failed for 0f9fd2c (results):


Took 10 s.
to rebuild, comment "PLS REBUILD/pr-validator-master-trunk@0f9fd2ca4f5ffa1b748fd49d33d569a8932d66f9" on PR 166

This comment has been minimized.

Show comment Hide comment
@scala-jenkins

scala-jenkins Apr 27, 2013

Job pr-validator-master-2.10.x failed for 0f9fd2c (results):


Took 77 s.
to rebuild, comment "PLS REBUILD/pr-validator-master-2.10.x@0f9fd2ca4f5ffa1b748fd49d33d569a8932d66f9" on PR 166

Job pr-validator-master-2.10.x failed for 0f9fd2c (results):


Took 77 s.
to rebuild, comment "PLS REBUILD/pr-validator-master-2.10.x@0f9fd2ca4f5ffa1b748fd49d33d569a8932d66f9" on PR 166

@scala-jenkins

This comment has been minimized.

Show comment Hide comment
@scala-jenkins

scala-jenkins Apr 26, 2013

Job pr-validator-master-trunk failed for a44d264 (results):


Took 5 s.
to rebuild, comment "PLS REBUILD/pr-validator-master-trunk@a44d26478e02064cd769d5b8e2e5a0a92dbfeb09" on PR 166

Job pr-validator-master-trunk failed for a44d264 (results):


Took 5 s.
to rebuild, comment "PLS REBUILD/pr-validator-master-trunk@a44d26478e02064cd769d5b8e2e5a0a92dbfeb09" on PR 166

This comment has been minimized.

Show comment Hide comment
@scala-jenkins

scala-jenkins Apr 27, 2013

Job pr-validator-master-2.10.x failed for a44d264 (results):


Took 118 s.
to rebuild, comment "PLS REBUILD/pr-validator-master-2.10.x@a44d26478e02064cd769d5b8e2e5a0a92dbfeb09" on PR 166

Job pr-validator-master-2.10.x failed for a44d264 (results):


Took 118 s.
to rebuild, comment "PLS REBUILD/pr-validator-master-2.10.x@a44d26478e02064cd769d5b8e2e5a0a92dbfeb09" on PR 166

@dotta

This comment has been minimized.

Show comment Hide comment
@dotta

dotta Jun 4, 2013

Owner

Alright, I'm closing this since nothing happened in the past 8 months (and I'm the one to blame for that). Also, considering the nice progress Mads is doing on scala-search, it looks like we will soon have a fully-working semantic search for Scala code.

Owner

dotta commented Jun 4, 2013

Alright, I'm closing this since nothing happened in the past 8 months (and I'm the one to blame for that). Also, considering the nice progress Mads is doing on scala-search, it looks like we will soon have a fully-working semantic search for Scala code.

@dotta dotta closed this Jun 4, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment