Skip to content
This repository was archived by the owner on Aug 5, 2024. It is now read-only.

fixes for null safety dart #136

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -9,3 +9,4 @@ xcuserdata

dart/tests/Speedtest.dart.js.deps
dart/tests/Speedtest.dart.js.map
.vscode/launch.json
317 changes: 107 additions & 210 deletions dart/DMPClass.dart

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions dart/PatchClass.dart
Original file line number Diff line number Diff line change
@@ -22,18 +22,16 @@ part of DiffMatchPatch;
* Class representing one patch operation.
*/
class Patch {
List<Diff> diffs;
int start1;
int start2;
List<Diff> diffs = List.empty(growable: true);
int start1 = 0;
int start2 = 0;
int length1 = 0;
int length2 = 0;

/**
* Constructor. Initializes with an empty list of diffs.
*/
Patch() {
this.diffs = <Diff>[];
}
Patch();

/**
* Emulate GNU diff's format.
681 changes: 525 additions & 156 deletions dart/tests/DiffMatchPatchTest.dart

Large diffs are not rendered by default.

18 changes: 8 additions & 10 deletions dart/tests/Speedtest.dart
Original file line number Diff line number Diff line change
@@ -5,10 +5,10 @@ import '../DiffMatchPatch.dart';
// dart2js -O4 --out=Speedtest.dart.js Speedtest.dart

void launch(Event e) {
HtmlElement input1 = document.getElementById('text1');
HtmlElement input2 = document.getElementById('text2');
String text1 = input1.text;
String text2 = input2.text;
Element? input1 = document.getElementById('text1');
Element? input2 = document.getElementById('text2');
String? text1 = input1!.text;
String? text2 = input2!.text;

DiffMatchPatch dmp = new DiffMatchPatch();
dmp.Diff_Timeout = 0.0;
@@ -19,20 +19,18 @@ void launch(Event e) {
DateTime date_end = new DateTime.now();

var ds = dmp.diff_prettyHtml(d);
document.getElementById('outputdiv').setInnerHtml(
'$ds<BR>Time: ${date_end.difference(date_start)} (h:mm:ss.mmm)',
document.getElementById('outputdiv')!.setInnerHtml('$ds<BR>Time: ${date_end.difference(date_start)} (h:mm:ss.mmm)',
validator: new TrustedNodeValidator());
}

void main() {
document.getElementById('launch').addEventListener('click', launch);
document.getElementById('outputdiv').setInnerHtml('');
document.getElementById('launch')!.addEventListener('click', launch);
document.getElementById('outputdiv')!.setInnerHtml('');
}

/// A NodeValidator which allows any contents.
/// The default validator strips 'style' attributes.
class TrustedNodeValidator implements NodeValidator {
bool allowsElement(Element element) => true;
bool allowsAttribute(Element element, String attributeName, String value)
=> true;
bool allowsAttribute(Element element, String attributeName, String value) => true;
}