Skip to content

Commit

Permalink
fix: apply comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ayame113 committed Jul 17, 2021
1 parent 3bd2372 commit 890c731
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
24 changes: 12 additions & 12 deletions lib/adapters/call-hierarchy-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import OutlineViewAdapter from "./outline-view-adapter"

/** Public: Adapts the documentSymbolProvider of the language server to the Outline View supplied by Atom IDE UI. */
export default class CallHierarchyAdapter {
private _cancellationTokens: WeakMap<LanguageClientConnection, CancellationTokenSource> = new WeakMap()
private _cancellationTokens = new WeakMap<LanguageClientConnection, CancellationTokenSource>()

/**
* Public: Determine whether this adapter can be used to adapt a language server based on the serverCapabilities
Expand All @@ -20,7 +20,7 @@ export default class CallHierarchyAdapter {
* @returns A {Boolean} indicating adapter can adapt the server based on the given serverCapabilities.
*/
public static canAdapt(serverCapabilities: ServerCapabilities): boolean {
return !!serverCapabilities.callHierarchyProvider
return Boolean(serverCapabilities.callHierarchyProvider)
}

/** Corresponds to lsp's CallHierarchyPrepareRequest */
Expand Down Expand Up @@ -53,11 +53,11 @@ export default class CallHierarchyAdapter {
return <CallHierarchyForAdapter<T>>{
type,
data: results?.map(convertCallHierarchyItem) ?? [],
itemAt(n: number) {
itemAt(num: number) {
if (type === "incoming") {
return <Promise<atomIde.CallHierarchy<T>>>this.adapter.getIncoming(this.connection, this.data[n].rawData)
return <Promise<atomIde.CallHierarchy<T>>>this.adapter.getIncoming(this.connection, this.data[num].rawData)
} else {
return <Promise<atomIde.CallHierarchy<T>>>this.adapter.getOutgoing(this.connection, this.data[n].rawData)
return <Promise<atomIde.CallHierarchy<T>>>this.adapter.getOutgoing(this.connection, this.data[num].rawData)
}
},
connection,
Expand All @@ -74,9 +74,9 @@ export default class CallHierarchyAdapter {
)
return <CallHierarchyForAdapter<"incoming">>{
type: "incoming",
data: results?.map?.((l) => convertCallHierarchyItem(l.from)) || [],
itemAt(n: number) {
return this.adapter.getIncoming(this.connection, this.data[n].rawData)
data: results?.map((res) => convertCallHierarchyItem(res.from)) ?? [],
itemAt(num: number) {
return this.adapter.getIncoming(this.connection, this.data[num].rawData)
},
connection,
adapter: this,
Expand All @@ -92,9 +92,9 @@ export default class CallHierarchyAdapter {
)
return <CallHierarchyForAdapter<"outgoing">>{
type: "outgoing",
data: results?.map((l) => convertCallHierarchyItem(l.to)) || [],
itemAt(n: number) {
return this.adapter.getOutgoing(this.connection, this.data[n].rawData)
data: results?.map((res) => convertCallHierarchyItem(res.to)) ?? [],
itemAt(num: number) {
return this.adapter.getOutgoing(this.connection, this.data[num].rawData)
},
connection,
adapter: this,
Expand All @@ -112,7 +112,7 @@ function convertCallHierarchyItem(rawData: CallHierarchyItem): CallHierarchyItem
...rawData.tags.reduce((set, tag) => {
// filter out null and remove duplicates
const entity = symbolTagToEntityKind(tag)
return entity == null ? set : set.add(entity)
return entity === null ? set : set.add(entity)
}, new Set<atomIde.SymbolTagKind>()),
]
: [],
Expand Down
8 changes: 4 additions & 4 deletions lib/auto-languageclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,10 +765,10 @@ export default class AutoLanguageClient {
point: Point
): Promise<atomIde.CallHierarchy<"incoming"> | null> {
const server = await this._serverManager.getServer(editor)
if (server == null || !CallHierarchyAdapter.canAdapt(server.capabilities)) {
if (server === null || !CallHierarchyAdapter.canAdapt(server.capabilities)) {
return null
}
this.callHierarchy = this.callHierarchy || new CallHierarchyAdapter()
this.callHierarchy = this.callHierarchy ?? new CallHierarchyAdapter()
return this.callHierarchy.getCallHierarchy(server.connection, editor, point, "incoming")
}

Expand All @@ -777,10 +777,10 @@ export default class AutoLanguageClient {
point: Point
): Promise<atomIde.CallHierarchy<"outgoing"> | null> {
const server = await this._serverManager.getServer(editor)
if (server == null || !CallHierarchyAdapter.canAdapt(server.capabilities)) {
if (server === null || !CallHierarchyAdapter.canAdapt(server.capabilities)) {
return null
}
this.callHierarchy = this.callHierarchy || new CallHierarchyAdapter()
this.callHierarchy = this.callHierarchy ?? new CallHierarchyAdapter()
return this.callHierarchy.getCallHierarchy(server.connection, editor, point, "outgoing")
}

Expand Down

0 comments on commit 890c731

Please sign in to comment.