From 02a5f409549a0c69a65a6d2a2019491bd9c1ac01 Mon Sep 17 00:00:00 2001 From: BBasile Date: Tue, 23 Jan 2018 07:42:26 +0100 Subject: [PATCH] fix #426 - Full output mode breaks `__traits` completion (#427) * fix #426 - Full output mode breaks `__traits` completion * Add constant completion for the new isDisabled trait --- appveyor.yml | 24 +++++++++---------- src/dcd/common/constants.d | 23 ++++++++++++++++++ src/dcd/common/messages.d | 2 +- tests/tc_traits/expected.txt | 46 ++++++++++++++++++++++++++++++++++++ tests/tc_traits/file.d | 1 + tests/tc_traits/run.sh | 5 ++++ 6 files changed, 88 insertions(+), 13 deletions(-) create mode 100644 tests/tc_traits/expected.txt create mode 100644 tests/tc_traits/file.d create mode 100755 tests/tc_traits/run.sh diff --git a/appveyor.yml b/appveyor.yml index 8c31ccf..06d554a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -19,18 +19,18 @@ environment: - DC: dmd DVersion: stable arch: x86 - - DC: ldc - DVersion: beta - arch: x86 - - DC: ldc - DVersion: beta - arch: x64 - - DC: ldc - DVersion: stable - arch: x86 - - DC: ldc - DVersion: stable - arch: x64 + # - DC: ldc + # DVersion: beta + # arch: x86 + # - DC: ldc + # DVersion: beta + # arch: x64 + # - DC: ldc + # DVersion: stable + # arch: x86 + # - DC: ldc + # DVersion: stable + # arch: x64 skip_tags: false branches: diff --git a/src/dcd/common/constants.d b/src/dcd/common/constants.d index 989d674..446f164 100644 --- a/src/dcd/common/constants.d +++ b/src/dcd/common/constants.d @@ -768,6 +768,29 @@ false false )`), ConstantCompletion("isAssociativeArray", `Works like $(D isArithmetic), except it's for associative array types.`), + + ConstantCompletion("isDisabled", r"$(P Takes one argument and returns `true` if it's a function declaration + marked with `@disable`.) + +--- +struct Foo +{ + @disable void foo(); + void bar(){} +} + +static assert(__traits(isDisabled, Foo.foo)); +static assert(!__traits(isDisabled, Foo.bar)); +--- + + $(P For any other declaration even if `@disable` is a syntactically valid + attribute `false` is returned because the annotation has no effect.) + +--- +@disable struct Bar{} + +static assert(!__traits(isDisabled, Bar)); +---"), ConstantCompletion("isFinalClass", `Works like $(D isAbstractClass), except it's for final classes.`), ConstantCompletion("isFinalFunction", `$(P Takes one argument. If that argument is a final function, $(D true) is returned, otherwise $(D false). diff --git a/src/dcd/common/messages.d b/src/dcd/common/messages.d index 7341ee3..c5511bf 100644 --- a/src/dcd/common/messages.d +++ b/src/dcd/common/messages.d @@ -241,7 +241,7 @@ bool sendRequest(Socket socket, AutocompleteRequest request) */ AutocompleteResponse getResponse(Socket socket) { - ubyte[1024 * 16] buffer; + ubyte[1024 * 24] buffer; auto bytesReceived = socket.receive(buffer); if (bytesReceived == Socket.ERROR) throw new Exception("Incorrect number of bytes received"); diff --git a/tests/tc_traits/expected.txt b/tests/tc_traits/expected.txt new file mode 100644 index 0000000..e5c14cf --- /dev/null +++ b/tests/tc_traits/expected.txt @@ -0,0 +1,46 @@ +identifiers +allMembers k +classInstanceSize k +compiles k +derivedMembers k +getAliasThis k +getAttributes k +getFunctionAttributes k +getFunctionVariadicStyle k +getLinkage k +getMember k +getOverloads k +getParameterStorageClasses k +getPointerBitmap k +getProtection k +getUnitTests k +getVirtualFunctions k +getVirtualIndex k +getVirtualMethods k +hasMember k +identifier k +isAbstractClass k +isAbstractFunction k +isArithmetic k +isAssociativeArray k +isDisabled k +isFinalClass k +isFinalFunction k +isFloating k +isFuture k +isIntegral k +isLazy k +isNested k +isOut k +isOverrideFunction k +isPOD k +isRef k +isSame k +isScalar k +isStaticArray k +isStaticFunction k +isTemplate k +isUnsigned k +isVirtualFunction k +isVirtualMethod k +parent k diff --git a/tests/tc_traits/file.d b/tests/tc_traits/file.d new file mode 100644 index 0000000..7e80c0e --- /dev/null +++ b/tests/tc_traits/file.d @@ -0,0 +1 @@ +__traits( diff --git a/tests/tc_traits/run.sh b/tests/tc_traits/run.sh new file mode 100755 index 0000000..ce617de --- /dev/null +++ b/tests/tc_traits/run.sh @@ -0,0 +1,5 @@ +set -e +set -u + +../../bin/dcd-client $1 file.d -c 9 > actual.txt +diff actual.txt expected.txt