Skip to content

Commit

Permalink
Automatically add shared collection.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielGavin committed Feb 22, 2024
1 parent a75c342 commit acb232a
Show file tree
Hide file tree
Showing 49 changed files with 357 additions and 250 deletions.
21 changes: 21 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.22000.0",
"compilerPath": "cl.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64"
}
],
"version": 4
}
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "cppvsdbg",
"request": "attach",
"name": "Attach OLS",
"processId": "${command:pickProcess}"
}
{
"type": "cppvsdbg",
"request": "launch",
"name": "Run unit",
"program": "C:\\Users\\Daniel\\Desktop\\Computer_Science\\ols\\test_unit.exe",
}
]
}
12 changes: 6 additions & 6 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ setlocal enabledelayedexpansion
if "%1" == "CI" (
set "PATH=%cd%\Odin;!PATH!"

rem odin test tests -collection:shared=src
rem odin test tests -collection:src=src
rem if %errorlevel% neq 0 exit 1

odin build src\ -collection:shared=src -out:ols.exe -o:speed
odin build src\ -collection:src=src -out:ols.exe -o:speed

call "tools/odinfmt/tests.bat"
if %errorlevel% neq 0 exit 1
) else if "%1" == "test" (
odin test tests -collection:shared=src -debug
odin test tests -collection:src=src -debug
) else if "%1" == "single_test" (
odin test tests -collection:shared=src -test-name:%2
odin test tests -collection:src=src -test-name:%2
) else if "%1" == "debug" (
odin build src\ -show-timings -collection:shared=src -microarch:native -out:ols.exe -o:minimal -no-bounds-check -use-separate-modules -debug
odin build src\ -show-timings -collection:src=src -microarch:native -out:ols.exe -o:minimal -no-bounds-check -use-separate-modules -debug
) else (
odin build src\ -show-timings -microarch:native -collection:shared=src -out:ols.exe -o:speed -no-bounds-check
odin build src\ -show-timings -microarch:native -collection:src=src -out:ols.exe -o:speed -no-bounds-check
)
10 changes: 5 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ then
#BUG in odin test, it makes the executable with the same name as a folder and gets confused.
cd tests

odin test ../tests -collection:shared=../src -o:speed $@
odin test ../tests -collection:src=../src -o:speed $@

if ([ $? -ne 0 ])
then
Expand Down Expand Up @@ -41,7 +41,7 @@ then
#BUG in odin test, it makes the executable with the same name as a folder and gets confused.
cd tests

odin test ../tests -collection:shared=../src -test-name:$@
odin test ../tests -collection:src=../src -test-name:$@

shift

Expand All @@ -61,7 +61,7 @@ then
#BUG in odin test, it makes the executable with the same name as a folder and gets confused.
cd tests

odin test ../tests -collection:shared=../src $@
odin test ../tests -collection:src=../src $@

if ([ $? -ne 0 ])
then
Expand All @@ -75,9 +75,9 @@ if [[ $1 == "debug" ]]
then
shift

odin build src/ -collection:shared=src -out:ols -use-separate-modules -debug $@
odin build src/ -collection:src=src -out:ols -use-separate-modules -debug $@
exit 0
fi


odin build src/ -collection:shared=src -out:ols -o:speed $@
odin build src/ -collection:src=src -out:ols -o:speed $@
4 changes: 2 additions & 2 deletions editors/vscode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion editors/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "git",
"url": "git://github.com/DanielGavin/ols.git"
},
"version": "0.1.23",
"version": "0.1.27",
"engines": {
"vscode": "^1.66.0"
},
Expand Down Expand Up @@ -46,6 +46,11 @@
"type": "object",
"title": "Odin language client configuration",
"properties": {
"ols.prompt.AskCreateOLS": {
"type": "boolean",
"default": true,
"description": "Ask if it should create an ols.json file if it's not in the project."
},
"ols.updates.askBeforeDownload": {
"type": "boolean",
"default": true,
Expand Down
8 changes: 6 additions & 2 deletions editors/vscode/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import * as vscode from 'vscode';
import { log } from "./util";

//modified from https://github.com/rust-analyzer/rust-analyzer/blob/master/editors/code/src/config.ts - 03.05.2021

export class Config {

readonly extensionId = "danielgavin.ols";
Expand Down Expand Up @@ -45,5 +43,11 @@ export class Config {

get debugEngine() { return this.get<string>("debug.engine"); }

get askCreateOLS() { return this.get<boolean>("prompt.AskCreateOLS"); }

public updateAskCreateOLS(ask: boolean) {
this.cfg.update("prompt.AskCreateOLS", ask, vscode.ConfigurationTarget.Global);
}

collections: any [] = [];
}
10 changes: 9 additions & 1 deletion editors/vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,22 @@ export async function activate(context: vscode.ExtensionContext) {
fs.access(olsFile, constants.F_OK).catch(async err => {
if (err) {

if (!config.askCreateOLS) {
return;
}

const userResponse = await vscode.window.showInformationMessage(
"No ols config file in the workspace root folder. Do you wish to create one?",
"Yes",
"No"
"No",
"Don't ask again"
);

if (userResponse === "Yes") {
createOlsConfig(ctx);
} else if (userResponse === "Don't ask again") {
config.updateAskCreateOLS(false);
return;
}

}
Expand Down
2 changes: 1 addition & 1 deletion odinfmt.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
odin build tools/odinfmt/main.odin -file -show-timings -collection:shared=src -out:odinfmt.exe -o:speed
odin build tools/odinfmt/main.odin -file -show-timings -collection:src=src -out:odinfmt.exe -o:speed
2 changes: 1 addition & 1 deletion odinfmt.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

odin build tools/odinfmt/main.odin -file -show-timings -collection:shared=src -out:odinfmt -o:speed
odin build tools/odinfmt/main.odin -file -show-timings -collection:src=src -out:odinfmt -o:speed
13 changes: 11 additions & 2 deletions ols.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
{
"$schema": "https://raw.githubusercontent.com/DanielGavin/ols/master/misc/ols.schema.json",
"collections": [
{
"name": "shared",
"name": "src",
"path": "src"
}
],
"profiles": [
{ "name": "linux_profile", "os": "linux", "checker_path": ["src/main.odin"]},
{ "name": "windows_profile", "os": "windows", "checker_path": ["src/main.odin", "src"]}
],
"profile": "windows_profile",
"enable_document_symbols": true,
"enable_semantic_tokens": true,
"enable_snippets": true,
"enable_references": true,
"enable_fake_methods": false,
"enable_inlay_hints": false,
"enable_procedure_snippet": false,
"verbose": false
}
}
12 changes: 6 additions & 6 deletions src/main.odin
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package main

import "core:encoding/json"
import "core:fmt"
import "core:log"
import "core:mem"
import "core:os"
import "core:strings"
import "core:reflect"
import "core:slice"
import "core:strconv"
import "core:thread"
import "core:encoding/json"
import "core:reflect"
import "core:strings"
import "core:sync"
import "core:thread"

import "core:intrinsics"

import "shared:server"
import "shared:common"
import "src:common"
import "src:server"

os_read :: proc(handle: rawptr, data: []byte) -> (int, int) {
ptr := cast(^os.Handle)handle
Expand Down
2 changes: 1 addition & 1 deletion src/odin/format/format.odin
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "core:odin/ast"
import "core:odin/parser"
import "core:os"
import "core:path/filepath"
import "shared:odin/printer"
import "src:odin/printer"

default_style := printer.default_style

Expand Down
2 changes: 1 addition & 1 deletion src/server/analysis.odin
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "core:strconv"
import "core:strings"
import "core:unicode/utf8"

import "shared:common"
import "src:common"

DocumentPositionContextHint :: enum {
Completion,
Expand Down
6 changes: 3 additions & 3 deletions src/server/build.odin
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import "core:runtime"
import "core:strings"
import "core:time"

import "shared:common"
import "src:common"

platform_os: map[string]bool = {
"windows" = true,
Expand Down Expand Up @@ -95,8 +95,8 @@ try_build_package :: proc(pkg_name: string) {
}

p := parser.Parser {
err = log_error_handler,
warn = log_warning_handler,
err = log_error_handler,
warn = log_warning_handler,
flags = {.Optional_Semicolons},
}

Expand Down
2 changes: 1 addition & 1 deletion src/server/caches.odin
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package server

import "shared:common"
import "src:common"

import "core:time"

Expand Down
16 changes: 11 additions & 5 deletions src/server/check.odin
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import "core:sync"
import "core:text/scanner"
import "core:thread"

import "shared:common"
import "src:common"

//Store uris we have reported on since last save. We use this to clear them on next save.
uris_reported := make([dynamic]string)
Expand Down Expand Up @@ -119,7 +119,10 @@ check :: proc(paths: []string, writer: ^Writer, config: ^common.Config) {
}
}

error.uri = strings.clone(string(buffer[source_pos:s.src_pos - 1]), context.temp_allocator)
error.uri = strings.clone(
string(buffer[source_pos:s.src_pos - 1]),
context.temp_allocator,
)

left_paren := scanner.scan(&s)

Expand Down Expand Up @@ -147,7 +150,7 @@ check :: proc(paths: []string, writer: ^Writer, config: ^common.Config) {
if seperator != ':' {
break scan_line
}

rhs_digit := scanner.scan(&s)

if rhs_digit != scanner.Int {
Expand All @@ -159,7 +162,7 @@ check :: proc(paths: []string, writer: ^Writer, config: ^common.Config) {
if !ok {
break scan_line
}

right_paren := scanner.scan(&s)

if right_paren != ')' {
Expand All @@ -180,7 +183,10 @@ check :: proc(paths: []string, writer: ^Writer, config: ^common.Config) {
continue
}

error.message = strings.clone(string(buffer[source_pos:s.src_pos - 1]), context.temp_allocator)
error.message = strings.clone(
string(buffer[source_pos:s.src_pos - 1]),
context.temp_allocator,
)
error.column = column
error.line = line

Expand Down
2 changes: 1 addition & 1 deletion src/server/collector.odin
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import path "core:path/slashpath"
import "core:strconv"
import "core:strings"

import "shared:common"
import "src:common"

SymbolCollection :: struct {
allocator: mem.Allocator,
Expand Down
Loading

0 comments on commit acb232a

Please sign in to comment.