Skip to content

query: Display definitions for duplicate files #409

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions elixir/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from . import lib
from . import data
import os
import sys
from collections import OrderedDict
from urllib import parse

Expand Down Expand Up @@ -294,8 +295,18 @@ def get_idents_defs(self, version, ident, family):
dBuf = []
rBuf = []
docBuf = []
prev_file_idx, prev_dbuf_slice = None, []

for file_idx, file_path in files_this_version:
# The file has the same contents as the previous file (same ID,
# different path). Duplicate definitions for the duplicate file.
if file_idx == prev_file_idx and len(prev_dbuf_slice) != 0:
to_add = []
for _, int_def_type, int_def_line in prev_dbuf_slice:
to_add.append((file_path, int_def_type, int_def_line))
dBuf.extend(to_add)
continue

# Advance defs, refs, and docs to the current file
while def_idx < file_idx:
def_idx, def_type, def_line, def_family = next(defs_this_ident)
Expand All @@ -305,11 +316,14 @@ def get_idents_defs(self, version, ident, family):
doc_idx, doc_line, doc_family = next(docs)

# Copy information about this identifier into dBuf, rBuf, and docBuf.
dbuf_range_start = len(dBuf)
while def_idx == file_idx:
if (def_family == family or family == 'A'
or lib.compatibleMacro(macros_this_ident, family)):
dBuf.append((file_path, def_type, def_line))
def_idx, def_type, def_line, def_family = next(defs_this_ident)
prev_dbuf_slice = dBuf[dbuf_range_start:]
prev_file_idx = file_idx

if ref_idx == file_idx:
if lib.compatibleFamily(family, ref_family) or family == 'A':
Expand Down