From 2003fe6508c4246a6a2a05c8843fc861405326ff Mon Sep 17 00:00:00 2001 From: Maxence Laurent Date: Sat, 25 Sep 2021 08:30:32 +0200 Subject: [PATCH] Use up-to-date libraries --- build.xml | 2 +- manifest.mf | 2 +- nbproject/genfiles.properties | 4 +- nbproject/project.properties | 13 ++- nbproject/project.xml | 79 ++++++++++++------- server/main.ts | 2 +- src/netbeanstypescript/CompileAction.java | 7 +- .../JsTypedBreakInterceptor.java | 70 ++++++++-------- .../JsTypedTextInterceptor.java | 16 ++-- .../OrganizeImportsAction.java | 4 +- src/netbeanstypescript/TSIndexerFactory.java | 3 +- src/netbeanstypescript/TSRefactoring.java | 3 +- src/netbeanstypescript/TSService.java | 3 +- .../api/lexer/LexUtilities.java | 5 +- 14 files changed, 124 insertions(+), 89 deletions(-) diff --git a/build.xml b/build.xml index f8d66bb..ffb39d4 100644 --- a/build.xml +++ b/build.xml @@ -7,7 +7,7 @@ - + diff --git a/manifest.mf b/manifest.mf index ff9385d..9ba48ab 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: 3.0.1 +OpenIDE-Module-Specification-Version: 3.0.2 diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index a5fba31..682e690 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -3,6 +3,6 @@ build.xml.script.CRC32=c7dc402d build.xml.stylesheet.CRC32=a56c6a5b@2.67.1 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=b67624fe +nbproject/build-impl.xml.data.CRC32=ac5ff7dd nbproject/build-impl.xml.script.CRC32=8b04660f -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.67.1 +nbproject/build-impl.xml.stylesheet.CRC32=49aa68b0@2.85 diff --git a/nbproject/project.properties b/nbproject/project.properties index ac0f346..e1b670f 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,4 +1,15 @@ -javac.source=1.7 +auxiliary.de-funfried-netbeans-plugins-externalcodeformatter.enabledFormatter_2e_JAVA=netbeans-formatter +auxiliary.de-funfried-netbeans-plugins-externalcodeformatter.enabledFormatter_2e_JAVASCRIPT=netbeans-formatter +auxiliary.de-funfried-netbeans-plugins-externalcodeformatter.enabledFormatter_2e_JSON=netbeans-formatter +auxiliary.de-funfried-netbeans-plugins-externalcodeformatter.enabledFormatter_2e_XML=netbeans-formatter +auxiliary.de-funfried-netbeans-plugins-externalcodeformatter.enableIndentationSettings=true +auxiliary.de-funfried-netbeans-plugins-externalcodeformatter.overrideTabSize=false +auxiliary.de-funfried-netbeans-plugins-externalcodeformatter.overrideTabSizeValue=4 +auxiliary.de-funfried-netbeans-plugins-externalcodeformatter.showNotifications=false +auxiliary.de-funfried-netbeans-plugins-externalcodeformatter.useProjectSettings=false +auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml +javac.source=11 javac.compilerargs=-Xlint -Xlint:-serial extra.module.files=nbts-services.js +javadoc.arch=${basedir}/arch.xml license.file=LICENSES.txt diff --git a/nbproject/project.xml b/nbproject/project.xml index d011400..1ffcb7f 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -12,7 +12,7 @@ 1 - 1.24.1 + 1.41 @@ -21,7 +21,7 @@ 1 - 1.38.1 + 1.61 @@ -30,7 +30,7 @@ 1 - 1.40.1 + 1.57 @@ -39,7 +39,7 @@ 1 - 0.9.1 + 0.25 @@ -48,7 +48,16 @@ 2 - 2.47.1.2.1.1.8 + 2.69.0.2.1.1.8.1 + + + + org.netbeans.modules.csl.types + + + + 1 + 1.13 @@ -57,7 +66,7 @@ 0 - 1.34.1.43 + 1.52.0.55 @@ -66,7 +75,15 @@ 1 - 1.38.1.1 + 1.56.0.1 + + + + org.netbeans.modules.editor.document + + + + 1.22.0.3 @@ -75,7 +92,7 @@ 2 - 1.37.1 + 1.56 @@ -84,7 +101,7 @@ 3 - 3.49.1.22.43 + 4.20.0.23.3.55 @@ -93,7 +110,7 @@ 1 - 1.85.1.43 + 2.33.0.55.3 @@ -102,7 +119,7 @@ 1 - 1.36.1 + 1.53 @@ -111,7 +128,7 @@ 1 - 1.58.1 + 1.78 @@ -120,7 +137,7 @@ 2 - 1.59.1.1 + 1.76.0.1 @@ -129,23 +146,23 @@ 1 - 1.78.3.8 + 9.20.0.8 - org.netbeans.modules.refactoring.api + org.netbeans.modules.parsing.indexing - 1.40.1.1 + 9.22.0.1.3.8 - org.openide.actions + org.netbeans.modules.refactoring.api - 6.35.1 + 1.60.0.1 @@ -153,7 +170,7 @@ - 7.62.1 + 7.81 @@ -161,7 +178,7 @@ - 7.38.1 + 7.55 @@ -169,7 +186,7 @@ - 8.12.1 + 9.25 @@ -177,7 +194,7 @@ - 7.43.1 + 7.61 @@ -185,7 +202,7 @@ - 7.39.1 + 7.58 @@ -193,7 +210,7 @@ - 6.62.2 + 6.81 @@ -201,7 +218,7 @@ - 8.39.1 + 9.21 @@ -209,7 +226,15 @@ - 8.25.1 + 8.47 + + + + org.openide.util.ui + + + + 9.21 @@ -217,7 +242,7 @@ - 6.71.1 + 6.90 diff --git a/server/main.ts b/server/main.ts index f4b2634..8eb9d1d 100644 --- a/server/main.ts +++ b/server/main.ts @@ -194,7 +194,7 @@ class Program { } getCompletionEntryDetails(fileName: string, position: number, entryName: string) { if (! this.fileInProject(fileName)) return null; - return this.service.getCompletionEntryDetails(fileName, position, entryName, void 0, void 0, void 0); + return this.service.getCompletionEntryDetails(fileName, position, entryName, undefined, undefined, undefined, undefined); } getCompletionEntryLocation(fileName: string, position: number, entryName: string) { if (! this.fileInProject(fileName)) return null; diff --git a/src/netbeanstypescript/CompileAction.java b/src/netbeanstypescript/CompileAction.java index 4397d58..3d78e63 100644 --- a/src/netbeanstypescript/CompileAction.java +++ b/src/netbeanstypescript/CompileAction.java @@ -50,7 +50,6 @@ import javax.swing.AbstractAction; import org.json.simple.JSONObject; import org.netbeans.api.progress.ProgressHandle; -import org.netbeans.api.progress.ProgressHandleFactory; import org.netbeans.modules.parsing.api.ParserManager; import org.netbeans.modules.parsing.api.ResultIterator; import org.netbeans.modules.parsing.api.Source; @@ -61,7 +60,7 @@ import org.openide.filesystems.FileUtil; import org.openide.util.Exceptions; import org.openide.util.RequestProcessor; -import org.openide.util.Utilities; +import org.openide.util.Lookup; /** * @@ -76,11 +75,11 @@ public CompileAction() { @Override public void actionPerformed(ActionEvent e) { final Collection fileObjects = - Utilities.actionsGlobalContext().lookupAll(FileObject.class); + Lookup.getDefault().lookupAll(FileObject.class); class CompileTask extends UserTask implements Runnable { @Override public void run() { - ProgressHandle progress = ProgressHandleFactory.createHandle("TypeScript compile"); + ProgressHandle progress = ProgressHandle.createHandle("TypeScript compile"); progress.start(); try { List sources = new ArrayList<>(fileObjects.size()); diff --git a/src/netbeanstypescript/JsTypedBreakInterceptor.java b/src/netbeanstypescript/JsTypedBreakInterceptor.java index e31b138..d6f1a2c 100644 --- a/src/netbeanstypescript/JsTypedBreakInterceptor.java +++ b/src/netbeanstypescript/JsTypedBreakInterceptor.java @@ -42,10 +42,10 @@ */ package netbeanstypescript; -import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.text.BadLocationException; +import javax.swing.text.Document; import org.netbeans.api.editor.mimelookup.MimePath; import org.netbeans.api.editor.mimelookup.MimeRegistration; import org.netbeans.api.editor.mimelookup.MimeRegistrations; @@ -57,13 +57,13 @@ import org.netbeans.editor.Utilities; import org.netbeans.lib.editor.util.CharSequenceUtilities; import org.netbeans.modules.csl.api.EditorOptions; -import org.netbeans.modules.csl.api.OffsetRange; import org.netbeans.modules.csl.spi.GsfUtilities; import org.netbeans.modules.editor.indent.api.IndentUtils; -//import module1.doc.JsDocumentationCompleter; import netbeanstypescript.lexer.JsDocumentationTokenId; import netbeanstypescript.api.lexer.JsTokenId; import netbeanstypescript.api.lexer.LexUtilities; +import org.netbeans.api.editor.document.LineDocumentUtils; +import org.netbeans.api.lexer.TokenId; import org.netbeans.spi.editor.typinghooks.TypedBreakInterceptor; /** @@ -112,8 +112,8 @@ public void insert(MutableContext context) throws BadLocationException { TokenHierarchy tokenHierarchy = TokenHierarchy.get(doc); int offset = context.getCaretOffset(); - int lineBegin = Utilities.getRowStart(doc, offset); - int lineEnd = Utilities.getRowEnd(doc, offset); + int lineBegin = LineDocumentUtils.getLineStart(doc, offset); + int lineEnd = LineDocumentUtils.getLineEnd(doc, offset); if (lineBegin == offset && lineEnd == offset) { // Pressed return on a blank newline - do nothing @@ -138,9 +138,9 @@ public void insert(MutableContext context) throws BadLocationException { // Insert a missing } if (!id.isError() && isInsertMatchingEnabled() && !isDocToken(id) && isAddRightBrace(doc, offset)) { - int indent = GsfUtilities.getLineIndent(doc, offset); + int indent = GsfUtilities.getLineIndent((Document)doc, offset); - int afterLastNonWhite = Utilities.getRowLastNonWhite(doc, offset); + int afterLastNonWhite = LineDocumentUtils.getLineLastNonWhitespace(doc, offset); // We've either encountered a further indented line, or a line that doesn't // look like the end we're after, so insert a matching end. @@ -166,7 +166,7 @@ public void insert(MutableContext context) throws BadLocationException { // I'm inserting a newline in the middle of a sentence, such as the scenario in #118656 // I should insert the end AFTER the text on the line String restOfLine = doc.getText(offset, - Math.min(end, Utilities.getRowEnd(doc, afterLastNonWhite)) - offset); + Math.min(end, LineDocumentUtils.getLineEnd(doc, afterLastNonWhite)) - offset); sb.append("\n"); // XXX On Windows, do \r\n? sb.append(IndentUtils.createIndentString(doc, indent + IndentUtils.indentLevelSize(doc))); // right brace must be included into the correct context - issue #219683 @@ -195,7 +195,7 @@ public void insert(MutableContext context) throws BadLocationException { // See if it's a block comment opener String text = token.text().toString(); if (comments && text.startsWith("/*") && ts.offset() == Utilities.getRowFirstNonWhite(doc, offset)) { - int indent = GsfUtilities.getLineIndent(doc, offset); + int indent = GsfUtilities.getLineIndent((Document)doc, offset); StringBuilder sb = new StringBuilder(); sb.append("\n"); // NOI18N sb.append(IndentUtils.createIndentString(doc, indent)); @@ -218,7 +218,7 @@ public void insert(MutableContext context) throws BadLocationException { if (id == JsTokenId.STRING || (id == JsTokenId.STRING_END) && offset < ts.offset()+ts.token().length()) { // Instead of splitting a string "foobar" into "foo"+"bar", just insert a \ instead! - //int indent = GsfUtilities.getLineIndent(doc, offset); + //int indent = GsfUtilities.getLineIndent((Document)doc, offset); //int delimiterOffset = id == JsTokenId.STRING_END ? ts.offset() : ts.offset()-1; //char delimiter = doc.getText(delimiterOffset,1).charAt(0); //doc.insertString(offset, delimiter + " + " + delimiter, null); @@ -234,7 +234,7 @@ public void insert(MutableContext context) throws BadLocationException { if (id == JsTokenId.REGEXP || (id == JsTokenId.REGEXP_END) && offset < ts.offset()+ts.token().length()) { // Instead of splitting a string "foobar" into "foo"+"bar", just insert a \ instead! - //int indent = GsfUtilities.getLineIndent(doc, offset); + //int indent = GsfUtilities.getLineIndent((Document)doc, offset); //doc.insertString(offset, "/ + /", null); //caret.setDot(offset+3); //return offset + 5 + indent; @@ -263,7 +263,7 @@ public void insert(MutableContext context) throws BadLocationException { JsTokenId prevTokenId = prevToken.id(); if (id == JsTokenId.BRACKET_RIGHT_CURLY && prevTokenId == JsTokenId.BRACKET_LEFT_CURLY || id == JsTokenId.BRACKET_RIGHT_BRACKET && prevTokenId == JsTokenId.BRACKET_LEFT_BRACKET) { - int indent = GsfUtilities.getLineIndent(doc, offset); + int indent = GsfUtilities.getLineIndent((Document)doc, offset); StringBuilder sb = new StringBuilder(); // XXX On Windows, do \r\n? sb.append("\n"); // NOI18N @@ -302,14 +302,14 @@ public void insert(MutableContext context) throws BadLocationException { && offset > ts.offset() && offset < ts.offset()+ts.token().length()) { // Continue *'s int begin = Utilities.getRowFirstNonWhite(doc, offset); - int end = Utilities.getRowEnd(doc, offset)+1; + int end = LineDocumentUtils.getLineEnd(doc, offset)+1; if (begin == -1) { begin = end; } String line = doc.getText(begin, end-begin); boolean isBlockStart = line.startsWith("/*") || (begin != -1 && begin < ts.offset()); if (isBlockStart || line.startsWith("*")) { - int indent = GsfUtilities.getLineIndent(doc, offset); + int indent = GsfUtilities.getLineIndent((Document)doc, offset); StringBuilder sb = new StringBuilder("\n"); if (isBlockStart) { indent++; @@ -335,7 +335,7 @@ public void insert(MutableContext context) throws BadLocationException { // Copy existing indentation inside the block sb.append("*"); //NOI18N int afterStar = isBlockStart ? begin+2 : begin+1; - line = doc.getText(afterStar, Utilities.getRowEnd(doc, afterStar)-afterStar); + line = doc.getText(afterStar, LineDocumentUtils.getLineEnd(doc, afterStar)-afterStar); for (int i = 0; i < line.length(); i++) { char c = line.charAt(i); if (c == ' ' || c == '\t') { //NOI18N @@ -375,7 +375,7 @@ public void insert(MutableContext context) throws BadLocationException { // (and a comment from the beginning, not a trailing comment) boolean previousLineWasComment = false; boolean nextLineIsComment = false; - int rowStart = Utilities.getRowStart(doc, offset); + int rowStart = LineDocumentUtils.getLineStart(doc, offset); if (rowStart > 0) { int prevBegin = Utilities.getRowFirstNonWhite(doc, rowStart - 1); if (prevBegin != -1) { @@ -386,7 +386,7 @@ public void insert(MutableContext context) throws BadLocationException { } } } - int rowEnd = Utilities.getRowEnd(doc, offset); + int rowEnd = LineDocumentUtils.getLineEnd(doc, offset); if (rowEnd < doc.getLength()) { int nextBegin = Utilities.getRowFirstNonWhite(doc, rowEnd + 1); if (nextBegin != -1) { @@ -405,7 +405,7 @@ public void insert(MutableContext context) throws BadLocationException { || (offset > ts.offset() && offset < ts.offset() + ts.token().length())) { if (ts.offset() + token.length() > offset + 1) { // See if the remaining text is just whitespace - String trailing = doc.getText(offset, Utilities.getRowEnd(doc, offset) - offset); + String trailing = doc.getText(offset, LineDocumentUtils.getLineEnd(doc, offset) - offset); if (trailing.trim().length() != 0) { continueComment = true; } @@ -421,7 +421,7 @@ public void insert(MutableContext context) throws BadLocationException { if (!continueComment) { // See if the next line is a comment; if so we want to continue // comments editing the middle of the comment - int nextLine = Utilities.getRowEnd(doc, offset) + 1; + int nextLine = LineDocumentUtils.getLineEnd(doc, offset) + 1; if (nextLine < doc.getLength()) { int nextLineFirst = Utilities.getRowFirstNonWhite(doc, nextLine); if (nextLineFirst != -1) { @@ -437,7 +437,7 @@ public void insert(MutableContext context) throws BadLocationException { if (continueComment) { // Line comments should continue - int indent = GsfUtilities.getLineIndent(doc, offset); + int indent = GsfUtilities.getLineIndent((Document)doc, offset); StringBuilder sb = new StringBuilder(); if (offset != begin || offset <= 0) { sb.append("\n"); @@ -446,7 +446,7 @@ public void insert(MutableContext context) throws BadLocationException { sb.append("//"); // NOI18N // Copy existing indentation int afterSlash = begin + 2; - String line = doc.getText(afterSlash, Utilities.getRowEnd(doc, afterSlash) - afterSlash); + String line = doc.getText(afterSlash, LineDocumentUtils.getLineEnd(doc, afterSlash) - afterSlash); for (int i = 0; i < line.length(); i++) { char c = line.charAt(i); if (c == ' ' || c == '\t') { @@ -505,12 +505,12 @@ public void cancelled(Context context) { * @throws BadLocationException */ private int getNextLineIndentation(BaseDocument doc, int offset) throws BadLocationException { - int indent = GsfUtilities.getLineIndent(doc, offset); + int indent = GsfUtilities.getLineIndent((Document)doc, offset); int currentOffset = offset; while (currentOffset > 0) { - if (!Utilities.isRowEmpty(doc, currentOffset) && !Utilities.isRowWhite(doc, currentOffset) + if (!LineDocumentUtils.isLineEmpty(doc, currentOffset) && !LineDocumentUtils.isLineWhitespace(doc, currentOffset) && !LexUtilities.isCommentOnlyLine(doc, currentOffset, language)) { - indent = GsfUtilities.getLineIndent(doc, currentOffset); + indent = GsfUtilities.getLineIndent((Document)doc, currentOffset); int parenBalance = LexUtilities.getLineBalance(doc, currentOffset, JsTokenId.BRACKET_LEFT_PAREN, JsTokenId.BRACKET_RIGHT_PAREN); if (parenBalance < 0) { @@ -523,7 +523,7 @@ private int getNextLineIndentation(BaseDocument doc, int offset) throws BadLocat } return indent; } - currentOffset = Utilities.getRowStart(doc, currentOffset) - 1; + currentOffset = LineDocumentUtils.getLineStart(doc, currentOffset) - 1; } return indent; @@ -563,7 +563,7 @@ private boolean isAddRightBrace(BaseDocument doc, int caretOffset) throws BadLoc boolean balancedAfter = false; do { - Token t = ts.token(); + Token t = ts.token(); if (t.id() == JsTokenId.BRACKET_LEFT_CURLY) { balance++; @@ -574,7 +574,7 @@ private boolean isAddRightBrace(BaseDocument doc, int caretOffset) throws BadLoc for (TokenSequenceIterator tsi = new TokenSequenceIterator(TokenHierarchy.get(doc).tokenSequenceList(ts.languagePath(), caretOffset, doc.getLength()), false); tsi.hasMore();) { TokenSequence sq = tsi.getSequence(); - Token t = sq.token(); + Token t = sq.token(); if (t.id() == JsTokenId.BRACKET_LEFT_CURLY) { balance++; @@ -592,7 +592,7 @@ private boolean isAddRightBrace(BaseDocument doc, int caretOffset) throws BadLoc return false; } - int caretRowStartOffset = org.netbeans.editor.Utilities.getRowStart(doc, caretOffset); + int caretRowStartOffset = LineDocumentUtils.getLineStart(doc, caretOffset); ts = LexUtilities.getPositionedSequence(doc, caretOffset, language); if (ts == null) { return false; @@ -635,7 +635,7 @@ private boolean isAddRightBrace(BaseDocument doc, int caretOffset) throws BadLoc * character on the caret row is returned. */ private int getRowOrBlockEnd(BaseDocument doc, int caretOffset, boolean[] insert) throws BadLocationException { - int rowEnd = org.netbeans.editor.Utilities.getRowLastNonWhite(doc, caretOffset); + int rowEnd = LineDocumentUtils.getLineLastNonWhitespace(doc, caretOffset); if (rowEnd == -1 || caretOffset >= rowEnd) { return caretOffset; } @@ -704,7 +704,7 @@ private int getUnbalancedCurlyOffset(BaseDocument doc, int offset) throws BadLoc int balance = 0; while (ts.movePrevious()) { - Token t = ts.token(); + Token t = ts.token(); if (t.id() == JsTokenId.BRACKET_RIGHT_CURLY) { balance++; @@ -732,7 +732,7 @@ private int getCurlyIndent(BaseDocument doc, int offset) { if (prevLineStart >= 0) { return IndentUtils.lineIndent(doc, lineStart); } else { - return GsfUtilities.getLineIndent(doc, offset); + return GsfUtilities.getLineIndent((Document)doc, offset); } } @@ -760,21 +760,21 @@ private int getCurlyIndent(BaseDocument doc, int offset) { } catch (BadLocationException ex) { LOGGER.log(Level.INFO, null, ex); } - return GsfUtilities.getLineIndent(doc, offset); + return GsfUtilities.getLineIndent((Document)doc, offset); } private boolean isDocToken(JsTokenId id) { return id == JsTokenId.BLOCK_COMMENT || id == JsTokenId.DOC_COMMENT; } - private static boolean hasCommentEnd(TokenSequence ts) { + private static boolean hasCommentEnd(TokenSequence ts) { while (ts.moveNext()) { - Token token = ts.token(); + Token token = ts.token(); if (token.id() == JsDocumentationTokenId.COMMENT_END) { return true; } else if (CharSequenceUtilities.endsWith(token.text(), "/")) { //NOI18N if (ts.moveNext()) { - Token nextToken = ts.token(); + Token nextToken = ts.token(); if (CharSequenceUtilities.textEquals(nextToken.text(), "/")) { //NOI18N ts.movePrevious(); continue; diff --git a/src/netbeanstypescript/JsTypedTextInterceptor.java b/src/netbeanstypescript/JsTypedTextInterceptor.java index f9caf43..3af979b 100644 --- a/src/netbeanstypescript/JsTypedTextInterceptor.java +++ b/src/netbeanstypescript/JsTypedTextInterceptor.java @@ -45,6 +45,7 @@ import java.util.concurrent.atomic.AtomicReference; import javax.swing.text.BadLocationException; import javax.swing.text.Caret; +import javax.swing.text.Document; import org.netbeans.api.editor.mimelookup.MimeRegistration; import org.netbeans.api.lexer.Language; import org.netbeans.api.lexer.Token; @@ -59,6 +60,7 @@ import netbeanstypescript.api.lexer.JsTokenId; import netbeanstypescript.api.lexer.LexUtilities; import netbeanstypescript.options.OptionsUtils; +import org.netbeans.api.editor.document.LineDocumentUtils; import org.netbeans.spi.editor.typinghooks.TypedTextInterceptor; /** @@ -136,7 +138,7 @@ public void run() { ts.move(dotPos); if (ts.moveNext() && (ts.offset() < dotPos)) { - GsfUtilities.setLineIndentation(doc, dotPos, previousAdjustmentIndent); + GsfUtilities.setLineIndentation((Document)doc, dotPos, previousAdjustmentIndent); } } } @@ -343,9 +345,9 @@ private void reindent(BaseDocument doc, int offset, TokenId id, Caret caret) if (begin != OffsetRange.NONE) { int beginOffset = begin.getStart(); - int indent = GsfUtilities.getLineIndent(doc, beginOffset); - previousAdjustmentIndent = GsfUtilities.getLineIndent(doc, offset); - GsfUtilities.setLineIndentation(doc, offset, indent); + int indent = GsfUtilities.getLineIndent((Document)doc, beginOffset); + previousAdjustmentIndent = GsfUtilities.getLineIndent((Document)doc, offset); + GsfUtilities.setLineIndentation((Document)doc, offset, indent); previousAdjustmentOffset = caret.getDot(); } } @@ -417,7 +419,7 @@ private void completeQuote(MutableContext context, char bracket, previousToken = ts.token(); } - int lastNonWhite = Utilities.getRowLastNonWhite(doc, dotPos); + int lastNonWhite = LineDocumentUtils.getLineLastNonWhitespace(doc, dotPos); // eol - true if the caret is at the end of line (ignoring whitespaces) boolean eol = lastNonWhite < dotPos; @@ -527,13 +529,13 @@ private boolean isQuoteCompletablePosition(BaseDocument doc, int dotPos) return true; } else { // test that we are in front of ) , " or ' ... etc. - int eol = Utilities.getRowEnd(doc, dotPos); + int eol = LineDocumentUtils.getLineEnd(doc, dotPos); if ((dotPos == eol) || (eol == -1)) { return false; } - int firstNonWhiteFwd = Utilities.getFirstNonWhiteFwd(doc, dotPos, eol); + int firstNonWhiteFwd = LineDocumentUtils.getNextNonWhitespace(doc, dotPos, eol); if (firstNonWhiteFwd == -1) { return false; diff --git a/src/netbeanstypescript/OrganizeImportsAction.java b/src/netbeanstypescript/OrganizeImportsAction.java index a933748..a129200 100644 --- a/src/netbeanstypescript/OrganizeImportsAction.java +++ b/src/netbeanstypescript/OrganizeImportsAction.java @@ -8,7 +8,7 @@ import org.json.simple.JSONObject; import org.netbeans.api.editor.EditorActionNames; import org.netbeans.api.editor.EditorActionRegistration; -import org.netbeans.api.progress.ProgressUtils; +import org.netbeans.api.progress.BaseProgressUtils; import org.netbeans.editor.BaseAction; import org.netbeans.editor.BaseDocument; import org.netbeans.editor.Utilities; @@ -54,7 +54,7 @@ public void run(ResultIterator ri) throws ParseException { } } } - ProgressUtils.runOffEventDispatchThread(new OrganizeImportsTask(), + BaseProgressUtils.runOffEventDispatchThread(new OrganizeImportsTask(), "Organize Imports", cancel, false); } } diff --git a/src/netbeanstypescript/TSIndexerFactory.java b/src/netbeanstypescript/TSIndexerFactory.java index 472846b..9fded5e 100644 --- a/src/netbeanstypescript/TSIndexerFactory.java +++ b/src/netbeanstypescript/TSIndexerFactory.java @@ -45,7 +45,6 @@ import java.util.Set; import java.util.logging.Level; import org.netbeans.api.progress.ProgressHandle; -import org.netbeans.api.progress.ProgressHandleFactory; import org.netbeans.modules.parsing.api.Snapshot; import org.netbeans.modules.parsing.api.Source; import org.netbeans.modules.parsing.spi.indexing.Context; @@ -145,7 +144,7 @@ public int getIndexVersion() { } static void compileIfEnabled(FileObject root, FileObject[] fileObjects) { - ProgressHandle progress = ProgressHandleFactory.createHandle("TypeScript compile on save"); + ProgressHandle progress = ProgressHandle.createHandle("TypeScript compile on save"); progress.start(); try { for (FileObject fileObject: fileObjects) { diff --git a/src/netbeanstypescript/TSRefactoring.java b/src/netbeanstypescript/TSRefactoring.java index 8c2d64a..5631106 100644 --- a/src/netbeanstypescript/TSRefactoring.java +++ b/src/netbeanstypescript/TSRefactoring.java @@ -59,8 +59,7 @@ import org.netbeans.modules.refactoring.api.*; import org.netbeans.modules.refactoring.spi.*; import org.netbeans.modules.refactoring.spi.ui.*; -import org.openide.DialogDisplayer; -import org.openide.NotifyDescriptor; +import org.openide.*; import org.openide.awt.Mnemonics; import org.openide.cookies.EditorCookie; import org.openide.filesystems.FileObject; diff --git a/src/netbeanstypescript/TSService.java b/src/netbeanstypescript/TSService.java index 866086f..859ca0f 100644 --- a/src/netbeanstypescript/TSService.java +++ b/src/netbeanstypescript/TSService.java @@ -50,7 +50,6 @@ import java.util.logging.Logger; import org.json.simple.JSONObject; import org.netbeans.api.progress.ProgressHandle; -import org.netbeans.api.progress.ProgressHandleFactory; import org.netbeans.modules.parsing.api.Snapshot; import org.netbeans.modules.parsing.spi.indexing.Context; import org.netbeans.modules.parsing.spi.indexing.ErrorsCache; @@ -238,7 +237,7 @@ static void postIndex(final URL rootURI) { } new Runnable() { RequestProcessor.Task task = RP.create(this); - ProgressHandle progress = ProgressHandleFactory.createHandle("TypeScript error checking", task); + ProgressHandle progress = ProgressHandle.createHandle("TypeScript error checking", task); @Override public void run() { TSIndexerFactory.compileIfEnabled(program.root, compileOnSave); diff --git a/src/netbeanstypescript/api/lexer/LexUtilities.java b/src/netbeanstypescript/api/lexer/LexUtilities.java index 6cb1e88..1bf0590 100644 --- a/src/netbeanstypescript/api/lexer/LexUtilities.java +++ b/src/netbeanstypescript/api/lexer/LexUtilities.java @@ -61,6 +61,7 @@ import org.netbeans.editor.BaseDocument; import org.netbeans.editor.Utilities; import netbeanstypescript.lexer.JsDocumentationTokenId; +import org.netbeans.api.editor.document.LineDocumentUtils; //import org.netbeans.modules.javascript2.editor.parser.JsParserResult; import org.netbeans.modules.parsing.api.Snapshot; import org.openide.util.Exceptions; @@ -320,8 +321,8 @@ public static boolean isCommentOnlyLine(BaseDocument doc, int offset, Language ts = LexUtilities.getJsTokenSequence(doc, begin); if (ts == null) {