Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter Implemetation / REVIEW #25

Open
wants to merge 142 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
2a696e0
Init with structure
ysndr Jan 5, 2022
eb08440
Chapter introduction
ysndr Jan 5, 2022
bfdf4b1
Static Nickel
ysndr Jan 5, 2022
51a1876
Fixes to existing content
ysndr Jan 6, 2022
f10cea0
Meta information section
ysndr Jan 6, 2022
663a6b9
Start on Record Shorthands
ysndr Jan 6, 2022
3b2d52c
Add subsubsection for static record access
ysndr Jan 6, 2022
8151ffa
Amend wording and graphic size
ysndr Jan 6, 2022
7e8509d
Linearization intro
ysndr Jan 7, 2022
2bf8cee
First words about different states
ysndr Jan 7, 2022
6c3b9f2
Finish states subsection
ysndr Jan 9, 2022
661d0f0
Reference smart pointers
ysndr Jan 9, 2022
783f63c
Add access methods
ysndr Jan 9, 2022
092cecd
Resolution by scope
ysndr Jan 10, 2022
98241c5
Correct type definition
ysndr Jan 11, 2022
a5b0721
Reference item_at algorithm
ysndr Jan 11, 2022
3193361
Apply suggestions from code review
ysndr Jan 11, 2022
85289ec
Address review comment on span structure
ysndr Jan 11, 2022
8f79076
Add more subsections to ast transfer outline
ysndr Jan 13, 2022
049a90a
Rename Method chapter
ysndr Jan 13, 2022
7f5fc4a
Remove Nickel AST section
ysndr Jan 13, 2022
9948bf6
Add symbols section in outline
ysndr Jan 13, 2022
849ed59
Add illustrative example in Nickel
ysndr Jan 13, 2022
4f0c45b
Amending reasoning for choosing eager approach
ysndr Jan 13, 2022
1fd345f
Change description of Building state
ysndr Jan 15, 2022
c9ac80a
Find most ~"concrete"~ -> "specific" element
ysndr Jan 15, 2022
aaee232
Add Usage Graph section
ysndr Jan 16, 2022
b5a7b61
WIP section on scopes
ysndr Jan 20, 2022
8689c79
Transfer from AST intro
ysndr Jan 24, 2022
b7d75fb
Scopes subsection reworked
ysndr Jan 24, 2022
7c38c0e
Linearizer subsection
ysndr Jan 24, 2022
631c9b6
General process started
ysndr Jan 24, 2022
aaeaaac
Fix definition list
ysndr Jan 24, 2022
3da38d7
Fix Code block
ysndr Jan 24, 2022
b249ffc
minor typos
ysndr Jan 24, 2022
51d8859
Intro general process
ysndr Jan 24, 2022
d98007d
Code typos
ysndr Jan 24, 2022
30ed2ce
Change process section title
ysndr Jan 24, 2022
4275249
Registering structures let and function args
ysndr Jan 24, 2022
fe0fe5a
Registering Records
ysndr Jan 24, 2022
e182ce7
Change record example
ysndr Jan 24, 2022
5a7f66c
fix misprinted listings
ysndr Jan 24, 2022
468d767
Format and fix to code examples
ysndr Jan 26, 2022
e6fffed
Overhaul some sentences
ysndr Jan 26, 2022
41c2448
Section: linearizing variable usage and record destructuring
ysndr Jan 26, 2022
c3456f5
Clarify `TermKind`s
ysndr Jan 27, 2022
14223a0
Fix typo
ysndr Jan 27, 2022
c4a2b92
Section Variable referencing
ysndr Jan 27, 2022
8b77edb
Fix code block: make it a listing
ysndr Jan 27, 2022
e4cc1f3
Reword linearization of name bindings
ysndr Jan 27, 2022
6f0aef5
Add lost chapter header back to document
ysndr Jan 27, 2022
2e062aa
Document linearizer fields
ysndr Jan 27, 2022
d2912a6
Section Metadata
ysndr Jan 27, 2022
7a275b0
Cleanup file
ysndr Jan 31, 2022
a4a70a4
Remove section headers for scopes and retyping
ysndr Jan 31, 2022
fc6d4aa
Post processing intro
ysndr Jan 31, 2022
5b134ed
Post-Processing: sorting
ysndr Jan 31, 2022
3ee378b
Post processing: Deferred Usages
ysndr Feb 1, 2022
d7ce021
Post processing: Resolving types
ysndr Feb 1, 2022
e0e670d
Cleanup figure code
ysndr Feb 1, 2022
aaf4e23
Section: Server::Intro
ysndr Feb 4, 2022
0decf02
Apply some text suggestions (style, grammar,typo)
ysndr Feb 5, 2022
582b251
Section: LSP Server :: Diagnostics and Caching
ysndr Feb 5, 2022
e96a1a4
Section: LSP Server :: Hover and references
ysndr Feb 5, 2022
d9b46a0
Fix word
ysndr Feb 6, 2022
9522440
Section: LSP Server :: Completion and Document symbols
ysndr Feb 6, 2022
72d52c0
Apply suggestions from code review
ysndr Feb 7, 2022
d7d2a93
Rework linearization Intro
ysndr Feb 8, 2022
e0ed9e9
Address review suggestions in States subsection
ysndr Feb 8, 2022
646f57b
Fix typo
ysndr Feb 8, 2022
a3d286a
Rewrite state subsection intro
ysndr Feb 8, 2022
4f0b00b
Apply suggestions from code review
ysndr Feb 8, 2022
ef3ffea
Rewrite Usage graph intro
ysndr Feb 8, 2022
544a9ab
Address comments to term kind definitions
ysndr Feb 8, 2022
4ff87c5
Try clarify retype_ident
ysndr Feb 8, 2022
b1b2de8
flatten single child section `Variable Usage`
ysndr Feb 8, 2022
3de02d3
Correctly format list
ysndr Feb 8, 2022
465ef20
Remove redundant sentence
ysndr Feb 8, 2022
07a3b67
Reword AST transfer intro
ysndr Feb 8, 2022
d6045e5
Make usage graph subsection more concise
ysndr Feb 9, 2022
c6f06da
Reword declarations subsection
ysndr Feb 9, 2022
2a0958c
Include Value Sta
ysndr Feb 9, 2022
a5062ea
Fix dash
ysndr Feb 9, 2022
723f06f
Reword records subsection
ysndr Feb 9, 2022
6036dc2
Rewrite Variable access subsection
ysndr Feb 9, 2022
a6759ac
general typos and words
ysndr Feb 13, 2022
caee52a
Update Nickel Syntax
ysndr Mar 9, 2022
7c1d66d
Apply suggestions from review
ysndr Mar 9, 2022
66ec962
Recall "record access"
ysndr Mar 9, 2022
b681e07
Attempt to make library separation figure more clear
ysndr Feb 18, 2022
249720e
Address some review comments
ysndr Mar 9, 2022
698d777
Make post-processing paragraph about reordering clearer
ysndr Mar 9, 2022
3905672
Apply suggested rewrite about type resolution
ysndr Mar 9, 2022
ddc6974
call pattern matches "patterns"
ysndr Mar 9, 2022
9118685
Add wikipedia entry of currying as footnote
ysndr Mar 9, 2022
c0910ad
Typos and commas
ysndr Mar 9, 2022
0dd4775
More detailed scope description
ysndr Mar 9, 2022
f3bc950
Fix listings
ysndr Mar 11, 2022
4e908cf
Apply prelude to chapter preview
ysndr Mar 12, 2022
5feded9
Reword introduction part a bit
ysndr Mar 14, 2022
ea15cb5
Add "Key objectives section"
ysndr Mar 14, 2022
a9c0cf8
Ad design decision section
ysndr Mar 15, 2022
8aec8ae
Elaborate Example
ysndr Mar 16, 2022
1c4ff64
More about traits and changes to rust intro
ysndr Mar 16, 2022
2c25489
Add more pandoc filters for plantuml and code inclusion
ysndr Mar 16, 2022
904ad5b
Add plantuml definition of nls type structure.
ysndr Mar 16, 2022
72ffa07
Lead into rust features
ysndr Mar 17, 2022
0ebbbf7
More clarifications on traits
ysndr Mar 17, 2022
4a29e6b
implrove linearization intro
ysndr Mar 17, 2022
7be11c3
Apply suggestions from code review
ysndr Mar 17, 2022
1f4e54b
Update chapter/methodology.md
ysndr Mar 17, 2022
ac2bfe9
Update chapter/methodology.md
ysndr Mar 17, 2022
b1ba3cd
Update chapter/methodology.md
ysndr Mar 17, 2022
6b02010
Update class diagram
ysndr Mar 21, 2022
512353c
Describe architecture
ysndr Mar 21, 2022
3b73f1e
Update nixpkgs
ysndr Mar 21, 2022
fc8f5ba
Use forked plantuml filter
ysndr Mar 21, 2022
2a357d7
Add item resolution activity diagram
ysndr Mar 21, 2022
3a86feb
Amend description of some resolution sections
ysndr Mar 21, 2022
56c9afe
Add landscape support
ysndr Mar 21, 2022
51164e3
Add meaningful caption to entity diagram
ysndr Mar 21, 2022
034e1ed
Explicitly ignore plantuml outputs
ysndr Mar 21, 2022
c94c1fd
Edit Server implementation section
ysndr Mar 21, 2022
ee2bbdd
Make sentence lighter
ysndr Mar 21, 2022
613360c
Include StubHost in diagram
ysndr Mar 21, 2022
8c087c4
Fix label in element lookup
ysndr Mar 21, 2022
33177b6
Fix scope example layout
ysndr Mar 23, 2022
46fd99a
Fix Code Block
ysndr Mar 23, 2022
0e74a02
Fix typos
ysndr Mar 23, 2022
dc9ab2c
Add descriptive sentence for each capability
ysndr Mar 25, 2022
d9da6f8
Rewrite introductive sentence for traits
ysndr Mar 25, 2022
8d4d230
More thorough LinearizationItem introduction
ysndr Mar 26, 2022
8d0fa6d
Split long sentence
ysndr Mar 26, 2022
7dcf653
Clarify LinarizationItem role
ysndr Mar 26, 2022
9ecc342
Add more detail about generic linearizer interface usage
ysndr Mar 26, 2022
2b9ea9b
Refer to objectives section
ysndr Mar 26, 2022
8fb36db
Apply suggestions from code review
ysndr Mar 26, 2022
e67230d
Add phases take-away
ysndr Mar 26, 2022
e57ee66
Remind core requirements for transfer
ysndr Mar 26, 2022
3b65ce0
Escape pdf url
ysndr Mar 23, 2022
c1eb04e
Add sequence diagrams for analysis
ysndr Mar 25, 2022
ad17e94
Fix various typos
ysndr Jul 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
branch=${{ github.head_ref }}
input="${branch%%#*}"
pdf_output="${{ env.PREVIEW_PATH }}/${branch}.pdf"

pdf_output_url=$(python -c "import urllib.parse; import sys; print(urllib.parse.quote(sys.argv[1]))" "$pdf_output")
mode=$([[ "$input" == "chapter/"* ]] && echo "chapter" || echo "all")

tag="${branch#*#}"
Expand All @@ -54,6 +54,7 @@ jobs:
echo "::set-output name=ref::$branch"
echo "::set-output name=input::$input"
echo "::set-output name=pdf_output::$pdf_output"
echo "::set-output name=pdf_output_url::$pdf_output_url"
echo "::set-output name=mode::$mode"
echo "::set-output name=tag::$tag"

Expand Down Expand Up @@ -166,4 +167,4 @@ jobs:
status: ${{ job.status }}
auto_inactive: false
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: "https://github.com/${{github.repository}}/tree/${{env.PREVIEW_REF}}/${{ steps.config.outputs.pdf_output }}"
env_url: "https://github.com/${{github.repository}}/tree/${{env.PREVIEW_REF}}/${{ steps.config.outputs.pdf_output_url }}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/*.pdf
!previews/**/*.pdf
plantuml-images/
.direnv/
225 changes: 225 additions & 0 deletions assets/class-diagram.plantuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
@startuml
skinparam linetype ortho
skinparam groupInheritance 2

package "Language Server Abstraction" {

package Analysis {

class Linearizer << (T,coral) >> {
-- Associated Types --
type Building;
type Completed;
type CompletionExtra;

-- Methods --
+ add_term(\n\
&mut self,\n\
&mut Linearization<Self::Building>,\n\
&Term,\n\
TermPos,\n\
TypeWrapper
)

+complete(Linearization<Self::Building>)\n\t-> Linearization<Self::Completed>

}

class Linearization<T: LinearizationState> << (S,steelblue) >> {
- state : T
- update_file(FileId, String)
}


class LinearizationState << (T,coral) >> {}

class Building << (S,steelblue) >> {
+ Vec<LinearizationItem<Unresolved>>,
+ scope: HashMap<Scope, Vec<ID>>,
}

class Completed << (S,steelblue) >> {
+ Vec<LinearizationItem<Unresolved>>,
- scope: HashMap<Scope, Vec<ID>>,
- id_to_index: HashMap<ID, usize>,

--
+ get_item(&self, usize) \n\
-> Option<&LinearizationItem<Resolved>>
+ get_in_scope(&self, LinearizationItem<Resolved>)\n\
-> Vec<&LinearizationItem<Resolved>>
+ item_at(&self,&Location) \n\
-> Option<&LinearizationItem<Resolved>>
}

class LinearizationItem<S: ResolutionState> << (S,steelblue) >> {
+ id: usize,
+ pos: RawSpan,
+ ty: S,
+ kind: TermKind,
+ scope: Scope,
+ meta: Option<MetaValue>,
}


class StubHost << (S,steelblue) >> {
}

class "Linearizer for StubHost" as impl_linearizer_for_StubHost << (I,lime) >> {
-- Associated Types --
type Building = ();
type Completed = ();
}

}

package "LSP Implementations" {
class Handler <R: RequestParams> << (T,coral) >> {
+ handle(Server, R, &Linearization<Completed>)
}

class GoToRef << (S,steelblue) >> {}
class GoToDef << (S,steelblue) >> {}
class Complete << (S,steelblue) >> {}
class Symbols << (S,steelblue) >> {}
class Hover << (S,steelblue) >> {}
}


package "Support Types" {
class Scope << (S,steelblue) >> {}
class ScopeId << (S,steelblue) >> {}
class Environment << (S,steelblue) >> {}
class TermKind << (S,steelblue) >> {}
}
}

package nls {

class Server << (S,steelblue) >> {
- cache: HashMap<FileId, Linearization<Completed>>

~ receive(Request)
~ reply(Response)
}

class AnalysisHost << (S,steelblue) >> {
- env: Environment,
- scope: Scope,
- next_scope_id: ScopeId,
- meta: Option<MetaValue>,
- let_binding: Option<ID>,
- access: Option<Vec<Ident>>,
- {field} record_fields: Option<(ID, Vec<(ID, Ident)>)>,
}

class "Linearizer for AnalysisHost" as impl_linearizer_for_AnalysisHost << (I,lime) >> {
-- Associated Types --
type Building = Building;
type Completed = Completed;
}

}

package Nickel {

package types {

circle MetaValue << (S,steelblue) >> {}

circle Term << (S,steelblue) >> {}

circle RawSpan << (S,steelblue) >> {}

circle Ident << (S,steelblue) >> {}

circle TypeWrapper << (S,steelblue) >> {}

}

class Parser << (S,steelblue) >> {
parse(String) -> Term
}

class TypeChecker<S: Linearizer> << (S,steelblue) >> {
type_check(S, Term)
}

class "Nickel" as Nickel_bin << (S,steelblue) >> {

}

}

AnalysisHost ..|> Linearizer
impl_linearizer_for_AnalysisHost . (AnalysisHost, Linearizer) : "Implementation"

StubHost ..|> Linearizer
impl_linearizer_for_StubHost . (StubHost, Linearizer) : "Implementation"

' impl_linearizer_for_AnalysisHost ..> Building
' impl_linearizer_for_AnalysisHost ..> Completed



Completed ..|> LinearizationState
Completed o--> "*" LinearizationItem
' Completed o--> Scope


Building o--> "*" LinearizationItem
Building ..|> LinearizationState

' Building o--> Scope

' AnalysisHost o--> Scope
' AnalysisHost o--> ScopeId
' AnalysisHost o--> Environment
' AnalysisHost o--> MetaValue
' AnalysisHost o--> Ident

Linearizer *..|> Linearization
' Linearizer ..> Term
' Linearizer ..> TypeWrapper
' Linearizer ..> Ident


' LinearizationItem o--> RawSpan
' LinearizationItem o--> Scope
' LinearizationItem o--> TermKind
' LinearizationItem o--> MetaValue

Scope o--> ScopeId

Server o--> Completed
Server ..> AnalysisHost
Server ..> TypeChecker
Server ..> Parser : "S = AnalysisHost"

Server ..> GoToRef
Server ..> GoToDef
Server ..> Complete
Server ..> Symbols
Server ..> Hover

GoToRef ..|> "R = GoToRefParams" Handler
GoToDef ..|>"R = GoToDefParams" Handler
Complete ..|>"R = CompletionParams" Handler
Symbols ..|>"R = SymbolsParams" Handler
Hover ..|> "R = HoverParams" Handler

TypeChecker *..|> Linearizer

Nickel_bin ..> StubHost
Nickel_bin ..Parser : "S = StubHost"
Nickel_bin ..> TypeChecker
' Parser ..> Term








@enduml
55 changes: 55 additions & 0 deletions assets/eager-analysis.plantuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@startuml

!pragma teoz true

actor User
participant NLS
entity Linearization
database Cache
participant Handler

group Ahead of time analysis

[o-> NLS : File update

activate NLS

NLS -> Linearization
activate Linearization
...
Linearization -> NLS
deactivate Linearization

NLS -> Cache: Store linearization for File
activate Cache
Cache -> NLS
deactivate Cache

NLS ->o?
deactivate NLS

end

User -> NLS: LSP Request
activate NLS

NLS -> Cache: lookup linearization
activate Cache

Cache -> NLS
deactivate Cache

NLS -> Handler: Pass request and linearization
activate Handler
deactivate NLS
note right of Handler
Performs lookup to
immutable linearization.
end note
Handler -> User: Send LSP Response

deactivate Handler



@enduml
47 changes: 47 additions & 0 deletions assets/element-lookup.plantuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@startuml
start
floating note right
**Inputs:**
linearization
cursor position (file, location)
end note


:binary search linearization:

""item.file == file"" and
""item.position == position"";

if (element found) then (exact match at ""idx"")
while (linearization[idx+1].position == position)
:set ""idx = idx+1"";
endwhile
stop
else (possible match)
repeat
:set ""idx = idx-1"";
if (""linearization[idx]"" in ""file"") then (possible match)
if (position inside span of ""linearization[idx]"") then (match)
stop
else (no match, check next element)
endif
else (no match)

note right
items are ordered by file
reading an item from a different ""file"" means:
all items from the matching file
have been visited without a match
end note
endif
repeat while (idx > 0) is (check next preceding element)
end
floating note right
no match in all preceding items
end note
endif




@enduml
Loading