Skip to content

Commit

Permalink
reduce disturbing user
Browse files Browse the repository at this point in the history
  • Loading branch information
xxxg0001 committed Dec 21, 2016
1 parent 8bcb8b1 commit 2ad8f2f
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 72 deletions.
31 changes: 5 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,8 @@ tbsub:dofunc()
```

# Change Log
Version 0.0.19
Supports multiple lua paths
skip find 'self' type on anonymous function (temporary)

Version 0.0.18
show lua script error to vscode.windows

Version 0.0.17
only parsing script when go to definition or show symbol

Version 0.0.16
fixed bugs
add config for lua version to solve lua4.x parsing

Version 0.0.13
fixed bug:open more than one files sometime goto definition fail
Goto Definition support some variable
search path modify to ?, ?.lua, $luapath/?,$luapath/?.lua, $workspaceroot/?, $workspaceroot/?.lua

Version 0.0.11
fixed bug: can't go to definition by if else body
support custom define include keyword
add search path

Version 0.0.8
support find definition from luapath
Version 0.0.23
reduce disturbing user
change lua error from vscode.windows to output( view->output)
parsing script when frist time go to definition or show symbol
parsing script when save document
36 changes: 36 additions & 0 deletions client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Version 0.0.23
reduce disturbing user
change lua error from vscode.windows to output( view->output)
parsing script when frist time go to definition or show symbol
parsing script when save document

Version 0.0.22
fixed some error
restore find 'self' on anonymous function

Version 0.0.19
Supports multiple lua paths
skip find 'self' on anonymous function (temporary)

Version 0.0.18
show lua script error to vscode.windows

Version 0.0.17
only parsing script when go to definition or show symbol

Version 0.0.16
fixed bugs
add config for lua version to solve lua4.x parsing

Version 0.0.13
fixed bug:open more than one files sometime goto definition fail
Goto Definition support some variable
search path modify to ?, ?.lua, $luapath/?,$luapath/?.lua, $workspaceroot/?, $workspaceroot/?.lua

Version 0.0.11
fixed bug: can't go to definition by if else body
support custom define include keyword
add search path

Version 0.0.8
support find definition from luapath
35 changes: 5 additions & 30 deletions client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,33 +62,8 @@ tbsub:dofunc()
```

# Change Log
Version 0.0.22
fixed some error
restore find 'self' on anonymous function

Version 0.0.19
Supports multiple lua paths
skip find 'self' on anonymous function (temporary)

Version 0.0.18
show lua script error to vscode.windows

Version 0.0.17
only parsing script when go to definition or show symbol

Version 0.0.16
fixed bugs
add config for lua version to solve lua4.x parsing

Version 0.0.13
fixed bug:open more than one files sometime goto definition fail
Goto Definition support some variable
search path modify to ?, ?.lua, $luapath/?,$luapath/?.lua, $workspaceroot/?, $workspaceroot/?.lua

Version 0.0.11
fixed bug: can't go to definition by if else body
support custom define include keyword
add search path

Version 0.0.8
support find definition from luapath
Version 0.0.23
reduce disturbing user
change lua error from vscode.windows to output( view->output)
parsing script when frist time go to definition or show symbol
parsing script when save document
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "support go to defintion and List Document Symbols.",
"author": "[email protected]",
"license": "MIT",
"version": "0.0.22",
"version": "0.0.23",
"publisher": "xxxg0001",
"engines": {
"vscode": "^1.4.0"
Expand Down
45 changes: 30 additions & 15 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
TextDocuments, TextDocument, Diagnostic, DiagnosticSeverity,
InitializeParams, InitializeResult, TextDocumentPositionParams,
CompletionItem, CompletionItemKind,Location,Range,DocumentSymbolParams,SymbolInformation,
DidOpenTextDocumentParams
DidOpenTextDocumentParams,DidSaveTextDocumentParams
} from 'vscode-languageserver';


Expand Down Expand Up @@ -99,6 +99,10 @@ documents.onDidChangeContent((change) => {
if( !luaFile) {
luaFile = new LuaFile(uniuri);
filesParsed[uniuri] = luaFile;
luaFile.ischanged = false
var content = documents.get(change.document.uri).getText();
var tb = parser.parse(content, {comments:false, locations:true, luaversion:LuaVersion});
parse2(uniuri, [], tb, false);
}
luaFile.ischanged = true;

Expand Down Expand Up @@ -212,20 +216,20 @@ function searchluafile(relpath:string, isRequire:boolean = false):string[] {
}
return list;
}
function updatefile(uri:string) {
function updatefile(uri:string, isSaving:boolean) {
var uniuri = uniformPath(uri);
var luaFile = filesParsed[uniuri];
try
{
if( !luaFile) {
if( luaFile == null) {
luaFile = new LuaFile(uniuri);
filesParsed[uniuri] = luaFile;
luaFile.ischanged = false
var content = documents.get(uri).getText();
var tb = parser.parse(content, {comments:false, locations:true, luaversion:LuaVersion});
parse2(uniuri, [], tb, false);
}
else if(luaFile.ischanged == true) {
else if(luaFile.ischanged == true && isSaving == true) {
luaFile.ischanged = false
var content = documents.get(uri).getText();
var tb = parser.parse(content, {comments:false, locations:true, luaversion:LuaVersion});
Expand All @@ -235,10 +239,9 @@ function updatefile(uri:string) {
}
catch(err)
{
connection.window.showErrorMessage(`${err} : ${uri}`);
console.log(`${err} : ${uri}`)
//connection.window.showErrorMessage(`${err} : ${uri}`);
}


}

function findParent(parent:any[]):any {
Expand Down Expand Up @@ -535,7 +538,7 @@ connection.onDidChangeWatchedFiles((change) => {
});

connection.onDocumentSymbol((documentSymbolParams:DocumentSymbolParams): SymbolInformation[] =>{
updatefile(documentSymbolParams.textDocument.uri);
updatefile(documentSymbolParams.textDocument.uri, false);
var symbolslist = [];
var uri = uniformPath(documentSymbolParams.textDocument.uri);
var luaFile:LuaFile = filesParsed[uri];
Expand All @@ -546,7 +549,7 @@ connection.onDocumentSymbol((documentSymbolParams:DocumentSymbolParams): SymbolI

connection.onDefinition((textDocumentPositionParams: TextDocumentPositionParams): Location[] => {

updatefile(textDocumentPositionParams.textDocument.uri);
updatefile(textDocumentPositionParams.textDocument.uri, false);

var list = [];
var line = textDocumentPositionParams.position.line;
Expand Down Expand Up @@ -593,18 +596,30 @@ connection.onDefinition((textDocumentPositionParams: TextDocumentPositionParams)
// return item;
// });

/*
connection.onDidOpenTextDocument((params:DidOpenTextDocumentParams) => {
// A text document got opened in VSCode.
// params.uri uniquely identifies the document. For documents store on disk this is a file URI.
// params.text the initial full content of the document.
connection.onDidSaveTextDocument((params:DidSaveTextDocumentParams) =>{
updatefile(params.textDocument.uri, true);
});

// connection.onDidOpenTextDocument((params:DidOpenTextDocumentParams) => {
// // A text document got opened in VSCode.
// // params.uri uniquely identifies the document. For documents store on disk this is a file URI.
// // params.text the initial full content of the document.

// });

/*
connection.onDidChangeTextDocument((params) => {
// The content of a text document did change in VSCode.
// params.uri uniquely identifies the document.
// params.contentChanges describe the content changes to the document.
var uniuri = uniformPath(change.document.uri);
var luaFile = filesParsed[uniuri];
if( !luaFile) {
luaFile = new LuaFile(uniuri);
filesParsed[uniuri] = luaFile;
}
luaFile.ischanged = true;
});
connection.onDidCloseTextDocument((params) => {
// A text document got closed in VSCode.
Expand Down

0 comments on commit 2ad8f2f

Please sign in to comment.