-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from pherrymason/error-diagnostics
Reporting error diagnostics by using `c3c build --test`
- Loading branch information
Showing
23 changed files
with
329 additions
and
180 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,3 @@ | ||
{ | ||
"makefile.configureOnOpen": false | ||
} |
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"runtime/debug" | ||
"time" | ||
|
||
"github.com/pherrymason/c3-lsp/internal/lsp/server" | ||
"github.com/pherrymason/c3-lsp/pkg/option" | ||
) | ||
|
||
func cmdLineArguments() (server.ServerOpts, bool) { | ||
var showHelp = flag.Bool("help", false, "Shows this help") | ||
var sendCrashReports = flag.Bool("send-crash-reports", false, "Automatically reports crashes to server.") | ||
|
||
var logFilePath = flag.String("log-path", "", "Enables logs and sets its filepath") | ||
var debug = flag.Bool("debug", false, "Enables debug mode") | ||
|
||
var c3Version = flag.String("lang-version", "", "Specify C3 language version.") | ||
var c3cPath = flag.String("c3c-path", "", "Path where c3c is located.") | ||
var diagnosticsDelay = flag.Int("diagnostics-delay", 2000, "Delay calculation of code diagnostics after modifications in source. In milliseconds, default 2000 ms.") | ||
|
||
flag.Parse() | ||
|
||
c3VersionOpt := option.None[string]() | ||
if *c3Version != "" { | ||
c3VersionOpt = option.Some(*c3Version) | ||
} | ||
c3cPathOpt := option.None[string]() | ||
if *c3cPath != "" { | ||
c3cPathOpt = option.Some(*c3cPath) | ||
} | ||
logFilePathOpt := option.None[string]() | ||
if *logFilePath != "" { | ||
logFilePathOpt = option.Some(*logFilePath) | ||
} | ||
|
||
return server.ServerOpts{ | ||
C3Version: c3VersionOpt, | ||
C3CPath: c3cPathOpt, | ||
DiagnosticsDelay: time.Duration(*diagnosticsDelay), | ||
DiagnosticsEnabled: true, | ||
LogFilepath: logFilePathOpt, | ||
Debug: *debug, | ||
SendCrashReports: *sendCrashReports, | ||
}, *showHelp | ||
} | ||
|
||
func printAppGreet(appName string, version string, commit string) { | ||
fmt.Printf("%s version %s (%s)\n", appName, version, commit) | ||
} | ||
|
||
func printHelp(appName string, version string, commit string) { | ||
printAppGreet(appName, version, commit) | ||
|
||
fmt.Println("\nOptions") | ||
flag.PrintDefaults() | ||
} | ||
|
||
func buildInfo() string { | ||
var Commit = func() string { | ||
if info, ok := debug.ReadBuildInfo(); ok { | ||
for _, setting := range info.Settings { | ||
if setting.Key == "vcs.revision" { | ||
return setting.Value | ||
} | ||
} | ||
} | ||
|
||
return "" | ||
}() | ||
|
||
return Commit | ||
} |
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 |
---|---|---|
|
@@ -3,17 +3,14 @@ package main | |
import ( | ||
"fmt" | ||
"log" | ||
"runtime/debug" | ||
"time" | ||
|
||
"github.com/getsentry/sentry-go" | ||
"github.com/pherrymason/c3-lsp/internal/lsp" | ||
"github.com/pherrymason/c3-lsp/pkg/option" | ||
flag "github.com/spf13/pflag" | ||
"github.com/pherrymason/c3-lsp/internal/lsp/server" | ||
) | ||
|
||
const version = "0.1.1" | ||
const prerelease = false | ||
const version = "0.2.0" | ||
const prerelease = true | ||
const appName = "C3-LSP" | ||
|
||
func getVersion() string { | ||
|
@@ -25,15 +22,15 @@ func getVersion() string { | |
} | ||
|
||
func main() { | ||
options := cmdLineArguments() | ||
options, showHelp := cmdLineArguments() | ||
commitHash := buildInfo() | ||
if options.showHelp { | ||
if showHelp { | ||
printHelp(appName, getVersion(), commitHash) | ||
|
||
return | ||
} | ||
|
||
if options.sendCrashReports { | ||
if options.SendCrashReports { | ||
err := sentry.Init(sentry.ClientOptions{ | ||
Dsn: "https://[email protected]/4507278372110336", | ||
Release: fmt.Sprintf("c3.lsp@%s+%s", getVersion(), commitHash), | ||
|
@@ -49,79 +46,6 @@ func main() { | |
defer sentry.Recover() | ||
} | ||
|
||
c3Version := option.None[string]() | ||
if options.c3Version != "" { | ||
c3Version = option.Some(options.c3Version) | ||
} | ||
|
||
logFilePath := option.None[string]() | ||
if options.logFilePath != "" { | ||
logFilePath = option.Some(options.logFilePath) | ||
} | ||
|
||
server := lsp.NewServer(lsp.ServerOpts{ | ||
Name: appName, | ||
Version: version, | ||
C3Version: c3Version, | ||
LogFilepath: logFilePath, | ||
SendCrashReports: options.sendCrashReports, | ||
Debug: options.debug, | ||
}) | ||
server := server.NewServer(options, appName, version) | ||
server.Run() | ||
} | ||
|
||
type Options struct { | ||
showHelp bool | ||
c3Version string | ||
logFilePath string | ||
debug bool | ||
sendCrashReports bool | ||
} | ||
|
||
func cmdLineArguments() Options { | ||
var showHelp = flag.Bool("help", false, "Shows this help") | ||
|
||
var sendCrashReports = flag.Bool("send-crash-reports", false, "Automatically reports crashes to server.") | ||
|
||
var logFilePath = flag.String("log-path", "", "Enables logs and sets its filepath") | ||
var debug = flag.Bool("debug", false, "Enables debug mode") | ||
|
||
var c3Version = flag.String("lang-version", "", "Specify C3 language version.") | ||
|
||
flag.Parse() | ||
|
||
return Options{ | ||
showHelp: *showHelp, | ||
c3Version: *c3Version, | ||
logFilePath: *logFilePath, | ||
debug: *debug, | ||
sendCrashReports: *sendCrashReports, | ||
} | ||
} | ||
|
||
func printAppGreet(appName string, version string, commit string) { | ||
fmt.Printf("%s version %s (%s)\n", appName, version, commit) | ||
} | ||
|
||
func printHelp(appName string, version string, commit string) { | ||
printAppGreet(appName, version, commit) | ||
|
||
fmt.Println("\nOptions") | ||
flag.PrintDefaults() | ||
} | ||
|
||
func buildInfo() string { | ||
var Commit = func() string { | ||
if info, ok := debug.ReadBuildInfo(); ok { | ||
for _, setting := range info.Settings { | ||
if setting.Key == "vcs.revision" { | ||
return setting.Value | ||
} | ||
} | ||
} | ||
|
||
return "" | ||
}() | ||
|
||
return Commit | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.