@Mat'sMug In my case I'm not rewriting... yet. This is going to go into the validator class which shouldn't do any rewriting. I already have a dependency on the RubberduckParserState there.
I guess my choices are 1) generalize the validator class into validator + rewriter class and take a dependency on the rewriter, or 2) update the RubberduckParserState to enable retrieval of the token streams.
I don't like #2 very much because that breaks the encapsulation; nobody should be using token streams unless we can make it explicitly read-only
#1 isn't that appealing because one reason for having a validator class to begin is to help make it fast to validate since it's used by the CanExecute method so it has to be light and focused.
Does VBA have a way of checking if an object implements multiple specific interfaces? Best I can think of is checking TypeOf Obj Is XXX multiple times.
COM does not have anything that lets you enumerate interfaces; you can only query whether an object implements a given interface but there is nothing official for enumerating it. That's why VBA doesn't make it easy to expose.
Hmm. Not sure I follow, sorry. If we're talking about custom VBA classes, you write Implements A: Implements B
and then you're required to implement them all.
but to guarantee that a class that implements A also implements B is entirely beyond the scope of interfaces because you're talking about implementation details.
So even if you had a interface A that has a member GetMeTheB which returns interface B, it's still up to the class to implement that method correctly
e.g., you have IMammal and ICanine . You then have a class called Dog which implements both. But there's no way of saying that just because a class implements ICanine that it also implements IMammal without doing a TypeOf Obj Is IMammal ?
@IvenBach Well, a cheap way to create a static class that's also a singleton is to use a standard module but encapsulate it as if it was a class (e.g. no public fields).
just realized that you'd be able to very easily use With Dog.AsMammal to access a few mammal methods without having to create a whole new variable. Brilliant!
I'm observing that the CanExecute doesn't always fire when it should.
for a given selection that should be valid, if I place cursor at end, then ctrl + home to select the line, it enables the method. But, if I put it at the start, then ctrl + end... it doesn't get toggled.
I also see that if I drag the selection, it does not fire when I release the mouse button. I think it should.
@this We do not only hide the compilation directives; we also hide whatever branch of an #if#then#else directive is not activated given the precompiled conditions.
@M.Doerner yes but there are other problems, unfortunately. If there's flags defined in the project's Conditional Compilation Argument, those will be always be false, regardless of how it's set
Because AIUI, we don't have a way to read that information.
Furthermore, the selection can become strange.... when we select any part of the directives, it is invalid. If we select only inside the active block, it is valid. But if we select inside the inactive block, it is invalid (even if the code is valid) because to the parser, I've just selected a lot of whitespace.
For the selection to work more intelligently than that, I'd need the parser to be aware of the compilation directives, I think.
I don't like that it's still "valid" inside the active block because extracting out of it would basically break the logic of the #If...#else block
well, no. It wouldn't. It'd be replaced with a call site
hmm now that I realize that, it becomes easier to fix the #else (or #if if it's the one active)
extract from the active block
then update the inactive block to use similar call statement. (manually)
so that's not too bad.
As a favor to the users, I suppose I can even add a warning to the user if the procedure or the module contains any directives that the process will operate on the active blocks and other inactive blocks must be manually updated.
I see. I was thinking that after I have the logic of actually extracting them, in the 2nd iteration, I'd make the default more smarter by analyzing the references
the way it is now, you must click on grid to see the dropdown
which I really don't like. it hsould be always visible, else I'd never know it was meant to be editable.
@all - RE: default for the first iteration --- I'd love to hear others' opinion -- should ByRef Parameter be the default rather than Private Local Variable? ( keep in mind 2nd iteration will make it a bit more smarter )
> This update includes some refactoring, and improved UI logic, notably warning about compilation directives. Also fix the repainting bug when moving the form and enabling resizing of the form.
drats should have thought to look somewhere else to implement that.
agreed about the placement - that was before me knowing RD has a warning style somewhere and I was following the only thing I had, the red X for the validation
@Mat'sMug what's your opinion on default? Vogel thinks it should default to ByRef Parameter - it's currently set to default to Private Local Variable. (in either cases they can be changed)
Yeah and that requires additional parsing. I guess the question is more -- which is more likely... an extracted variable will be a parameter or simply moved over?
I assumed more common would be to moving variables than parameters but Vogel thinks otherwise.
only want to have a default that doesn't require them to change every time until I get the 2nd iteration.
Minor UI cleanup, enabling resizing of the form Remove literals here and there into the resource file for internationalization Correct a bug with the (None) selection
Rename of some classes for clear self-documentation Refactoring various things and remove unused things Handle the case of the compilation directives or constants in the selection
@Vogel612 just to check I understood your comments about null-object pattern... that means I need to modify the ReturnParameter member so that its getter will return a None object, rather than null?
RetailCoder.VBE Merge pull request #3579 from Vogel612/german-i18n a day ago
Retailcoder.VBE/UI Make CodeMetrics Headings refer to the i18n Resx 8 days ago
Well, i know that OASIS-SVN can trap for Ctrl+S in VBE, and I think the default Save button can be replaced with our custom Save button, so we can handle that and re-read.