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

Always prefer source locations over interface files during definition lookup #26

Closed
fwcd opened this issue Mar 16, 2021 · 2 comments · Fixed by #68
Closed

Always prefer source locations over interface files during definition lookup #26

fwcd opened this issue Mar 16, 2021 · 2 comments · Fixed by #68
Labels
enhancement New feature or request

Comments

@fwcd
Copy link
Owner

fwcd commented Mar 16, 2021

Find symbols in the project's source file, even if the compiler refers to a definition from an ICurry file.

@fwcd fwcd added the enhancement New feature or request label Mar 16, 2021
@fwcd fwcd pinned this issue Jul 26, 2023
@fwcd
Copy link
Owner Author

fwcd commented Jul 26, 2023

The issue seems to be that the interface (.icurry) files seem to take precedence in the frontend if they already exist, otherwise the source file locations (e.g. <path to pakcs>/lib/Prelude.curry) are indexed as intended. This is where the indexing happens on the language server side:

-- Update symbol store
valueSymbols <- join <$> mapM toSymbols (CT.allBindings $ CE.valueEnv env)
typeSymbols <- join <$> mapM toSymbols (CT.allBindings $ CE.tyConsEnv env)
modSymbols <- join <$> mapM toSymbols (nubOrdOn ppToText $ mapMaybe (CI.qidModule . fst) $ CT.allImports (CE.valueEnv env))
let symbolDelta = valueSymbols ++ typeSymbols ++ modSymbols
combiner = unionBy ((==) `on` (\s' -> (sKind s', sQualIdent s', sIsFromCurrySource s')))
modify $ \s -> s
{ idxSymbols = insertAllIntoTrieWith combiner ((\s' -> (TE.encodeUtf8 $ sIdent s', [s'])) <$> symbolDelta) $ idxSymbols s
, idxModuleSymbols = insertAllIntoTrieWith (unionBy ((==) `on` sQualIdent)) ((\s' -> (TE.encodeUtf8 $ sQualIdent s', [s'])) <$> modSymbols) $ idxModuleSymbols s
}

Since the symbols are only indexed once, the language server will keep the correct source path for until it is restarted, if the .icurry didn't exist at startup. Thus we would have to update the frontend to always 'prefer' the source file's location.

@fwcd fwcd changed the title Improve definition lookup Always prefer source locations over interface files during definition lookup Jul 26, 2023
@fwcd
Copy link
Owner Author

fwcd commented Feb 9, 2024

A potential solution here would be to attach source information via #line directives in the .icurry files, similar to those emitted by the C preprocessor. The frontend should also know how to parse these directives and include them in the abstract representation, for use by the language server.

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

Successfully merging a pull request may close this issue.

1 participant