每当我在新的eclipse窗口中测试我的语法时,我会在保存时遇到一些例外。 不知道为什么。 我想也许xtext期待一个java项目。因为我尝试使用java项目然后它没有任何异常。 我扩展了一个示例项目(homeautomation)。所以也许它已经实现了。但我无法弄清楚在哪里 你能告诉我为什么xtext期待一个java项目。
这是我的代码:
/*******************************************************************************
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
grammar org.eclipse.xtext.example.homeautomation.RuleEngine with org.eclipse.xtext.xbase.Xbase
import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase
generate ruleEngine "http://www.eclipse.org/Xtext/example/RuleEngine"
Model:
(declarations += GIHeader) ;
//declarations+=Declaration*;
GIHeader: //General Information about Test
KWHeader
;
Declaration:
Section;
KWHeader:
('CLASSIFICATION' | 'classification') PROPERTY_VALUE+ (properties+=Property+) &
('NAME' | 'name') PROPERTY_VALUE+ (properties+=Property+) &
('PROJECTS' |'projects') PROPERTY_VALUE+ (properties+=Property+) &
('NUMBER' | 'number') PROPERTY_VALUE+ (int+=PropNumber+) &
('testcase' | 'test case' | 'TESTCASE' | 'TEST CASE' | 'Testcase' | 'Test Case')
(properties+=Property)+
;
// We modify the concrete syntax of two Xbase expressions and make them indentation-aware
XBlockExpression returns xbase::XExpression:
{xbase::XBlockExpression}
BEGIN
(expressions+=XExpressionOrVarDeclaration ';'?)*
END;
XSwitchExpression returns xbase::XExpression:
{xbase::XSwitchExpression}
'switch' (=>('(' declaredParam=JvmFormalParameter ':') switch=XExpression ')'
| =>(declaredParam=JvmFormalParameter ':')? switch=XExpression)
BEGIN
(cases+=XCasePart)*
('default' ':' default=XExpression )?
END;
Property:
id=ID | int=INT | prop=PROPERTY_VALUE | spec=SPECIAL
;
PropNumber:
int=INT | spec=SPECIAL
;
// The following synthetic tokens are used for the indentation-aware blocks
terminal BEGIN: 'synthetic:BEGIN'; // increase indentation
terminal END: 'synthetic:END'; // decrease indentation
terminal WS: ('\t'|'\r'|'\n')+;
PROPERTY_VALUE: (':' | '=');// !('\n' | '\r')*;
SPECIAL: (' '|'/'|';'|','|'!'|'§'|'$'|'%'|'&'|'('|')'|'='|'?'|'*'|'+'|'.'|'-'|'>'|'<'|'|'|'['|']')
(' '|'/'|';'|','|'!'|'§'|'$'|'%'|'&'|'('|')'|'='|'?'|'*'|'+'|'.'|'-'|'>'|'<'|'|'|'['|']')*
;
// Single line comment
terminal SL_COMMENT: '#' !('\n'|'\r')* ('\r'? '\n')?;
例外。
1849463 [Worker-21] ERROR org.eclipse.xtext.builder.impl.XtextBuilder - Java Model Exception: Java Model Status [asdf does not exist]
java.lang.RuntimeException: Java Model Exception: Java Model Status [asdf does not exist]
at org.eclipse.xtext.builder.JDTAwareSourceFolderProvider.getSourceFolders(JDTAwareSourceFolderProvider.java:36)
at org.eclipse.xtext.builder.EclipseOutputConfigurationProvider.createAndOverlayOutputConfiguration(EclipseOutputConfigurationProvider.java:153)
at org.eclipse.xtext.builder.EclipseOutputConfigurationProvider.getOutputConfigurations(EclipseOutputConfigurationProvider.java:110)
at org.eclipse.xtext.builder.BuilderParticipant.getOutputConfigurations(BuilderParticipant.java:580)
at org.eclipse.xtext.builder.BuilderParticipant.build(BuilderParticipant.java:203)
at org.eclipse.xtext.builder.impl.RegistryBuilderParticipant$DeferredBuilderParticipant.build(RegistryBuilderParticipant.java:161)
at org.eclipse.xtext.builder.impl.RegistryBuilderParticipant.build(RegistryBuilderParticipant.java:69)
at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:252)
at org.eclipse.xtext.builder.impl.XtextBuilder.fullBuild(XtextBuilder.java:280)
at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:117)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:734)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:299)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:302)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:358)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:381)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: Java Model Exception: Java Model Status [asdf does not exist]
at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException(JavaElement.java:556)
at org.eclipse.jdt.internal.core.JavaModelManager.getPerProjectInfoCheckExistence(JavaModelManager.java:2344)
at org.eclipse.jdt.internal.core.JavaProject.getPerProjectInfo(JavaProject.java:1909)
at org.eclipse.jdt.internal.core.JavaProject.getRawClasspath(JavaProject.java:1931)
at org.eclipse.xtext.builder.JDTAwareSourceFolderProvider.getSourceFolders(JDTAwareSourceFolderProvider.java:34)
... 21 more
!ENTRY org.apache.log4j 4 0 2015-08-06 13:29:47.262
!MESSAGE org.eclipse.xtext.builder.impl.XtextBuilder - Java Model Exception: Java Model Status [asdf does not exist]
!STACK 0
java.lang.RuntimeException: Java Model Exception: Java Model Status [asdf does not exist]
at org.eclipse.xtext.builder.JDTAwareSourceFolderProvider.getSourceFolders(JDTAwareSourceFolderProvider.java:36)
at org.eclipse.xtext.builder.EclipseOutputConfigurationProvider.createAndOverlayOutputConfiguration(EclipseOutputConfigurationProvider.java:153)
at org.eclipse.xtext.builder.EclipseOutputConfigurationProvider.getOutputConfigurations(EclipseOutputConfigurationProvider.java:110)
at org.eclipse.xtext.builder.BuilderParticipant.getOutputConfigurations(BuilderParticipant.java:580)
at org.eclipse.xtext.builder.BuilderParticipant.build(BuilderParticipant.java:203)
at org.eclipse.xtext.builder.impl.RegistryBuilderParticipant$DeferredBuilderParticipant.build(RegistryBuilderParticipant.java:161)
at org.eclipse.xtext.builder.impl.RegistryBuilderParticipant.build(RegistryBuilderParticipant.java:69)
at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:252)
at org.eclipse.xtext.builder.impl.XtextBuilder.fullBuild(XtextBuilder.java:280)
at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:117)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:734)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:299)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:302)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:358)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:381)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: Java Model Exception: Java Model Status [asdf does not exist]
at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException(JavaElement.java:556)
at org.eclipse.jdt.internal.core.JavaModelManager.getPerProjectInfoCheckExistence(JavaModelManager.java:2344)
at org.eclipse.jdt.internal.core.JavaProject.getPerProjectInfo(JavaProject.java:1909)
at org.eclipse.jdt.internal.core.JavaProject.getRawClasspath(JavaProject.java:1931)
at org.eclipse.xtext.builder.JDTAwareSourceFolderProvider.getSourceFolders(JDTAwareSourceFolderProvider.java:34)
... 21 more
答案 0 :(得分:1)
您使用的Xbase在非Java项目中不起作用。所以,是的,这给你带来了问题。但是,例外可能更友好。你能报一张票吗?