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

feat: defmodule snippet infer module name #398

Merged

Conversation

lucacervello
Copy link
Contributor

defmodule snippet infer module name

recording 🎥

Screen.Recording.2024-03-14.at.09.29.30.mov

@lucacervello lucacervello force-pushed the defmodule-snippet-infer-module-name branch from f97809b to dc54829 Compare March 14, 2024 08:35
result =
uri
|> Path.split()
|> Enum.reduce(false, fn
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what the first element of the accumulator signifies here?

The clause with support is confusing me a tad.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually the module in test/support don't use Test in the module name like https://github.com/elixir-tools/next-ls/blob/main/test/support/utils.ex

Can you explain what the first element of the accumulator signifies here?

do you mean false?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant the tuple {:test, []}. I'm not sure what the atom is doing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used here to check if there is support under test

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the line that I am asking about.

I'm not sure where you use that later, you said something about tests ending in "Test", but i'm not seeing that either in this code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my bad, I'll try to explain.

I'm looking for three folders

  • lib where usually the code is, lib/foo.ex it's translated to Foo (without lib)
  • test where usually the tests are, test/foo_test.exs it's translated to FooTest (without test)
  • support where usually are utils for tests, test/support/foo.ex it's translated to Foo (without test and support)

here are some tests that can help https://github.com/elixir-tools/next-ls/blob/9d65b759ac0cf86c943190342cf829097fc62346/test/next_ls/snippet_test.exs

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, i understand now, thanks!

basically you are just striping lib/, test/ and test/support/ from the beginning for the path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes 👍

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lucacervello When you use someone else's code, please mention the source. If possible, contacting the author would be best; otherwise, it appears quite unethical.

https://github.com/lexical-lsp/lexical/blob/2178b4beab5d1a04cb83990e09b3dc232ed941cb/apps/server/lib/lexical/server/code_intelligence/completion/translations/macro.ex#L567C5-L603C8

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the code on main.

Sorry about that!

test/next_ls/completions_test.exs Show resolved Hide resolved
@mhanberg
Copy link
Collaborator

You're on fire!

Comment on lines +116 to +117
def ascend(nil, acc, _callback), do: acc

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this change necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@mhanberg mhanberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will merge after my last comment is answered.

@mhanberg mhanberg force-pushed the defmodule-snippet-infer-module-name branch from 9d65b75 to 0c48c40 Compare March 15, 2024 15:10
@mhanberg mhanberg enabled auto-merge (squash) March 15, 2024 15:10
@mhanberg mhanberg merged commit 4151895 into elixir-tools:main Mar 15, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants