-
Notifications
You must be signed in to change notification settings - Fork 51
Conversation
Can you add specs to this please? |
@50Wliu How would I add specs? (New to contributing to others' projects) |
You can see https://github.com/atom/language-shellscript/blob/master/spec/shell-unix-bash-spec.coffee for an example of specs. A simple example is also located here: https://github.com/atom/atom/blob/master/CONTRIBUTING.md#specs-styleguide |
That's quite a lot of work for a quick fix... Is describe 'not', ->
it 'indicates that the next statement should be turned around', ->
describe 'turn around', ->
it 'turns true when false'
it 'turns false when true' enough for this piece of code? Where should I place it? |
Yeah, it's just to make sure that your fix doesn't break accidentally in the future. Anyway, something like this should work: it 'tokenizes numbers', ->
{tokens} = 'numbers and stuff here'
expect(tokens[0]).toEqual value: 'the character', scopes: ['language scopes (Log Cursor Scopes or something in the Command Palette)']
expect(tokens[1]).toEqual ...etc. Just place it at the end of https://github.com/atom/language-sql/blob/master/spec/grammar-spec.coffee. |
Adds specs
Added specs, is this good? |
@@ -106,7 +106,7 @@ | |||
'name': 'storage.modifier.sql' | |||
} | |||
{ | |||
'match': '\\b\\d+\\b' | |||
'match': '\\b\\d+(\\.\\d+)?\\b' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is something like 5.
valid? If so, this should be changed to \\d*
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I did a little test:
mysql> INSERT INTO NumberTest (number) VALUES (1.0);
mysql> INSERT INTO NumberTest (number) VALUES (1.);
mysql> INSERT INTO NumberTest (number) VALUES (.1);
mysql> SELECT * FROM NumberTest;
+----+--------+
| id | number |
+----+--------+
| 1 | 1.0000 |
| 2 | 1.0000 |
| 3 | 0.1000 |
+----+--------+
mysql> SELECT * FROM NumberTest WHERE number=.1;
+----+--------+
| id | number |
+----+--------+
| 3 | 0.1000 |
+----+--------+
mysql> SELECT * FROM NumberTest WHERE number=1.;
+----+--------+
| id | number |
+----+--------+
| 1 | 1.0000 |
| 2 | 1.0000 |
+----+--------+
And numbers can indeed start or end with a period.
Should I use (\\d+)|(\\.\\d+)|(\\d+\\.)|(\\d+\\.\\d+)
then, or is there a better way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to work for the most part: \\b(\\d+(\\.(\\d+)?)?)|(\\.\\d+)\\b
The only problem I can find is that the 3.
in 3.a
will be tokenized as a number when it shouldn't be. Same with 3a
.
In addition, this branch has conflicts now, so if you could rebase, that would be great. |
@50Wliu Rebased |
Github is still saying that this branch has conflicts. |
And what are those conflicts? :s |
Not sure...how exactly did you rebase? |
Copied all code from my other patch, added the code of this patch, and pushed again On Mon, Oct 19, 2015 at 11:41 PM, Wliu notifications@github.com wrote:
|
Yeah...that won't work. Git won't see that as a resolution to conflicts. What you need to do instead is |
I will tomorrow, currently not available to do anything with git On Mon, Oct 19, 2015 at 11:45 PM, Wliu notifications@github.com wrote:
|
charlie@chiyuu:~/git/language-sql$ git pull master
fatal: 'master' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
charlie@chiyuu:~/git/language-sql$ git pull origin
Already up-to-date.
charlie@chiyuu:~/git/language-sql$ git checkout patch-3
Already on 'patch-3'
Your branch is up-to-date with 'origin/patch-3'.
charlie@chiyuu:~/git/language-sql$ git merge master
Already up-to-date.
charlie@chiyuu:~/git/language-sql$ git merge origin
Already up-to-date. I don't know what I am doing wrong... Edit: The |
Oh whoops, that's because you're on a fork. Try |
If this is all too much work feel free to just close this PR and make a new branch/PR :). |
charlie@chiyuu:~/git/language-sql$ git pull upstream
fatal: 'upstream' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
charlie@chiyuu:~/git/language-sql$ git pull https://github.com/atom/language-sql.git
From https://github.com/atom/language-sql
* branch HEAD -> FETCH_HEAD
Already up-to-date.
Wrong directory... Think it's fixed now |
Conflicts: spec/grammar-spec.coffee
Ok. Last thing before I merge: it doesn't look like you changed the decimal regex yet to support the edge cases |
Oh, I lost that part of code. Let me re-add that |
Also added tests |
Will merge once the build goes green 😄. |
Thanks in advantage for all the experience I got by doing this, and sorry if I wasted any of your time. Hope we can meet again in the future 😊 |
Looks like Travis is busy... |
Haha, yup. I'll just merge this now because the regex and tests both look good. Thanks a lot for sticking with this! |
@C-Bouthoorn specs actually failed, so I just fixed them on master: 05efcd8. For next time, you can run specs locally through |
I will, thanks |
As discussed here, added decimal highlighting in SQL