# Display directive

**URL:** <https://community.haxe.org/t/display-directive/2295>\
**Category:** Haxe\
**Created:** [March 5, 2020, 1:45pm UTC](https://community.haxe.org/t/display-directive/2295 "2020-03-05T13:45:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [March 5, 2020, 1:45pm UTC](https://community.haxe.org/t/display-directive/2295/1 "2020-03-05T13:45:23Z")

</div>

Hej all !

I used to have statements like `#if display` in my code and it seems it doesn’t work anymore, like it doesn’t enter this statement on display mode. Did something changed about that please ?

Note : I’m on last nightly builds…

---

<div class="post-metadata">

**Author:** ![Gama11](https://community.haxe.org/user_avatar/community.haxe.org/gama11/32/7_2.png) [@Gama11](https://community.haxe.org/u/Gama11)\
**Post date:** [March 5, 2020, 1:52pm UTC](https://community.haxe.org/t/display-directive/2295/2 "2020-03-05T13:52:57Z")

</div>

There are two cases where `display` is expected not to be defined right now:

- [diagnostics](https://github.com/vshaxe/vshaxe/wiki/Diagnostics)
- the [completion cache](https://github.com/vshaxe/vshaxe/wiki/Completion-Cache) build (which is just a regular compilation, but with `--no-output`)

Both of these can be disabled with a setting - if you still have issues after that, there might be a bug.

---

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [March 5, 2020, 1:56pm UTC](https://community.haxe.org/t/display-directive/2295/3 "2020-03-05T13:56:16Z")

</div>

Thanks for your reply !

I didn’t know about this behaviour in completion cache, it comes from that I think.

Thanks again 🙂

---

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [March 5, 2020, 1:59pm UTC](https://community.haxe.org/t/display-directive/2295/4 "2020-03-05T13:59:01Z")

</div>

It’s maybe a stupid question but couldn’t we have `display` using completion cache ? Or maybe just add `-D display` to the regular compilation with `--no-output` ? Or maybe we can define it by ourselves somewhere ?

---

<div class="post-metadata">

**Author:** ![Gama11](https://community.haxe.org/user_avatar/community.haxe.org/gama11/32/7_2.png) [@Gama11](https://community.haxe.org/u/Gama11)\
**Post date:** [March 5, 2020, 2:03pm UTC](https://community.haxe.org/t/display-directive/2295/5 "2020-03-05T14:03:58Z")

</div>

No, that would cause problems. You can however check for `--no-output` like this:

> <https://github.com/vshaxe/haxe-test-adapter/blob/1d9d6330ecf1847b3caad70e5b136770251a70c6/test-adapter/_testadapter/Macro.hx#L62>

---

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [March 5, 2020, 2:08pm UTC](https://community.haxe.org/t/display-directive/2295/6 "2020-03-05T14:08:30Z")

</div>

Ok, so if I understand well, I have to write a macro which checks if there is `--no-output` and then define `display` by myself right ?  
BTW, do you know how disable completion cache in VSCode ? Because I tried to disable it and it still doesn’t work 😕

---

<div class="post-metadata">

**Author:** ![Gama11](https://community.haxe.org/user_avatar/community.haxe.org/gama11/32/7_2.png) [@Gama11](https://community.haxe.org/u/Gama11)\
**Post date:** [March 5, 2020, 2:10pm UTC](https://community.haxe.org/t/display-directive/2295/7 "2020-03-05T14:10:09Z")

</div>

Well, I was sort of assuming you already _have_ a macro, because that’s usually where you want to check for this… 🙂 Where else do you need `#if display`?

---

<div class="post-metadata">

**Author:** ![Gama11](https://community.haxe.org/user_avatar/community.haxe.org/gama11/32/7_2.png) [@Gama11](https://community.haxe.org/u/Gama11)\
**Post date:** [March 5, 2020, 2:10pm UTC](https://community.haxe.org/t/display-directive/2295/8 "2020-03-05T14:10:47Z")

</div>

And no, you definitely don’t want to define `display` yourself, that will almost certainly cause compiler errors.

---

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [March 5, 2020, 2:13pm UTC](https://community.haxe.org/t/display-directive/2295/9 "2020-03-05T14:13:12Z")

</div>

I have a `#if display` in order to add or not `@:forward` on my abstract…  
So the only solution is to disable completion cache right ? If so, can you show me where can I disable it becasue I’ve tried and it seems not working 😕

---

<div class="post-metadata">

**Author:** ![Gama11](https://community.haxe.org/user_avatar/community.haxe.org/gama11/32/7_2.png) [@Gama11](https://community.haxe.org/u/Gama11)\
**Post date:** [March 5, 2020, 2:14pm UTC](https://community.haxe.org/t/display-directive/2295/10 "2020-03-05T14:14:32Z")

</div>

> [@filt3rek](#):
>
> I have a `#if display` in order to add or not `@:forward` on my abstract

Huh, but why? 🙂

The setting documented in the wiki should work fine. Maybe it’s not the completion cache build after all that’s the problem here.

---

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [March 5, 2020, 2:19pm UTC](https://community.haxe.org/t/display-directive/2295/11 "2020-03-05T14:19:30Z")

</div>

Just to ease compiler because I don’t need `@:forward` on my abstract for completion…  
I don’t know if it’s cache completion or not that why I ask if something changed about `display` because my whole thing worked fine before and know it just doesn’t enter the if statement and it doesn’t work anymore.  
When I remove this check `#if display` all works fine but I just want it to have the same behaviour as before even if I can let the `@:forward` during completion… It shouldn’t be a problem…

---

<div class="post-metadata">

**Author:** ![Gama11](https://community.haxe.org/user_avatar/community.haxe.org/gama11/32/7_2.png) [@Gama11](https://community.haxe.org/u/Gama11)\
**Post date:** [March 5, 2020, 2:20pm UTC](https://community.haxe.org/t/display-directive/2295/12 "2020-03-05T14:20:23Z")

</div>

Well, as I said earlier:

> [@Gama11](#):
>
> Both of these can be disabled with a setting - if you still have issues after that, there might be a bug.

---

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [March 5, 2020, 2:23pm UTC](https://community.haxe.org/t/display-directive/2295/13 "2020-03-05T14:23:10Z")

</div>

Ok, I’ll dig around that…  
And for the future will it be the default behaviour for cache completion ? (no having `display`defined ?)  
That’s pitty no being able to use this compiler directive using cache completion 😕

---

<div class="post-metadata">

**Author:** ![Gama11](https://community.haxe.org/user_avatar/community.haxe.org/gama11/32/7_2.png) [@Gama11](https://community.haxe.org/u/Gama11)\
**Post date:** [March 5, 2020, 2:27pm UTC](https://community.haxe.org/t/display-directive/2295/14 "2020-03-05T14:27:57Z")

</div>

I think you misunderstood. The completion cache build has never had `display` defined, nor should it matter for this use case. Having a completion cache does not mean you can’t use `#if display` during actual display requests.

---

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [March 5, 2020, 2:33pm UTC](https://community.haxe.org/t/display-directive/2295/15 "2020-03-05T14:33:37Z")

</div>

Maybe I misunderstand yes.

Let me try to explain : I have a TextsBuilder a kind of `haxe.XmlProxy` that builds static class fields from the ids from the xml that contains my strings in order to have them during completion.  
All worked fine before, and since I don’t know when, I haven’t modified anything and now it does’nt work anymore just because of the `#if display` somewhere. If I remove this `#if display`, all works fine with or without cache completion. If I let it, both with or without cache completion, it doesn’t display my fields.

---

<div class="post-metadata">

**Author:** ![Gama11](https://community.haxe.org/user_avatar/community.haxe.org/gama11/32/7_2.png) [@Gama11](https://community.haxe.org/u/Gama11)\
**Post date:** [March 5, 2020, 2:47pm UTC](https://community.haxe.org/t/display-directive/2295/16 "2020-03-05T14:47:04Z")

</div>

It sounds like you might want to isolate this to a MCVE and probably report it as a Haxe issue.

---

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [March 5, 2020, 2:47pm UTC](https://community.haxe.org/t/display-directive/2295/17 "2020-03-05T14:47:51Z")

</div>

Here you can see why I need to play with `@:forward`, in order to not have these fields on runtime because it won’t be resolved by `DotAccess` : [package ftk;import haxe.macro.Context;import haxe.macro.Expr;/\*\* \* . - Pastebin.com](https://pastebin.com/irEh0M2P)

---

<div class="post-metadata">

**Author:** ![Gama11](https://community.haxe.org/user_avatar/community.haxe.org/gama11/32/7_2.png) [@Gama11](https://community.haxe.org/u/Gama11)\
**Post date:** [March 5, 2020, 2:53pm UTC](https://community.haxe.org/t/display-directive/2295/18 "2020-03-05T14:53:19Z")

</div>

That doesn’t exactly look like a MCVE to me (seems to depend on some external file XML).

---

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [March 5, 2020, 5:33pm UTC](https://community.haxe.org/t/display-directive/2295/19 "2020-03-05T17:33:43Z")

</div>

I’ve seen your answer after posting. I’ll write a “MCVE”… 👌

---

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [March 5, 2020, 9:17pm UTC](https://community.haxe.org/t/display-directive/2295/20 "2020-03-05T21:17:07Z")

</div>

Here is the minimaliest example I could do :

```haxe
class Main{
	static function main(){
		Texts.list
	}
}

/*class Texts {
    public static var list : DotAccess;
}
 
//#if display
@:forward
//#end
abstract DotAccess(MyList) from MyList to MyList {}
 
class MyList{
	public var foo : String;
}*/

```

With build : `haxe -main Main -js jean-claude-van-damme.js`

Strange thing is that it works if the code is inside the same file (here when you remove comments) but when you put the fragment that is commented into a separate file Texts.hx, it doesn’t work anymore.  
When I write “work”, I mean on “completion-time”, when you put the dot after `Texts.list` in static main, it gives `foo` in completion without `#if display` but it doesn’t when there is this statement.

I hope it can help.

[Next page](https://community.haxe.org/t/display-directive/2295.md?page=2)
