Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Added decimal highlighting #24

Merged
merged 8 commits into from
Oct 20, 2015
Merged

Added decimal highlighting #24

merged 8 commits into from
Oct 20, 2015

Conversation

Cxarli
Copy link
Contributor

@Cxarli Cxarli commented Oct 16, 2015

As discussed here, added decimal highlighting in SQL

@winstliu
Copy link
Contributor

Can you add specs to this please?

@Cxarli
Copy link
Contributor Author

Cxarli commented Oct 16, 2015

@50Wliu How would I add specs? (New to contributing to others' projects)

@winstliu
Copy link
Contributor

@Cxarli
Copy link
Contributor Author

Cxarli commented Oct 16, 2015

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?

@winstliu
Copy link
Contributor

That's quite a lot of work for a quick fix

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.

@Cxarli
Copy link
Contributor Author

Cxarli commented Oct 16, 2015

Added specs, is this good?

@@ -106,7 +106,7 @@
'name': 'storage.modifier.sql'
}
{
'match': '\\b\\d+\\b'
'match': '\\b\\d+(\\.\\d+)?\\b'
Copy link
Contributor

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*.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@winstliu
Copy link
Contributor

In addition, this branch has conflicts now, so if you could rebase, that would be great.

@Cxarli
Copy link
Contributor Author

Cxarli commented Oct 19, 2015

@50Wliu Rebased

@winstliu
Copy link
Contributor

Github is still saying that this branch has conflicts.

@Cxarli
Copy link
Contributor Author

Cxarli commented Oct 19, 2015

And what are those conflicts? :s

@winstliu
Copy link
Contributor

Not sure...how exactly did you rebase?

@Cxarli
Copy link
Contributor Author

Cxarli commented Oct 19, 2015

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:

Not sure...how exactly did you rebase?

Reply to this email directly or view it on GitHub:
#24 (comment)

@winstliu
Copy link
Contributor

Copied all code from my other patch, added the code of this patch, and pushed again

Yeah...that won't work. Git won't see that as a resolution to conflicts. What you need to do instead is git pull master, checkout patch-3, and then git merge master. Git will tell you that there are conflicts; then just go in to each file that has conflicts, resolve them, commit, and push.

@Cxarli
Copy link
Contributor Author

Cxarli commented Oct 19, 2015

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:

Copied all code from my other patch, added the code of this patch, and pushed again

Yeah...that won't work. Git won't see that as a resolution to conflicts. What you need to do instead is git pull master, checkout patch-3, and then git merge master. Git will tell you that there are conflicts; then just go in to each file that has conflicts, resolve them, commit, and push.

Reply to this email directly or view it on GitHub:
#24 (comment)

@Cxarli
Copy link
Contributor Author

Cxarli commented Oct 20, 2015

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 ~/git/language-sql is from git clone git@github.com:C-Bouthoorn/language-sql.git

@winstliu
Copy link
Contributor

Oh whoops, that's because you're on a fork. Try git pull upstream and if that doesn't work, git pull https://github.com/atom/language-sql.git.

@winstliu
Copy link
Contributor

If this is all too much work feel free to just close this PR and make a new branch/PR :).

@Cxarli
Copy link
Contributor Author

Cxarli commented Oct 20, 2015

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.

Doesn't seem to work either. I'll create a new branch

Wrong directory... Think it's fixed now

Conflicts:
	spec/grammar-spec.coffee
@winstliu
Copy link
Contributor

Ok. Last thing before I merge: it doesn't look like you changed the decimal regex yet to support the edge cases .1, 1., etc.

@Cxarli
Copy link
Contributor Author

Cxarli commented Oct 20, 2015

Oh, I lost that part of code. Let me re-add that

@Cxarli
Copy link
Contributor Author

Cxarli commented Oct 20, 2015

Also added tests

@winstliu
Copy link
Contributor

Will merge once the build goes green 😄.

@Cxarli
Copy link
Contributor Author

Cxarli commented Oct 20, 2015

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 😊

@Cxarli
Copy link
Contributor Author

Cxarli commented Oct 20, 2015

Looks like Travis is busy...

@winstliu
Copy link
Contributor

Haha, yup. I'll just merge this now because the regex and tests both look good. Thanks a lot for sticking with this!

winstliu pushed a commit that referenced this pull request Oct 20, 2015
Added decimal highlighting
@winstliu winstliu merged commit e8d02eb into atom:master Oct 20, 2015
@Cxarli Cxarli deleted the patch-3 branch October 20, 2015 15:41
@Cxarli Cxarli restored the patch-3 branch October 20, 2015 16:08
@winstliu
Copy link
Contributor

@C-Bouthoorn specs actually failed, so I just fixed them on master: 05efcd8. For next time, you can run specs locally through apm test or View -> Developer -> Run Package Specs.

@Cxarli
Copy link
Contributor Author

Cxarli commented Oct 21, 2015

I will, thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants