-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the declaration type and identifier parsing code into the shared…
… ddm pacakge
- Loading branch information
1 parent
da651c7
commit 3ebc4a0
Showing
3 changed files
with
24 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package ddm | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
// ParseDeclarationPath parses path to separate out the declaration type and identifier. | ||
// Typically this will be a "a/b" path where "a" is the type and and "b" | ||
// is the declaration. | ||
func ParseDeclarationPath(path string) (string, string, error) { | ||
split := strings.SplitN(path, "/", 2) | ||
if len(split) != 2 { | ||
return "", "", fmt.Errorf("invalid path element count: %d", len(split)) | ||
} | ||
if split[0] == "" || split[1] == "" { | ||
return "", "", errors.New("empty type or identifier path elements") | ||
} | ||
return split[0], split[1], nil | ||
} |
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