Commit Graph

54 Commits

Author SHA1 Message Date
Nick Vella
b671577223 HackStudio: Project templates and New Project dialog
This commit adds a simple project template system to HackStudio,
as well as a pretty New Project dialog, inspired by early VS.NET
and MS Office.
2021-02-13 19:49:30 +01:00
Itamar
ef9bfbd383 LanguageServers/Cpp: Autocomplete declarations from included headers
We now also look at the available declarations from included header
files when autocompleting names.

Additionally, you can now request autocomplete on an empty token, which
brings up all available names, starting from the inner-most scope.
2021-02-10 23:09:40 +01:00
Itamar
64c80f6ea4 LanguageServers/Cpp: Autocomplete function and struct/class names 2021-02-10 23:09:40 +01:00
Itamar
e42b9e879c HackStudio: Show notification if 'make' is not available
We previously popped a MessageBox for this, but a notification is less
disruptive.
2021-02-10 23:04:54 +01:00
Itamar
72fdab7bfb LanguageServers/Cpp: ParserAutoComplete engine inspects header files
... and performs preprocessing on the source code before parsing.

To support this, we are now able to keep track of multiple
files in the autocomplete engine. We re-parse a file whenever it is
edited.
2021-02-08 23:10:38 +01:00
Itamar
02038a0ede LanguageServers/Cpp: Use FileDB and AutoCompleteEngine base class 2021-02-08 23:10:38 +01:00
Itamar
bed06b13f3 LanguageServers/Cpp: Add FileDB and pass project_root in Greet()
FileDB wraps the access to the contents of project files.

When asked to fetch a file, FileDB will either return its in-memory
model of the file if it has been "opened" by the language-server
protocol, or otherwise fetch it from the filesystem.

Previously, the cpp language server did not pledge "rpath" and got
access to the contents of files whenever they were opened by the
language client.
However, features like inspection of header files require the language
server to get the content of files that were not opened by the client.

The language server now pledges rpath but makes sure to only unveil
the project's directory and /usr/include.
2021-02-08 23:10:38 +01:00
AnotherTest
09a43969ba Everywhere: Replace dbgln<flag>(...) with dbgln_if(flag, ...)
Replacement made by `find Kernel Userland -name '*.h' -o -name '*.cpp' | sed -i -Ee 's/dbgln\b<(\w+)>\(/dbgln_if(\1, /g'`
2021-02-08 18:08:55 +01:00
AnotherTest
b68e34cc2e UserspaceEmulator: Use vdbgln() instead of dbgln() when reporting
This will avoid conflict with the upcoming compiletime checks.
2021-02-08 18:08:55 +01:00
Ben Wiederhake
0a2304ba05 Everywhere: Fix weird includes 2021-02-08 18:03:57 +01:00
Ben Wiederhake
7961e09c29 Everywhere: Add semantically-missing includes
For example, FindInFilesWidget.h mentions GUI::TableView, but did not include
it. On the other hand, all source files that include FindInFilesWidget.h
also include TableView.h, so the issue is only cosmetical.
2021-02-08 18:03:57 +01:00
Andreas Kling
50308f6fda Shell: Move Shell syntax highlighter LibShell 2021-02-07 17:07:33 +01:00
Andreas Kling
ddbf20ecf6 LibSyntax+LibGUI+LibJS: Move JS syntax highlighter to LibJS
This is a little bit messy but the basic idea is:

Syntax::Highlighter now has a Syntax::HighlighterClient to talk to the
outside world. It mostly communicates in LibGUI primitives that are
available in headers, so inlineable.

GUI::TextEditor inherits from Syntax::HighlighterClient.

This let us to move GUI::JSSyntaxHighlighter to JS::SyntaxHighlighter
and remove LibGUI's dependency on LibJS.
2021-02-07 16:56:02 +01:00
Andreas Kling
43c7d7d285 LibSyntax: Move GUI::Highlighter to Syntax::Highlighter in LibSyntax
This is a move towards dropping more LibGUI dependencies.
2021-02-07 15:15:10 +01:00
Andreas Kling
ff2438e0ce LibGUI+LibCpp: Move C++ syntax highlighter to LibCpp
This makes LibGUI not depend on LibCpp.
2021-02-07 14:40:36 +01:00
Andreas Kling
89483a9408 UserspaceEmulator: Implement a proper VM allocator
This patch brings Kernel::RangeAllocator to UserspaceEmulator in a
slightly simplified form.

It supports the basic three allocation types needed by virt$mmap():
allocate_anywhere, allocate_specific, and allocate_randomized.

Porting virt$mmap() and virt$munmap() to use the allocator makes
UE work correctly once again. :^)
2021-02-06 23:15:44 +01:00
Andreas Kling
9dacd7c0ec UserspaceEmulator: Stub out virt$msyscall()
This is a no-op inside UE for now.
2021-02-06 23:15:44 +01:00
Sahan Fernando
7e9122950e Profiler: Display timing information in ProfileTimelineWidget
Currently, there is no way to know when in a profile's duration a
sample was taken. This commit adds a basic timestamp to the timeline
widget, and a black bar to show where the cursor is hovering over.
2021-02-06 08:55:34 +01:00
Andreas Kling
e87eac9273 Userland: Add LibSystem and funnel all syscalls through it
This achieves two things:

- Programs can now intentionally perform arbitrary syscalls by calling
  syscall(). This allows us to work on things like syscall fuzzing.

- It restricts the ability of userspace to make syscalls to a single
  4KB page of code. In order to call the kernel directly, an attacker
  must now locate this page and call through it.
2021-02-05 12:23:39 +01:00
Zac
cc2f35badd TextEditor: Implement word wrapping
Add a new wrapping mode to the TextEditor that will wrap lines at the
spaces between words.

Replace the previous menubar checkbox 'Wrapping Mode' in HackStudio and
the TextEditor with an exclusive submenu which allows switching between
'No wrapping', 'Wrap anywhere' and 'Wrap at words'. 'Wrap anywhere' (the
new 'Wrap lines') is still the default mode.

Setting the wrapping mode in the constructors of the TextEditorWidget
and HackStudio has been removed, it is now set when constructing the
menubar actions.
2021-02-03 10:33:23 +01:00
Matteo Sozzi
2031baebce HackStudio: do not open empty directories as file
When _double clicking_ or _right click > Open_ in the tree view, the
selected directory, if empty, was open in the editor section as file.
2021-02-03 10:15:09 +01:00
Matteo Sozzi
a8dfba6348 HackStudio: tree_view on_activiation changes
When opening a file in the tree view with _double click_, the file name
was not the same as opening the same file with _right click > Open_.

This caused the opne_files_view to have the same file in it, but with
two different names.
2021-02-03 10:15:09 +01:00
Andreas Kling
1ce03f4f34 LibIPC: Stop sending client ID to clients
The client ID is not useful to normal clients anymore, so stop telling
everyone what their ID is.
2021-02-01 11:32:00 +01:00
Matteo Sozzi
40da077f6c HackStudio: added new directory action
Added the possibility to create a new directory in the current project.
2021-02-01 09:52:13 +01:00
Brendan Coles
50092ea0ca Inspector: Exit if inspected process has not pledged accept 2021-01-31 09:08:51 +01:00
Matteo Sozzi
32a363ded5 HackStudio: removed toggle_index
Removed `m_project_tree_view->toggle_index()` when adding new file to
project.
2021-01-30 22:59:59 +01:00
Brendan Coles
58abdde2e4 Inspector: Allow browsing inspection data in UI after process exits 2021-01-30 14:10:10 +01:00
Matteo Sozzi
f80b40b411 HackStudio: do not toggle_index in open_project
When opening a new project `m_prject_tree_view->toggle_index()` is not
needed because `m_project_tree_view->set_model()` already updates the
indexes.
2021-01-30 14:08:41 +01:00
Itamar
fa18010477 HackStudio: Integate with C++ parser-based autocomplete
By default, C++ auto completion will still be performed by the
lexer-based logic.
However, the parser-based logic can be switched on via the menubar.
2021-01-27 21:10:57 +01:00
Itamar
8ed96eb27c HackStudio: Attach previous Language Client when detaching
Previously, if a new LanguageClient was created & destroyed, the
ServerConnection to the language server would be left without an
attached LanguageClient.
As a result, auto-completion results would not be updated in the UI.

Starting with this commit, the LanguageClient holds a WeakPtr to the
previous LanguageClient that was attached to the ServerConnection,
and re-attaches it after detaching itself.
2021-01-27 21:10:57 +01:00
Itamar
c85dad2383 HackStudio: Add parser-based c++ autocomplete engine 2021-01-27 21:10:57 +01:00
asynts
eea72b9b5c Everywhere: Hook up remaining debug macros to Debug.h. 2021-01-25 09:47:36 +01:00
asynts
8465683dcf Everywhere: Debug macros instead of constexpr.
This was done with the following script:

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/dbgln<debug_([a-z_]+)>/dbgln<\U\1_DEBUG>/' {} \;

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/if constexpr \(debug_([a-z0-9_]+)/if constexpr \(\U\1_DEBUG/' {} \;
2021-01-25 09:47:36 +01:00
asynts
bb483f7ef4 Everywhere: Name debug macros more consistently.
Personally, I prefer the naming convention DEBUG_FOO over FOO_DEBUG, but
the majority of the debug macros are already named in the latter naming
convention, so I just enforce consistency here.

This was done with the following script:

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/DEBUG_PATH/PATH_DEBUG/' {} \;
2021-01-25 09:47:36 +01:00
asynts
acdcf59a33 Everywhere: Remove unnecessary debug comments.
It would be tempting to uncomment these statements, but that won't work
with the new changes.

This was done with the following commands:

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/#define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/#define/ { toggle = 1 }' {} \;

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/ #define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/ #define/ { toggle = 1 }' {} \;
2021-01-25 09:47:36 +01:00
asynts
1a3a0836c0 Everywhere: Use CMake to generate AK/Debug.h.
This was done with the help of several scripts, I dump them here to
easily find them later:

    awk '/#ifdef/ { print "#cmakedefine01 "$2 }' AK/Debug.h.in

    for debug_macro in $(awk '/#ifdef/ { print $2 }' AK/Debug.h.in)
    do
        find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/#ifdef '$debug_macro'/#if '$debug_macro'/' {} \;
    done

    # Remember to remove WRAPPER_GERNERATOR_DEBUG from the list.
    awk '/#cmake/ { print "set("$2" ON)" }' AK/Debug.h.in
2021-01-25 09:47:36 +01:00
Ben Wiederhake
9058a8367f UserspaceEmulator: Improve error message for typos 2021-01-23 16:47:09 +01:00
Ben Wiederhake
792fa9f9fd UserspaceEmulator: Implement chown
Now we can run 'ue chown anon ReadMe.md' :^)
2021-01-23 16:47:09 +01:00
Andreas Kling
c5df0532c0 HackStudio: Handle failed fork() in TerminalWrapper a bit better 2021-01-23 08:39:59 +01:00
asynts
27bc48e06c Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-22 22:14:30 +01:00
Andreas Kling
bf0719092f Kernel+Userland: Remove shared buffers (shbufs)
All users of this mechanism have been switched to anonymous files and
passing file descriptors with sendfd()/recvfd().

Shbufs got us where we are today, but it's time we say good-bye to them
and welcome a much more idiomatic replacement. :^)
2021-01-17 09:07:32 +01:00
Andreas Kling
cc8b3c92ba Everywhere: Remove a bunch of now-unnecessary shared_buffer pledges 2021-01-17 09:07:32 +01:00
Andreas Kling
05dbfe9ab6 Kernel: Remove sys$shbuf_seal() and userland wrappers
There are no remaining users of this syscall so let it go. :^)
2021-01-17 00:18:01 +01:00
Andreas Kling
b818cf898e Kernel+Userland: Remove sys$shbuf_allow_all() and userland wrappers
Nobody is using globally shared shbufs anymore, so let's remove them.
2021-01-16 22:43:03 +01:00
Ben Wiederhake
7ed002d1ca UserlandEmulator: Fix data loss in realpath/readlink
This 'data loss' was introduced in 809a8ee693, because
I hoped we could eventually outlaw overlong paths entirely. This sparked some discussion:
https://github.com/SerenityOS/serenity/discussions/4357
Among other things, we agree that yeah, the Kernel can and should be able to return
paths of arbitrary length. This means that the 'arbitrary' maximum of PATH_MAX in
UserspaceEmulator should be considered to be unnecessary data loss, and as such, needs to
be fixed.
2021-01-16 22:40:53 +01:00
Andreas Kling
d312011708 Everywhere: Drop "shared_buffer" in most GUI programs, pledge "recvfd"
Now that WindowServer broadcasts the system theme using an anonymous
file, we need clients to pledge "recvfd" so they can receive it.

Some programs keep the "shared_buffer" pledge since it's still used for
a handful of things.
2021-01-16 19:30:32 +01:00
Andreas Kling
de31e82f97 Kernel: Remove sys$shbuf_set_volatile() and userland wrappers
There are no remaining users of this syscall so let's remove it! :^)
2021-01-16 14:52:04 +01:00
Andreas Kling
c71807a3fc Everywhere: Convert a handful of String::format() => formatted() 2021-01-16 14:52:04 +01:00
Andreas Kling
12879184ce UserspaceEmulator: Support the anon_create, sendfd and recvfd syscalls 2021-01-15 14:17:19 +01:00
Andreas Kling
20915795a8 Everywhere: Pledge "sendfd" in WindowServer client programs
This is needed for the new way we transfer window backing stores.
2021-01-15 14:10:32 +01:00