-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support direct use completions, absolute shape ids
This commit makes it so you can manually type out a use statement, and get completions for the absolute shape id. It also adds support for completion/definition/hover for absolute shape ids in general.
- Loading branch information
1 parent
d9f82f9
commit cfe22db
Showing
9 changed files
with
436 additions
and
84 deletions.
There are no files selected for viewing
This file contains 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
72 changes: 72 additions & 0 deletions
72
src/main/java/software/amazon/smithy/lsp/document/DocumentId.java
This file contains 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,72 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.smithy.lsp.document; | ||
|
||
import java.nio.CharBuffer; | ||
import org.eclipse.lsp4j.Range; | ||
|
||
/** | ||
* An inaccurate representation of an identifier within a model. It is | ||
* inaccurate in the sense that the string value it references isn't | ||
* necessarily a valid identifier, it just looks like an identifier. | ||
*/ | ||
public final class DocumentId { | ||
/** | ||
* Represents the different kinds of identifiers that can be used to match. | ||
*/ | ||
public enum Type { | ||
/** | ||
* Just a shape name, no namespace or member. | ||
*/ | ||
ID, | ||
|
||
/** | ||
* Same as {@link Type#ID}, but with a namespace. | ||
*/ | ||
ABSOLUTE_ID, | ||
|
||
/** | ||
* Just a namespace - will have one or more {@code .}. | ||
*/ | ||
NAMESPACE, | ||
|
||
/** | ||
* Same as {@link Type#ABSOLUTE_ID}, but with a member - will have a {@code $}. | ||
*/ | ||
ABSOLUTE_WITH_MEMBER, | ||
|
||
/** | ||
* Same as {@link Type#ID}, but with a member - will have a {@code $}. | ||
*/ | ||
RELATIVE_WITH_MEMBER; | ||
} | ||
|
||
private final Type type; | ||
private final CharBuffer buffer; | ||
private final Range range; | ||
|
||
DocumentId(Type type, CharBuffer buffer, Range range) { | ||
this.type = type; | ||
this.buffer = buffer; | ||
this.range = range; | ||
} | ||
|
||
public Type getType() { | ||
return type; | ||
} | ||
|
||
public String copyIdValue() { | ||
return buffer.toString(); | ||
} | ||
|
||
public CharBuffer borrowIdValue() { | ||
return buffer; | ||
} | ||
|
||
public Range getRange() { | ||
return range; | ||
} | ||
} |
This file contains 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 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.