Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
nvim-java/lua/pkgm/specs/base-spec.lua at create-pull-request/patch · nvim-java/nvim-java · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Uh oh!
There was an error while loading.
Please reload this page
.
nvim-java
/
nvim-java
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
95
Star
1.7k
Code
Issues
32
Pull requests
6
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Files
Expand file tree
create-pull-request/patch
Breadcrumbs
nvim-java
/
lua
/
pkgm
/
specs
/
base-spec.lua
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
220 lines (179 loc) · 5.36 KB
create-pull-request/patch
Breadcrumbs
nvim-java
/
lua
/
pkgm
/
specs
/
base-spec.lua
Copy path
Top
File metadata and controls
Code
Blame
220 lines (179 loc) · 5.36 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
local
class
=
require
(
'
java-core.utils.class
'
)
local
log
=
require
(
'
java-core.utils.log2
'
)
local
system
=
require
(
'
java-core.utils.system
'
)
local
err
=
require
(
'
java-core.utils.errors
'
)
---
@class
pkgm.VersionRange
---
@field
from
string
---
@field
to
string
---
@alias
pkgm.UrlValue
string
|
table<string
,
pkgm.UrlValue>
---
@class
pkgm.BaseSpecConfig
---
@field
name
string
---
@field
version
string
|
'
*
'
---
@field
version_range
?
pkgm.VersionRange
---
@field
urls
?
table<string
,
pkgm.UrlValue>
---
@field
url
?
string
|
pkgm.UrlValue
---
@field
[
string] string
---
@class
pkgm.BaseSpec
:
pkgm.PackageSpec
local
BaseSpec
=
class
()
---
@param
config
pkgm.BaseSpecConfig
function
BaseSpec
:
_init
(
config
)
log
.
debug
(
'
Initializing BaseSpec with config
'
,
config
)
self
.
_name
=
config
.
name
self
.
_version
=
config
.
version
self
.
_version_range
=
config
.
version_range
self
.
_template_vars
=
{}
if
not
config
.
url
and
not
config
.
urls
then
err
.
throw
(
'
BaseSpec: Neither url nor urls provided
'
)
end
self
.
_url
=
config
.
url
self
.
_urls
=
config
.
urls
for
key
,
value
in
pairs
(
config
)
do
if
key
~=
'
name
'
and
key
~=
'
version
'
and
key
~=
'
version_range
'
and
key
~=
'
urls
'
and
key
~=
'
url
'
then
self
.
_template_vars
[
key
]
=
value
end
end
log
.
debug
(
'
Template vars
'
,
self
.
_template_vars
)
end
---
@return
string
function
BaseSpec
:
get_name
()
log
.
debug
(
'
get_name() returning:
'
..
self
.
_name
)
return
self
.
_name
end
---
@return
string
function
BaseSpec
:
get_version
()
log
.
debug
(
'
get_version() returning:
'
..
self
.
_version
)
return
self
.
_version
end
---
@param
name
string
---
@param
version
string
---
@return
boolean
function
BaseSpec
:
is_match
(
name
,
version
)
local
version_desc
=
self
.
_version
or
'
range
'
log
.
debug
(
'
is_match() checking name=
'
..
name
..
'
version=
'
..
version
..
'
against spec name=
'
..
self
.
_name
..
'
spec version=
'
..
version_desc
)
if
name
~=
self
.
_name
then
log
.
debug
(
'
Name mismatch
'
)
return
false
end
if
self
.
_version
==
'
*
'
then
log
.
debug
(
'
Wildcard version match
'
)
return
true
end
if
self
.
_version_range
then
local
in_range
=
self
:
is_version_in_range
(
version
,
self
.
_version_range
.
from
,
self
.
_version_range
.
to
)
log
.
debug
(
'
Version range check:
'
..
tostring
(
in_range
))
return
in_range
end
local
exact_match
=
version
==
self
.
_version
log
.
debug
(
'
Exact version match:
'
..
tostring
(
exact_match
))
return
exact_match
end
---
@param
name
string
---
@param
version
string
---
@return
string
function
BaseSpec
:
get_url
(
name
,
version
)
log
.
debug
(
'
get_url() called with name=
'
..
name
..
'
version=
'
..
version
)
if
self
.
_url
then
log
.
debug
(
'
Resolving url
'
)
local
url_template
=
self
:
resolve_hierarchical_url
(
self
.
_url
)
return
self
:
parse_url_template
(
url_template
,
name
,
version
)
end
if
not
self
.
_urls
then
err
.
throw
(
'
BaseSpec: Neither url nor urls provided
'
)
end
log
.
debug
(
'
Resolving urls table
'
)
local
url_template
=
self
:
resolve_hierarchical_url
(
self
.
_urls
)
if
not
url_template
then
err
.
throw
(
'
BaseSpec: No url found for current system configuration
'
)
end
return
self
:
parse_url_template
(
url_template
,
name
,
version
)
end
---
@private
---
@param
url_value
string
|
table
---
@return
string
|
nil
function
BaseSpec
:
resolve_hierarchical_url
(
url_value
)
if
type
(
url_value
)
==
'
string
'
then
log
.
debug
(
'
URL is string:
'
..
url_value
)
return
url_value
end
if
type
(
url_value
)
~=
'
table
'
then
log
.
error
(
'
URL value must be string or table
'
)
return
nil
end
local
platform
=
system
.
get_os
()
log
.
debug
(
'
Platform:
'
..
platform
)
local
platform_value
=
url_value
[
platform
]
if
not
platform_value
then
log
.
error
(
'
No URL for platform:
'
..
platform
)
return
nil
end
if
type
(
platform_value
)
==
'
string
'
then
log
.
debug
(
'
Platform-specific URL:
'
..
platform_value
)
return
platform_value
end
local
arch
=
system
.
get_arch
()
log
.
debug
(
'
Architecture:
'
..
arch
)
local
arch_value
=
platform_value
[
arch
]
if
not
arch_value
then
log
.
error
(
'
No URL for architecture:
'
..
arch
)
return
nil
end
if
type
(
arch_value
)
==
'
string
'
then
log
.
debug
(
'
Architecture-specific URL:
'
..
arch_value
)
return
arch_value
end
local
bit_depth
=
system
.
get_bit_depth
()
log
.
debug
(
'
Bit depth:
'
..
bit_depth
)
local
bit_value
=
arch_value
[
bit_depth
]
if
not
bit_value
or
type
(
bit_value
)
~=
'
string
'
then
log
.
error
(
'
No URL for bit depth:
'
..
bit_depth
)
return
nil
end
log
.
debug
(
'
Bit-depth-specific URL:
'
..
bit_value
)
return
bit_value
end
---
@private
---
@param
url_template
string
---
@param
name
string
---
@param
version
string
---
@return
string
function
BaseSpec
:
parse_url_template
(
url_template
,
name
,
version
)
local
vars
=
vim
.
tbl_extend
(
'
force
'
, {
name
=
name
,
version
=
version
,
},
self
.
_template_vars
)
return
self
:
parse_template
(
url_template
,
vars
)
end
---
@private
---
@param
version
string
---
@param
from
string
---
@param
to
string
---
@return
boolean
function
BaseSpec
:
is_version_in_range
(
version
,
from
,
to
)
log
.
debug
(
'
Checking if
'
..
version
..
'
is between
'
..
from
..
'
and
'
..
to
)
return
version
>=
from
and
version
<=
to
end
---
@protected
---
@param
template
string
---
@param
vars
table<string
,
string>
---
@return
string
function
BaseSpec
:
parse_template
(
template
,
vars
)
log
.
debug
(
'
Parsing template:
'
..
template
)
local
result
=
template
for
key
,
value
in
pairs
(
vars
)
do
local
pattern
=
'
{{
'
..
key
..
'
}}
'
result
=
result
:
gsub
(
pattern
,
value
)
log
.
debug
(
'
Replaced
'
..
pattern
..
'
with
'
..
value
)
end
log
.
debug
(
'
Parsed result:
'
..
result
)
return
result
end
return
BaseSpec
You can’t perform that action at this time.