This repository has been archived by the owner on Jan 5, 2019. It is now read-only.
forked from emicklei/proto
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add inline comment for package. small refactoring
- Loading branch information
Ernest Micklei
authored and
Ernest Micklei
committed
Feb 7, 2017
1 parent
e62f83b
commit 29265cd
Showing
12 changed files
with
101 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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,37 @@ | ||
package proto | ||
|
||
import "fmt" | ||
|
||
// Package specifies the namespace for all proto elements. | ||
type Package struct { | ||
Name string | ||
} | ||
|
||
// Accept dispatches the call to the visitor. | ||
func (p *Package) Accept(v Visitor) { | ||
v.VisitPackage(p) | ||
Name string | ||
Comment *Comment | ||
} | ||
|
||
func (p *Package) parse(pr *Parser) error { | ||
tok, lit := pr.scanIgnoreWhitespace() | ||
if tIDENT != tok { | ||
return fmt.Errorf("found %q, expected identifier", lit) | ||
if !isKeyword(tok) { | ||
return pr.unexpected(lit, "package identifier", p) | ||
} | ||
} | ||
p.Name = lit | ||
return nil | ||
} | ||
|
||
// Accept dispatches the call to the visitor. | ||
func (p *Package) Accept(v Visitor) { | ||
v.VisitPackage(p) | ||
} | ||
|
||
// inlineComment is part of commentInliner. | ||
func (p *Package) inlineComment(c *Comment) { | ||
p.Comment = c | ||
} | ||
|
||
// columns returns printable source tokens | ||
func (p *Package) columns() (cols []aligned) { | ||
cols = append(cols, notAligned("package "), notAligned(p.Name), alignedSemicolon) | ||
if p.Comment != nil { | ||
cols = append(cols, notAligned(" //"), notAligned(p.Comment.Message)) | ||
} | ||
return | ||
} |
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
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