JS: report right end of js() error
This commit is contained in:
@@ -48,6 +48,8 @@
|
|||||||
|
|
||||||
package com.google.gwt.dev.js.rhino;
|
package com.google.gwt.dev.js.rhino;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@@ -325,42 +327,18 @@ public class Context {
|
|||||||
return locale;
|
return locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static void reportWarning(@NotNull String message, @NotNull CodePosition startPosition, @NotNull CodePosition endPosition)
|
||||||
* Report a warning using the error reporter for the current thread.
|
|
||||||
*
|
|
||||||
* @param message the warning message to report
|
|
||||||
* @param sourceName a string describing the source, such as a filename
|
|
||||||
* @param lineno the starting line number
|
|
||||||
* @param lineSource the text of the line (may be null)
|
|
||||||
* @param lineOffset the offset into lineSource where problem was detected
|
|
||||||
*/
|
|
||||||
public static void reportWarning(String message, String sourceName,
|
|
||||||
int lineno, String lineSource,
|
|
||||||
int lineOffset)
|
|
||||||
{
|
{
|
||||||
Context cx = Context.getContext();
|
Context cx = Context.getContext();
|
||||||
cx.getErrorReporter().warning(message, sourceName, lineno,
|
cx.getErrorReporter().warning(message, startPosition, endPosition);
|
||||||
lineSource, lineOffset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static void reportError(@NotNull String message, @NotNull CodePosition startPosition, @NotNull CodePosition endPosition)
|
||||||
* Report an error using the error reporter for the current thread.
|
|
||||||
*
|
|
||||||
* @param message the error message to report
|
|
||||||
* @param sourceName a string describing the source, such as a filename
|
|
||||||
* @param lineno the starting line number
|
|
||||||
* @param lineSource the text of the line (may be null)
|
|
||||||
* @param lineOffset the offset into lineSource where problem was detected
|
|
||||||
*/
|
|
||||||
public static void reportError(String message, String sourceName,
|
|
||||||
int lineno, String lineSource,
|
|
||||||
int lineOffset)
|
|
||||||
{
|
{
|
||||||
Context cx = getCurrentContext();
|
Context cx = getCurrentContext();
|
||||||
if (cx != null) {
|
if (cx != null) {
|
||||||
cx.errorCount++;
|
cx.errorCount++;
|
||||||
cx.getErrorReporter().error(message, sourceName, lineno,
|
cx.getErrorReporter().error(message, startPosition, endPosition);
|
||||||
lineSource, lineOffset);
|
|
||||||
} else {
|
} else {
|
||||||
throw new EvaluatorException(message);
|
throw new EvaluatorException(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,8 @@
|
|||||||
|
|
||||||
package com.google.gwt.dev.js.rhino;
|
package com.google.gwt.dev.js.rhino;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is interface defines a protocol for the reporting of
|
* This is interface defines a protocol for the reporting of
|
||||||
* errors during JavaScript translation or execution.
|
* errors during JavaScript translation or execution.
|
||||||
@@ -51,15 +53,11 @@ public interface ErrorReporter {
|
|||||||
* The implementing class may choose to ignore the warning
|
* The implementing class may choose to ignore the warning
|
||||||
* if it desires.
|
* if it desires.
|
||||||
*
|
*
|
||||||
* @param message a String describing the warning
|
* @param message a String describing the error
|
||||||
* @param sourceName a String describing the JavaScript source
|
* @param startPosition position before error token
|
||||||
* where the warning occured; typically a filename or URL
|
* @param endPosition position after error token
|
||||||
* @param line the line number associated with the warning
|
|
||||||
* @param lineSource the text of the line (may be null)
|
|
||||||
* @param lineOffset the offset into lineSource where problem was detected
|
|
||||||
*/
|
*/
|
||||||
void warning(String message, String sourceName, int line,
|
void warning(@NotNull String message, @NotNull CodePosition startPosition, @NotNull CodePosition endPosition);
|
||||||
String lineSource, int lineOffset);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report an error.
|
* Report an error.
|
||||||
@@ -73,12 +71,8 @@ public interface ErrorReporter {
|
|||||||
* errors, however.
|
* errors, however.
|
||||||
*
|
*
|
||||||
* @param message a String describing the error
|
* @param message a String describing the error
|
||||||
* @param sourceName a String describing the JavaScript source
|
* @param startPosition position before error token
|
||||||
* where the error occured; typically a filename or URL
|
* @param endPosition position after error token
|
||||||
* @param line the line number associated with the error
|
|
||||||
* @param lineSource the text of the line (may be null)
|
|
||||||
* @param lineOffset the offset into lineSource where problem was detected
|
|
||||||
*/
|
*/
|
||||||
void error(String message, String sourceName, int line,
|
void error(@NotNull String message, @NotNull CodePosition startPosition, @NotNull CodePosition endPosition);
|
||||||
String lineSource, int lineOffset);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -407,9 +407,7 @@ public class IRFactory {
|
|||||||
private void reportError(String msgResource) {
|
private void reportError(String msgResource) {
|
||||||
|
|
||||||
String message = Context.getMessage0(msgResource);
|
String message = Context.getMessage0(msgResource);
|
||||||
Context.reportError(
|
ts.reportSyntaxError(message, null);
|
||||||
message, ts.getSourceName(), ts.getLineno(),
|
|
||||||
ts.getLine(), ts.getOffset());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only needed to get file/line information. Could create an interface
|
// Only needed to get file/line information. Could create an interface
|
||||||
|
|||||||
@@ -1419,7 +1419,7 @@ public class TokenStream {
|
|||||||
*/
|
*/
|
||||||
public void reportSyntaxError(String messageProperty, Object[] args) {
|
public void reportSyntaxError(String messageProperty, Object[] args) {
|
||||||
String message = Context.getMessage(messageProperty, args);
|
String message = Context.getMessage(messageProperty, args);
|
||||||
Context.reportError(message, getSourceName(), secondToLastPosition.getLine(), getLine(), secondToLastPosition.getOffset());
|
Context.reportError(message, secondToLastPosition, lastPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1429,12 +1429,12 @@ public class TokenStream {
|
|||||||
*/
|
*/
|
||||||
private void reportTokenError(String messageProperty, Object[] args) {
|
private void reportTokenError(String messageProperty, Object[] args) {
|
||||||
String message = Context.getMessage(messageProperty, args);
|
String message = Context.getMessage(messageProperty, args);
|
||||||
Context.reportError(message, getSourceName(), lastPosition.getLine(), getLine(), lastPosition.getOffset());
|
Context.reportError(message, lastPosition, new CodePosition(getLineno(), getOffset()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reportTokenWarning(String messageProperty, Object[] args) {
|
private void reportTokenWarning(String messageProperty, Object[] args) {
|
||||||
String message = Context.getMessage(messageProperty, args);
|
String message = Context.getMessage(messageProperty, args);
|
||||||
Context.reportWarning(message, getSourceName(), lastPosition.getLine(), getLine(), lastPosition.getOffset());
|
Context.reportWarning(message, lastPosition, new CodePosition(getLineno(), getOffset()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user