diff --git a/README.md b/README.md index 2de67e2..e960539 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Download the latest netbeanstypescript.nbm file from the [Releases](https://gith ### Versioning -The version number of this plugin reflects the version of TypeScript it incorporates (currently 2.2.1), with an extra digit for new versions that do not involve a TypeScript update. We intend to keep this plugin up to date with new versions of TypeScript when they come out. +The version number of this plugin reflects the version of TypeScript it incorporates (currently 2.3.2), with an extra digit for new versions that do not involve a TypeScript update. We intend to keep this plugin up to date with new versions of TypeScript when they come out. ### Contributing diff --git a/build.xml b/build.xml index 5d4bf48..d5ce2e1 100644 --- a/build.xml +++ b/build.xml @@ -8,7 +8,7 @@ - + diff --git a/manifest.mf b/manifest.mf index 70a66af..c752f69 100644 --- a/manifest.mf +++ b/manifest.mf @@ -3,4 +3,4 @@ AutoUpdate-Show-In-Client: true OpenIDE-Module: netbeanstypescript OpenIDE-Module-Layer: netbeanstypescript/resources/layer.xml OpenIDE-Module-Localizing-Bundle: netbeanstypescript/Bundle.properties -OpenIDE-Module-Specification-Version: 2.2.1.0 +OpenIDE-Module-Specification-Version: 2.3.2.0 diff --git a/server/main.ts b/server/main.ts index ed9cf75..8a1054c 100644 --- a/server/main.ts +++ b/server/main.ts @@ -650,9 +650,10 @@ class Program { return res; }); } - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]) { + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], + formatOptions: ts.FormatCodeSettings) { if (! this.fileInProject(fileName)) return null; - return this.service.getCodeFixesAtPosition(fileName, start, end, errorCodes); + return this.service.getCodeFixesAtPosition(fileName, start, end, errorCodes, formatOptions); } } diff --git a/server/ts-patches b/server/ts-patches index e384726..5a86b4e 100644 --- a/server/ts-patches +++ b/server/ts-patches @@ -1,6 +1,6 @@ --- compiler/checker.ts +++ compiler/checker.ts -@@ -2249,6 +2249,13 @@ +@@ -2970,6 +2970,13 @@ appendSymbolNameOnly(symbol, writer); } parentSymbol = symbol; @@ -16,7 +16,7 @@ // Let the writer know we just wrote out a symbol. The declaration emitter writer uses --- services/completions.ts +++ services/completions.ts -@@ -111,6 +111,7 @@ +@@ -118,6 +118,7 @@ kind: SymbolDisplay.getSymbolKind(typeChecker, symbol, location), kindModifiers: SymbolDisplay.getSymbolModifiers(symbol), sortText: "0", @@ -36,8 +36,8 @@ + declaration => createDefinitionInfo(declaration, getNodeKind(declaration), shorthandSymbolName, shorthandContainerName)); } - return getDefinitionFromSymbol(typeChecker, symbol, node); -@@ -131,7 +133,9 @@ + if (isJsxOpeningLikeElement(node.parent)) { +@@ -162,7 +164,9 @@ !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { // Just add all the declarations. forEach(declarations, declaration => { @@ -50,11 +50,11 @@ --- services/types.ts +++ services/types.ts -@@ -566,6 +566,7 @@ +@@ -593,6 +593,7 @@ kind: string; // see ScriptElementKind kindModifiers: string; // see ScriptElementKindModifier, comma separated sortText: string; + type?: string; /** - * An optional span that indicates the text to be replaced by this completion item. It will be - * set if the required span differs from the one generated by the default replacement behavior and should + * An optional span that indicates the text to be replaced by this completion item. It will be + * set if the required span differs from the one generated by the default replacement behavior and should diff --git a/server/tsconfig.json b/server/tsconfig.json index aafe698..101ecf9 100644 --- a/server/tsconfig.json +++ b/server/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "noImplicitAny": true, "noImplicitThis": true, - "removeComments": true + "removeComments": true, + "target": "es5" }, "files": ["main.ts"] } diff --git a/src/netbeanstypescript/TSFormatter.java b/src/netbeanstypescript/TSFormatter.java index 9c64007..ff676c6 100644 --- a/src/netbeanstypescript/TSFormatter.java +++ b/src/netbeanstypescript/TSFormatter.java @@ -57,9 +57,7 @@ */ public class TSFormatter implements Formatter { - @Override - public void reformat(Context context, ParserResult pr) { - final BaseDocument doc = (BaseDocument) context.document(); + public static JSONObject getFormattingSettings(BaseDocument doc) { JSONObject settings = new JSONObject(); settings.put("indentSize", IndentUtils.indentLevelSize(doc)); settings.put("tabSize", IndentUtils.tabSize(doc)); @@ -98,9 +96,15 @@ public void reformat(Context context, ParserResult pr) { jsPrefs.get("functionDeclBracePlacement", "").startsWith("NEW")); settings.put("placeOpenBraceOnNewLineForControlBlocks", jsPrefs.get("ifBracePlacement", "").startsWith("NEW")); + return settings; + } + + @Override + public void reformat(Context context, ParserResult pr) { + final BaseDocument doc = (BaseDocument) context.document(); final Object edits = TSService.call("getFormattingEdits", GsfUtilities.findFileObject(doc), context.startOffset(), context.endOffset(), - settings); + getFormattingSettings(doc)); if (edits == null) { return; } diff --git a/src/netbeanstypescript/TSHintsProvider.java b/src/netbeanstypescript/TSHintsProvider.java index 69f85bc..a135dc6 100644 --- a/src/netbeanstypescript/TSHintsProvider.java +++ b/src/netbeanstypescript/TSHintsProvider.java @@ -78,7 +78,8 @@ public void computeSuggestions(HintsManager manager, final RuleContext context, for (OffsetRange span: errsBySpan.keySet()) { final FileObject fileObj = context.parserResult.getSnapshot().getSource().getFileObject(); Object fixes = TSService.call("getCodeFixesAtPosition", fileObj, span.getStart(), span.getEnd(), - errsBySpan.get(span)); // amazingly, LinkedHashSet's toString is valid JSON + errsBySpan.get(span), // amazingly, LinkedHashSet's toString is valid JSON + TSFormatter.getFormattingSettings(context.doc)); if (fixes == null) { continue; } @@ -108,13 +109,7 @@ public void implement() { public void run() { try { for (JSONObject change: (List) fix.get("changes")) { - OffsetRange changed = TSFormatter.applyEdits(context.doc, - change.get("textChanges")); - // Code fixes are badly formatted, so reformat the affected range - // https://github.com/Microsoft/TypeScript/issues/12249 - if (changed != null) { - formatter.reformat(changed.getStart(), changed.getEnd()); - } + TSFormatter.applyEdits(context.doc, change.get("textChanges")); } } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); diff --git a/src/netbeanstypescript/tsconfig/TSConfigCodeCompletion.java b/src/netbeanstypescript/tsconfig/TSConfigCodeCompletion.java index e6f2ee8..9550988 100644 --- a/src/netbeanstypescript/tsconfig/TSConfigCodeCompletion.java +++ b/src/netbeanstypescript/tsconfig/TSConfigCodeCompletion.java @@ -63,7 +63,7 @@ public class TSConfigCodeCompletion implements CodeCompletionHandler { static class TSConfigElementHandle implements ElementHandle { private static final Set commandLineOnlySet = new HashSet<>(Arrays.asList( - "help", "init", "locale", "project", "version")); + "all", "help", "init", "locale", "project", "version")); String name; boolean commandLineOnly; @@ -71,17 +71,20 @@ static class TSConfigElementHandle implements ElementHandle { boolean hidden; String message; TSConfigElementHandle element; + String deprecated; TSConfigElementHandle(JSONObject obj) { name = (String) obj.get("name"); commandLineOnly = commandLineOnlySet.contains(name); type = obj.get("type"); - hidden = Boolean.TRUE.equals(obj.get("experimental")); JSONObject description = (JSONObject) obj.get("description"); if (description != null) { message = (String) description.get("message"); - } else if (Boolean.TRUE.equals(obj.get("isTSConfigOnly"))) { - message = "No description available"; + if (message.startsWith("[Deprecated]")) { + int depMessageEnd = message.indexOf('.', 12); + deprecated = message.substring(12, depMessageEnd >= 0 ? depMessageEnd + 1 : message.length()); + hidden = true; + } } else { hidden = true; } diff --git a/src/netbeanstypescript/tsconfig/TSConfigParser.java b/src/netbeanstypescript/tsconfig/TSConfigParser.java index abcd928..7b5e95e 100644 --- a/src/netbeanstypescript/tsconfig/TSConfigParser.java +++ b/src/netbeanstypescript/tsconfig/TSConfigParser.java @@ -38,7 +38,6 @@ package netbeanstypescript.tsconfig; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; @@ -347,8 +346,8 @@ ConfigNode root() { continue; } checkType(res, value, optionInfo); - if (key.equals("out")) { - res.addError("'out' option is deprecated. Use 'outFile' instead.", + if (optionInfo.deprecated != null) { + res.addError("'" + key + "' option is deprecated." + optionInfo.deprecated, value.keyOffset, value.endOffset, Severity.WARNING); } if (optionInfo.commandLineOnly) { @@ -388,7 +387,8 @@ private void checkType(Result res, ConfigNode value, TSConfigElementHandle optio } } else if (type instanceof JSONArray) { List allAllowed = (List) type; - if (! allAllowed.contains(value.value)) { + Object v = value.value; + if (! (v instanceof String && allAllowed.contains(((String) v).toLowerCase()))) { StringBuilder sb = new StringBuilder("Compiler option '").append(key).append("' must be one of: "); boolean first = true; for (Object allowed: allAllowed) {