Skip to content

Commit

Permalink
LSP implementation improvements, added support for showMessage and sh…
Browse files Browse the repository at this point in the history
…owDocument.

Added Vue support (Syntax Highlighting and LSP). Closes SpartanJ/ecode#38.
Added Java LSP support.
Improved auto close XML tags. Closes SpartanJ/ecode#39.
Improved UIMenuCheckBox behavior.
  • Loading branch information
SpartanJ committed Feb 10, 2023
1 parent 2689e02 commit d786aec
Show file tree
Hide file tree
Showing 19 changed files with 409 additions and 45 deletions.
14 changes: 14 additions & 0 deletions bin/assets/plugins/lspclient.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,20 @@
"command": "OmniSharp -lsp",
"file_patterns": ["%.cs$", "%.csx$"],
"rootIndicationFileNames": ["%.sln$"]
},
{
"language": "vue",
"name": "vls",
"url": "https://github.com/vuejs/vetur/tree/master/server",
"command": "vls --stdio",
"file_patterns": ["%.vue$"]
},
{
"language": "java",
"name": "jdtls",
"url": "https://github.com/eclipse/eclipse.jdt.ls",
"command": "jdtls",
"file_patterns": ["%.java$"]
}
]
}
9 changes: 7 additions & 2 deletions include/eepp/ui/doc/syntaxdefinition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,15 @@ class EE_API SyntaxDefinition {

const std::string& getLSPName() const;

void setVisible( bool visible );
SyntaxDefinition& setVisible( bool visible );

bool isVisible() const;

protected:
bool getAutoCloseXMLTags() const;

SyntaxDefinition& setAutoCloseXMLTags(bool autoCloseXMLTags);

protected:
std::string mLanguageName;
String::HashType mLanguageId;
std::vector<std::string> mFiles;
Expand All @@ -88,6 +92,7 @@ class EE_API SyntaxDefinition {
std::string mComment;
std::vector<std::string> mHeaders;
std::string mLSPName;
bool mAutoCloseXMLTags{ false };
bool mVisible{ true };
};

Expand Down
2 changes: 2 additions & 0 deletions include/eepp/ui/doc/syntaxdefinitionmanager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ class EE_API SyntaxDefinitionManager {
void addNelua();

void addTeal();

void addVue();
};

}}} // namespace EE::UI::Doc
Expand Down
2 changes: 1 addition & 1 deletion include/eepp/ui/uimenucheckbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class EE_API UIMenuCheckBox : public UIMenuItem {
UISkin* mSkinActive;
UISkin* mSkinInactive;

virtual Uint32 onMouseUp( const Vector2i& position, const Uint32& flags );
Uint32 onMessage( const NodeMessage* msg );

virtual void onStateChange();
};
Expand Down
105 changes: 102 additions & 3 deletions projects/linux/ee.creator.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 8.0.2, 2023-02-08T16:38:47. -->
<!-- Written by QtCreator 8.0.2, 2023-02-09T22:23:21. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down Expand Up @@ -1204,7 +1204,6 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">ecode-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="QString" key="RunConfiguration.Arguments">../</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
Expand Down Expand Up @@ -1431,9 +1430,109 @@
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">21</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.1</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Replacement for &quot;Desktop&quot;</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Replacement for &quot;Desktop&quot;</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{6d057187-158a-4883-8d5b-d470a6b6b025}</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/programming/eepp/projects/linux</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Default</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericBuildConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="QString" key="Analyzer.Valgrind.FilterExternalIssues">false</value>
<value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">/usr/bin/kcachegrind</value>
<value type="QString" key="Analyzer.Valgrind.LeakCheckOnFinish">2</value>
<value type="QString" key="Analyzer.Valgrind.SelfModifyingCodeDetection">2</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="QString" key="Analyzer.Valgrind.ShowReachable">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">/usr/bin/valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="QString">11</value>
<value type="QString">14</value>
<value type="QString">12</value>
<value type="QString">13</value>
<value type="QString">2</value>
<value type="QString">3</value>
<value type="QString">4</value>
<value type="QString">5</value>
<value type="QString">6</value>
<value type="QString">7</value>
<value type="QString">8</value>
<value type="QString">9</value>
<value type="QString">10</value>
<value type="QString">0</value>
<value type="QString">1</value>
</valuelist>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="qlonglong">1</value>
<value type="qlonglong">2</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
Expand Down
12 changes: 11 additions & 1 deletion src/eepp/ui/doc/syntaxdefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,24 @@ const std::string& SyntaxDefinition::getLSPName() const {
return mLSPName;
}

void SyntaxDefinition::setVisible( bool visible ) {
SyntaxDefinition& SyntaxDefinition::setVisible( bool visible ) {
mVisible = visible;
return *this;
}

bool SyntaxDefinition::isVisible() const {
return mVisible;
}

bool SyntaxDefinition::getAutoCloseXMLTags() const {
return mAutoCloseXMLTags;
}

SyntaxDefinition& SyntaxDefinition::setAutoCloseXMLTags( bool autoCloseXMLTags ) {
mAutoCloseXMLTags = autoCloseXMLTags;
return *this;
}

const std::string& SyntaxDefinition::getLanguageName() const {
return mLanguageName;
}
Expand Down
67 changes: 64 additions & 3 deletions src/eepp/ui/doc/syntaxdefinitionmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ SyntaxDefinitionManager::SyntaxDefinitionManager() {
addNelua();

addTeal();

addVue();
}

void SyntaxDefinitionManager::addPlainText() {
Expand Down Expand Up @@ -152,7 +154,8 @@ void SyntaxDefinitionManager::addXML() {
},
{},
"",
{ "<%?xml" } } );
{ "<%?xml" } } )
.setAutoCloseXMLTags( true );
}

void SyntaxDefinitionManager::addHTML() {
Expand Down Expand Up @@ -186,7 +189,8 @@ void SyntaxDefinitionManager::addHTML() {
},
{},
"",
{ "<html", "<![Dd][Oo][Cc][Tt][Yy][Pp][Ee]%s[Hh][Tt][Mm][Ll]>" } } );
{ "<html", "<![Dd][Oo][Cc][Tt][Yy][Pp][Ee]%s[Hh][Tt][Mm][Ll]>" } } )
.setAutoCloseXMLTags( true );
}

void SyntaxDefinitionManager::addCSS() {
Expand Down Expand Up @@ -880,7 +884,8 @@ void SyntaxDefinitionManager::addPHP() {
},
{},
"",
{ "^#!.*[ /]php" } } );
{ "^#!.*[ /]php" } } )
.setAutoCloseXMLTags( true );

add( { "PHPCore",
{},
Expand Down Expand Up @@ -3863,6 +3868,62 @@ void SyntaxDefinitionManager::addTeal() {
{ "^#!.*[ /]tl" } } );
}

void SyntaxDefinitionManager::addVue() {
add( { "Vue-HTML",
{},
{
{ { "%{%{%{", "%}%}%}" }, "function", "JavaScript" },
{ { "%{%{", "%}%}" }, "function", "JavaScript" },
{ { "<!%-%-", "%-%->" }, "comment" },
{ { "%f[^>][^<]", "%f[<]" }, "normal" },
{ { "\"", "\"", "\\" }, "string" },
{ { "'", "'", "\\" }, "string" },
{ { "0x[%da-fA-F]+" }, "number" },
{ { "-?%d+[%d%.]*f?" }, "number" },
{ { "-?%.?%d+f?" }, "number" },
{ { "%f[^<]![%a_][%w%_%-]*" }, "keyword2" },
{ { "%f[^<][%a_][%w%_%-]*" }, "function" },
{ { "%f[^<]/[%a_][%w%_%-]*" }, "function" },
{ { "[%a_][%w_]*" }, "keyword" },
{ { "[/<>=]" }, "operator" },
},
{},
"",
{} } )
.setVisible( false )
.setAutoCloseXMLTags( true );

add( { "Vue",
{ "%.vue?$" },
{
{ { "<%s*[sS][cC][rR][iI][pP][tT]%s*>", "<%s*/%s*[sS][cC][rR][iI][pP][tT]>" },
"function",
"JavaScript" },
{ { "<%s*[sS][tT][yY][lL][eE][^>]*>", "<%s*/%s*[sS][tT][yY][lL][eE]%s*>" },
"function",
"CSS" },
{ { "<%s*[tT][eE][mM][pP][lL][aA][tT][eE][^>]*>",
"<%s*/%s*[tT][eE][mM][pP][lL][aA][tT][eE]%s*>" },
"function",
"Vue-HTML" },
{ { "<!%-%-", "%-%->" }, "comment" },
{ { "%f[^>][^<]", "%f[<]" }, "normal" },
{ { "\"", "\"", "\\" }, "string" },
{ { "'", "'", "\\" }, "string" },
{ { "0x[%da-fA-F]+" }, "number" },
{ { "-?%d+[%d%.]*f?" }, "number" },
{ { "-?%.?%d+f?" }, "number" },
{ { "%f[^<]![%a_][%w%_%-]*" }, "keyword2" },
{ { "%f[^<][%a_][%w%_%-]*" }, "function" },
{ { "%f[^<]/[%a_][%w%_%-]*" }, "function" },
{ { "[%a_][%w_]*" }, "keyword" },
{ { "[/<>=]" }, "operator" },
},
{},
"",
{} } );
}

SyntaxDefinition& SyntaxDefinitionManager::add( SyntaxDefinition&& syntaxStyle ) {
mDefinitions.emplace_back( std::move( syntaxStyle ) );
return mDefinitions.back();
Expand Down
5 changes: 1 addition & 4 deletions src/eepp/ui/uicodeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3430,11 +3430,8 @@ bool UICodeEditor::checkAutoCloseXMLTag( const String& text ) {
return false;
if ( line[start.column() - 1] != '>' || ( line.size() > 2 && line[start.column() - 2] == '/' ) )
return false;
// Only close tags if the current line syntax is XML or HTML
const SyntaxDefinition& definition = mHighlighter.getSyntaxDefinitionFromTextPosition( start );
const String::HashType xmlType = String::hash( "xml" );
const String::HashType htmlType = String::hash( "html" );
if ( definition.getLanguageId() != xmlType && definition.getLanguageId() != htmlType )
if ( !definition.getAutoCloseXMLTags() )
return false;
size_t foundOpenPos = line.find_last_of( "<", start.column() - 1 );
if ( foundOpenPos == String::InvalidPos || start.column() - foundOpenPos < 1 )
Expand Down
9 changes: 7 additions & 2 deletions src/eepp/ui/uimenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,13 @@ Uint32 UIMenu::onKeyDown( const KeyEvent& event ) {
if ( nullptr != mItemSelected && nullptr != getEventDispatcher() ) {
mItemSelected->sendMouseEvent(
Event::MouseClick, getEventDispatcher()->getMousePos(), EE_BUTTON_LMASK );
NodeMessage msg( mItemSelected, NodeMessage::MouseUp, EE_BUTTON_LMASK );
mItemSelected->messagePost( &msg );
if ( mItemSelected ) {
NodeMessage msg( mItemSelected, NodeMessage::MouseUp, EE_BUTTON_LMASK );
mItemSelected->messagePost( &msg );
}
if ( mItemSelected ) {
mItemSelected->forceKeyDown( event );
}
}
break;
default:
Expand Down
16 changes: 9 additions & 7 deletions src/eepp/ui/uimenucheckbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,15 @@ void UIMenuCheckBox::switchActive() {
setActive( !mActive );
}

Uint32 UIMenuCheckBox::onMouseUp( const Vector2i& Pos, const Uint32& Flags ) {
UIMenuItem::onMouseUp( Pos, Flags );

if ( getParent()->isVisible() && ( Flags & EE_BUTTONS_LRM ) )
switchActive();

return 1;
Uint32 UIMenuCheckBox::onMessage( const NodeMessage* msg ) {
switch ( msg->getMsg() ) {
case NodeMessage::MouseUp: {
if ( msg->getFlags() & EE_BUTTON_LMASK )
switchActive();
break;
}
}
return 0;
}

void UIMenuCheckBox::onStateChange() {
Expand Down
7 changes: 6 additions & 1 deletion src/eepp/ui/uimenuitem.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include <eepp/ui/uimenu.hpp>
#include <eepp/ui/uimenuitem.hpp>
#include <eepp/ui/uiscenenode.hpp>
#include <eepp/window/input.hpp>
#include <eepp/window/window.hpp>

namespace EE { namespace UI {

Expand Down Expand Up @@ -69,8 +72,10 @@ Uint32 UIMenuItem::onMouseLeave( const Vector2i& pos, const Uint32& flags ) {
}

Uint32 UIMenuItem::onMouseClick( const Vector2i&, const Uint32& flags ) {
if ( ( flags & EE_BUTTON_LMASK ) && ( !mOnShouldCloseCb || mOnShouldCloseCb( this ) ) )
if ( !getUISceneNode()->getWindow()->getInput()->isShiftPressed() &&
( flags & EE_BUTTON_LMASK ) && ( !mOnShouldCloseCb || mOnShouldCloseCb( this ) ) ) {
getParent()->asType<UIMenu>()->backpropagateHide();
}
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/thirdparty/efsw
Loading

0 comments on commit d786aec

Please sign in to comment.