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

Basic support for namespacing get-function calls #13

Merged
merged 5 commits into from Mar 13, 2019
Merged

Conversation

jathak
Copy link
Member

@jathak jathak commented Mar 9, 2019

Resolves #11.

If the argument passed to get-function is a string literal, we'll add a namespace if necessary.

For all other get-function calls, we'll emit a warning saying that a namespace may be required. We might eventually be able to detect some of these with some more sophisticated logic here, but for now we'll just handle the basics.

Resolves #11.

If the argument passed to get-function is a string literal, we'll add a
namespace if necessary.

For all other get-function calls, we'll emit a warning saying that a
namespace may be required. We might eventually be able to detect some of
these with some more sophisticated logic here, but for now we'll just
handle the basics.
@jathak jathak requested a review from nex3 March 9, 2019 00:56
} else {
_warn(
"WARNING: Could not determine if namespace is required for "
"get-function call @",
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: What's this @ for?

lib/src/migrator.dart Outdated Show resolved Hide resolved
lib/src/migrator.dart Outdated Show resolved Hide resolved
test/migrations/namespace_get_function.hrx Outdated Show resolved Hide resolved
Also changes warning message to use span.message and updates tests to
use only ASCII characters for checking log.
@jathak jathak requested a review from nex3 March 11, 2019 21:36
var beforeParen = node.span.end.offset - 1;
_currentMigration.patches.add(Patch(
node.span.file.span(beforeParen, beforeParen),
", \$module: $namespace"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Emit quotes around the namespace, in case it's a color name or something. There is actually a Sass library named true, so this isn't even purely hypothetical.

,
8 | $fn4: get-function($x);
| ^^
'
Copy link
Contributor

Choose a reason for hiding this comment

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

Also test a getting a function from a core library when the function's namespaced name doesn't match its original name, and getting a function from a library named true or whatever.

@jathak jathak requested a review from nex3 March 11, 2019 22:13
if (nameArgument is! StringExpression ||
(nameArgument as StringExpression).text.asPlain == null) {
print(nameArgument.span.message(
"WARNING - get-function call may require \$module parameter"));
Copy link
Contributor

Choose a reason for hiding this comment

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

It's probably a good idea to print this to stderr.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is there an equivalent to the prints matcher for testing stderr?

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately no there isn't. Usually when I'm testing command-line executables, I just run them via Process.runSync() or the test_process package so I don't have to worry about mocking out all the APIs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, in that case, I'll leave this as is for now. I've made an issue (#14) for this, which I'll handle in a separate PR

test/migrations/namespace_get_function.hrx Show resolved Hide resolved
@jathak jathak merged commit 502aace into master Mar 13, 2019
@jathak jathak deleted the get-function branch March 13, 2019 19:07
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.

None yet

2 participants