summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCpp
AgeCommit message (Collapse)Author
2022-09-19LibCpp: Add .clang-format to disable clang-format for the LibCpp TestsBrian Gianforcaro
We don't format these files, as they might have been intentionally formatted differently from the normal serenity style for testing. So ignore them from our global style, so clang-format doesn't pick them up by accident.
2022-09-17Everywhere: Fix badly-formatted includesBen Wiederhake
2022-07-12Everywhere: Replace single-char StringView op. arguments with charssin-ack
This prevents us from needing a sv suffix, and potentially reduces the need to run generic code for a single character (as contains, starts_with, ends_with etc. for a char will be just a length and equality check). No functional changes.
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-06-14LibCpp: Support "FIXME" for commentsFerhat Geçdoğan
2022-05-29Everywhere: Fix a bunch of typosLinus Groh
2022-05-21LibCodeComprehension: Re-organize code comprehension related codeItamar
This moves all code comprehension-related code to a new library, LibCodeComprehension. This also moves some types related to code comprehension tasks (such as autocomplete, find declaration) out of LibGUI and into LibCodeComprehension.
2022-04-17LibCpp: Parse inheritanceItamar
2022-04-09LibGfx: Move other font-related files to LibGfx/Font/Simon Wanner
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-31LanguageServers/Cpp: Add SemanticType::PreprocessorMacroItamar
This adds a new semantic token type, PreprocessorMacro. Calls to preprocessor macros will now be highlighted when semantic highlighting is enabled in Hack Studio.
2022-03-31LibCpp: Fix parsing of macro callsItamar
Previously, macro calls with 0 arguments where incorrectly parsed as calls to a macro with a single argument that doesn't contain any tokens.
2022-03-19LibCpp: Change class_name to use StringView instead of char const*Lenny Maiorani
This helps make the overall codebase consistent. `class_name()` in `Kernel` is always `StringView`, but not elsewhere. Additionally, this results in the `strlen` (which needs to be done when printing or other operations) always being computed at compile-time.
2022-03-10Libraries: Use default constructors/destructors in LibCppLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2022-03-05LibCpp: Don't include parameter type in FunctionType::to_string if nullItamar
The type of a function parameter can be null if we failed to parse it. In such a case, calling to_string() on a FunctionType node used to cause a null dereference. This caused the language server to crash when processing AK/StdLibExtraDetails.h
2022-02-27LanguageServers/Cpp: Make find declaration of enums workItamar
2022-02-27LibCpp: Set end position for the return type node of FunctionType nodesItamar
Previously we didn't set the end position for the return type node of function FunctionType nodes. This caused a VERIFY failure crash when dumping an AST that contains such nodes.
2022-02-23Libraries/LibCpp: Add parser test for out-of-line function definitionsItamar
2022-02-23LibCpp: Allow qualified names in AST Declaration nodesItamar
Previously, the names of declarations where stored as a simple StringView. Because of that, we couldn't parse out-of-line function definitions, which have qualified names. For example, we couldn't parse the following snippet: ``` void MyClass::foo(){} ``` To fix this, we now store the name of a declaration with a ASTNode::Name node, which represents a qualified named.
2022-02-09LibCpp: Add SemanticSyntaxHighlighterItamar
The SemanticSyntaxHighlighter uses TokenInfo results from the language server to provide 'semantic' syntax highlighting, which provides more fin-grained text spans results. For example, the SemanticSyntaxHighlighter can color function calls, member fields references and user-defined types in different colors. With the simple lexer-only syntax highlighter, all of these tokens were given the same text highlighting span type. Since we have to provide immediate highlighting feedback to the user after each edit and before we get the result for the language server, we use a heuristic which computes the diff between the current tokens and the last known tokens with compete semantic information (We use LibDiff for this). This heuristic is not very performant, and starts feeling sluggish with bigger (~200 LOC) files. A possible future improvement would be only computing the diff for tokens in text ranges that have changes since the last commit.
2022-02-09LibCpp: Update regressions tests resultsItamar
The LibCpp regression tests results have to be updated after tweaking the token end position calculation logic of some token types.
2022-02-09LibCpp: Fix lexing of IncludePath tokenItamar
Previously, there was a duplicate IncludePath token in the lexing result.
2022-02-09LibCpp: Add Preprocessor:unprocessed_token()Itamar
2022-02-09LibCpp: Add public Parser::tokens() methodItamar
2022-02-09LibCpp: Fix end position calculation for various AST node typesItamar
Previously, the end position of the Type and Name nodes was incorrect. It was incorrectly set to the start position of the next unconsumed token. This commit adds a previous_token_end() method and uses it to correctly get the end position for these node types.
2022-02-09LibCpp: Fix parent of parameter type nodeItamar
Previously, the parent of a parameter's Type node was incorrectly set to the parent of the Parameter node. We now set the parent of the parameter's Type node to the Parameter node itself.
2022-02-09LibCpp: Fix Declaration::is_member()Itamar
Previously, Declaration::is_member() was just a stub that always returned false. It now works by checking whether the parent ASTNode is a declaration of a struct or a class type.
2022-02-07Userland: Undefine FOR_EACH_TOKEN_TYPE everywherekleines Filmröllchen
This was causing some macro redefinition errors after the headers ended up in the same file through some includes. The simple fix is to undefine the macro after use.
2022-01-25AK: Standardize the behaviour of GenericLexer::consume_until overloadsIdan Horowitz
Before this commit all consume_until overloads aside from the Predicate one would consume (and ignore) the stop char/string, while the Predicate overload would not, in order to keep behaviour consistent, the other overloads no longer consume the stop char/string as well.
2022-01-25AK: Add a consume_until(StringView) overload to GenericLexerIdan Horowitz
This allows us to skip a strlen call.
2021-12-05LibCpp: Cast unused smart-pointer return values to voidSam Atkins
2021-12-03LibCpp: Add "ignore invalid statements" option to PreprocessorItamar
When we run the Preprocessor from the CppComprehensionEngine of the language server, we don't want the preprocessor to crash if it encounters an invalid preprocessor statement (for example, an #endif statement without an accompanying previous #if statement). To achieve this, this commit adds an "ignore_invalid_statements" flag to the preprocessor which is set by the CppComprehensionEngine. Fixes #11064.
2021-11-30LibCpp: Update list of well-known C++ types to match current AKAndreas Kling
2021-11-30LibCpp: Use StringView for the known keywords arrayAndreas Kling
2021-11-29LibCpp: Fix copy paste typo in Parser::match_secondary_expressionBrian Gianforcaro
This was caught by SonarCloud.
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-09-28LibCpp: Remove redundant comparison to Token::Type::PipePipeBrian Gianforcaro
SonarCloud flagged this 'Identical sub-expressions on both sides of operator "||"'. When looking at the git history it looks like it was just a copy / paste mistake that happened when Token::Type::Arrow support was added.
2021-08-21LibCpp: Use lex_iterable() where applicableItamar
2021-08-21LibCpp: Add lex_iterable() method to the LexerItamar
This allows us to collect the tokens iteratively instead of having to lex the whole program and then get a tokens vector.
2021-08-21LibCpp: Lex before processing the source in the PreprocessorItamar
Previously, the preprocessor first split the source into lines, and then processed and lexed each line separately. This patch makes the preprocessor first lex the source, and then do the processing on the tokenized representation. This generally simplifies the code, and also fixes an issue we previously had with multiline comments (we did not recognize them correctly when processing each line separately).
2021-08-21LibCpp: Allow whitespace between # and preprocessor directiveItamar
For example, '# include <stdio.h>' is now supported by the Lexer.
2021-08-14Tests: Add regression tests for the LibCpp preprocessorItamar
Similarly to the LibCpp parser regression tests, these tests run the preprocessor on the .cpp test files under Userland/LibCpp/Tests/preprocessor, and compare the output with existing .txt ground truth files.
2021-08-14LibCpp: Move parser tests to Userland/Libraries/LibCpp/Tests/parserItamar
2021-08-14LibCpp: Evaluate function-like macro callsItamar
2021-08-14LibCpp: Understand preprocessor macro definition and invocationItamar
The preprocessor now understands when a function-like macro is defined, and can also parse calls to such macros. The actual evaluation of function-like macros will be done in a separate commit.
2021-08-14LibCpp: Add lexer option to ignore whitespace tokensItamar
2021-08-07LibCpp: Do macro substitution in the preprocessor instead of the parserItamar
After this change, the parser is completely separated from preprocessor concepts.
2021-08-07LibCpp: Import definitions from headers while processingItamar
When the preprocessor encounters an #include statement it now adds the preprocessor definitions that exist in the included header to its own set of definitions. We previously only aggregated the definitions from headers after processing the source, which was less correct. (For example, there could be an #ifdef that depends on a definition from another header).
2021-08-07LibCpp: Do lexing in the PreprocessorItamar
We now call Preprocessor::process_and_lex() and pass the result to the parser. Doing the lexing in the preprocessor will allow us to maintain the original position information of tokens after substituting definitions.
2021-08-07LibCpp: Support initializing the lexer with a "start line"Itamar