Completion doesn't work for local variables #68

Closed
Manindra29 opened this Issue Jun 4, 2014 · 3 comments

Comments

Projects
None yet
1 participant
@Manindra29
Member

Manindra29 commented Jun 4, 2014

void setup(){
    String test = "asd";
    test.
}

Completion doesn't appear after typing test.

When I changed the way in which CompilationUnit(CU) is created in the 1.0.3b release, this regression bug was introduced.

Earlier, a CU was created only if there were no syntax errors. Hence we could get completions even inside block containing dirty code.

Now, the CU is created and then overwritten - in two stages - once during syntax check, and again during compilation check stage. In case of a syntax error in the current block of code, AST isn't created for the contents of the block, hence no info on test in the above example code. This change was done to account for some preprocessing related offset changes that get introduced during the second preprocessing step just before compile check.

This is a delicate and major bug.

@Manindra29 Manindra29 added the bug label Jun 4, 2014

@Manindra29 Manindra29 changed the title from Completion doesn't work for local variable to Completion doesn't work for local variables Jun 4, 2014

@Manindra29 Manindra29 added the critical label Jun 4, 2014

@Manindra29

This comment has been minimized.

Show comment
Hide comment
@Manindra29

Manindra29 Jun 5, 2014

Member

Made a possible fix by maintaining two CUs - one CU which is created when no syntax errors are present(can represent older code when current code has syntax errors); The other CU which always represents the latest code in the editor.

Member

Manindra29 commented Jun 5, 2014

Made a possible fix by maintaining two CUs - one CU which is created when no syntax errors are present(can represent older code when current code has syntax errors); The other CU which always represents the latest code in the editor.

@Manindra29

This comment has been minimized.

Show comment
Hide comment
@Manindra29

Manindra29 Jun 5, 2014

Member

One problem I've found with the current solution is that scroll to definition doesn't work inside the current block of code, which is being edited. For ex:

void setup() {
    String test;
    size(640,360);
    flock = new Flock();
    // Add an initial set of boids into the system
    for (int i = 0; i < 200; i++) {
      Boid b = new Boid(width/2,height/2);
      flock.addBoid(b);
    }
    smooth();
    test = <cursor here>
}    

Ctrl + Click doesn't work for any identifiers inside setup() - flock, Boid, etc. as long as code contains syntax errors. It works outside the setup() block.
@shiffman, your thoughts on this? Is the solution good enough or should I try to make scroll to declaration work completely? It could be a difficult task.

Member

Manindra29 commented Jun 5, 2014

One problem I've found with the current solution is that scroll to definition doesn't work inside the current block of code, which is being edited. For ex:

void setup() {
    String test;
    size(640,360);
    flock = new Flock();
    // Add an initial set of boids into the system
    for (int i = 0; i < 200; i++) {
      Boid b = new Boid(width/2,height/2);
      flock.addBoid(b);
    }
    smooth();
    test = <cursor here>
}    

Ctrl + Click doesn't work for any identifiers inside setup() - flock, Boid, etc. as long as code contains syntax errors. It works outside the setup() block.
@shiffman, your thoughts on this? Is the solution good enough or should I try to make scroll to declaration work completely? It could be a difficult task.

Manindra29 added a commit that referenced this issue Jun 5, 2014

@Manindra29

This comment has been minimized.

Show comment
Hide comment
@Manindra29

Manindra29 Jun 10, 2014

Member

Fixed for next release.

Member

Manindra29 commented Jun 10, 2014

Fixed for next release.

@Manindra29 Manindra29 closed this Jun 10, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment