mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
v1.0.2-alpha
- Cancel previous completion requests - Removed logging - Increased input connection's text handling limit - Fix invisible line number in wordwrap layout
This commit is contained in:
@@ -20,6 +20,7 @@ import com.itsaky.androidide.R;
|
||||
import com.itsaky.androidide.app.StudioApp;
|
||||
import com.itsaky.androidide.interfaces.LanguageServerListener;
|
||||
import com.itsaky.androidide.language.java.manager.JavaCharacter;
|
||||
import com.itsaky.androidide.language.java.server.JavaLanguageServer;
|
||||
import com.itsaky.androidide.language.xml.completion.XMLCompletionService;
|
||||
import com.itsaky.androidide.models.AndroidProject;
|
||||
import com.itsaky.androidide.models.ConstantsBridge;
|
||||
@@ -30,6 +31,7 @@ import com.itsaky.androidide.utils.Environment;
|
||||
import com.itsaky.androidide.utils.FileUtil;
|
||||
import com.itsaky.androidide.utils.PreferenceManager;
|
||||
import com.itsaky.androidide.utils.StudioUtils;
|
||||
import com.itsaky.lsp.LanguageClient;
|
||||
import com.itsaky.toaster.Toaster;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -37,15 +39,6 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import com.blankj.utilcode.util.ZipUtils;
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
import com.itsaky.androidide.language.java.server.JavaLanguageServer;
|
||||
import android.os.Handler;
|
||||
import com.itsaky.lsp.InitializeParams;
|
||||
import com.itsaky.lsp.DidChangeConfigurationParams;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.itsaky.lsp.LanguageClient;
|
||||
import net.lingala.zip4j.ZipFile;
|
||||
|
||||
public class StudioApp extends MultiDexApplication
|
||||
@@ -166,9 +159,7 @@ public class StudioApp extends MultiDexApplication
|
||||
if(!(gson && jls && proto)) {
|
||||
try {
|
||||
extractJls();
|
||||
} catch (Throwable e) {
|
||||
Logger.instance("StudioApp").e(ThrowableUtils.getFullStackTrace(e));
|
||||
}
|
||||
} catch (Throwable e) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,9 +170,7 @@ public class StudioApp extends MultiDexApplication
|
||||
ZipFile file = new ZipFile(jlsZip, ConstantsBridge.JLS_ZIP_PASSWORD_HASH.toCharArray());
|
||||
file.extractAll(Environment.JLS_HOME.getAbsolutePath());
|
||||
FileUtils.delete(jlsZip);
|
||||
} catch (Throwable th) {
|
||||
Logger.instance("UnzipJLS").e(ThrowableUtils.getFullStackTrace(th));
|
||||
}
|
||||
} catch (Throwable th) {}
|
||||
}
|
||||
|
||||
private boolean setupLibsIfNeeded() {
|
||||
|
||||
@@ -33,6 +33,7 @@ public class JavaAutoComplete implements AutoCompleteProvider {
|
||||
public List<Either<SuggestItem, CompletionItem>> getAutoCompleteItems(CodeEditor editor, String prefix, boolean isInCodeBlock, TextAnalyzeResult colors, int line) {
|
||||
final JavaLanguageServer server = StudioApp.getInstance().getJavaLanguageServer();
|
||||
if(server != null) {
|
||||
if(lastId != -1) server.cancelRequest(lastId);
|
||||
TextDocumentIdentifier id = new TextDocumentIdentifier();
|
||||
id.uri = editor.getFile().toURI();
|
||||
TextDocumentPositionParams p = new TextDocumentPositionParams();
|
||||
|
||||
+3
-6
@@ -1,5 +1,6 @@
|
||||
package com.itsaky.androidide.language.java.server;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import androidx.core.util.Pair;
|
||||
import com.blankj.utilcode.util.ThreadUtils;
|
||||
import com.blankj.utilcode.util.ThrowableUtils;
|
||||
@@ -7,12 +8,10 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.itsaky.androidide.app.StudioApp;
|
||||
import com.itsaky.androidide.models.AndroidProject;
|
||||
import com.itsaky.androidide.shell.ShellServer;
|
||||
import com.itsaky.androidide.utils.Environment;
|
||||
import com.itsaky.androidide.utils.FileUtil;
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
import com.itsaky.lsp.CancelParams;
|
||||
import com.itsaky.lsp.CodeActionParams;
|
||||
@@ -20,6 +19,7 @@ import com.itsaky.lsp.CompletionItem;
|
||||
import com.itsaky.lsp.CompletionList;
|
||||
import com.itsaky.lsp.DidChangeConfigurationParams;
|
||||
import com.itsaky.lsp.DidChangeTextDocumentParams;
|
||||
import com.itsaky.lsp.DidChangeWatchedFilesParams;
|
||||
import com.itsaky.lsp.DidCloseTextDocumentParams;
|
||||
import com.itsaky.lsp.DidOpenTextDocumentParams;
|
||||
import com.itsaky.lsp.DidSaveTextDocumentParams;
|
||||
@@ -31,12 +31,12 @@ import com.itsaky.lsp.JavaStartProgressParams;
|
||||
import com.itsaky.lsp.LanguageClient;
|
||||
import com.itsaky.lsp.Message;
|
||||
import com.itsaky.lsp.PublishDiagnosticsParams;
|
||||
import com.itsaky.lsp.SignatureHelp;
|
||||
import com.itsaky.lsp.TextDocumentPositionParams;
|
||||
import com.itsaky.lsp.TextEdit;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
@@ -46,9 +46,6 @@ import java.util.List;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import com.itsaky.lsp.DidChangeWatchedFilesParams;
|
||||
import com.itsaky.lsp.SignatureHelp;
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
public class JavaLanguageServer implements ShellServer.Callback {
|
||||
|
||||
|
||||
-1
@@ -21,7 +21,6 @@ import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
|
||||
public class XMLCompletionService {
|
||||
private HashMap<String, Attr> attrs;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.itsaky.androidide.models;
|
||||
|
||||
import com.blankj.utilcode.util.ThrowableUtils;
|
||||
import com.itsaky.androidide.app.StudioApp;
|
||||
import com.itsaky.androidide.language.java.manager.JavaCharacter;
|
||||
import com.itsaky.androidide.language.java.server.JavaLanguageServer;
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
import com.itsaky.lsp.CompletionItem;
|
||||
import com.itsaky.lsp.CompletionItemKind;
|
||||
import com.itsaky.lsp.Position;
|
||||
@@ -13,7 +12,6 @@ import com.itsaky.lsp.TextEdit;
|
||||
import io.github.rosemoe.editor.text.Cursor;
|
||||
import io.github.rosemoe.editor.widget.CodeEditor;
|
||||
import java.util.List;
|
||||
import com.itsaky.androidide.language.java.manager.JavaCharacter;
|
||||
|
||||
public class CompletionItemWrapper implements SuggestItem, Comparable {
|
||||
|
||||
@@ -96,9 +94,7 @@ public class CompletionItemWrapper implements SuggestItem, Comparable {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
Logger.instance("CompletionItemWrapper").e("onSelectThis, Error: ", ThrowableUtils.getFullStackTrace(th));
|
||||
}
|
||||
} catch (Throwable th) {}
|
||||
}
|
||||
|
||||
private void requestSignature(CodeEditor editor) {
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import com.itsaky.androidide.models.LogLine;
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package io.github.rosemoe.editor.text;
|
||||
|
||||
import android.util.Log;
|
||||
import io.github.rosemoe.editor.interfaces.EditorLanguage;
|
||||
import io.github.rosemoe.editor.util.IntPair;
|
||||
import java.util.List;
|
||||
@@ -300,9 +299,7 @@ public final class Cursor {
|
||||
String sub = line.substring(0, getLeftColumn());
|
||||
try {
|
||||
count += mLanguage.getIndentAdvance(sub);
|
||||
} catch (Exception e) {
|
||||
Log.w("EditorCursor", "Language object error", e);
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
StringBuilder sb = new StringBuilder(text);
|
||||
sb.insert(1, createIndent(count));
|
||||
text = sb;
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package io.github.rosemoe.editor.text;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
@@ -79,10 +77,7 @@ public class SpanRecycler {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.w(LOG_TAG, e);
|
||||
}
|
||||
Log.i(LOG_TAG, "Recycler exited");
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package io.github.rosemoe.editor.text;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.github.rosemoe.editor.interfaces.CodeAnalyzer;
|
||||
@@ -95,7 +93,6 @@ public class TextAnalyzer {
|
||||
public synchronized void analyze(Content origin) {
|
||||
AnalyzeThread thread = this.mThread;
|
||||
if (thread == null || !thread.isAlive()) {
|
||||
Log.d("TextAnalyzer", "Starting a new thread for analyzing");
|
||||
thread = this.mThread = new AnalyzeThread(mLock, mCodeAnalyzer, origin);
|
||||
thread.setName("TextAnalyzeDaemon-" + nextThreadId());
|
||||
thread.setDaemon(true);
|
||||
@@ -217,12 +214,10 @@ public class TextAnalyzer {
|
||||
lock.wait();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
Log.d("AnalyzeThread", "Analyze daemon is being interrupted -> Exit");
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
} catch (Exception ex) {
|
||||
Log.i("AnalyzeThread", "Analyze daemon got exception -> Exit", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.MutableInt;
|
||||
import android.util.TypedValue;
|
||||
import android.view.ActionMode;
|
||||
@@ -760,7 +759,6 @@ public class CodeEditor extends View implements ContentListener, TextAnalyzer.Ca
|
||||
}
|
||||
mLanguageSymbolPairs = mLanguage.getSymbolPairs();
|
||||
if (mLanguageSymbolPairs == null) {
|
||||
Log.w(LOG_TAG, "Language(" + mLanguage.toString() + ") returned null for symbol pairs. It is a mistake.");
|
||||
mLanguageSymbolPairs = new SymbolPairMatch();
|
||||
}
|
||||
mLanguageSymbolPairs.setParent(mOverrideSymbolPairs);
|
||||
@@ -991,7 +989,6 @@ public class CodeEditor extends View implements ContentListener, TextAnalyzer.Ca
|
||||
private void print() {
|
||||
double time = (System.nanoTime() - startClock) / 1e6;
|
||||
if (time > 3.0) {
|
||||
Log.d(LOG_TAG, "Fatal: drawView() used " + time + " ms");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1057,13 +1054,13 @@ public class CodeEditor extends View implements ContentListener, TextAnalyzer.Ca
|
||||
postDrawLineNumbers.clear();
|
||||
LongArrayList postDrawCurrentLines = new LongArrayList();
|
||||
List<CursorPaintAction> postDrawCursor = new ArrayList<>();
|
||||
MutableInt firstLn = isFirstLineNumberAlwaysVisible() ? new MutableInt(-1) : null;
|
||||
MutableInt firstLn = isFirstLineNumberAlwaysVisible() && isWordwrap() ? new MutableInt(-1) : null;
|
||||
|
||||
drawRows(canvas, textOffset, postDrawLineNumbers, postDrawCursor, postDrawCurrentLines, firstLn);
|
||||
|
||||
offsetX = -getOffsetX();
|
||||
|
||||
if (lineNumberNotPinned) {
|
||||
if (isLineNumberEnabled() && lineNumberNotPinned) {
|
||||
drawLineNumberBackground(canvas, offsetX, lineNumberWidth + mDividerMargin, color.getColor(EditorColorScheme.LINE_NUMBER_BACKGROUND));
|
||||
drawDivider(canvas, offsetX + lineNumberWidth + mDividerMargin, color.getColor(EditorColorScheme.LINE_DIVIDER));
|
||||
int lineNumberColor = mColors.getColor(EditorColorScheme.LINE_NUMBER);
|
||||
@@ -3129,7 +3126,6 @@ public class CodeEditor extends View implements ContentListener, TextAnalyzer.Ca
|
||||
mPaint.setTypeface(typefaceText);
|
||||
mFontCache.clearCache();
|
||||
if (2 * mPaint.measureText("/") != mPaint.measureText("//")) {
|
||||
Log.w(LOG_TAG, "Font issue:Your font is painting '/' and '//' differently, which will cause the editor to render slowly than other fonts.");
|
||||
mCharPaint = true;
|
||||
} else {
|
||||
mCharPaint = false;
|
||||
@@ -3574,7 +3570,6 @@ public class CodeEditor extends View implements ContentListener, TextAnalyzer.Ca
|
||||
|
||||
if (start > end) {
|
||||
setSelectionRegion(lineRight, columnRight, lineLeft, columnLeft, makeRightVisible);
|
||||
Log.w(LOG_TAG, "setSelectionRegion() error: start > end:start = " + start + " end = " + end + " lineLeft = " + lineLeft + " columnLeft = " + columnLeft + " lineRight = " + lineRight + " columnRight = " + columnRight);
|
||||
return;
|
||||
}
|
||||
boolean lastState = mCursor.isSelected();
|
||||
@@ -4202,7 +4197,6 @@ public class CodeEditor extends View implements ContentListener, TextAnalyzer.Ca
|
||||
continue;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.w(LOG_TAG, "Error occurred while calling Language's NewlineHandler", e);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -4342,9 +4336,7 @@ public class CodeEditor extends View implements ContentListener, TextAnalyzer.Ca
|
||||
heightMeasureSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.EXACTLY);
|
||||
warn = true;
|
||||
}
|
||||
if (warn) {
|
||||
Log.i(LOG_TAG, "onMeasure():Code editor does not support wrap_content mode when measuring.It will just fill the whole space.");
|
||||
}
|
||||
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ import android.os.SystemClock;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.KeyCharacterMap;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.inputmethod.BaseInputConnection;
|
||||
@@ -38,7 +37,7 @@ import io.github.rosemoe.editor.text.Cursor;
|
||||
class EditorInputConnection extends BaseInputConnection {
|
||||
|
||||
private final static String LOG_TAG = "EditorInputConnection";
|
||||
final static int TEXT_LENGTH_LIMIT = 1000000;
|
||||
final static int TEXT_LENGTH_LIMIT = 10000000;
|
||||
|
||||
private final CodeEditor mEditor;
|
||||
protected int mComposingLine = -1;
|
||||
@@ -157,7 +156,6 @@ class EditorInputConnection extends BaseInputConnection {
|
||||
try {
|
||||
return getTextRegionInternal(start, end, flags);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
Log.w(LOG_TAG, "Failed to get text region for IME", e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -467,7 +465,6 @@ class EditorInputConnection extends BaseInputConnection {
|
||||
mComposingEnd = endPos.column;
|
||||
mEditor.invalidate();
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
Log.w(LOG_TAG, "set composing region for IME failed", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -17,7 +17,6 @@ package io.github.rosemoe.editor.widget;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.RectF;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
@@ -19,7 +19,6 @@ import android.annotation.SuppressLint;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
@@ -181,7 +180,6 @@ public class TextActionPopupWindow extends TextComposeBasePopup implements View.
|
||||
int panelX = (int) ((handleLeftX + handleRightX) / 2f);
|
||||
panel.setExtendedX(mDpUnit * 28);
|
||||
panel.setExtendedY(panelY);
|
||||
Log.d("onTextSelectionEnd", "panelX: " + panelX + ", panelY: " + panelY);
|
||||
panel.show();
|
||||
mContainer.requestFocus();
|
||||
//mSelectAll.clearFocus();
|
||||
|
||||
Reference in New Issue
Block a user