@Override
        public void onLocationLinkClick(String url, int lineNumber) {
          SourceMapping sourceMapping = debuggerState.getSourceMapping();
          if (sourceMapping == null) {
            // Ignore. Maybe the debugger has just been shutdown.
            return;
          }

          PathUtil path = sourceMapping.getLocalSourcePath(url);
          if (path != null) {
            maybeNavigateToDocument(path, lineNumber);
          }
        }
 public int getSource(int target) {
   if (target == this.target) {
     return this.source;
   } else {
     return parent.getSource(target);
   }
 }
Example #3
0
  protected void check(
      Map<String, String> originalInputs,
      String generatedSource,
      String sourceMapFileContent,
      SourceMapSupplier supplier) {
    // Find all instances of the __XXX__ pattern in the original
    // source code.
    Map<String, Token> originalTokens = findTokens(originalInputs);

    // Find all instances of the __XXX__ pattern in the generated
    // source code.
    Map<String, Token> resultTokens = findTokens(generatedSource);

    // Ensure that the generated instances match via the source map
    // to the original source code.

    // Ensure the token counts match.
    assertEquals(originalTokens.size(), resultTokens.size());

    SourceMapping reader;
    try {
      reader = SourceMapConsumerFactory.parse(sourceMapFileContent, supplier);
    } catch (SourceMapParseException e) {
      throw new RuntimeException("unexpected exception", e);
    }

    // Map the tokens from the generated source back to the
    // input source and ensure that the map is correct.
    for (Token token : resultTokens.values()) {
      OriginalMapping mapping =
          reader.getMappingForLine(token.position.getLine() + 1, token.position.getColumn() + 1);

      assertNotNull(mapping);

      // Find the associated token in the input source.
      Token inputToken = originalTokens.get(token.tokenName);
      assertNotNull(inputToken);
      assertEquals(mapping.getOriginalFile(), inputToken.inputName);

      // Ensure that the map correctly points to the token (we add 1
      // to normalize versus the Rhino line number indexing scheme).
      assertEquals(mapping.getLineNumber(), inputToken.position.getLine() + 1);

      int start = inputToken.position.getColumn() + 1;
      if (inputToken.tokenName.startsWith("STR")) {
        // include the preceding quote.
        start--;
      }

      if (validateColumns) {
        assertEquals(start, mapping.getColumnPosition());
      }

      // Ensure that if the token name does not being with an 'STR' (meaning a
      // string) it has an original name.
      if (!inputToken.tokenName.startsWith("STR")) {
        assertTrue("missing name for " + inputToken.tokenName, !mapping.getIdentifier().isEmpty());
      }

      // Ensure that if the mapping has a name, it matches the token.
      if (!mapping.getIdentifier().isEmpty()) {
        assertEquals(mapping.getIdentifier(), "__" + inputToken.tokenName + "__");
      }
    }
  }
 /** @see #runApplication(String) */
 public boolean runApplication(PathUtil applicationPath) {
   String baseUri = ResourceUriUtils.getAbsoluteResourceBaseUri();
   SourceMapping sourceMapping = StaticSourceMapping.create(baseUri);
   return runApplication(sourceMapping, sourceMapping.getRemoteSourceUri(applicationPath));
 }
 public boolean isIdentity() {
   // FIXME: It's possible that parent was not the identity but that
   // this overriding fixed it.
   return (source == target) && parent.isIdentity();
 }
 public MappingType getMappingType() {
   // FIXME: Mapping type might be weaker than parent.
   return parent.getMappingType();
 }
 public Mapping inverse() {
   return new OverridingTargetMapping((TargetMapping) parent.inverse(), target, source);
 }
 public int size() {
   return parent.getSourceOpt(target) >= 0 ? parent.size() : parent.size() + 1;
 }