【问题标题】:Xtext Content Assist not triggered by CTRL+SPACE inside the Orion web editorOrion Web 编辑器中的 CTRL+SPACE 未触发 Xtext Content Assist
【发布时间】:2018-07-26 06:08:53
【问题描述】:

我正在尝试将 Xtext (2.14.0) 与 Orion Web 编辑器一起使用,但即使是一个简单的示例,CTRL+SPACE也不会触发内容辅助> 在 Orion 编辑器中。

据我所知,CTRL+SPACE 默认用于触发 Orion 编辑器内的内容辅助。

我还想提一下,如果我在 "contentAssistCharTriggers" 选项中添加一个字符(如 Xtext 文档中所述),则指定的字符会触发内容辅助,但 CTRL +SPACE还是不行。

有谁知道可能是什么问题?

更新: 我正在使用基本的 xtext 状态机示例。 以下是用于嵌入 Orion 编辑器的 html 文件:

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="Content-Language" content="en-us">
	<title>Example Web Editor</title>
	<link rel="stylesheet" type="text/css" href="dependencies/orion/code_edit/built-codeEdit.css"/>
	<link rel="stylesheet" type="text/css" href="xtext/2.14.0/xtext-orion.css"/>
	<link rel="stylesheet" type="text/css" href="style.css"/>
	<script src="webjars/requirejs/2.3.2/require.min.js"></script>
	<script type="text/javascript">
		var baseUrl = window.location.pathname;
		var fileIndex = baseUrl.indexOf("index.html");
		if (fileIndex > 0)
			baseUrl = baseUrl.slice(0, fileIndex);
		require.config({
			baseUrl: baseUrl,
			paths: {
				"text": "webjars/requirejs-text/2.0.15/text",
				"jquery": "webjars/jquery/2.2.4/jquery.min",
				"xtext/xtext-orion": "xtext/2.14.0/xtext-orion"
			}
		});
		require(["dependencies/orion/code_edit/built-codeEdit-amd"], function() {
			require(["xtext/xtext-orion"], function(xtext) {
				xtext.createEditor({
					baseUrl: baseUrl,
					syntaxDefinition: "xtext-resources/generated/mylang-syntax",
					contentAssistCharTriggers: " "				
				});
			});
		});
	</script>
</head>
<body>

<div class="container">
	<div class="header">
		<h1>Demo</h1>
	</div>
	<div class="content">
		<div id="xtext-editor" data-editor-xtext-lang="mylang"></div>
	</div>
</div>

</body>
</html>

【问题讨论】:

  • 你能提供一个最小的可重复的例子吗?你检查了 javascript 控制台是否有错误?
  • 我已经用更多信息更新了我的帖子。控制台中没有 javascript 错误。据我所见,当使用 CTRL+SPACE 触发内容辅助时,内容辅助提供者似乎不受 Orion 编辑器的限制。如果您在“setState”函数(第 39719 行)上设置断点并检查 ContentAssist 对象的“_mode”属性,则可以在 build-codeEdit-amd.js 文件中检查这一点。当您使用 CTRL+SPACE 时,您会看到它是“未定义的”。此外,如果您使用“contentAssistCharTriggers”中指定的字符,则“_mode”属性设置正确。
  • 这就是为什么我要求一个“完整”的例子(github/gitlab/...)
  • 您选择了哪个版本的猎户座。如果你从一个非空文件开始会发生什么
  • 意思是:输入一个空格。内容辅助

标签: xtext eclipse-orion


【解决方案1】:

这是适合我的索引 html(使用 crtl+space 进行内容辅助)

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="Content-Language" content="en-us">
    <title>Example Web Editor</title>
    <link rel="stylesheet" type="text/css" href="orion/code_edit/built-codeEdit.css"/>
    <link rel="stylesheet" type="text/css" href="xtext/2.14.0/xtext-orion.css"/>
    <link rel="stylesheet" type="text/css" href="style.css"/>
    <script src="webjars/requirejs/2.3.2/require.min.js"></script>
    <script type="text/javascript">
        var baseUrl = window.location.pathname;
        var fileIndex = baseUrl.indexOf("index.html");
        if (fileIndex > 0)
            baseUrl = baseUrl.slice(0, fileIndex);
        require.config({
            baseUrl: baseUrl,
            paths: {
                "text": "webjars/requirejs-text/2.0.15/text",
                "jquery": "webjars/jquery/2.2.4/jquery.min",
                "xtext/xtext-orion": "xtext/2.14.0/xtext-orion"
            }
        });
        require(["orion/code_edit/built-codeEdit-amd"], function() {
            require(["xtext/xtext-orion"], function(xtext) {
                xtext.createEditor({
                    baseUrl: baseUrl,
                    syntaxDefinition: "xtext-resources/generated/mydsl-syntax"
                });
            });
        });
    </script>
</head>
<body>

<div class="container">
    <div class="header">
        <h1>Example MyDsl Web Editor</h1>
    </div>
    <div class="content">
        <div id="xtext-editor" data-editor-xtext-lang="mydsl">
        </div>  
    </div>
</div>

</body>
</html>

这就是你的东西的样子

【讨论】:

【解决方案2】:

将 requirejs 更新到 2.3.6 并将 jquery 更新到 3.3.1-1 使 codeEdit 与您的版本一起工作。 我们更新了将于 2019 年春季推出的 Xtext 2.17 中的所有内容。

【讨论】:

猜你喜欢
  • 2015-08-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-12-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多