summaryrefslogtreecommitdiff
path: root/protoReformat.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-03-27 17:18:00 -0500
committerJeff Carr <[email protected]>2025-03-27 17:18:00 -0500
commitbdc2e4fadf75f08f6d44fa984ea4d3d78f9dede2 (patch)
treee934c120150563cfe2573ebbe9648e903ab1504f /protoReformat.go
parentfb881df443918a6c5d271af691759adb7c0afa9e (diff)
general updates
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)
+ })
+}