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

gwt sourcemap: incorrect source line #9038

Open
dankurka opened this issue Jun 10, 2015 · 3 comments
Open

gwt sourcemap: incorrect source line #9038

dankurka opened this issue Jun 10, 2015 · 3 comments
Assignees

Comments

@dankurka
Copy link
Member

Originally reported on Google Code with ID 9103

Found in GWT Release (e.g. 2.4.0, 2.5.1, trunk): 2.7

Detailed description (please be as specific as possible):

code (https://gist.github.com/develar/fa092f4c9ef12325ecba, sample project attached):

public void onClick(ClickEvent event) {
                if (label.getText().equals("")) {
                    MySampleApplicationService.App.getInstance().getMessage("Hello,
World!", new MyAsyncCallback(label));
                } else {
                    label.setText("");
                }

                internalMethod();
            } !!! sourcemap entry is incorrect: source line 24 specified, but must
be 33. !!!

See attached screenshot.

Problem: IDEA cannot correctly map generated method param name to source. In any case
I implemented workaround on IDEA side, but GWT sourcemaps should be correct.


Reported by develar on 2015-01-17 14:34:54


- _Attachment: [sample.zip](https://storage.googleapis.com/google-code-attachments/google-web-toolkit/issue-9103/comment-0/sample.zip)_ - _Attachment: Screen Shot 2015-01-17 at 15.23.26.png
![Screen Shot 2015-01-17 at 15.23.26.png](https://storage.googleapis.com/google-code-attachments/google-web-toolkit/issue-9103/comment-0/Screen Shot 2015-01-17 at 15.23.26.png)_
@dankurka
Copy link
Member Author

And, please note — GWT produces poor sourcemap. TypeScript/CoffeScript/Kotlin/etc sourcemaps
are detailed, AST/PSI-aware (not line by line, but node by node). As result, only GWT
requires some hacks to impement name mappings  (so, support of TypeScript/CoffeScript/Kotlin/etc
is more reliable).

Reported by develar on 2015-01-17 14:42:59

@dankurka dankurka self-assigned this Jun 10, 2015
@dankurka
Copy link
Member Author

I have found a similar issue with sourcemaps at work.  We had an off-by-24 error that
was caused by CrossSiteIframeLinker.getModulePrefix.  That method emits (for us) 24
lines of code which is then added to a ScriptFragmentEditsArtifact, which it seems
is supposed to offset the sourcemaps to account for these extra lines.  However, this
artifact is not considered, and the sourcemaps come out a bit wonky.

My workaround (in a custom subclass of CrossSiteIframeLinker): 

  @Override
  protected String getModulePrefix(TreeLogger logger, LinkerContext context, String
strongName)
      throws UnableToCompleteException {
    String original = super.getModulePrefix(logger, context, strongName);
    // The newlines in the module prefix are not correctly adjusted for in the sourcemaps.
    // Replacing the newlines here allows the sourcemaps to line up correctly
    return original.replaceAll("\n", "");
  }

Reported by James@wetheinter.net on 2015-04-09 17:17:29

@dankurka
Copy link
Member Author

Issue 9046 has been merged into this issue.

Reported by t.broyer on 2015-05-24 22:54:25

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

1 participant