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

fix(dart) - add highlighting for class and function names #4169

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

guuido
Copy link
Contributor

@guuido guuido commented Nov 12, 2024

Resolves #4091

Changes

Before class and function names were not decorated and this could impact readability

image

Now these elements are correctly highlighted

image

Checklist

  • Added markup tests, or they don't apply here because...
  • Updated the changelog at CHANGES.md

Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

5 files changed

Total change +258 B

View Changes
file base pr diff
es/core.min.js 8.18 KB 8.18 KB -4 B
es/highlight.min.js 8.18 KB 8.18 KB -4 B
es/languages/dart.min.js 1.12 KB 1.26 KB +138 B
highlight.min.js 8.22 KB 8.22 KB -4 B
languages/dart.min.js 1.13 KB 1.26 KB +132 B

{
// prevent built-in types with capital letter from being selected as title.class
match: BUILT_IN_TYPES_REGEX,
skip: true
Copy link
Member

Choose a reason for hiding this comment

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

Why skip?

Copy link
Member

Choose a reason for hiding this comment

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

Why wouldn't a built-in class also get title.class? That or perhaps built_in I'd think...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using this snippet as an example:

class Person {
  String name;
  int age;

  Person(this.name, this.age);
}

Currently the library already marks String as built_in, so I added this regex to prevent String from being matched as title.class. I may have misunderstood what skip is used for (still learning how the library works) - I set skip: true because otherwise String wasn't decorated at all. I thought we wanted to preserve the current behavior, but if it's ok to use title.class for built-in classes I can remove this part

src/languages/dart.js Outdated Show resolved Hide resolved
Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

5 files changed

Total change +258 B

View Changes
file base pr diff
es/core.min.js 8.18 KB 8.18 KB -3 B
es/highlight.min.js 8.18 KB 8.18 KB -3 B
es/languages/dart.min.js 1.12 KB 1.25 KB +135 B
highlight.min.js 8.22 KB 8.22 KB -2 B
languages/dart.min.js 1.13 KB 1.26 KB +131 B

Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

5 files changed

Total change +274 B

View Changes
file base pr diff
es/core.min.js 8.18 KB 8.18 KB +3 B
es/highlight.min.js 8.18 KB 8.18 KB +3 B
es/languages/dart.min.js 1.12 KB 1.25 KB +135 B
highlight.min.js 8.22 KB 8.22 KB +2 B
languages/dart.min.js 1.13 KB 1.26 KB +131 B

Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

5 files changed

Total change +163 B

View Changes
file base pr diff
es/core.min.js 8.18 KB 8.18 KB -2 B
es/highlight.min.js 8.18 KB 8.18 KB -2 B
es/languages/dart.min.js 1.12 KB 1.21 KB +87 B
highlight.min.js 8.22 KB 8.22 KB -2 B
languages/dart.min.js 1.13 KB 1.21 KB +82 B

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.

(Dart) Highlight colors for Class and Constructor Calls
2 participants