mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
detailed information for the type errors from PGFService
This commit is contained in:
@@ -128,7 +128,9 @@ doTranslate pgf input mcat mfrom mto =
|
||||
)]
|
||||
| tree <- trees])]
|
||||
jsonParseOutput (PGF.ParseFailed _) = []
|
||||
jsonParseOutput (PGF.TypeError errs) = [("typeErrors",showJSON [show (PGF.ppTcError err) | (fid,err) <- errs])]
|
||||
jsonParseOutput (PGF.TypeError errs) = [("typeErrors",showJSON [toJSObject [("fid", showJSON fid)
|
||||
,("msg", showJSON (show (PGF.ppTcError err)))
|
||||
] | (fid,err) <- errs])]
|
||||
|
||||
-- used in phrasebook
|
||||
doTranslateGroup :: PGF -> String -> Maybe PGF.Type -> Maybe PGF.Language -> Maybe PGF.Language -> JSValue
|
||||
@@ -198,7 +200,9 @@ doParse pgf input mcat mfrom = showJSON $ map toJSObject
|
||||
where
|
||||
jsonParseOutput (PGF.ParseOk trees) = [("trees",showJSON trees)]
|
||||
jsonParseOutput (PGF.ParseFailed _) = []
|
||||
jsonParseOutput (PGF.TypeError errs) = [("typeErrors",showJSON [show (PGF.ppTcError err) | (fid,err) <- errs])]
|
||||
jsonParseOutput (PGF.TypeError errs) = [("typeErrors",showJSON [toJSObject [("fid", showJSON fid)
|
||||
,("msg", showJSON (show (PGF.ppTcError err)))
|
||||
] | (fid,err) <- errs])]
|
||||
|
||||
doComplete :: PGF -> String -> Maybe PGF.Type -> Maybe PGF.Language -> Maybe Int -> JSValue
|
||||
doComplete pgf input mcat mfrom mlimit = showJSON $ map toJSObject $ limit
|
||||
@@ -328,7 +332,13 @@ instance JSON PGF.Expr where
|
||||
|
||||
instance JSON PGF.BracketedString where
|
||||
readJSON x = return (PGF.Leaf "")
|
||||
showJSON x = showJSON ""
|
||||
showJSON (PGF.Bracket cat fid index _ bs)
|
||||
= showJSON $ toJSObject [("cat", showJSON cat)
|
||||
,("fid", showJSON fid)
|
||||
,("index", showJSON index)
|
||||
,("children", showJSON bs)
|
||||
]
|
||||
showJSON (PGF.Leaf s) = showJSON $ toJSObject [("token", s)]
|
||||
|
||||
-- * PGF utilities
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
APPDIR=`dirname $0`;
|
||||
GWT_DIR="/home/angelov/gwt-2.0.4"
|
||||
GWT_CLASSPATH="$GWT_DIR/gwt-user.jar:$GWT_DIR/gwt-dev.jar"
|
||||
|
||||
if [ -z "$GWT_CLASSPATH" ]; then
|
||||
echo 'ERROR: $GWT_CLASSPATH is not set'
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
APPDIR=`dirname $0`;
|
||||
|
||||
GWT_DIR="/home/angelov/gwt-2.0.4"
|
||||
GWT_CLASSPATH="$GWT_DIR/gwt-user.jar:$GWT_DIR/gwt-dev.jar"
|
||||
|
||||
if [ -z "$GWT_CLASSPATH" ]; then
|
||||
echo 'ERROR: $GWT_CLASSPATH is not set'
|
||||
echo 'Set $GWT_CLASSPATH to point to the GWT JAR files. For example:'
|
||||
|
||||
@@ -54,10 +54,10 @@ public class FridgeApp implements EntryPoint {
|
||||
}
|
||||
|
||||
if (tr.getTypeErrors() != null)
|
||||
for (String error : tr.getTypeErrors()) {
|
||||
for (PGF.TcError error : tr.getTypeErrors()) {
|
||||
SimplePanel panel = new SimplePanel();
|
||||
panel.addStyleName("my-typeError");
|
||||
panel.add(new HTML("<pre>"+error+"</pre>"));
|
||||
panel.add(new HTML("<pre>"+error.getMsg()+"</pre>"));
|
||||
outputPanel.add(panel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,9 +63,9 @@ public class PGF {
|
||||
protected TranslationResult() { }
|
||||
|
||||
public final native String getFrom() /*-{ return this.from; }-*/;
|
||||
public final native String getBracketedString() /*-{ return this.brackets; }-*/;
|
||||
public final native BracketedString getBracketedString() /*-{ return this.brackets; }-*/;
|
||||
public final native IterableJsArray<Translation> getTranslations() /*-{ return this.translations; }-*/;
|
||||
public final native String[] getTypeErrors() /*-{ return this.typeErrors; }-*/;
|
||||
public final native TcError[] getTypeErrors() /*-{ return this.typeErrors; }-*/;
|
||||
}
|
||||
|
||||
public static class Translation extends JavaScriptObject {
|
||||
@@ -137,9 +137,27 @@ public class PGF {
|
||||
protected ParseResult() { }
|
||||
|
||||
public final native String getFrom() /*-{ return this.from; }-*/;
|
||||
public final native String getBracketedString() /*-{ return this.brackets; }-*/;
|
||||
public final native BracketedString getBracketedString() /*-{ return this.brackets; }-*/;
|
||||
public final native String[] getTrees() /*-{ return this.trees; }-*/;
|
||||
public final native String[] getTypeErrors() /*-{ return this.typeErrors; }-*/;
|
||||
public final native TcError[] getTypeErrors() /*-{ return this.typeErrors; }-*/;
|
||||
}
|
||||
|
||||
public static class BracketedString extends JavaScriptObject {
|
||||
protected BracketedString() { }
|
||||
|
||||
public final native String getToken() /*-{ return this.token; }-*/;
|
||||
|
||||
public final native String getCat() /*-{ return this.cat; }-*/;
|
||||
public final native int getFId() /*-{ return this.fid; }-*/;
|
||||
public final native int getIndex() /*-{ return this.index; }-*/;
|
||||
public final native BracketedString[] getChildren() /*-{ return this.children; }-*/;
|
||||
}
|
||||
|
||||
public static class TcError extends JavaScriptObject {
|
||||
protected TcError() { }
|
||||
|
||||
public final native int getFId() /*-{ return this.fid; }-*/;
|
||||
public final native String getMsg() /*-{ return this.msg; }-*/;
|
||||
}
|
||||
|
||||
public String graphvizAbstractTree(String pgfURL, String abstractTree) {
|
||||
|
||||
@@ -66,13 +66,18 @@ public class TranslateApp implements EntryPoint {
|
||||
}
|
||||
}
|
||||
|
||||
if (tr.getTypeErrors() != null)
|
||||
for (String error : tr.getTypeErrors()) {
|
||||
SimplePanel panel = new SimplePanel();
|
||||
if (tr.getTypeErrors() != null && tr.getTypeErrors().length > 0) {
|
||||
for (PGF.TcError error : tr.getTypeErrors()) {
|
||||
VerticalPanel panel = new VerticalPanel();
|
||||
panel.addStyleName("my-typeError");
|
||||
panel.add(new HTML("<pre>"+error+"</pre>"));
|
||||
Label errLabel = new Label("Type Error");
|
||||
errLabel.addStyleName("my-error-title");
|
||||
HTML msgHTML = new HTML("<pre>"+error.getMsg()+"</pre>");
|
||||
panel.add(errLabel);
|
||||
panel.add(msgHTML);
|
||||
outputPanel.add(panel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void onError (Throwable e) {
|
||||
|
||||
@@ -84,6 +84,10 @@
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.my-error-title {
|
||||
background: #DDDDDD;
|
||||
}
|
||||
|
||||
.my-treeimage {
|
||||
width: 650px;
|
||||
height: 520px;
|
||||
|
||||
Reference in New Issue
Block a user