diff --git a/app/src/main/java/com/itsaky/androidide/language/java/JavaAutoComplete.java b/app/src/main/java/com/itsaky/androidide/language/java/JavaAutoComplete.java index 9015f2ef2..266d8f15d 100644 --- a/app/src/main/java/com/itsaky/androidide/language/java/JavaAutoComplete.java +++ b/app/src/main/java/com/itsaky/androidide/language/java/JavaAutoComplete.java @@ -1,8 +1,6 @@ /************************************************************************************ * This file is part of AndroidIDE. - * - * - * + * * AndroidIDE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -17,8 +15,6 @@ * along with AndroidIDE. If not, see . * **************************************************************************************/ - - package com.itsaky.androidide.language.java; import com.itsaky.androidide.lsp.LSPProvider; @@ -54,26 +50,33 @@ public class JavaAutoComplete implements AutoCompleteProvider { params.setTextDocument(new TextDocumentIdentifier(fileUri)); future = languageServer.getTextDocumentService().completion(params); - if(future.isCancelled()) return new ArrayList(); + if(future.isCancelled()) { + LOG.debug ("Completion request was cancelled"); + return finalizeResults(new ArrayList()); + } try { Either, CompletionList> either = future.get(); - if(either.isLeft()) - return sort(either.getLeft()); + if(either.isLeft()) { + return finalizeResults(either.getLeft()); + } - if(either.isRight()) - return sort(either.getRight().getItems()); + if(either.isRight()) { + return finalizeResults(either.getRight().getItems()); + } } catch (Throwable th) { - // Ignore this exception. An empty list will be sent after this - // This exeption is thrown probably because the request was cancelled or interrupted + LOG.error("CompletionError", th); } + } else { + LOG.error("Cannot compute completions for Java file. No LanguageServer implementation found."); } return new ArrayList(); } - private List sort(List items) { + private List finalizeResults(List items) { Collections.sort(items, RESULT_SORTER); + LOG.debug ("CompletionResults", items); return items; } diff --git a/app/src/main/java/com/itsaky/androidide/language/java/JavaLanguage.java b/app/src/main/java/com/itsaky/androidide/language/java/JavaLanguage.java index a600e7fa1..0c91b2ff0 100644 --- a/app/src/main/java/com/itsaky/androidide/language/java/JavaLanguage.java +++ b/app/src/main/java/com/itsaky/androidide/language/java/JavaLanguage.java @@ -1,8 +1,6 @@ /************************************************************************************ * This file is part of AndroidIDE. * - * - * * AndroidIDE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -17,8 +15,6 @@ * along with AndroidIDE. If not, see . * **************************************************************************************/ - - package com.itsaky.androidide.language.java; import com.itsaky.androidide.lexers.java.JavaLexer; diff --git a/app/src/main/java/com/itsaky/androidide/lsp/LSPClientLauncher.java b/app/src/main/java/com/itsaky/androidide/lsp/LSPClientLauncher.java index d30d214f6..9f678d112 100644 --- a/app/src/main/java/com/itsaky/androidide/lsp/LSPClientLauncher.java +++ b/app/src/main/java/com/itsaky/androidide/lsp/LSPClientLauncher.java @@ -1,8 +1,6 @@ /************************************************************************************ * This file is part of AndroidIDE. - * - * - * + * * AndroidIDE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -17,8 +15,6 @@ * along with AndroidIDE. If not, see . * **************************************************************************************/ - - package com.itsaky.androidide.lsp; import com.itsaky.androidide.utils.Logger; @@ -31,6 +27,7 @@ import java.util.Objects; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; import org.eclipse.lsp4j.jsonrpc.Launcher; +import java.util.Locale; /** * Launches a client for a Language server and handles connection. @@ -74,7 +71,7 @@ public abstract class LSPClientLauncher extends Thread { try { launch(); } catch (Throwable th) { - // TODO Log this + LOG.error("Error starting language server", th); } } @@ -162,7 +159,9 @@ public abstract class LSPClientLauncher extends Thread { Writable data = writeQueue.take(); this.out.write(data.data); this.out.flush(); - } catch (Throwable e) { } + } catch (Throwable e) { + LOG.error ("Failed to write to LSP4J socket", e); + } } } @@ -174,7 +173,6 @@ public abstract class LSPClientLauncher extends Thread { class Writable { byte[] data; - public Writable(byte[] data) { this.data = data; } diff --git a/app/src/main/java/com/itsaky/androidide/lsp/StandardStreamsLauncher.java b/app/src/main/java/com/itsaky/androidide/lsp/StandardStreamsLauncher.java index 49ecaff8b..6e067fa35 100644 --- a/app/src/main/java/com/itsaky/androidide/lsp/StandardStreamsLauncher.java +++ b/app/src/main/java/com/itsaky/androidide/lsp/StandardStreamsLauncher.java @@ -1,8 +1,6 @@ /************************************************************************************ * This file is part of AndroidIDE. - * - * - * + * * AndroidIDE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -17,8 +15,6 @@ * along with AndroidIDE. If not, see . * **************************************************************************************/ - - package com.itsaky.androidide.lsp; import com.blankj.utilcode.util.CloseUtils; @@ -44,7 +40,7 @@ public class StandardStreamsLauncher extends LSPClientLauncher { this.out = new BufferedOutputStream( out ); this.langCode = langCode; } - + @Override protected void launch() { final Launcher server = createClientLauncher(languageClient, in, out); @@ -57,7 +53,11 @@ public class StandardStreamsLauncher extends LSPClientLauncher { try { listening.get(); } catch (Throwable th) { - + LOG.error ( + "---> StandardStreamsLauncher <---", + "An error occured while waiting for language server process to stop", + th + ); } shutdown(); @@ -74,6 +74,7 @@ public class StandardStreamsLauncher extends LSPClientLauncher { if (listening != null && !listening.isDone()) { listening.cancel(true); } + CloseUtils.closeIO(in, out); } } diff --git a/app/src/main/java/com/itsaky/androidide/lsp/handlers/JLSHandler.java b/app/src/main/java/com/itsaky/androidide/lsp/handlers/JLSHandler.java index d1773782c..55395e9e3 100644 --- a/app/src/main/java/com/itsaky/androidide/lsp/handlers/JLSHandler.java +++ b/app/src/main/java/com/itsaky/androidide/lsp/handlers/JLSHandler.java @@ -1,8 +1,6 @@ /************************************************************************************ * This file is part of AndroidIDE. * - * - * * AndroidIDE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -17,7 +15,6 @@ * along with AndroidIDE. If not, see . * **************************************************************************************/ - package com.itsaky.androidide.lsp.handlers; import com.itsaky.androidide.app.StudioApp; @@ -89,9 +86,11 @@ public class JLSHandler implements LSPHandler { final IDELanguageServer server = LSPProvider.getServerForLanguage(LSPProvider.LANGUAGE_JAVA); - if (server == null) + if (server == null) { + LOG.error ("Cannot initialize Java Language Server. Server instance is null!"); return Optional.empty(); - + } + final List folders = new ArrayList<>(); final File file = new File(rootPath); final WorkspaceFolder folder = new WorkspaceFolder(); @@ -119,18 +118,18 @@ public class JLSHandler implements LSPHandler { } return Optional.of(result); } catch (Throwable e) { + LOG.error ("An error occurred while initializing language server.", e); return Optional.empty(); } } @Override public void initialized() { - final IDELanguageServer server = LSPProvider.getServerForLanguage(LSPProvider.LANGUAGE_JAVA); - if (server == null) + if (server == null) { return; + } server.initialized(new InitializedParams()); - } @Override @@ -146,7 +145,7 @@ public class JLSHandler implements LSPHandler { readerThread.setDaemon(true); readerThread.start(); } - + private File getOutputFile () { return new File (FileUtil.getExternalStorageDir(), "ide_xlog/jls_output.txt"); } diff --git a/app/src/main/java/com/itsaky/androidide/managers/ToolsManager.java b/app/src/main/java/com/itsaky/androidide/managers/ToolsManager.java index 856534bd8..55f3313c7 100644 --- a/app/src/main/java/com/itsaky/androidide/managers/ToolsManager.java +++ b/app/src/main/java/com/itsaky/androidide/managers/ToolsManager.java @@ -1,8 +1,6 @@ /************************************************************************************ * This file is part of AndroidIDE. * - * - * * AndroidIDE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -18,7 +16,6 @@ * **************************************************************************************/ - package com.itsaky.androidide.managers; import com.blankj.utilcode.util.FileIOUtils; @@ -118,12 +115,10 @@ public class ToolsManager { } public static String getArchSpecificAsset (String name) { - LOG.info ("ARCH_SPECIFIC_ASSET: " + ARCH_SPECIFIC_ASSET_DATA_DIR + "/" + name); return ARCH_SPECIFIC_ASSET_DATA_DIR + "/" + name; } public static String getCommonAsset (String name) { - LOG.info ("COMMON_ASSET: " + COMMON_ASSET_DATA_DIR + "/" + name); return COMMON_ASSET_DATA_DIR + "/" + name; } diff --git a/app/src/main/java/com/itsaky/androidide/syntax/lexer/impls/java/HighlightRangeHelper.java b/app/src/main/java/com/itsaky/androidide/syntax/lexer/impls/java/HighlightRangeHelper.java index 1306c00f5..bb022ba22 100644 --- a/app/src/main/java/com/itsaky/androidide/syntax/lexer/impls/java/HighlightRangeHelper.java +++ b/app/src/main/java/com/itsaky/androidide/syntax/lexer/impls/java/HighlightRangeHelper.java @@ -1,8 +1,6 @@ /************************************************************************************ * This file is part of AndroidIDE. * - * - * * AndroidIDE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -21,10 +19,10 @@ package com.itsaky.androidide.syntax.lexer.impls.java; -import androidx.core.util.Pair; import com.itsaky.androidide.utils.LSPUtils; -import com.itsaky.lsp.JavadocHighlights; import com.itsaky.lsp.SemanticHighlight; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import org.eclipse.lsp4j.Range; @@ -41,220 +39,7 @@ public class HighlightRangeHelper { } public void sort () { - highlights.sort(LSPUtils.RANGE_START_COMPARATOR); - } - - /** - * Check if have any Javadoc highlight starting at the provided line and column - * - * @param line The start line - * @param column The start column - * @return A pair containing the color id as first element - * and the found range as the second. - */ - public Pair findJavadocColorSchemeId (int line, int column) { - final JavadocHighlights jd = highlights.javadocs; - - int index = -1; - - if((index = containsStartPosition(jd.authorTags, line, column)) != -1) { - return Pair.create(JD_AUTHOR_TAG, jd.authorTags.get(index)); - } - - if((index = containsStartPosition(jd.authorNames, line, column)) != -1) { - return Pair.create(JD_AUTHOR_NAME, jd.authorNames.get(index)); - } - - if((index = containsStartPosition(jd.deprecatedTags, line, column)) != -1) { - return Pair.create(JD_DEPRECATED_TAG, jd.deprecatedTags.get(index)); - } - - if((index = containsStartPosition(jd.deprecatedMessages, line, column)) != -1) { - return Pair.create(JD_DEPRECATED_MESSAGE, jd.deprecatedMessages.get(index)); - } - - if((index = containsStartPosition(jd.docrootTags, line, column)) != -1) { - return Pair.create(JD_DOCROOT_TAG, jd.docrootTags.get(index)); - } - - if((index = containsStartPosition(jd.hiddenTags, line, column)) != -1) { - return Pair.create(JD_HIDDEN_TAG, jd.hiddenTags.get(index)); - } - - if((index = containsStartPosition(jd.hiddenMessages, line, column)) != -1) { - return Pair.create(JD_HIDDEN_MESSAGE, jd.hiddenMessages.get(index)); - } - - if((index = containsStartPosition(jd.indexTags, line, column)) != -1) { - return Pair.create(JD_INDEX_TAG, jd.indexTags.get(index)); - } - - if((index = containsStartPosition(jd.indexDescriptions, line, column)) != -1) { - return Pair.create(JD_INDEX_DESCRIPTION, jd.indexDescriptions.get(index)); - } - - if((index = containsStartPosition(jd.indexSearchTerms, line, column)) != -1) { - return Pair.create(JD_INDEX_SEARCH_TERM, jd.indexSearchTerms.get(index)); - } - - if((index = containsStartPosition(jd.inheritDocTags, line, column)) != -1) { - return Pair.create(JD_INHERITDOC_TAG, jd.inheritDocTags.get(index)); - } - - if((index = containsStartPosition(jd.linkTags, line, column)) != -1) { - return Pair.create(JD_LINK_TAG, jd.linkTags.get(index)); - } - - if((index = containsStartPosition(jd.linkLabels, line, column)) != -1) { - return Pair.create(JD_LINK_LABEL, jd.linkLabels.get(index)); - } - - if((index = containsStartPosition(jd.linkReferences, line, column)) != -1) { - return Pair.create(JD_LINK_REFERENCE, jd.linkReferences.get(index)); - } - - if((index = containsStartPosition(jd.literalTags, line, column)) != -1) { - return Pair.create(JD_LITERAL_TAG, jd.literalTags.get(index)); - } - - if((index = containsStartPosition(jd.literalTexts, line, column)) != -1) { - return Pair.create(JD_LITERAL_TEXT, jd.literalTexts.get(index)); - } - - if((index = containsStartPosition(jd.paramTags, line, column)) != -1) { - return Pair.create(JD_PARAM_TAG, jd.paramTags.get(index)); - } - - if((index = containsStartPosition(jd.paramNames, line, column)) != -1) { - return Pair.create(JD_PARAM_NAME, jd.paramNames.get(index)); - } - - if((index = containsStartPosition(jd.paramDescriptions, line, column)) != -1) { - return Pair.create(JD_PARAM_DESCRIPTION, jd.paramDescriptions.get(index)); - } - - if((index = containsStartPosition(jd.providesTags, line, column)) != -1) { - return Pair.create(JD_PROVIDES_TAG, jd.providesTags.get(index)); - } - - if((index = containsStartPosition(jd.providesDescriptions, line, column)) != -1) { - return Pair.create(JD_PROVIDES_DESCRIPTION, jd.providesDescriptions.get(index)); - } - - if((index = containsStartPosition(jd.providesServiceTypes, line, column)) != -1) { - return Pair.create(JD_PROVIDES_SERVICETYPE, jd.providesServiceTypes.get(index)); - } - - if((index = containsStartPosition(jd.returnTags, line, column)) != -1) { - return Pair.create(JD_RETURN_TAG, jd.returnTags.get(index)); - } - - if((index = containsStartPosition(jd.returnDescriptions, line, column)) != -1) { - return Pair.create(JD_RETURN_DESCRIPTION, jd.returnDescriptions.get(index)); - } - - if((index = containsStartPosition(jd.seeTags, line, column)) != -1) { - return Pair.create(JD_SEE_TAG, jd.seeTags.get(index)); - } - - if((index = containsStartPosition(jd.seeReferences, line, column)) != -1) { - return Pair.create(JD_SEE_REFERENCE, jd.seeReferences.get(index)); - } - - if((index = containsStartPosition(jd.serialDataTags, line, column)) != -1) { - return Pair.create(JD_SERIALDATA_TAG, jd.serialDataTags.get(index)); - } - - if((index = containsStartPosition(jd.serialDataDescriptions, line, column)) != -1) { - return Pair.create(JD_SERIALDATA_DESCRIPTION, jd.serialDataDescriptions.get(index)); - } - - if((index = containsStartPosition(jd.serialTags, line, column)) != -1) { - return Pair.create(JD_SERIAL_TAG, jd.serialTags.get(index)); - } - - if((index = containsStartPosition(jd.sinceTags, line, column)) != -1) { - return Pair.create(JD_SINCE_TAG, jd.sinceTags.get(index)); - } - - if((index = containsStartPosition(jd.sinceBodies, line, column)) != -1) { - return Pair.create(JD_SINCE_BODY, jd.sinceBodies.get(index)); - } - - if((index = containsStartPosition(jd.summaryTags, line, column)) != -1) { - return Pair.create(JD_SUMMARY_TAG, jd.summaryTags.get(index)); - } - - if((index = containsStartPosition(jd.summaryMessages, line, column)) != -1) { - return Pair.create(JD_SUMMARY_MESSAGE, jd.summaryMessages.get(index)); - } - - if((index = containsStartPosition(jd.throwsTags, line, column)) != -1) { - return Pair.create(JD_THROWS_TAG, jd.throwsTags.get(index)); - } - - if((index = containsStartPosition(jd.throwsNames, line, column)) != -1) { - return Pair.create(JD_THROWS_NAME, jd.throwsNames.get(index)); - } - - if((index = containsStartPosition(jd.throwsDescriptions, line, column)) != -1) { - return Pair.create(JD_THROWS_DESCRIPTION, jd.throwsDescriptions.get(index)); - } - - if((index = containsStartPosition(jd.usesTags, line, column)) != -1) { - return Pair.create(JD_USES_TAG, jd.usesTags.get(index)); - } - - if((index = containsStartPosition(jd.usesDescriptions, line, column)) != -1) { - return Pair.create(JD_USES_DESCRIPTION, jd.usesDescriptions.get(index)); - } - - if((index = containsStartPosition(jd.usesServiceTypes, line, column)) != -1) { - return Pair.create(JD_USES_SERVICETYPE, jd.usesServiceTypes.get(index)); - } - - if((index = containsStartPosition(jd.valueTags, line, column)) != -1) { - return Pair.create(JD_VALUE_TAG, jd.valueTags.get(index)); - } - - if((index = containsStartPosition(jd.valueReferences, line, column)) != -1) { - return Pair.create(JD_VALUE_REFERENCE, jd.valueReferences.get(index)); - } - - if((index = containsStartPosition(jd.versionTags, line, column)) != -1) { - return Pair.create(JD_VERSION_TAG, jd.versionTags.get(index)); - } - - if((index = containsStartPosition(jd.versionBodies, line, column)) != -1) { - return Pair.create(JD_VERSION_BODY, jd.versionBodies.get(index)); - } - - if((index = containsStartPosition(jd.unknownTags, line, column)) != -1) { - return Pair.create(JD_UNKNOWN_BLOCKTAG, jd.unknownTags.get(index)); - } - - if((index = containsStartPosition(jd.unknownTagContents, line, column)) != -1) { - return Pair.create(JD_UNKNOWN_BLOCKTAG_CONTENT, jd.unknownTagContents.get(index)); - } - - if((index = containsStartPosition(jd.unknownInlineTags, line, column)) != -1) { - return Pair.create(JD_UNKNOWN_INLINETAG, jd.unknownInlineTags.get(index)); - } - - if((index = containsStartPosition(jd.unknownInlineTagContents, line, column)) != -1) { - return Pair.create(JD_UNKNOWN_INLINETAG_CONTENT, jd.unknownInlineTagContents.get(index)); - } - - return Pair.create(HighlightRangeHelper.NOT_FOUND, null); - } - - private int containsStartPosition (List ranges, int line, int column) { - int index = LSPUtils.binarySearchStartPosition(ranges, line, column); - if(index >= 0 && index < ranges.size()) { - return index; - } - - return -1; + sortHighlights(LSPUtils.RANGE_START_COMPARATOR); } public boolean isEnumType(int line, int column) { @@ -358,4 +143,35 @@ public class HighlightRangeHelper { } return false; } + + public void sortHighlights(Comparator comparator) { + final SemanticHighlight h = this.highlights; + sortAll(comparator, + + // Semantic highlights + h.packages, + h.enumTypes, + h.classNames, + h.annotationTypes, + h.interfaces, + h.enums, + h.statics, + h.fields, + h.parameters, + h.locals, + h.exceptionParams, + h.methodDeclarations, + h.methodInvocations, + h.constructors, + h.staticInits, + h.instanceInits, + h.typeParams, + h.resourceVariables); + } + + private void sortAll (Comparator comparator, List... lists) { + for (List list : lists) { + Collections.sort(list, comparator); + } + } } diff --git a/app/src/main/java/com/itsaky/androidide/syntax/lexer/impls/java/JavaLexerImpl.java b/app/src/main/java/com/itsaky/androidide/syntax/lexer/impls/java/JavaLexerImpl.java index b287b319a..f86d6940a 100644 --- a/app/src/main/java/com/itsaky/androidide/syntax/lexer/impls/java/JavaLexerImpl.java +++ b/app/src/main/java/com/itsaky/androidide/syntax/lexer/impls/java/JavaLexerImpl.java @@ -1,8 +1,6 @@ /************************************************************************************ * This file is part of AndroidIDE. - * - * - * + * * AndroidIDE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -17,10 +15,8 @@ * along with AndroidIDE. If not, see . * **************************************************************************************/ - package com.itsaky.androidide.syntax.lexer.impls.java; -import androidx.core.util.Pair; import com.itsaky.androidide.lexers.java.JavaLexer; import com.itsaky.androidide.models.ConstantsBridge; import com.itsaky.androidide.syntax.lexer.Lexer; @@ -31,12 +27,12 @@ import com.itsaky.androidide.utils.LSPUtils; import com.itsaky.androidide.utils.Logger; import com.itsaky.lsp.SemanticHighlight; import com.itsaky.lsp.services.IDELanguageServer; +import io.github.rosemoe.editor.interfaces.EditorLanguage; import io.github.rosemoe.editor.interfaces.NewlineHandler; import io.github.rosemoe.editor.struct.BlockLine; import io.github.rosemoe.editor.struct.Span; import io.github.rosemoe.editor.text.CharPosition; import io.github.rosemoe.editor.text.Content; -import io.github.rosemoe.editor.text.Indexer; import io.github.rosemoe.editor.text.TextAnalyzeResult; import io.github.rosemoe.editor.text.TextAnalyzer; import io.github.rosemoe.editor.text.TextUtils; @@ -53,7 +49,6 @@ import org.antlr.v4.runtime.CharStreams; import org.eclipse.lsp4j.Diagnostic; import org.eclipse.lsp4j.Position; import org.eclipse.lsp4j.Range; -import io.github.rosemoe.editor.interfaces.EditorLanguage; public class JavaLexerImpl extends io.github.rosemoe.editor.langs.AbstractCodeAnalyzer { @@ -392,77 +387,6 @@ public class JavaLexerImpl extends io.github.rosemoe.editor.langs.AbstractCodeAn wasClassName = true; break; case JavaLexer.BLOCK_COMMENT : - - /** - * Comment span must be initially added to - * highlight '/**' and starting comment text as a comment. - */ - type = TokenType.COMMENT; - span = colors.addIfNeeded(line, column, EditorColorScheme.COMMENT); - wasClassName = false; - - final Indexer indexer = content.getIndexer(); - final CharPosition endPos = indexer.getCharPosition(currentToken.getStopIndex()); - - final Position startPosition = new Position(line, column); - final Position endPosition = new Position(endPos.line, endPos.column); - colors.addCommentRange(line, new Range(startPosition, endPosition)); - - int l = line; - int c = column; - - int el = -1; - int ec = -1; - - try { - scan_comment: while (helper != null) { - if(l == endPos.line && c == endPos.column) { - // Reached end of comment - // Nothing to search for - break scan_comment; - } - - final Pair result = helper.findJavadocColorSchemeId(l, c); - final int colorId = result.first; - final Range range = result.second; - if(colorId != HighlightRangeHelper.NOT_FOUND) { - - // We found a valid start position of a JavaDoc element - // Add it to the scheme - colors.addIfNeeded(l, c, colorId); - - // Store end line and column - el = range.getEnd().getLine(); - ec = range.getEnd().getCharacter(); - - if(el >= content.getLineCount()) { - break scan_comment; - } - - // Skip to the end line and column - l = el; - c = ec; - - // Again add the normal comment highlight - // After the javadoc element - if(ec >= content.getColumnCount(el)) { - el ++; - ec = 0; - } - - colors.addIfNeeded(el, ec, EditorColorScheme.COMMENT); - } - - c ++; - if(c >= content.getColumnCount(l)) { - l ++; - c = 0; - } - } - } catch (Throwable th) { - } - - break; case JavaLexer.LINE_COMMENT : type = TokenType.COMMENT; span = colors.addIfNeeded(line, column, EditorColorScheme.COMMENT); diff --git a/app/src/main/java/com/itsaky/androidide/utils/InputStreamWriter.java b/app/src/main/java/com/itsaky/androidide/utils/InputStreamWriter.java index 7c95e881f..c065cb21e 100644 --- a/app/src/main/java/com/itsaky/androidide/utils/InputStreamWriter.java +++ b/app/src/main/java/com/itsaky/androidide/utils/InputStreamWriter.java @@ -51,12 +51,12 @@ public class InputStreamWriter implements Runnable { try { final BufferedReader reader = new BufferedReader (new InputStreamReader (in)); while (true) { - final int data = reader.read(); - if (data == -1) { + final String data = reader.readLine(); + if (data == null) { break; } - os.write(data); + os.write(data.concat("\n").getBytes()); os.flush(); } } catch (Throwable th) { diff --git a/lsp/src/main/java/com/itsaky/lsp/JavadocHighlights.java b/lsp/src/main/java/com/itsaky/lsp/JavadocHighlights.java deleted file mode 100644 index 143862d2c..000000000 --- a/lsp/src/main/java/com/itsaky/lsp/JavadocHighlights.java +++ /dev/null @@ -1,162 +0,0 @@ -/************************************************************************************ - * This file is part of AndroidIDE. - * - * - * - * AndroidIDE is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * AndroidIDE is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with AndroidIDE. If not, see . - * -**************************************************************************************/ -package com.itsaky.lsp; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import org.eclipse.lsp4j.Range; - -public class JavadocHighlights { - - public final List - - authorTags = new ArrayList<>(), - authorNames = new ArrayList<>(), - - deprecatedTags = new ArrayList<>(), - deprecatedMessages = new ArrayList<>(), - - docrootTags = new ArrayList<>(), - - hiddenTags = new ArrayList<>(), - hiddenMessages = new ArrayList<>(), - - indexTags = new ArrayList<>(), - indexDescriptions = new ArrayList<>(), - indexSearchTerms = new ArrayList<>(), - - inheritDocTags = new ArrayList<>(), - - linkTags = new ArrayList<>(), - linkLabels = new ArrayList<>(), - linkReferences = new ArrayList<>(), - - literalTags = new ArrayList<>(), - literalTexts = new ArrayList<>(), - - paramTags = new ArrayList<>(), - paramNames = new ArrayList<>(), - paramDescriptions = new ArrayList<>(), - - providesTags = new ArrayList<>(), - providesServiceTypes = new ArrayList<>(), - providesDescriptions = new ArrayList<>(), - - returnTags = new ArrayList<>(), - returnDescriptions = new ArrayList<>(), - - seeTags = new ArrayList<>(), - seeReferences = new ArrayList<>(), - - serialDataTags = new ArrayList<>(), - serialDataDescriptions = new ArrayList<>(), - - serialTags = new ArrayList<>(), - - sinceTags = new ArrayList<>(), - sinceBodies = new ArrayList<>(), - - summaryTags = new ArrayList<>(), - summaryMessages = new ArrayList<>(), - - throwsTags = new ArrayList<>(), - throwsDescriptions = new ArrayList<>(), - throwsNames = new ArrayList<>(), - - usesTags = new ArrayList<>(), - usesDescriptions = new ArrayList<>(), - usesServiceTypes = new ArrayList<>(), - - valueTags = new ArrayList<>(), - valueReferences = new ArrayList<>(), - - versionTags = new ArrayList<>(), - versionBodies = new ArrayList<>(), - - unknownTags = new ArrayList<>(), - unknownTagContents = new ArrayList<>(), - - unknownInlineTags = new ArrayList<>(), - unknownInlineTagContents = new ArrayList<>(); - - public void sort(Comparator comparator) { - sortAll(comparator, asArray()); - } - - public List[] asArray () { - return new List[] { - authorTags, - authorNames, - deprecatedTags, - deprecatedMessages, - docrootTags, - hiddenTags, - hiddenMessages, - indexTags, - indexSearchTerms, - inheritDocTags, - inheritDocTags, - linkTags, - linkLabels, - linkReferences, - literalTags, - literalTexts, - paramTags, - paramNames, - paramDescriptions, - providesTags, - providesDescriptions, - providesServiceTypes, - returnTags, - returnDescriptions, - seeTags, - seeReferences, - serialDataTags, - serialDataDescriptions, - serialTags, - sinceTags, - sinceBodies, - summaryTags, - summaryMessages, - throwsTags, - throwsNames, - throwsDescriptions, - usesTags, - usesDescriptions, - usesServiceTypes, - valueTags, - valueReferences, - versionTags, - versionBodies, - unknownTags, - unknownTagContents, - unknownInlineTags, - unknownInlineTagContents - }; - } - - private void sortAll (Comparator comparator, List... lists) { - for (List list : lists) { - Collections.sort(list, comparator); - } - } -} diff --git a/lsp/src/main/java/com/itsaky/lsp/SemanticHighlight.java b/lsp/src/main/java/com/itsaky/lsp/SemanticHighlight.java index 1bcc57e3a..631459ba4 100644 --- a/lsp/src/main/java/com/itsaky/lsp/SemanticHighlight.java +++ b/lsp/src/main/java/com/itsaky/lsp/SemanticHighlight.java @@ -1,27 +1,23 @@ /************************************************************************************ - * This file is part of AndroidIDE. - * - * - * - * AndroidIDE is free software: you can redistribute it and/or modify + * This file is part of Java Language Server (https://github.com/itsaky/java-language-server) + * + * Java Language Server is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * AndroidIDE is distributed in the hope that it will be useful, + * Java Language Server is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with AndroidIDE. If not, see . + * along with Java Language Server. If not, see . * **************************************************************************************/ package com.itsaky.lsp; import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; import java.util.List; import org.eclipse.lsp4j.Range; @@ -48,38 +44,4 @@ public class SemanticHighlight { instanceInits = new ArrayList<>(), typeParams = new ArrayList<>(), resourceVariables = new ArrayList<>(); - - public final JavadocHighlights javadocs = new JavadocHighlights(); - - public void sort(Comparator comparator) { - sortAll(comparator, - - // Semantic highlights - packages, - enumTypes, - classNames, - annotationTypes, - interfaces, - enums, - statics, - fields, - parameters, - locals, - exceptionParams, - methodDeclarations, - methodInvocations, - constructors, - staticInits, - instanceInits, - typeParams, - resourceVariables); - - javadocs.sort(comparator); - } - - private void sortAll (Comparator comparator, List... lists) { - for (List list : lists) { - Collections.sort(list, comparator); - } - } } diff --git a/lsp/src/main/java/com/itsaky/lsp/SemanticHighlightsParams.java b/lsp/src/main/java/com/itsaky/lsp/SemanticHighlightsParams.java index 952cb0861..590b50841 100644 --- a/lsp/src/main/java/com/itsaky/lsp/SemanticHighlightsParams.java +++ b/lsp/src/main/java/com/itsaky/lsp/SemanticHighlightsParams.java @@ -1,22 +1,23 @@ /************************************************************************************ - * This file is part of AndroidIDE. + * This file is part of Java Language Server (https://github.com/itsaky/java-language-server) * - * + * Copyright (C) 2021 Akash Yadav * - * AndroidIDE is free software: you can redistribute it and/or modify + * Java Language Server is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * AndroidIDE is distributed in the hope that it will be useful, + * Java Language Server is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with AndroidIDE. If not, see . + * along with Java Language Server. If not, see . * **************************************************************************************/ + package com.itsaky.lsp; import org.eclipse.lsp4j.TextDocumentIdentifier; @@ -25,7 +26,6 @@ public class SemanticHighlightsParams { private TextDocumentIdentifier _textDocument; - public TextDocumentIdentifier getTextDocument() { return this._textDocument; } diff --git a/lsp/src/main/java/com/itsaky/lsp/services/IDELanguageClient.java b/lsp/src/main/java/com/itsaky/lsp/services/IDELanguageClient.java index 94bf206ba..8dad12ead 100644 --- a/lsp/src/main/java/com/itsaky/lsp/services/IDELanguageClient.java +++ b/lsp/src/main/java/com/itsaky/lsp/services/IDELanguageClient.java @@ -1,22 +1,23 @@ /************************************************************************************ - * This file is part of AndroidIDE. + * This file is part of Java Language Server (https://github.com/itsaky/java-language-server) * - * + * Copyright (C) 2021 Akash Yadav * - * AndroidIDE is free software: you can redistribute it and/or modify + * Java Language Server is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * AndroidIDE is distributed in the hope that it will be useful, + * Java Language Server is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with AndroidIDE. If not, see . + * along with Java Language Server. If not, see . * **************************************************************************************/ + package com.itsaky.lsp.services; import com.itsaky.lsp.SemanticHighlight; diff --git a/lsp/src/main/java/com/itsaky/lsp/services/IDELanguageClientAware.java b/lsp/src/main/java/com/itsaky/lsp/services/IDELanguageClientAware.java index 813f73b6b..c0930e816 100644 --- a/lsp/src/main/java/com/itsaky/lsp/services/IDELanguageClientAware.java +++ b/lsp/src/main/java/com/itsaky/lsp/services/IDELanguageClientAware.java @@ -1,22 +1,23 @@ /************************************************************************************ - * This file is part of AndroidIDE. + * This file is part of Java Language Server (https://github.com/itsaky/java-language-server) * - * + * Copyright (C) 2021 Akash Yadav * - * AndroidIDE is free software: you can redistribute it and/or modify + * Java Language Server is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * AndroidIDE is distributed in the hope that it will be useful, + * Java Language Server is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with AndroidIDE. If not, see . + * along with Java Language Server. If not, see . * **************************************************************************************/ + package com.itsaky.lsp.services; public interface IDELanguageClientAware { diff --git a/lsp/src/main/java/com/itsaky/lsp/services/IDELanguageServer.java b/lsp/src/main/java/com/itsaky/lsp/services/IDELanguageServer.java index 01c13be69..199945c7b 100644 --- a/lsp/src/main/java/com/itsaky/lsp/services/IDELanguageServer.java +++ b/lsp/src/main/java/com/itsaky/lsp/services/IDELanguageServer.java @@ -1,25 +1,27 @@ /************************************************************************************ - * This file is part of AndroidIDE. + * This file is part of Java Language Server (https://github.com/itsaky/java-language-server) * - * + * Copyright (C) 2021 Akash Yadav * - * AndroidIDE is free software: you can redistribute it and/or modify + * Java Language Server is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * AndroidIDE is distributed in the hope that it will be useful, + * Java Language Server is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with AndroidIDE. If not, see . + * along with Java Language Server. If not, see . * **************************************************************************************/ + package com.itsaky.lsp.services; import java.util.concurrent.CompletableFuture; + import org.eclipse.lsp4j.InitializeParams; import org.eclipse.lsp4j.InitializeResult; import org.eclipse.lsp4j.InitializedParams; @@ -31,7 +33,7 @@ import org.eclipse.lsp4j.jsonrpc.services.JsonRequest; /** * Custom implementation of {@link org.eclipse.lsp4j.services.LanguageServer}. - * This helps providing custom commands and services to AndroidIDE + * This helps providing custom commands and services to Java Language Server */ public interface IDELanguageServer { /** @@ -116,4 +118,4 @@ public interface IDELanguageServer { default void setTrace(SetTraceParams params) { throw new UnsupportedOperationException(); } -} +} \ No newline at end of file diff --git a/lsp/src/main/java/com/itsaky/lsp/services/IDETextDocumentService.java b/lsp/src/main/java/com/itsaky/lsp/services/IDETextDocumentService.java index e4c061a22..5af2a828e 100644 --- a/lsp/src/main/java/com/itsaky/lsp/services/IDETextDocumentService.java +++ b/lsp/src/main/java/com/itsaky/lsp/services/IDETextDocumentService.java @@ -1,25 +1,26 @@ /************************************************************************************ - * This file is part of AndroidIDE. + * This file is part of Java Language Server (https://github.com/itsaky/java-language-server) * - * + * Copyright (C) 2021 Akash Yadav * - * AndroidIDE is free software: you can redistribute it and/or modify + * Java Language Server is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * AndroidIDE is distributed in the hope that it will be useful, + * Java Language Server is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with AndroidIDE. If not, see . + * along with Java Language Server. If not, see . * **************************************************************************************/ + package com.itsaky.lsp.services; import org.eclipse.lsp4j.services.TextDocumentService; -public interface IDETextDocumentService extends TextDocumentService { -} +public interface IDETextDocumentService extends TextDocumentService{ +} \ No newline at end of file diff --git a/lsp/src/main/java/com/itsaky/lsp/services/IDEWorkspaceService.java b/lsp/src/main/java/com/itsaky/lsp/services/IDEWorkspaceService.java index 7adb7a596..1665e32d8 100644 --- a/lsp/src/main/java/com/itsaky/lsp/services/IDEWorkspaceService.java +++ b/lsp/src/main/java/com/itsaky/lsp/services/IDEWorkspaceService.java @@ -1,22 +1,23 @@ /************************************************************************************ - * This file is part of AndroidIDE. + * This file is part of Java Language Server (https://github.com/itsaky/java-language-server) * - * + * Copyright (C) 2021 Akash Yadav * - * AndroidIDE is free software: you can redistribute it and/or modify + * Java Language Server is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * AndroidIDE is distributed in the hope that it will be useful, + * Java Language Server is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with AndroidIDE. If not, see . + * along with Java Language Server. If not, see . * **************************************************************************************/ + package com.itsaky.lsp.services; import java.util.List; @@ -166,4 +167,4 @@ public interface IDEWorkspaceService { default void didDeleteFiles(DeleteFilesParams params) { throw new UnsupportedOperationException(); } -} +} \ No newline at end of file diff --git a/sdk-info/src/main/java/org/eclipse/jdt/core/Signature.java b/sdk-info/src/main/java/org/eclipse/jdt/core/Signature.java index b83958c61..e889038a0 100644 --- a/sdk-info/src/main/java/org/eclipse/jdt/core/Signature.java +++ b/sdk-info/src/main/java/org/eclipse/jdt/core/Signature.java @@ -1,22 +1,3 @@ -/************************************************************************************ - * This file is part of AndroidIDE. - * - * - * - * AndroidIDE is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * AndroidIDE is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with AndroidIDE. If not, see . - * -**************************************************************************************/ /******************************************************************************* * Copyright (c) 2000, 2019 IBM Corporation and others. * diff --git a/shell/src/main/java/com/itsaky/androidide/shell/CommonProcessExecutor.java b/shell/src/main/java/com/itsaky/androidide/shell/CommonProcessExecutor.java index 298052e07..4b9186f77 100644 --- a/shell/src/main/java/com/itsaky/androidide/shell/CommonProcessExecutor.java +++ b/shell/src/main/java/com/itsaky/androidide/shell/CommonProcessExecutor.java @@ -1,8 +1,6 @@ /************************************************************************************ * This file is part of AndroidIDE. * - * - * * AndroidIDE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -122,7 +120,7 @@ public class CommonProcessExecutor implements IProcessExecutor { try { proc.waitFor(); } catch (InterruptedException e) { - // ignored + // Ignored } listener.onExit(proc.exitValue()); diff --git a/shell/src/main/java/com/itsaky/androidide/shell/IProcessExecutor.java b/shell/src/main/java/com/itsaky/androidide/shell/IProcessExecutor.java index 17b11cfb1..1d30976f5 100644 --- a/shell/src/main/java/com/itsaky/androidide/shell/IProcessExecutor.java +++ b/shell/src/main/java/com/itsaky/androidide/shell/IProcessExecutor.java @@ -1,8 +1,6 @@ /************************************************************************************ * This file is part of AndroidIDE. - * - * - * + * * AndroidIDE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/shell/src/main/java/com/itsaky/androidide/shell/ProcessExecutorFactory.java b/shell/src/main/java/com/itsaky/androidide/shell/ProcessExecutorFactory.java index 1ebb70a2d..019840077 100644 --- a/shell/src/main/java/com/itsaky/androidide/shell/ProcessExecutorFactory.java +++ b/shell/src/main/java/com/itsaky/androidide/shell/ProcessExecutorFactory.java @@ -1,8 +1,6 @@ /************************************************************************************ * This file is part of AndroidIDE. * - * - * * AndroidIDE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -31,16 +29,4 @@ public class ProcessExecutorFactory { public static IProcessExecutor commonExecutor () { return executor; } - - public static int exec (ProcessStreamsHolder holder, String ... args) throws InterruptedException, IOException { - return executor.exec(holder, args); - } - - public static int exec (ProcessStreamsHolder holder, boolean redirectErr, String ... args) throws InterruptedException, IOException { - return executor.exec(holder, redirectErr, args); - } - - public static void execAsync (ProcessStreamsHolder holder, IProcessExitListener exitListener, boolean redirectErr, String ... args) throws IOException { - executor.execAsync(holder, exitListener, redirectErr, args); - } }