Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[Dltk-dev] javascript debug hover.

Hi,

i am currently debugging the _javascript_ hover part and there are things that go wrong.
most of them i could fix pretty easy (calculating problems what is really the selection under the mouse and so on)

But 1 is a bit of a problem, i have this in my script:

globals.variable = 10;

when i have that in a watch _expression_ "globals.variable" it is fine. But when i hover over the name.
Then i just get "Object" this is because the debugger engine gets "variable" and not what should be in the current context "globals.variable"

I also already know where it goes wrong: _javascript_SelectionEngine
private void processMember(ReferenceResolverContext buildContext,
            AssitUtils.PositionCalculator calc, final List result,
            String selection)

first searches through the code assist code:

Set resolveGlobals = buildContext.resolveGlobals(selection);

that does return something but then the loop:

while (it.hasNext()){
            IReference r=(IReference) it.next();
            r.addModelElements(result);
        }

doesn't add anything because the:
UncknownReference or/and the TransparanetRef don't have a parent and then a FakeField object will not be added. (it finds 3 of them that are not used after that...)

then it goes into the search engine with this searchrequestor:

    SearchRequestor requestor = new SearchRequestor() {

            public void acceptSearchMatch(SearchMatch match)
                    throws CoreException {
                FieldReferenceMatch mr = (FieldReferenceMatch) match;
                ASTNode nm=mr.getNode();
                if (nm instanceof VaribleDeclarationReference){
                    VaribleDeclarationReference vm=(VaribleDeclarationReference) nm;
                    IReference reference = vm.getReference();
                    if (reference!=null){
                        reference.addModelElements(result);
                    }
                }
               
               
            }

        };
That does find a VaribleDeclarationReference  (typo i guess) and that one does have a TransparentRef so a FakeField will be added
The problem is that VaribleDeclarationReference   has exactly the right full name, But its reference doesn't that only holds the last part..

So then i come back in the _javascript_DebugHover:

for (int i = 0; i < resolve.length; i++) {
                IModelElement scriptElement = resolve[i];
                if (scriptElement instanceof IField) {
                    IField field = (IField) scriptElement;
                    String snippet = field.getElementName();
                    try {
                        IDbgpProperty property = propCmds.getProperty(snippet);
                        return getResultText(snippet, ScriptValue.createValue(
                                frame, property));

that gets the element name of the field which is the last part. And that will be send to the engine.
that of course wont be right evaluated because it doesn't understand only that part.

Also if i look at PropertyGetCommand:

int shName = longName.indexOf('.');
        if (shName == -1)
            shName = longName.length();
        String shortName = longName.substring(0, shName);

it has the notion of a long an short name
So that side seems to support it just fine. (don't know why it makes a shortName to send that also back but it does)

so 2 questions, first why is the code assist part done but then completely discarded (at least in this situation)
where can i change it that i can send the VariableDeclarationReference name instead of the simple name?
What do you think would be best?

Because in the end i only want to know 1 thing right?
Is the current selection under the mouse a Variable or not, and if that is the case then use the complete selection to evaluate it.

johan




Back to the top