summaryrefslogtreecommitdiff
path: root/protoReformat.go
diff options
context:
space:
mode:
Diffstat (limited to 'protoReformat.go')
-rw-r--r--protoReformat.go25
1 files changed, 22 insertions, 3 deletions
diff --git a/protoReformat.go b/protoReformat.go
index 5cd685d..962e7b2 100644
--- a/protoReformat.go
+++ b/protoReformat.go
@@ -54,6 +54,8 @@ func protoReformatComments(filename string) error {
}
var newfile string
+ newfile = commentPreprocessorFull(string(data))
+ saveFile(filename, newfile)
log.Info("filename", filename)
alltest := makeLineIter(data)
@@ -61,7 +63,8 @@ func protoReformatComments(filename string) error {
for line := range alltest {
newfile += fmt.Sprintln(commentPreprocessor(line))
}
- saveFile(filename, newfile)
+ newfile = commentPreprocessorFull(newfile)
+ // saveFile(filename, newfile)
return nil
}
@@ -488,9 +491,8 @@ func (it *LinesScanner) Next() string {
// END DEFINE THE ITERATOR
// turns: "/* test */ reserved /* linkPreviews */ 4;"
-// into:
+// into: reserved 1; // test // linkPreviews
func commentPreprocessor(line string) string {
-
// Match all /* comment */ blocks
re := regexp.MustCompile(`/\*([^*]+)\*/`)
matches := re.FindAllStringSubmatch(line, -1)
@@ -514,3 +516,20 @@ func commentPreprocessor(line string) string {
return line
}
+
+// /* this
+// - thing
+// */
+//
+// becomes
+//
+// this
+// thing
+func commentPreprocessorFull(full string) string {
+ // Match all /* comment */ blocks
+ re := regexp.MustCompile(`/\*([^*]+)\*/`)
+
+ return re.ReplaceAllStringFunc(full, func(s string) string {
+ return strings.ToUpper(s)
+ })
+}