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

[Java] Syntax highlighting failure if method name ends with 'class' #1141

Closed
StrangeNoises opened this issue Sep 14, 2017 · 6 comments
Closed

Comments

@StrangeNoises
Copy link
Contributor

If the sequence of letters in the word 'class' appears at the end of a method name, syntax colouring is broken from that point on.

As per this example, which compiles and runs:

screen shot 2017-09-14 at 16 04 09

If you change any letter in the 'class' part of 'asSubclass', or add any letters to the end, eg: to '.asSublass(' or '.asSubclasse(' it all goes right. But of course, that's not the name of the method in java.lang.Class, so it doesn't compile...

(I've seen other problems with Java highlighting. This is just the first I've been able to isolate.)

Herewith pasted the code as well so you can try it...

import java.text.*;

public class Test {
	public static void main(String... args) {
		try {
			Number n = NumberFormat.getInstance().parse("1234.56");
			System.out.println("Value "+n+" is a "+n.getClass().getName());
			Class<? extends Double> cdbl = n.getClass().asSubclass(Double.class);
			System.out.println("If we got here it's a Double as expected.");
			System.out.println("But nothing is syntax coloured any more");
			System.out.println("Nothing. It's all blank. Except the word 'class'");
			System.out.println("But remove one letter from the 'class' in 'asSubclass' and it all goes right.");
			System.out.println("(Except of course it doesn't compile because that's not the name of the method.)");
		} catch (ParseException pe) {
			// it's gone wrong here too hasn't it...
			System.err.println("Give us a number!");
		} catch (ClassCastException cce) {
			System.err.println("It wasn't a Double?");
		}
	}
}
michaelblyons added a commit to michaelblyons/SublimeSyntax-Defaults that referenced this issue Sep 14, 2017
@StrangeNoises
Copy link
Contributor Author

Just came in to note that it affects methods ending in 'interface' too. It looks like your fix should catch that already though.

michaelblyons added a commit to michaelblyons/SublimeSyntax-Defaults that referenced this issue Sep 15, 2017
@ismell
Copy link

ismell commented Jan 22, 2018

Is this still valid? Just tried with the latest dev build

@StrangeNoises
Copy link
Contributor Author

I'll check tomorrow. I'm in no state to do so tonight, and don't have the dev machine to hand; on the other similar tickets was trusting to my earlier comments that they were fixed. Contextually I expect it probably is though as I haven't been aware of ongoing issues in recent usage.

@HugoLamarche
Copy link

I have the same issue with the following code :
class Foo { private int crazyclass; public void bar(); }

if you change crazyclass to crazyclas for example the color highlight is ok on void bar();

@StrangeNoises
Copy link
Contributor Author

I'm sorry I never got back after Jan 22.

On the dev build (3157) it all looks correct, including HugoLamarche's example above.

deathaxe pushed a commit to deathaxe/sublime-packages that referenced this issue Aug 25, 2019
This PR proposes to close some already fixed issues, which were not (correctly) referenced in the fixing pull requests.

Closes sublimehq#442
Closes sublimehq#685
Closes sublimehq#691 (invalid)
Closes sublimehq#795
Closes sublimehq#807
Closes sublimehq#903
Closes sublimehq#1141
Closes sublimehq#1172
Closes sublimehq#1245
Closes sublimehq#1257
Closes sublimehq#1286
Closes sublimehq#1320
Closes sublimehq#1357
Closes sublimehq#1382 (wontfix)
Closes sublimehq#1403
Closes sublimehq#1451
Closes sublimehq#1453 (maybe)
Closes sublimehq#1472
Closes sublimehq#1495
Closes sublimehq#1540
Closes sublimehq#1542
Closes sublimehq#1565
Closes sublimehq#1576
Closes sublimehq#1625
Closes sublimehq#1880
Closes sublimehq#1898
Closes sublimehq#1940 (invalid)
@wbond
Copy link
Member

wbond commented Oct 24, 2019

This issue has been solved by a previous commit, hence it is being closed.

@wbond wbond closed this as completed Oct 24, 2019
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

No branches or pull requests

4 participants