Skip to content

Commit

Permalink
Upgrade to TypeScript 2.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffrey-easyesi committed May 17, 2017
1 parent aa4602e commit 9d0865e
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<!-- Paths to the TypeScript installation to copy files from, and the Node.js executable to
use while building. Adjust these according to your own environment. -->
<property name="typescript" value="${env.HOME}/TypeScript-2.2.1"/>
<property name="typescript" value="${env.HOME}/TypeScript-2.3.2"/>
<property name="node.executable" value="node"/>

<target name="compile" depends="projectized-common.compile">
Expand Down
2 changes: 1 addition & 1 deletion manifest.mf
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions server/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
14 changes: 7 additions & 7 deletions server/ts-patches
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- compiler/checker.ts
+++ compiler/checker.ts
@@ -2249,6 +2249,13 @@
@@ -2970,6 +2970,13 @@
appendSymbolNameOnly(symbol, writer);
}
parentSymbol = symbol;
Expand All @@ -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",
Expand All @@ -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 => {
Expand All @@ -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
3 changes: 2 additions & 1 deletion server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"compilerOptions": {
"noImplicitAny": true,
"noImplicitThis": true,
"removeComments": true
"removeComments": true,
"target": "es5"
},
"files": ["main.ts"]
}
12 changes: 8 additions & 4 deletions src/netbeanstypescript/TSFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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;
}
Expand Down
11 changes: 3 additions & 8 deletions src/netbeanstypescript/TSHintsProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer>'s toString is valid JSON
errsBySpan.get(span), // amazingly, LinkedHashSet<Integer>'s toString is valid JSON
TSFormatter.getFormattingSettings(context.doc));
if (fixes == null) {
continue;
}
Expand Down Expand Up @@ -108,13 +109,7 @@ public void implement() {
public void run() {
try {
for (JSONObject change: (List<JSONObject>) 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);
Expand Down
11 changes: 7 additions & 4 deletions src/netbeanstypescript/tsconfig/TSConfigCodeCompletion.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,28 @@ public class TSConfigCodeCompletion implements CodeCompletionHandler {

static class TSConfigElementHandle implements ElementHandle {
private static final Set<String> commandLineOnlySet = new HashSet<>(Arrays.asList(
"help", "init", "locale", "project", "version"));
"all", "help", "init", "locale", "project", "version"));

String name;
boolean commandLineOnly;
Object type;
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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/netbeanstypescript/tsconfig/TSConfigParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 9d0865e

Please sign in to comment.