Comments (7)
second hint (because check detection logic might be a bit complex): check detection calls check.configureProperty
which uses Reflect.setField
on checks under detection to run them with different settings.
The same configureProperty
is used after reading a checkstyle configuration file during a "normal" checkstyle run.
from genjvm.
I just checked and this is still a problem.
from genjvm.
I've changed one of the tests like so:
@Test
public function testDetectSeparatorWrap() {
var check = new SeparatorWrapCheck();
var detectedChecks:Array<CheckConfig> = DetectCodingStyle.detectCodingStyle([check], [buildCheckFile(SAMPLE_CODING_STYLE)]);
Assert.areEqual(1, detectedChecks.length);
Assert.areEqual("SeparatorWrap", detectedChecks[0].type);
var props = cast detectedChecks[0].props;
Sys.println(props); // {}
Sys.println(check.option); // eol
Sys.println(props.option); // null
Assert.areEqual(WrapCheckBaseOption.EOL, props.option);
}
So the expected value is on the original instance of SeperatorWrapCheck
, but the props
object is empty.
I've noticed that ConfigUtils.makeCheckConfig
uses Reflect.fields(check)
, which is not guaranteed to work for classes:
This method is only guaranteed to work on anonymous structures. Refer to `Type.getInstanceFields` for a function supporting class instances.
from genjvm.
Yes the tests pass after changing that to for (prop in Type.getInstanceFields(Type.getClass(check))) {
. But then the non-genjvm tests fail with Cannot access field for writing
.
Anyway, genjvm is within the spec here, but to be honest I'm not sure why we can't just make Reflect.fields
call Type.getInstanceFields
if the passed object is a Haxe-class.
from genjvm.
I guess I should have read the docs more carefully instead of going with what worked when writing that function.
getInstanceFields
works but an extra Reflect.isFunction
is needed to skip putting functions into the resulting check configuration.
from genjvm.
fixed in HaxeCheckstyle/haxe-checkstyle#498
note: I rearranged build files a bit, there is now a testJava.hxml
and a testJvm.hxml
from genjvm.
Alright, thanks for the info! I also realized that I would have to add this isFunction
check if I wanted to call getInstanceFields
from Reflect.fields
. That seems pretty heavy, so I prefer to not do it and point to the documentation.
I would only consider this if all targets already worked like that, but I don't think that's the case. You probably just got lucky that it works on the targets you were using.
from genjvm.
Related Issues (20)
- Stack overflow on recursive signatures HOT 6
- StringBuf.add vs. Int HOT 2
- Invalid boxed primitve comparison HOT 8
- Assertion on nested native arrays
- [quest] Haxe unit test compilation HOT 2
- Missing super call on field-init-generated constructor HOT 1
- Last `case` does not need a goto
- API patches (like String methods) HOT 2
- javac synchronized equivalent HOT 4
- Interfaces vs. type parameters HOT 4
- haxe.CallStack HOT 3
- Emojis HOT 1
- [quest] Haxe unit test verification endgame HOT 1
- `@:strict`
- enums again HOT 2
- switch on string HOT 1
- Boolop generation isn't ideal HOT 1
- Method name clashes HOT 2
- Box-variance HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from genjvm.