This commit is contained in:
Liang Ding 2015-11-27 16:55:28 +08:00
parent f3dadc4795
commit ac0cc1ea04
7 changed files with 9 additions and 13 deletions

View File

@ -329,12 +329,11 @@ func FindDeclarationHandler(w http.ResponseWriter, r *http.Request) {
cursorCh, _ := strconv.Atoi(found[strings.LastIndex(found, ":")+1:]) cursorCh, _ := strconv.Atoi(found[strings.LastIndex(found, ":")+1:])
data := map[string]interface{}{} data := map[string]interface{}{}
result.Data = &data
data["path"] = filepath.ToSlash(path) data["path"] = filepath.ToSlash(path)
data["cursorLine"] = cursorLine data["cursorLine"] = cursorLine
data["cursorCh"] = cursorCh data["cursorCh"] = cursorCh
result.Data = data
} }
// FindUsagesHandler handles request of finding usages. // FindUsagesHandler handles request of finding usages.

View File

@ -79,6 +79,8 @@ func GoFmtHandler(w http.ResponseWriter, r *http.Request) {
} }
data := map[string]interface{}{} data := map[string]interface{}{}
result.Data = &data
data["code"] = code data["code"] = code
result.Data = data result.Data = data
@ -100,8 +102,6 @@ func GoFmtHandler(w http.ResponseWriter, r *http.Request) {
code = string(output) code = string(output)
data["code"] = code data["code"] = code
result.Data = data
fout, err = os.Create(filePath) fout, err = os.Create(filePath)
fout.WriteString(code) fout.WriteString(code)
if err := fout.Close(); nil != err { if err := fout.Close(); nil != err {

View File

@ -193,6 +193,7 @@ func GetFileHandler(w http.ResponseWriter, r *http.Request) {
} }
data := map[string]interface{}{} data := map[string]interface{}{}
result.Data = &data
buf, _ := ioutil.ReadFile(path) buf, _ := ioutil.ReadFile(path)
@ -227,8 +228,6 @@ func GetFileHandler(w http.ResponseWriter, r *http.Request) {
data["content"] = content data["content"] = content
data["path"] = path data["path"] = path
} }
result.Data = data
} }
// SaveFileHandler handles request of saving file. // SaveFileHandler handles request of saving file.

View File

@ -57,6 +57,8 @@ func GetOutlineHandler(w http.ResponseWriter, r *http.Request) {
} }
data := map[string]interface{}{} data := map[string]interface{}{}
result.Data = &data
// ast.Print(fset, f) // ast.Print(fset, f)
line, ch := getCursor(code, int(f.Name.Pos())) line, ch := getCursor(code, int(f.Name.Pos()))
@ -129,8 +131,6 @@ func GetOutlineHandler(w http.ResponseWriter, r *http.Request) {
data["structDecls"] = structDecls data["structDecls"] = structDecls
data["interfaceDecls"] = interfaceDecls data["interfaceDecls"] = interfaceDecls
data["typeDecls"] = typeDecls data["typeDecls"] = typeDecls
result.Data = data
} }
// getCursor calculates the cursor position (line, ch) by the specified offset. // getCursor calculates the cursor position (line, ch) by the specified offset.

View File

@ -56,6 +56,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
} }
data := map[string]interface{}{} data := map[string]interface{}{}
result.Data = &data
executable := filepath.Clean(conf.Wide.Playground + "/" + strings.Replace(fileName, ".go", suffix, -1)) executable := filepath.Clean(conf.Wide.Playground + "/" + strings.Replace(fileName, ".go", suffix, -1))
@ -71,6 +72,4 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
} }
data["executable"] = executable data["executable"] = executable
result.Data = data
} }

View File

@ -73,6 +73,7 @@ func SaveHandler(w http.ResponseWriter, r *http.Request) {
} }
data := map[string]interface{}{} data := map[string]interface{}{}
result.Data = &data
data["code"] = code data["code"] = code
@ -93,8 +94,6 @@ func SaveHandler(w http.ResponseWriter, r *http.Request) {
return return
} }
result.Data = data
} }
// ShortURLHandler handles request of short URL. // ShortURLHandler handles request of short URL.

View File

@ -456,7 +456,7 @@ var playground = {
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
success: function (result) { success: function (result) {
// console.log(data); console.log(result);
var data = result.data; var data = result.data;