Explorar o código

LanguageServers/Cpp: Add type to Declarations

Itamar %!s(int64=4) %!d(string=hai) anos
pai
achega
71c7597130

+ 6 - 0
Userland/DevTools/HackStudio/AutoCompleteResponse.h

@@ -97,6 +97,7 @@ inline bool encode(Encoder& encoder, const GUI::AutocompleteProvider::Declaratio
     encoder << declaration.name;
     if (!encode(encoder, declaration.position))
         return false;
+    encoder << (u32)declaration.type;
     return true;
 }
 
@@ -108,6 +109,11 @@ inline bool decode(Decoder& decoder, GUI::AutocompleteProvider::Declaration& dec
 
     if (!decode(decoder, declaration.position))
         return false;
+    u32 type;
+    if (!decoder.decode( type))
+        return false;
+
+    declaration.type = static_cast<GUI::AutocompleteProvider::DeclarationType>(type);
     return true;
 }
 

+ 8 - 0
Userland/Libraries/LibGUI/AutocompleteProvider.h

@@ -62,9 +62,17 @@ public:
         size_t column { 0 };
     };
 
+    enum class DeclarationType {
+        Function,
+        Struct,
+        Class,
+        Variable
+    };
+
     struct Declaration {
         String name;
         ProjectLocation position;
+        DeclarationType type;
     };
 
     virtual void provide_completions(Function<void(Vector<Entry>)>) = 0;