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

Origin/lsp #23

Merged
merged 19 commits into from
Sep 12, 2023
Merged

Origin/lsp #23

merged 19 commits into from
Sep 12, 2023

Conversation

lovestaco
Copy link
Collaborator

@lovestaco lovestaco commented Sep 7, 2023

What type of MR is this? (check all applicable)

  • πŸ• Feature
  • πŸ› Bug Fix
  • πŸ“ Doc Update
  • 🎨 Style
  • πŸ§‘β€πŸ’» Code Refactor
  • πŸ”₯ Performance Improvements
  • βœ… Test
  • πŸ€– Build
  • πŸ” CI
  • ⏩ Revert

Description

  • This MR updates the feature suggestenvs which was previously using l2 -e='your_search_query' using the LSP built for l2.
  • We will proceed to use LSP for future features.
		{
			"jsonrpc": "2.0",
			"id": 2,
			"method": "suggest/environmentVariables",
			"params": {
				"textDocument": {
					"uri": "file:///home/lovestaco/repos/Lama2/elfparser/ElfTestSuite/root_variable_override/api/y_0020_root_override.l2"
				},
				"position": {
					"line": 1,
					"character": 2
				},
				"searchQuery": "<your_search_query>"
			}
		}

Important files to start review from

Mobile & Desktop Screenshots/Recordings

Bug fix for envs within string enclosed env placeholder

image

Unsupported error for windows

image

Added tests?

  • πŸ‘ yes
  • πŸ™… no, because they aren't needed
  • πŸ™‹ no, because I need help

Added to documentation?

  • πŸ“œ README.md
  • πŸ™… no documentation needed

Prettify the repositary

npm run format

  • πŸ‘
  • πŸ™… no

src/extension.ts Outdated
// The L2 version, if less than v1.5.0, does not support the `l2 -e <filepath>` feature.
// Therefore, we use the extension to fetch variables from the l2.env file for suggestions.
/**
* The L2 version, if less than v1.5.0, does not support the `l2 -e <filepath>` feature.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's ditch this feature. We'll go 100% LSP from v1.5.9. We can remove it from backend in v1.5.9 as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

src/extension.ts Outdated
// Therefore, we fetch variables from both the l2.env and l2config.env files for suggestions using this command.
suggestEnvVariables = lama2RegisterCompletionItemProvider();
/**
* L2 versions greater than or equal to v1.5.0 support the `l2 -e <filepath>` feature.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to retain this as well. Only LSP going forward.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool

sendRequestToLSPReadResponse,
} from "../request/generalRequest";

export function initlizeServer(langServer: ChildProcess, requestId: number) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling.

ErrorCodes,
IJSONRPCResponse,
logToChannel,
} from "../response/generalResponse";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can get imports based on project root everywhere if possible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do in the next MR, tried, taking a lot of time


return completions;
if (isCursorInsideTemplateLiteral(lineText, cursorPosition.character)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isCursorInVarContainer

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

// Function to send requests to the Language Server Protocol and read responses
export function sendRequestToLSPReadResponse(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplify name - maybe something like: askLSP (and response type is clear by return type)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay


const chunks: any[] = [];
process.stdout.on("data", (data) => {
chunks.push(data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can put these event handlers as separate as functions; as of now this function is a bit too long and not super easy to read.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right addressed it

const { msg: message, logType = "info", dataObject, dataString } = options;

const timestamp = new Date().toLocaleTimeString();
const logTypeInfo = LOG_TYPES[logType.toLowerCase()] || LOG_TYPES["info"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't L45 setting logType default value? I don't think we need ||

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acts like default value

   logToChannel({
        msg: "Received envs from server",
        dataObject: response,
      });

@lovestaco lovestaco merged commit f985d88 into main Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants