Commit graph

397 commits

Author SHA1 Message Date
Lenny Maiorani
7070713ec8 DevTools: Use default constructors/destructors
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-02-16 07:33:15 -05:00
Harrison Marshall
f538545987 HackStudio: Fix crash when requesting parameter list
When requesting a parameter hint message with `Ctrl + p` in a file that
doesn't have a language server, we would crash.

Now, rather than verifying that we have a language server, we return
early if we don't have one.
2022-02-14 13:48:05 +01:00
kleines Filmröllchen
704bb361bb LibCore: Allow event loops on other threads to wake up
Because the wake pipe is thread-local, it was previously not possible
to wake an event loop across a thread. Therefore, this commit
rearchitects event loop waking by making the wake function a member of
the event loop itself and having it keep a pointer to its thread's wake
pipe. The global wake() function calls wake on the current thread's
event loop.

This also fixes a bug in BackgroundAction: it should wake the event loop
it was created on, instead of the current thread's event loop.
2022-02-13 23:06:53 +01:00
Idan Horowitz
c8ab45e79f Userland: Run gml-format
This brings the existing GML files up to spec with the new requirements
2022-02-13 02:36:35 +02:00
Itamar
506c13d143 HackStudio: Put the Build directory inside the Serenity repository
Previously, the build directory for building serenity components was a
temporary directory in /tmp which was generated whenever a different
serenity component was built.

Instead of doing that, Hack Studio now simply uses the Build/ directory
inside the Serenity repository, similar to what is done in host builds.

This makes it so we don't re-build when switching back and forth between
different components.
It also makes it easier to inspect the build products.
2022-02-12 11:51:48 +01:00
Itamar
8bb4d46676 HackStudio: Only query token information if semantic highlighting is on 2022-02-12 11:24:32 +01:00
Daste
542e18b367 HackStudio: Fix error handling logic in delete_action
The `result.is_error()` check was inverted, causing a crash.
2022-02-10 21:41:05 +02:00
Daste
11c53a1944 HackStudio: Don't save file when filename is empty
When saving a new file, save_as_action will return if the filename
input was empty, but save_action would still try to save the file.
Added a guard to make sure we never try to save files with empty
filenames.
2022-02-10 18:42:45 +01:00
electrikmilk
3c11dc5bd3 Base+HackStudio: Add or insert missing icons
Insert or add icons where they are missing.
2022-02-10 10:27:26 +00:00
Itamar
8ec4328fcb HackStudio: Allow toggling between simple and semantic highlighting
Until it becomes enough stable and performant, semantic highlighting is
disabled by default.

It can be toggled on via the "Project" menu in HackStudio.
2022-02-09 00:51:31 +01:00
Itamar
aba2e03b71 HackStudio: Use the C++ semantic syntax highlighter
HackStudio::Editor will now send a request to get semantic token
information to the language server whenever there's a short pause in
editing.

The result is used by the semantic c++ syntax highlighter to provide
better highlighting information.
2022-02-09 00:51:31 +01:00
Itamar
33043f269d HackStudio: Add tokens_info_result() and tokens_info_result() IPC calls
These IPC calls are used in the communication with the language server
to fetch semantic information about the tokens in a code document.
2022-02-09 00:51:31 +01:00
Itamar
76000e9137 LanguageServers/Cpp: Make find_declaration_of() more flexible
Previously, find_declaration_of() only worked for AST nodes of type
Identifier. It now also works for declaration node, member variables
and function parameters.
2022-02-09 00:51:31 +01:00
Itamar
a54d0cc805 LibGUI+HackStudio: Add TokenInfo struct for language-server IPC
The TokenInfo struct contains the token's position and a
"semantic type". The semantic type is a more fine-grained token type
than what's in Cpp::Token::Type.
For example, the semantic token type differentiates between a reference
to a variable and to a function parameter. In the normal Token::Type,
both would be Token::Type::Identifier.
2022-02-09 00:51:31 +01:00
Itamar
605becb28b LibCpp: Update regressions tests results
The LibCpp regression tests results have to be updated after tweaking
the token end position calculation logic of some token types.
2022-02-09 00:51:31 +01:00
electrikmilk
4263dad838 Base: Change JSON file icon to add CSS file icon
Add CSS icon and add replacement JSON icon as the colors conflict.

Update HackStudioWidget.cpp
2022-02-08 22:42:47 +00:00
davidot
1c4c251be3 LibJS+Everywhere: Remove all VM::clear_exception() calls
Since VM::exception() no longer exists this is now useless. All of these
calls to clear_exception were just to clear the VM state after some
(potentially) failed evaluation and did not use the exception itself.
2022-02-08 09:12:42 +00:00
kleines Filmröllchen
6ee597369d Meta+Userland: Run the GML formatter on CI and pre-commit
Now that the GML formatter is both perserving comments and also mostly
agrees to the existing GML style, it can be used to auto-format all the
GML files in the system. This commit does not only contain the scripts
for running the formatting on CI and the pre-commit hook, but also
initially formats all the existing GML files so that the hook is
successfull.
2022-02-07 18:39:50 +01:00
kleines Filmröllchen
4931c88b13 LibGUI: Remove GML prefix in favor of proper namespace
Prefixes are very much a C thing which we don't need in C++. This commit
moves all GML-related classes in LibGUI into the GUI::GML namespace, a
change somewhat overdue.
2022-02-07 18:39:50 +01:00
electrikmilk
e7b8498a4a Base: Add GML file type icon
Add 16x16 and 32x32 icons for GML files.
2022-02-07 09:25:22 +00:00
Linus Groh
6f20f49b21 Everywhere: Rename JS::PropertyKey variables from property_{name => key}
PropertyKey used to be called PropertyName, but got renamed. Let's
update all the variables of this type as well.
2022-02-06 22:02:45 +00:00
Ali Mohammad Pur
6d64b13a1b LibDebug+Everywhere: Avoid void* -> FlatPtr -> void* dance
And limit the `void*` to the functions that interface the system (i.e.
ptrace wrappers).
This generally makes the code less riddled with casts.
2022-01-28 22:51:27 +00:00
kleines Filmröllchen
145eeb57ab Userland: Remove a bunch of unnecessary Vector imports
How silly :^)
2022-01-28 23:40:25 +01:00
Itamar
106e414800 HackStudio: Fix path to language-server IPC socket
The path to the language server local socket was accidentally broken
in 2e1bbcb.
2022-01-28 13:17:54 +01:00
Luke Wilde
631bbcd00a LibJS: Refactor interpreter to use Script and Source Text Modules
This also refactors interpreter creation to follow
InitializeHostDefinedRealm, but I couldn't fit it in the title :^)

This allows us to follow the spec much more closely rather than being
completely ad-hoc with just the parse node instead of having all the
surrounding data such as the realm of the parse node.

The interpreter creation refactor creates the global execution context
once and doesn't take it off the stack. This allows LibWeb to take the
global execution context and manually handle it, following the HTML
spec. The HTML spec calls this the "realm execution context" of the
environment settings object.

It also allows us to specify the globalThis type, as it can be
different from the global object type. For example, on the web, Window
global objects use a WindowProxy global this value to enforce the same
origin policy on operations like [[GetOwnProperty]].

Finally, it allows us to directly call Program::execute in perform_eval
and perform_shadow_realm_eval as this moves
global_declaration_instantiation into Interpreter::run
(ScriptEvaluation) as per the spec.

Note that this doesn't evalulate Source Text Modules yet or refactor
the bytecode interpreter, that's work for future us :^)

This patch was originally build by Luke for the environment settings
object change but was also needed for modules. So I (davidot) have
modified it with the new completion changes and setup for that.

Co-authored-by: davidot <davidot@serenityos.org>
2022-01-22 01:21:18 +00:00
Itamar
0367893e53 HackStudio: Change ProjectBuilder dependency declaration logic
Previously when generating the HackStudio CMake build file,
we used all dependency libraries that are specified in
target_link_libraries commands as the dependencies of a library.

The recent addition of LibCryptSHA2 broke things because that library
is not declared with serenity_lib like most other libraries
(it uses special linking properties).
This means that we don't declare it in the CMake file we generate.

To fix this, we now filter the dependencies and only include libraries
that we define in the build CMake file.
2022-01-19 19:57:31 +01:00
Brian Gianforcaro
89592601b6 HackStudio: Hookup git commit message detection and highlighting 2022-01-18 09:01:16 +01:00
sin-ack
2e1bbcb0fa LibCore+LibIPC+Everywhere: Return Stream::LocalSocket from LocalServer
This change unfortunately cannot be atomically made without a single
commit changing everything.

Most of the important changes are in LibIPC/Connection.cpp,
LibIPC/ServerConnection.cpp and LibCore/LocalServer.cpp.

The notable changes are:
- IPCCompiler now generates the decode and decode_message functions such
  that they take a Core::Stream::LocalSocket instead of the socket fd.
- IPC::Decoder now uses the receive_fd method of LocalSocket instead of
  doing system calls directly on the fd.
- IPC::ConnectionBase and related classes now use the Stream API
  functions.
- IPC::ServerConnection no longer constructs the socket itself; instead,
  a convenience macro, IPC_CLIENT_CONNECTION, is used in place of
  C_OBJECT and will generate a static try_create factory function for
  the ServerConnection subclass. The subclass is now responsible for
  passing the socket constructed in this function to its
  ServerConnection base; the socket is passed as the first argument to
  the constructor (as a NonnullOwnPtr<Core::Stream::LocalServer>) before
  any other arguments.
- The functionality regarding taking over sockets from SystemServer has
  been moved to LibIPC/SystemServerTakeover.cpp. The Core::LocalSocket
  implementation of this functionality hasn't been deleted due to my
  intention of removing this class in the near future and to reduce
  noise on this (already quite noisy) PR.
2022-01-15 13:29:48 +03:30
Itamar
be81278634 HackStudio: Use ProjectBuilder to build and run the current project
This enables building and running standalone serenity components from
Hack Studio :^)
2022-01-12 14:55:19 +01:00
Itamar
bb6324a9a9 HackStudio: Add ProjectBuilder component
ProjectBuilder takes care of building and running the current project
from Hack Studio.

The existing functionality of building javascript and Makefile projects
remains, and in addition to it the ability to build standalone serenity
components is added.

If the Hack Studio project is the serenity repository itself,
ProjectBuilder will attempt building the component that the currently
active file belongs to.

It does so by creating a new CMake file which adds the component as a
build subdirectory.
It also parses all CMake files in the serenity repository to gather all
available libraries. It declares the libraries and their dependencies in
this CMake file.

It then uses the HACKSTUDIO_BUILD CMake option to direct the build
system to use this CMake file instead of doing a full system build.
2022-01-12 14:55:19 +01:00
Itamar
afb4c447b4 HackStudio: Add optional parameters to TerminalWrapper::run()
The optional parameters allow specifying a working directory and
controlling whether or not to block until the command returns.
2022-01-12 14:55:19 +01:00
Itamar
3afd17db9d HackStudio: Add Project::project_is_serenity() function 2022-01-12 14:55:19 +01:00
Itamar
fbdd6df185 LibCore: Make Core::command return CommandResult struct
Previously, Core::command only returned a String which contained the
data from stdout.

The CommandResult struct contains the exit code as well as the data
from stdout and stderr.
2022-01-12 14:55:19 +01:00
creator1creeper1
d4484f4de3 HackStudio: Propagate errors using try_set_main_widget
The documentation tooltip and parameters hint tooltip initialization
functions are now fallible and now call try_set_main_widget
instead of set_main_widget. They are only called by Editor's new
custom try_create function.
2022-01-09 00:56:11 +01:00
creator1creeper1
4c0b8a70e2 HackStudio: Propagate errors using try_set_main_widget in main 2022-01-09 00:56:11 +01:00
Linus Groh
eb60d16549 LibJS: Convert Interpreter::run() to ThrowCompletionOr<Value>
Instead of making it a void function, checking for an exception, and
then receiving the relevant result via VM::last_value(), we can
consolidate all of this by using completions.

This allows us to remove more uses of VM::exception(), and all uses of
VM::last_value().
2022-01-08 23:43:03 +01:00
mjz19910
3102d8e160 Everywhere: Fix many spelling errors 2022-01-07 10:56:59 +01:00
Ben Wiederhake
8b8cd18482 HackStudio: Avoid unnecessary copies in CodeComprehensionEngine 2022-01-01 15:40:39 +01:00
Conor Byrne
14b2656107 HackStudio: Use String instead of LexicalPath
LexicalPath is a 'heavier' object than a String that is mainly used for
path parsing and validation, we don't actually need any of that in
GitRepo and its related files, so let's move to String :^)

I've also done some east-const conversion in the files that I was
editing for the string change.
2022-01-01 14:47:23 +01:00
Conor Byrne
4cfc992125 HackStudio: Add new multiline commit dialog
This new commit dialog features multi-line input and a line and column
indicator. A great improvement over the last one, if you ask me! :^)
2022-01-01 14:47:23 +01:00
Conor Byrne
507ad1954f HackStudio: Fix crash when clicking unstaged files
In certain cases, an index might be invalid in the unstaged files view.
We must check if this index is valid before attempting to read the
index's data.
2021-12-31 14:12:54 +01:00
Timothy Flynn
565a880ce5 Userland: Link directly against LibUnicodeData where needed
This is partially a revert of commits:
    10a8b6d411
    561b67a1ad

Rather than adding the prot_exec pledge requried to use dlopen(), we can
link directly against LibUnicodeData in applications that we know need
that library.

This might make the dlopen() dance a bit unnecessary. The same purpose
might now be fulfilled with weak symbols. That can be revisted next, but
for now, this at least removes the potential security risk of apps like
the Browser having prot_exec privileges.
2021-12-30 14:18:12 +01:00
Maciej
6cfa58c7f3 HackStudio: Highlight AF files as INI 2021-12-28 11:36:12 +01:00
Conor Byrne
cc1b2b95f7 HackStudio: Ask to create a non-existent directory when making a project
Previously, if the parent directory didn't exist when making a project,
it would say that the creation directory was 'invalid' which isn't
necessarily true.

This patch prompts the user to ask if they would like to create the
parent directory when creating a project, instead of treating it as an
'invalid' directory.
2021-12-27 23:20:54 +01:00
Itamar
1ec917aa23 HackStudio: Attach debuggee to "Console" terminal tab
Previously the debuggee process used the same tty of the HackStudio
process.

We now set things up so the debuggee gets attached to the
TerminalWrapper in the "Console" tab.
2021-12-22 02:14:32 -08:00
Itamar
0cea8d1310 HackStudio: Separate master & slave PTY setup in TerminalWrapper
Previously the setup for both the master and slave pseudoterminals was
done in TerminalWrapper::run_command.

This commit separates the relevant logic into
TerminalWrapper::setup_master_pseudoterminal
and TerminalWrapper::setup_slave_pseudoterminal.
2021-12-22 02:14:32 -08:00
Itamar
83dd1e5b80 HackStudio: Rename "Build" tab to "Console"
The TerminalWrapper in this tab is not only used for displaying build
output, so "Console" would be a better name.
2021-12-22 02:14:32 -08:00
Daniel Bertalan
4a81b33c07 Everywhere: Fix -Winconsistent-missing-override warnings from Clang
This option is already enabled when building Lagom, so let's enable it
for the main build too. We will no longer be surprised by Lagom Clang
CI builds failing while everything compiles locally.

Furthermore, the stronger `-Wsuggest-override` warning is enabled in
this commit, which enforces the use of the `override` keyword in all
classes, not just those which already have some methods marked as
`override`. This works with both GCC and Clang.
2021-12-11 13:14:15 -08:00
scwfri
8d0143a380 HackStudio+TextEditor: Persist EditingEngineType across editors
Persist EditingEngine mode in HackStudio and TextEditor when opening new
files or editing splits. Previously, the EditingEngine defaulted to a
RegularEditingEngine for a new Editor, even if Vim Emulation had been
selected in the existing Editor.
2021-12-09 21:31:06 +01:00
Andreas Kling
971b3645ef LibIPC: Add IPC::take_over_accepted_client_from_system_server<Client>()
This is an encapsulation of the common work done by all of our
single-client IPC servers on startup:

    1. Create a Core::LocalSocket, taking over an accepted fd.
    2. Create an application-specific ClientConnection object,
       wrapping the socket.

It's not a huge change in terms of lines saved, but I do feel that it
improves expressiveness. :^)
2021-12-06 19:22:16 +01:00