Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CCE in CompilationUnitImpl #840

Closed
stevemessick opened this issue Dec 14, 2011 · 9 comments
Closed

CCE in CompilationUnitImpl #840

stevemessick opened this issue Dec 14, 2011 · 9 comments
Assignees

Comments

@stevemessick
Copy link
Contributor

Converting JS code to Dart is uncovering new bugs. Here's a stack traces. Source is below.

java.lang.ClassCastException: com.google.dart.compiler.ast.DartPropertyAccess cannot be cast to com.google.dart.compiler.ast.DartIdentifier
    at com.google.dart.tools.core.internal.model.CompilationUnitImpl$CompilationUnitStructureBuilder.visitMethodDefinition(CompilationUnitImpl.java:290)
    at com.google.dart.tools.core.internal.model.CompilationUnitImpl$CompilationUnitStructureBuilder.visitMethodDefinition(CompilationUnitImpl.java:1)
    at com.google.dart.compiler.ast.DartMethodDefinition.accept(DartMethodDefinition.java:90)
    at com.google.dart.compiler.ast.DartNodeTraverser.visit(DartNodeTraverser.java:413)
    at com.google.dart.compiler.ast.DartUnit.visitChildren(DartUnit.java:99)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitNode(DartNodeTraverser.java:54)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitUnit(DartNodeTraverser.java:391)
    at com.google.dart.tools.core.internal.model.CompilationUnitImpl$CompilationUnitStructureBuilder.visitUnit(CompilationUnitImpl.java:324)
    at com.google.dart.tools.core.internal.model.CompilationUnitImpl$CompilationUnitStructureBuilder.visitUnit(CompilationUnitImpl.java:1)
    at com.google.dart.compiler.ast.DartUnit.accept(DartUnit.java:107)
    at com.google.dart.tools.core.internal.model.CompilationUnitImpl.buildStructure(CompilationUnitImpl.java:1519)
    at com.google.dart.tools.core.internal.model.OpenableElementImpl.generateInfos(OpenableElementImpl.java:477)
    at com.google.dart.tools.core.internal.model.DartElementImpl.openWhenClosed(DartElementImpl.java:520)
    at com.google.dart.tools.core.internal.model.CompilationUnitImpl.makeConsistent(CompilationUnitImpl.java:1371)
    at com.google.dart.tools.core.internal.operation.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:95)
    at com.google.dart.tools.core.internal.operation.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:206)
    at com.google.dart.tools.core.internal.operation.DartModelOperation.run(DartModelOperation.java:374)
    at com.google.dart.tools.core.internal.operation.DartModelOperation.runOperation(DartModelOperation.java:441)
    at com.google.dart.tools.core.internal.model.CompilationUnitImpl.reconcile(CompilationUnitImpl.java:1426)
    at com.google.dart.tools.ui.internal.text.dart.DartReconcilingStrategy$1.run(DartReconcilingStrategy.java:159)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at com.google.dart.tools.ui.internal.text.dart.DartReconcilingStrategy.reconcile(DartReconcilingStrategy.java:134)
    at com.google.dart.tools.ui.internal.text.dart.DartReconcilingStrategy.reconcile(DartReconcilingStrategy.java:102)
    at com.google.dart.tools.ui.internal.text.functions.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:93)
    at com.google.dart.tools.ui.internal.text.functions.DartCompositeReconcilingStrategy.reconcile(DartCompositeReconcilingStrategy.java:120)
    at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77)
    at com.google.dart.tools.ui.internal.text.functions.DartReconciler.process(DartReconciler.java:387)
    at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)

import('dart:html');

// Content section used alot

main() {

  var content = document.query('content');

  if (!window.FileReader) {

    content.innerHTML = "<p>This browser doesnt support the File API</p>";

  } else {

  // Page Layout

  content.innerHTML =

    '<p>Pick a text file or drag one into this area <br> <input type="file" id="file" /></p>' +

    '<p><b>Name:</b> <span id="name"></span><br>' +

    '<b>File Size:</b> <span id="size"></span><br>' +

    '<b>Content:</b> <br><br> <pre id="file-content"></pre>' +

    '</p>';

  }

}

// Prints out file properties.

displayFile(file) {

  document.query('name').textContent = file.fileName;

  document.query('size').textContent = file.fileSize;

  document.

    document.getElementById('name').textContent = file.fileName;

    document.getElementById('size').textContent = file.fileSize;

    document.getElementById('file-content').style.border = "1px solid black";

    var reader = new FileReader();

    reader.onload = function(event) {

      document.getElementById('file-content').textContent =

        event.target.result;

    };

    reader.onerror = function() {

      document.getElementById('file-content').innerHTML = 'Unable to read ' + file.fileName;

    };

    reader.readAsText(file);

  }

  // Input handler

  document.getElementById('file').onchange = function() {

    displayFile(this.files[0]);

  };

  // Add invisible border to drop area

  content.style.border = '4px solid transparent';

  // Add dragging events

  content.ondragenter = function() {

    content.style.border = '4px solid #b1ecb3';

    return false;

  };

  content.ondragover = function() {

    return false;

  };

  content.ondragleave = function() {

    return false;

  };

  content.ondrop = function(event) {

    content.style.border = '4px solid transparent';

    displayFile(event.dataTransfer.files[0]);

    return false;

  };

}

@stevemessick
Copy link
Contributor Author

Set owner to @bwilkerson.

@bwilkerson
Copy link
Member

Removed the owner.
Removed Area-Editor label.
Added Area-Compiler label.

@DartBot
Copy link

DartBot commented Dec 14, 2011

This comment was originally written by [email protected]


Set owner to @jtmcdole.

@DartBot
Copy link

DartBot commented Dec 14, 2011

This comment was originally written by [email protected]


Added Duplicate label.
Marked as being merged into #839.

@bwilkerson
Copy link
Member

I also thought this was a duplicate, but it isn't, it's on the editor side.


Set owner to @bwilkerson.
Removed Area-Compiler label.
Added Area-Editor, Started labels.
Marked as being merged into #.

@bwilkerson
Copy link
Member

http://codereview.chromium.org/8914015/


Added Fixed label.

@jtmcdole
Copy link
Contributor

I'm wondering if the parser should have produced a different AST structure as well. According to this print out, things go off in the bushes fast:

...
    DartMethodDefinition (document.getElementById)
        DartFunction
            DartParameter (file)
            DartBlock
                DartExprStmt
                    DartBinaryExpression (ASSIGN)
                        DartIdentifier (onchange)
                        DartFunctionExpression (function)
                            DartFunction
                                DartBlock
                                    DartExprStmt
                                        DartUnqualifiedInvocation
                                            DartIdentifier (displayFile)
                                            DartArrayAccess
                                                DartPropertyAccess
                                                    DartThisExpression
                                                    DartIdentifier (files)
                                                DartIntegerLiteral (0)
                DartExprStmt
                    DartBinaryExpression (ASSIGN)
                        DartPropertyAccess
                            DartPropertyAccess
                                DartIdentifier (content)
                                DartIdentifier (style)
                            DartIdentifier (border)
                        DartStringLiteral ("4px solid transparent")

...

@bwilkerson
Copy link
Member

It would be ideal if the parser could recognize this as a statement rather than a method declaration (and then issue an error indicating that statements must be contained in methods or functions), but that seems like a fairly large change for this code base when we know it's likely to be replaced.

@jtmcdole
Copy link
Contributor

I'm going to copy your name extraction and put up a CL for DartC; I'll add you to it as well.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants