Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

[Bug]: App crashed #1127

Closed
2 tasks done
SoytanM opened this issue Jul 18, 2023 · 4 comments
Closed
2 tasks done

[Bug]: App crashed #1127

SoytanM opened this issue Jul 18, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@SoytanM
Copy link

SoytanM commented Jul 18, 2023

What happened?

The app is crashing when I am using overwrite super class method options.

What's the expected behavior?

Overwrite super class method

What version of AndroidIDE you're using?

v2.5.1 (debug builds)

Relevant log output

AndroidIDE crash report
Manufacturer: Xiaomi
Device: RedmiNote7Pro
ABI: arm64-v8a
SDK version: 29
App version: v2.5.1-beta (251)

 Stacktrace: 
java.lang.StringIndexOutOfBoundsException: Column 8 out of bounds. line: 133 , column count (line separator included):3
	at io.github.rosemoe.sora.text.Content.checkLineAndColumn(Unknown Source:44)
	at io.github.rosemoe.sora.text.Content.insertInternal(Unknown Source:6)
	at io.github.rosemoe.sora.text.Content.insert(Unknown Source:9)
	at com.itsaky.androidide.lsp.java.actions.generators.OverrideSuperclassMethodsAction$$ExternalSyntheticLambda0.run(Unknown Source:103)
	at android.os.Handler.handleCallback(Handler.java:883)
	at android.os.Handler.dispatchMessage(Handler.java:100)
	at android.os.Looper.loop(Looper.java:224)
	at android.app.ActivityThread.main(ActivityThread.java:7592)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

Duplicate issues

  • This issue has not been reported yet.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@SoytanM SoytanM added the bug Something isn't working label Jul 18, 2023
@itsaky
Copy link
Member

itsaky commented Jul 21, 2023

Hey there @SoytanM,

Can you tell me what method or methods are you trying to override? It would be helpful for me to reproduce this issue.

@SoytanM
Copy link
Author

SoytanM commented Jul 21, 2023

Watch this video

@itsaky
Copy link
Member

itsaky commented Jul 21, 2023

Thanks for the video. That was helpful.

itsaky added a commit that referenced this issue Jul 21, 2023
When the 'keepComments' flag is set, the compiler uses JavadocTokenizer for tokenizing the source code. While creating the LineMap instance, the JavadocTokenizer sets the 'expandTabs' flag to true which expands '\t' characters to spaces. This is needed while generating HTML pages for the Javadoc. However, if the tabs are expanded to spaces, then getPosition(...) and getColumnNumber(...) methods in the LineMap class return indices which cannot be directly used to insert text in the source code. This results in StringIndexOutOfBoundsException when trying to insert text in the editor (#1127, and probably #916 as well).

This commit adds the 'keepCommentsOverride' option to the compiler which is used by NBParserFactory to override the 'keepComments' flag. The CompileBatch class sets this option to 'ignore' which ignores the 'keepComments' flag so that JavadocTokenizer is not used for tokenization.
@itsaky
Copy link
Member

itsaky commented Jul 21, 2023

This has been fixed in 1e07da7.

@itsaky itsaky closed this as completed Jul 21, 2023
itsaky added a commit that referenced this issue Aug 5, 2023
When the 'keepComments' flag is set, the compiler uses JavadocTokenizer for tokenizing the source code. While creating the LineMap instance, the JavadocTokenizer sets the 'expandTabs' flag to true which expands '\t' characters to spaces. This is needed while generating HTML pages for the Javadoc. However, if the tabs are expanded to spaces, then getPosition(...) and getColumnNumber(...) methods in the LineMap class return indices which cannot be directly used to insert text in the source code. This results in StringIndexOutOfBoundsException when trying to insert text in the editor (#1127, and probably #916 as well).

This commit adds the 'keepCommentsOverride' option to the compiler which is used by NBParserFactory to override the 'keepComments' flag. The CompileBatch class sets this option to 'ignore' which ignores the 'keepComments' flag so that JavadocTokenizer is not used for tokenization.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants