with source_gen package, how can I get initializer value?Code Splitting in DartImplement an Observer pattern in DartHow do I create a blank Future in Dart + how do I return a future currently in progress?How to write abstract class constructors so that it will be flexible for extending in sub classesHow to pass values to phaser (Dart port) State.init() function?When to use mixins and when to use interfaces in Dart?Flutter Mixed Layout - Grid with RowsHow to get a String from an AsyncSnapshot<String> in Flutter FutureBuilder?Flutter map_view center to user locationDart(/Flutter): Create function in initializer list
Watching something be written to a file live with tail
Why Is Death Allowed In the Matrix?
How did the USSR manage to innovate in an environment characterized by government censorship and high bureaucracy?
strToHex ( string to it's hex representation as string)
What does it mean to describe someone as a butt steak?
Why do falling prices hurt debtors?
Are the number of citations and number of published articles the most important criteria for a tenure promotion?
What are the differences between the usage of 'it' and 'they'?
What does "Puller Prush Person" mean?
Have astronauts in space suits ever taken selfies? If so, how?
What's the point of deactivating Num Lock on login screens?
Why don't electron-positron collisions release infinite energy?
Is it possible to do 50 km distance without any previous training?
What typically incentivizes a professor to change jobs to a lower ranking university?
Can a Warlock become Neutral Good?
How to format long polynomial?
Has the BBC provided arguments for saying Brexit being cancelled is unlikely?
Minkowski space
Why was the small council so happy for Tyrion to become the Master of Coin?
Why doesn't H₄O²⁺ exist?
How does one intimidate enemies without having the capacity for violence?
How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?
Show that if two triangles built on parallel lines, with equal bases have the same perimeter only if they are congruent.
What are these boxed doors outside store fronts in New York?
with source_gen package, how can I get initializer value?
Code Splitting in DartImplement an Observer pattern in DartHow do I create a blank Future in Dart + how do I return a future currently in progress?How to write abstract class constructors so that it will be flexible for extending in sub classesHow to pass values to phaser (Dart port) State.init() function?When to use mixins and when to use interfaces in Dart?Flutter Mixed Layout - Grid with RowsHow to get a String from an AsyncSnapshot<String> in Flutter FutureBuilder?Flutter map_view center to user locationDart(/Flutter): Create function in initializer list
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I would like to get the initializer in the field corrected_time in code below. I found the field.initializer
, but couldn't get much further. (the @Init annotation is temporary solution for now):
mixin PrerenderDoc on Doc implements AllowDelete
@Init(init_int: 0)
int corrected_time = 0;
dart
add a comment |
I would like to get the initializer in the field corrected_time in code below. I found the field.initializer
, but couldn't get much further. (the @Init annotation is temporary solution for now):
mixin PrerenderDoc on Doc implements AllowDelete
@Init(init_int: 0)
int corrected_time = 0;
dart
Sent email to the right folks working on the analyzer API
– Kevin Moore
Mar 8 at 21:07
add a comment |
I would like to get the initializer in the field corrected_time in code below. I found the field.initializer
, but couldn't get much further. (the @Init annotation is temporary solution for now):
mixin PrerenderDoc on Doc implements AllowDelete
@Init(init_int: 0)
int corrected_time = 0;
dart
I would like to get the initializer in the field corrected_time in code below. I found the field.initializer
, but couldn't get much further. (the @Init annotation is temporary solution for now):
mixin PrerenderDoc on Doc implements AllowDelete
@Init(init_int: 0)
int corrected_time = 0;
dart
dart
asked Mar 8 at 4:02
ChiNhanChiNhan
512
512
Sent email to the right folks working on the analyzer API
– Kevin Moore
Mar 8 at 21:07
add a comment |
Sent email to the right folks working on the analyzer API
– Kevin Moore
Mar 8 at 21:07
Sent email to the right folks working on the analyzer API
– Kevin Moore
Mar 8 at 21:07
Sent email to the right folks working on the analyzer API
– Kevin Moore
Mar 8 at 21:07
add a comment |
1 Answer
1
active
oldest
votes
I'm guessing that field
is an instance of FieldElement
. Unfortunately, if that's the case, then the answer is that analyzer doesn't have a value for the initializer. The analyzer only computes values for (a subset of) expressions that are constant expressions. For field initializers, that means that the field needs to be declared to be const
, and the one in the example isn't.
(Annotations are constants and hence have values, which is why your workaround works.)
If the field were declared const
, then you could use VariableElement.constantValue
to access a representation of the value (VariableElement
is a superclass of FieldElement
).
The other option available to you is to use the AST structure and examine the structure of the expression, but if you want / need to handle anything more than just simple literal values, that can be quite complex.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55056540%2fwith-source-gen-package-how-can-i-get-initializer-value%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I'm guessing that field
is an instance of FieldElement
. Unfortunately, if that's the case, then the answer is that analyzer doesn't have a value for the initializer. The analyzer only computes values for (a subset of) expressions that are constant expressions. For field initializers, that means that the field needs to be declared to be const
, and the one in the example isn't.
(Annotations are constants and hence have values, which is why your workaround works.)
If the field were declared const
, then you could use VariableElement.constantValue
to access a representation of the value (VariableElement
is a superclass of FieldElement
).
The other option available to you is to use the AST structure and examine the structure of the expression, but if you want / need to handle anything more than just simple literal values, that can be quite complex.
add a comment |
I'm guessing that field
is an instance of FieldElement
. Unfortunately, if that's the case, then the answer is that analyzer doesn't have a value for the initializer. The analyzer only computes values for (a subset of) expressions that are constant expressions. For field initializers, that means that the field needs to be declared to be const
, and the one in the example isn't.
(Annotations are constants and hence have values, which is why your workaround works.)
If the field were declared const
, then you could use VariableElement.constantValue
to access a representation of the value (VariableElement
is a superclass of FieldElement
).
The other option available to you is to use the AST structure and examine the structure of the expression, but if you want / need to handle anything more than just simple literal values, that can be quite complex.
add a comment |
I'm guessing that field
is an instance of FieldElement
. Unfortunately, if that's the case, then the answer is that analyzer doesn't have a value for the initializer. The analyzer only computes values for (a subset of) expressions that are constant expressions. For field initializers, that means that the field needs to be declared to be const
, and the one in the example isn't.
(Annotations are constants and hence have values, which is why your workaround works.)
If the field were declared const
, then you could use VariableElement.constantValue
to access a representation of the value (VariableElement
is a superclass of FieldElement
).
The other option available to you is to use the AST structure and examine the structure of the expression, but if you want / need to handle anything more than just simple literal values, that can be quite complex.
I'm guessing that field
is an instance of FieldElement
. Unfortunately, if that's the case, then the answer is that analyzer doesn't have a value for the initializer. The analyzer only computes values for (a subset of) expressions that are constant expressions. For field initializers, that means that the field needs to be declared to be const
, and the one in the example isn't.
(Annotations are constants and hence have values, which is why your workaround works.)
If the field were declared const
, then you could use VariableElement.constantValue
to access a representation of the value (VariableElement
is a superclass of FieldElement
).
The other option available to you is to use the AST structure and examine the structure of the expression, but if you want / need to handle anything more than just simple literal values, that can be quite complex.
answered Mar 9 at 0:54
Brian WilkersonBrian Wilkerson
461
461
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55056540%2fwith-source-gen-package-how-can-i-get-initializer-value%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Sent email to the right folks working on the analyzer API
– Kevin Moore
Mar 8 at 21:07