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

Baseline HTTP parser + lexer + syntax highlighter. #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Jarlid
Copy link

@Jarlid Jarlid commented Mar 4, 2025

No description provided.


REQUEST_TARGET="regexp:\S*"
HTTP_VERSION="regexp:HTTP/\d\.\d"// HTTP-name "/" DIGIT "." DIGIT
// HTTP-name = %s"HTTP"
Copy link
Contributor

Choose a reason for hiding this comment

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

Закомментированные определения стоит подчистить


////////////////////////////////////////////////////// FIELD LINE //////////////////////////////////////////////////////

field_line ::= field_name ":" [OWS] field_value [OWS]
Copy link
Contributor

Choose a reason for hiding this comment

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

Это же Имя заголовка:Значение? Дай подходящее имя, пожалуйста, чтобы в дереве было понятно с чем имеем дело

///////////////////////////////////////////////////// MESSAGE BODY /////////////////////////////////////////////////////

message_body ::= ( message_line | CRLF )+
message_line ::= ANY_TOKEN
Copy link
Contributor

Choose a reason for hiding this comment

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

Может сделать private, чтобы не выделять в psiTree каждую строку сообщения? Попробовать сделать так, чтобы в дереве просто элемент message_body со всем содержимым.
Ну и я бы переименовал в request_body

http_file ::= requests

requests ::= request_block*
requests ::= ( request_block | request_definer | comment | CRLF )*
Copy link
Contributor

Choose a reason for hiding this comment

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

Похоже pin/recoverWhile нужно ещё здесь проработать, т.к. добавление в начале файла < ломает всё дерево, ни один элемент больше не распознаётся, только отдельные токены.
Примеры с этим (и не только) символом есть здесь и ниже
https://www.jetbrains.com/help/idea/exploring-http-syntax.html#per_request_variables

import com.intellij.psi.tree.IElementType

class HttpSyntaxHighlighter : SyntaxHighlighterBase() {
companion object {
Copy link
Contributor

Choose a reason for hiding this comment

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

Перемести везде companion object в конец класса, пожалуйста

@@ -35,10 +35,9 @@ class HttpRunLineMarkerProvider : RunLineMarkerContributor() {
override fun getInfo(psiElement: PsiElement): Info? {
val leafElement = psiElement as? LeafPsiElement ?: return null
if (leafElement.tokenType !in URL_TYPES) return null
Copy link
Contributor

Choose a reason for hiding this comment

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

!= HttpTypes.REQUEST_TARGET, раз он теперь единственный, не обязательно заводить setOf

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.

2 participants