Add diagnostic documentation for most of the ffi diagnostics
Change-Id: I37ba1852dea9c7e53966050eafaed9bb61cffbb8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229580 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
committed by
Commit Bot
parent
85b79f0856
commit
7272aadca4
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,33 @@ import 'package:analyzer/file_system/file_system.dart';
|
||||
|
||||
/// Helper for creating mock packages.
|
||||
class MockPackages {
|
||||
/// Create a fake 'ffi' package that can be used by tests.
|
||||
static void addFfiPackageFiles(Folder rootFolder) {
|
||||
var libFolder = rootFolder.getChildAssumingFolder('lib');
|
||||
libFolder.getChildAssumingFile('ffi.dart').writeAsStringSync(r'''
|
||||
import 'dart:ffi';
|
||||
|
||||
const Allocator calloc = _CallocAllocator();
|
||||
|
||||
abstract class Allocator {
|
||||
Pointer<T> allocate<T extends NativeType>(int byteCount, {int? alignment});
|
||||
|
||||
void free(Pointer pointer);
|
||||
}
|
||||
|
||||
class Utf8 extends Opaque {}
|
||||
|
||||
class _CallocAllocator implements Allocator {
|
||||
@override
|
||||
Pointer<T> allocate<T extends NativeType>(int byteCount, {int? alignment})
|
||||
=> throw '';
|
||||
|
||||
@override
|
||||
void free(Pointer pointer) => throw '';
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
/// Create a fake 'js' package that can be used by tests.
|
||||
static void addJsPackageFiles(Folder rootFolder) {
|
||||
var libFolder = rootFolder.getChildAssumingFolder('lib');
|
||||
|
||||
@@ -662,6 +662,8 @@ class NativeType {
|
||||
|
||||
class Handle extends NativeType {}
|
||||
|
||||
abstract class Opaque extends NativeType {}
|
||||
|
||||
class Void extends NativeType {}
|
||||
|
||||
class Int8 extends NativeType {
|
||||
|
||||
+1318
-14
File diff suppressed because it is too large
Load Diff
@@ -313,6 +313,7 @@ class PubPackageResolutionTest extends ContextResolutionTest {
|
||||
void writeTestPackageConfig(
|
||||
PackageConfigFileBuilder config, {
|
||||
String? languageVersion,
|
||||
bool ffi = false,
|
||||
bool js = false,
|
||||
bool meta = false,
|
||||
}) {
|
||||
@@ -324,6 +325,14 @@ class PubPackageResolutionTest extends ContextResolutionTest {
|
||||
languageVersion: languageVersion ?? testPackageLanguageVersion,
|
||||
);
|
||||
|
||||
if (ffi) {
|
||||
var ffiPath = '/packages/ffi';
|
||||
MockPackages.addFfiPackageFiles(
|
||||
getFolder(ffiPath),
|
||||
);
|
||||
config.add(name: 'ffi', rootPath: ffiPath);
|
||||
}
|
||||
|
||||
if (js) {
|
||||
var jsPath = '/packages/js';
|
||||
MockPackages.addJsPackageFiles(
|
||||
|
||||
@@ -451,6 +451,6 @@ class _SnippetTest extends PubPackageResolutionTest {
|
||||
);
|
||||
}
|
||||
}
|
||||
writeTestPackageConfig(packageConfigBuilder, meta: true);
|
||||
writeTestPackageConfig(packageConfigBuilder, ffi: true, meta: true);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user