-
-
Notifications
You must be signed in to change notification settings - Fork 394
Unreachable Code #6960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Unreachable Code #6960
Changes from 5 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
816e29e
Add a warning for unreachable code
UnderscoreTud ff6c45b
Clean up EffSuppressWarnings and add the ability to disable the unrea…
UnderscoreTud a091a6c
Add comments
UnderscoreTud 21bca9b
Requested Changes
UnderscoreTud e38462f
Merge branch 'dev/feature' into feature/unreachable-code-warning
sovdeeth 849cbd7
Generify compareTo method
UnderscoreTud 1562983
Add docs to ExecutionIntent
UnderscoreTud 18591ad
Fix lines using spaces instead of tabs for indentation (unsure how th…
UnderscoreTud fc14b86
Add ExecutionIntent to EffContinue, and fix its toString
UnderscoreTud 065c5c8
Improve SecLoop's intent detection
UnderscoreTud c1bf355
Merge branch 'dev/feature' into feature/unreachable-code-warning
UnderscoreTud 8a51732
Use instanceof pattern matching
UnderscoreTud cd80a39
Use MoreObject.toStringHelper
UnderscoreTud 0ab6a00
Replace all space indentations with tabs
UnderscoreTud ce79b11
Add simple helper methods for getting relative sections
UnderscoreTud 501253d
Add comments to SecLoop#guaranteedToLoop
UnderscoreTud 3afdbb6
Capitalize the 'C' in EffExit's errors
UnderscoreTud b6e7f01
Return a copy of the sections list rather than a view in the section …
UnderscoreTud 245d1e5
Make EffContinue's and EffExit's patterns stricter
UnderscoreTud 666f94c
Fix ArrayOutOfBoundsException when using Section.getSections of a typ…
UnderscoreTud 79fcc25
Update javadocs
UnderscoreTud e6e6000
Merge branch 'dev/feature' into feature/unreachable-code-warning
UnderscoreTud 3fea368
Requested Changes
UnderscoreTud 79074af
Update src/main/java/ch/njol/skript/sections/SecConditional.java
UnderscoreTud fd3d93d
Merge branch 'dev/feature' into feature/unreachable-code-warning
sovdeeth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package ch.njol.skript.lang; | ||
|
||
import com.google.common.base.Preconditions; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* Used to describe the intention of a {@link TriggerItem}. | ||
* Currently only used to tell whether the item halts the execution or not and print the appropriate warnings. | ||
* | ||
* @see TriggerItem#executionIntent() | ||
*/ | ||
public sealed interface ExecutionIntent extends Comparable<ExecutionIntent> | ||
permits ExecutionIntent.StopTrigger, ExecutionIntent.StopSections { | ||
|
||
static StopTrigger stopTrigger() { | ||
return new StopTrigger(); | ||
} | ||
|
||
static StopSections stopSections(int levels) { | ||
Preconditions.checkArgument(levels > 0, "Depth must be at least 1"); | ||
return new StopSections(levels); | ||
} | ||
|
||
static StopSections stopSection() { | ||
return new StopSections(1); | ||
} | ||
UnderscoreTud marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@Nullable ExecutionIntent use(); | ||
|
||
final class StopTrigger implements ExecutionIntent { | ||
UnderscoreTud marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
private StopTrigger() {} | ||
|
||
@Override | ||
public StopTrigger use() { | ||
return new StopTrigger(); | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("ComparatorMethodParameterNotUsed") | ||
public int compareTo(@NotNull ExecutionIntent other) { | ||
return other instanceof StopTrigger ? 0 : 1; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "StopTrigger"; | ||
} | ||
|
||
} | ||
|
||
record StopSections(int levels) implements ExecutionIntent { | ||
|
||
public @Nullable ExecutionIntent.StopSections use() { | ||
return levels > 1 ? new StopSections(levels - 1) : null; | ||
} | ||
|
||
@Override | ||
public int compareTo(@NotNull ExecutionIntent other) { | ||
if (other instanceof StopTrigger) | ||
return -1; | ||
UnderscoreTud marked this conversation as resolved.
Show resolved
Hide resolved
|
||
int levels = ((StopSections) other).levels; | ||
return Integer.compare(this.levels, levels); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.