-
Notifications
You must be signed in to change notification settings - Fork 30
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
JDK 9+ Support #91
Merged
JDK 9+ Support #91
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,10 +10,14 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: olafurpg/setup-scala@v10 | ||
with: | ||
java-version: [email protected] | ||
- run: sbt test | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: olafurpg/setup-scala@v10 | ||
with: | ||
java-version: [email protected] | ||
- run: sbt checkAll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
package com.sourcegraph.semanticdb_javac; | ||
|
||
import com.sun.tools.javac.code.Kinds; | ||
import com.sun.tools.javac.code.Scope; | ||
import com.sun.tools.javac.code.Symbol; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.IdentityHashMap; | ||
import javax.lang.model.element.Element; | ||
import javax.lang.model.element.ExecutableElement; | ||
import java.util.*; | ||
|
||
import static com.sourcegraph.semanticdb_javac.Debugging.pprint; | ||
|
||
|
@@ -33,7 +31,7 @@ public String semanticdbSymbol(Symbol sym, LocalSymbolsCache locals) { | |
} | ||
|
||
public boolean isNone(Symbol sym) { | ||
return sym == null || sym.kind == Kinds.NIL || (sym.kind & Kinds.ERRONEOUS) != 0; | ||
return sym == null; | ||
} | ||
|
||
private String uncachedSemanticdbSymbol(Symbol sym, LocalSymbolsCache locals) { | ||
|
@@ -97,18 +95,13 @@ private SemanticdbSymbols.Descriptor semanticdbDescriptor(Symbol sym) { | |
* SemanticDB spec</a>. | ||
*/ | ||
private String methodDisambiguator(Symbol.MethodSymbol sym) { | ||
Scope.Entry lookup = | ||
sym.owner.members().lookup(sym.name, s -> s instanceof Symbol.MethodSymbol); | ||
ArrayList<Symbol> peers = new ArrayList<>(); | ||
while (lookup != null) { | ||
if (lookup.sym != null) { | ||
peers.add(lookup.sym); | ||
Iterable<? extends Element> elements = sym.owner.getEnclosedElements(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice find 👍 This looks like a decent replacement for |
||
ArrayList<ExecutableElement> methods = new ArrayList<>(); | ||
for (Element e : elements) { | ||
if (e instanceof ExecutableElement && e.getSimpleName() == sym.name) { | ||
methods.add((ExecutableElement) e); | ||
} | ||
lookup = lookup.next(); | ||
} | ||
// NOTE(olafur): reverse the iteration from `Scope.Entry` to get order in which the symbols are | ||
// defined in source. | ||
Collections.reverse(peers); | ||
// NOTE(olafur): sort static methods last, according to the spec. Historical note: this | ||
// requirement is | ||
// part of the SemanticDB spec because static methods and non-static methods have a different | ||
|
@@ -117,8 +110,9 @@ private String methodDisambiguator(Symbol.MethodSymbol sym) { | |
// definitions. | ||
// In practice, it's unusual to mix static and non-static methods so this shouldn't be a big | ||
// issue. | ||
peers.sort((a, b) -> Boolean.compare(a.isStatic(), b.isStatic())); | ||
int index = peers.indexOf(sym); | ||
methods.sort( | ||
(a, b) -> Boolean.compare(a.getReceiverType() == null, b.getReceiverType() == null)); | ||
int index = methods.indexOf(sym); | ||
if (index == 0) return "()"; | ||
return String.format("(+%d)", index); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍