Skip to content

Commit bf9cc59

Browse files
committed
Merge package:source_span into the tools monorepo
2 parents faf2b86 + 4aec583 commit bf9cc59

28 files changed

+4605
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Set update schedule for GitHub Actions
2+
# See https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
3+
4+
version: 2
5+
updates:
6+
7+
- package-ecosystem: github-actions
8+
directory: /
9+
schedule:
10+
interval: monthly
11+
labels:
12+
- autosubmit
13+
groups:
14+
github-actions:
15+
patterns:
16+
- "*"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# A CI configuration to auto-publish pub packages.
2+
3+
name: Publish
4+
5+
on:
6+
pull_request:
7+
branches: [ master ]
8+
push:
9+
tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ]
10+
11+
jobs:
12+
publish:
13+
if: ${{ github.repository_owner == 'dart-lang' }}
14+
uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Dart CI
2+
3+
on:
4+
# Run on PRs and pushes to the default branch.
5+
push:
6+
branches: [ master ]
7+
pull_request:
8+
branches: [ master ]
9+
schedule:
10+
- cron: "0 0 * * 0"
11+
12+
env:
13+
PUB_ENVIRONMENT: bot.github
14+
15+
jobs:
16+
# Check code formatting and static analysis on a single OS (linux)
17+
# against Dart dev.
18+
analyze:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
sdk: [dev]
24+
steps:
25+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
26+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
27+
with:
28+
sdk: ${{ matrix.sdk }}
29+
- id: install
30+
name: Install dependencies
31+
run: dart pub get
32+
- name: Check formatting
33+
run: dart format --output=none --set-exit-if-changed .
34+
if: always() && steps.install.outcome == 'success'
35+
- name: Analyze code
36+
run: dart analyze --fatal-infos
37+
if: always() && steps.install.outcome == 'success'
38+
39+
# Run tests on a matrix consisting of two dimensions:
40+
# 1. OS: ubuntu-latest, (macos-latest, windows-latest)
41+
# 2. release channel: dev
42+
test:
43+
needs: analyze
44+
runs-on: ${{ matrix.os }}
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
# Add macos-latest and/or windows-latest if relevant for this package.
49+
os: [ubuntu-latest]
50+
sdk: [3.1.0, dev]
51+
steps:
52+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
53+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
54+
with:
55+
sdk: ${{ matrix.sdk }}
56+
- id: install
57+
name: Install dependencies
58+
run: dart pub get
59+
- name: Run VM tests
60+
run: dart test --platform vm
61+
if: always() && steps.install.outcome == 'success'
62+
- name: Run Chrome tests
63+
run: dart test --platform chrome
64+
if: always() && steps.install.outcome == 'success'

pkgs/source_span/.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Don’t commit the following directories created by pub.
2+
.buildlog
3+
.dart_tool/
4+
.pub/
5+
build/
6+
packages
7+
.packages
8+
9+
# Or the files created by dart2js.
10+
*.dart.js
11+
*.js_
12+
*.js.deps
13+
*.js.map
14+
15+
# Include when developing application packages.
16+
pubspec.lock

pkgs/source_span/CHANGELOG.md

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
## 1.10.1-wip
2+
3+
* Require Dart 3.1
4+
5+
## 1.10.0
6+
7+
* Add a `SourceFile.codeUnits` property.
8+
* Require Dart 2.18
9+
* Add an API usage example in `example/`.
10+
11+
## 1.9.1
12+
13+
* Properly handle multi-line labels for multi-span highlights.
14+
15+
* Populate the pubspec `repository` field.
16+
17+
## 1.9.0
18+
19+
* Add `SourceSpanWithContextExtension.subspan` that returns a
20+
`SourceSpanWithContext` rather than a plain `SourceSpan`.
21+
22+
## 1.8.2
23+
24+
* Fix a bug where highlighting multiple spans with `null` URLs could cause an
25+
assertion error. Now when multiple spans are passed with `null` URLs, they're
26+
highlighted as though they all come from different source files.
27+
28+
## 1.8.1
29+
30+
* Fix a bug where the URL header for the highlights with multiple files would
31+
get omitted only one span has a non-null URI.
32+
33+
## 1.8.0
34+
35+
* Stable release for null safety.
36+
37+
## 1.7.0
38+
39+
* Add a `SourceSpan.subspan()` extension method which returns a slice of an
40+
existing source span.
41+
42+
## 1.6.0
43+
44+
* Add support for highlighting multiple source spans at once, providing more
45+
context for span-based messages. This is exposed through the new APIs
46+
`SourceSpan.highlightMultiple()` and `SourceSpan.messageMultiple()` (both
47+
extension methods), `MultiSourceSpanException`, and
48+
`MultiSourceSpanFormatException`.
49+
50+
## 1.5.6
51+
52+
* Fix padding around line numbers that are powers of 10 in
53+
`FileSpan.highlight()`.
54+
55+
## 1.5.5
56+
57+
* Fix a bug where `FileSpan.highlight()` would crash for spans that covered a
58+
trailing newline and a single additional empty line.
59+
60+
## 1.5.4
61+
62+
* `FileSpan.highlight()` now properly highlights point spans at the beginning of
63+
lines.
64+
65+
## 1.5.3
66+
67+
* Fix an edge case where `FileSpan.highlight()` would put the highlight
68+
indicator in the wrong position when highlighting a point span after the end
69+
of a file.
70+
71+
## 1.5.2
72+
73+
* `SourceFile.span()` now goes to the end of the file by default, rather than
74+
ending one character before the end of the file. This matches the documented
75+
behavior.
76+
77+
* `FileSpan.context` now includes the full line on which the span appears for
78+
empty spans at the beginning and end of lines.
79+
80+
* Fix an edge case where `FileSpan.highlight()` could crash when highlighting a
81+
span that ended with an empty line.
82+
83+
## 1.5.1
84+
85+
* Produce better source span highlights for multi-line spans that cover the
86+
entire last line of the span, including the newline.
87+
88+
* Produce better source span highlights for spans that contain Windows-style
89+
newlines.
90+
91+
## 1.5.0
92+
93+
* Improve the output of `SourceSpan.highlight()` and `SourceSpan.message()`:
94+
95+
* They now include line numbers.
96+
* They will now print every line of a multiline span.
97+
* They will now use Unicode box-drawing characters by default (this can be
98+
controlled using [`term_glyph.ascii`][]).
99+
100+
[`term_glyph.ascii`]: https://pub.dartlang.org/documentation/term_glyph/latest/term_glyph/ascii.html
101+
102+
## 1.4.1
103+
104+
* Set max SDK version to `<3.0.0`, and adjust other dependencies.
105+
106+
## 1.4.0
107+
108+
* The `new SourceFile()` constructor is deprecated. This constructed a source
109+
file from a string's runes, rather than its code units, which runs counter to
110+
the way Dart handles strings otherwise. The `new StringFile.fromString()`
111+
constructor (see below) should be used instead.
112+
113+
* The `new SourceFile.fromString()` constructor was added. This works like `new
114+
SourceFile()`, except it uses code units rather than runes.
115+
116+
* The current behavior when characters larger than `0xFFFF` are passed to `new
117+
SourceFile.decoded()` is now considered deprecated.
118+
119+
## 1.3.1
120+
121+
* Properly highlight spans for lines that include tabs with
122+
`SourceSpan.highlight()` and `SourceSpan.message()`.
123+
124+
## 1.3.0
125+
126+
* Add `SourceSpan.highlight()`, which returns just the highlighted text that
127+
would be included in `SourceSpan.message()`.
128+
129+
## 1.2.4
130+
131+
* Fix a new strong mode error.
132+
133+
## 1.2.3
134+
135+
* Fix a bug where a point span at the end of a file without a trailing newline
136+
would be printed incorrectly.
137+
138+
## 1.2.2
139+
140+
* Allow `SourceSpanException.message`, `SourceSpanFormatException.source`, and
141+
`SourceSpanWithContext.context` to be overridden in strong mode.
142+
143+
## 1.2.1
144+
145+
* Fix the declared type of `FileSpan.start` and `FileSpan.end`. In 1.2.0 these
146+
were mistakenly changed from `FileLocation` to `SourceLocation`.
147+
148+
## 1.2.0
149+
150+
* **Deprecated:** Extending `SourceLocation` directly is deprecated. Instead,
151+
extend the new `SourceLocationBase` class or mix in the new
152+
`SourceLocationMixin` mixin.
153+
154+
* Dramatically improve the performance of `FileLocation`.
155+
156+
## 1.1.6
157+
158+
* Optimize `getLine()` in `SourceFile` when repeatedly called.
159+
160+
## 1.1.5
161+
162+
* Fixed another case in which `FileSpan.union` could throw an exception for
163+
external implementations of `FileSpan`.
164+
165+
## 1.1.4
166+
167+
* Eliminated dart2js warning about overriding `==`, but not `hashCode`.
168+
169+
## 1.1.3
170+
171+
* `FileSpan.compareTo`, `FileSpan.==`, `FileSpan.union`, and `FileSpan.expand`
172+
no longer throw exceptions for external implementations of `FileSpan`.
173+
174+
* `FileSpan.hashCode` now fully agrees with `FileSpan.==`.
175+
176+
## 1.1.2
177+
178+
* Fixed validation in `SourceSpanWithContext` to allow multiple occurrences of
179+
`text` within `context`.
180+
181+
## 1.1.1
182+
183+
* Fixed `FileSpan`'s context to include the full span text, not just the first
184+
line of it.
185+
186+
## 1.1.0
187+
188+
* Added `SourceSpanWithContext`: a span that also includes the full line of text
189+
that contains the span.
190+
191+
## 1.0.3
192+
193+
* Cleanup equality operator to accept any Object rather than just a
194+
`SourceLocation`.
195+
196+
## 1.0.2
197+
198+
* Avoid unintentionally allocating extra objects for internal `FileSpan`
199+
operations.
200+
201+
* Ensure that `SourceSpan.operator==` works on arbitrary `Object`s.
202+
203+
## 1.0.1
204+
205+
* Use a more compact internal representation for `FileSpan`.
206+
207+
## 1.0.0
208+
209+
This package was extracted from the
210+
[`source_maps`](https://pub.dev/packages/source_maps) package, but the
211+
API has many differences. Among them:
212+
213+
* `Span` has been renamed to `SourceSpan` and `Location` has been renamed to
214+
`SourceLocation` to clarify their purpose and maintain consistency with the
215+
package name. Likewise, `SpanException` is now `SourceSpanException` and
216+
`SpanFormatException` is not `SourceSpanFormatException`.
217+
218+
* `FixedSpan` and `FixedLocation` have been rolled into the `Span` and
219+
`Location` classes, respectively.
220+
221+
* `SourceFile` is more aggressive about validating its arguments. Out-of-bounds
222+
lines, columns, and offsets will now throw errors rather than be silently
223+
clamped.
224+
225+
* `SourceSpan.sourceUrl`, `SourceLocation.sourceUrl`, and `SourceFile.url` now
226+
return `Uri` objects rather than `String`s. The constructors allow either
227+
`String`s or `Uri`s.
228+
229+
* `Span.getLocationMessage` and `SourceFile.getLocationMessage` are now
230+
`SourceSpan.message` and `SourceFile.message`, respectively. Rather than
231+
taking both a `useColor` and a `color` parameter, they now take a single
232+
`color` parameter that controls both whether and which color is used.
233+
234+
* `Span.isIdentifier` has been removed. This property doesn't make sense outside
235+
of a source map context.
236+
237+
* `SourceFileSegment` has been removed. This class wasn't widely used and was
238+
inconsistent in its choice of which parameters were considered relative and
239+
which absolute.

pkgs/source_span/LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright 2014, the Dart project authors.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are
5+
met:
6+
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above
10+
copyright notice, this list of conditions and the following
11+
disclaimer in the documentation and/or other materials provided
12+
with the distribution.
13+
* Neither the name of Google LLC nor the names of its
14+
contributors may be used to endorse or promote products derived
15+
from this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)