Skip to content

Commit

Permalink
Working language server
Browse files Browse the repository at this point in the history
Signed-off-by: worksofliam <[email protected]>
  • Loading branch information
worksofliam committed Dec 6, 2024
1 parent 41ce1a3 commit e3438b2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 25 deletions.
3 changes: 2 additions & 1 deletion extension/server/src/providers/linter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export function initialise(connection: _Connection) {
document.getText(),
{
withIncludes: true,
ignoreCache: true
ignoreCache: true,
collectReferences: true
}
).then(cache => {
if (cache) {
Expand Down
10 changes: 2 additions & 8 deletions extension/server/src/providers/project/references.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ export async function findAllLocalReferences(def: Declaration): Promise<Location
// Don't add duplicates
if (!locations.some(loc => loc.uri === keyPath)) {
locations.push(
// First, we push the copybook where it is brought in.
// We do this because we don't have references for non-**free
Location.create(proc.position.path, Range.create(proc.position.line, 0, proc.position.line, 0)),

// Then we push the references. Empty for non-**free
...proc.references.map(ref => Location.create(
keyPath,
Expand Down Expand Up @@ -91,14 +87,12 @@ export async function findAllLocalReferences(def: Declaration): Promise<Location
// Okay, we found something with a similar name in another file...
if (possibleDef) {
if (possibleDef.position.path === def.position.path) {
if (document.getText(Range.create(0, 0, 0, 6)).toUpperCase() !== `**FREE` || possibleDef.references.length === 0) {
if (possibleDef.references.length === 0) {
locations.push(
// First, we push the copybook where it is brought in.
// We do this because we don't have references for non-**free
Location.create(uri, Range.create(foundInclude.line, 0, foundInclude.line, 0)),
);

} else {
// But since it's **free, and we probably have referneces...
locations.push(
// Then we push the references. Empty for non-**free
...possibleDef.references.map(ref => Location.create(
Expand Down
15 changes: 0 additions & 15 deletions extension/server/src/providers/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,9 @@ export async function referenceProvider(params: ReferenceParams): Promise<Locati
const document = documents.get(uri);

if (document) {
const isFree = (document.getText(Range.create(0, 0, 0, 6)).toUpperCase() === `**FREE`);

const doc = await parser.getDocs(uri, document.getText());

if (doc) {
if (isFree) {
Linter.getErrors(
{
uri,
content: document.getText()
},
{
CollectReferences: true
},
doc
);
}

const def = Cache.referenceByOffset(doc, document.offsetAt(currentPos));

if (def) {
Expand Down
3 changes: 2 additions & 1 deletion extension/server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ documents.onDidChangeContent(handler => {
handler.document.getText(),
{
withIncludes: true,
ignoreCache: true
ignoreCache: true,
collectReferences: true
}
).then(cache => {
if (cache) {
Expand Down

0 comments on commit e3438b2

Please sign in to comment.