Curious Error while using QuickFix [message #1712227] |
Thu, 22 October 2015 05:04  |
Eclipse User |
|
|
|
Hello,
I am getting the following error in my editor, while using quickfix:
The type org.eclipse.jface.text.IDocumentExtension3 cannot be resolved. It is indirectly referenced from required .class files
This is my validator class:
class MyLanguageValidator extends AbstractMyLanguageValidator {
public static final String UNCAPITALIZED_NAME = "my.language.quickfix.UncapitalizedName";
@Check
def checkNameIsUppercase(Element e) {
if (!Character::isUpperCase(e.name.charAt(0))) {
warning("Element name \"" + e.name + "\" should be capitalized.", null, MyLanguagePackage.ELEMENT__NAME, UNCAPITALIZED_NAME)
}
}
}
And this is my quickfix class:
public class MyLanguageQuickfixProvider extends DefaultQuickfixProvider {
@Fix(MyLanguageValidator.UNCAPITALIZED_NAME)
public void capitalizeName(final Issue issue,
IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, "Capitalize element name",
"Capitalize name of the element \"" + issue.getData()[0]
+ "\".", "upcase.png", new IModification() {
@Override
public void apply(IModificationContext context)
throws Exception {
IXtextDocument xtextDocument = context
.getXtextDocument();
String firstLetter = xtextDocument.get(
issue.getOffset(), 1);
xtextDocument.replace(issue.getOffset(), 1,
firstLetter.toUpperCase());
}
});
}
}
I know, that such an error can occure unexpectedly in Eclipse and to solve it, it is necessary to remove and add the JRE System Library in the Java build path, inside the project's properties but unfortunately that doesn't help.
How can I solve the problem?
|
|
|
|
|
|
|
Re: Curious Error while using QuickFix [message #1712344 is a reply to message #1712249] |
Fri, 23 October 2015 04:22   |
Eclipse User |
|
|
|
Sebastian Zarnekow wrote on Thu, 22 October 2015 11:21Hmm not that I'm aware of. Which version of eclipse.text is on your
classpath?
Sebastian,
first of all, thank you very much for the quick and excellent support!
I am using Version 2.4.3 and I still don't understand, why there is an EAttribute missing in the Literals. Here is an example DSL:
Element:
'Element' name=ID
description=STRING?
('firstParameter' firstParameter=DOUBLE)
('subelement' subelement=[Subelement])
'end' 'Element'
;
Subelement:
'Subelement' name=ID
description=STRING?
('secondparameter' secondparameter=DOUBLE)
'end' 'Subelement'
;
This is how it is used:
Element MyElement
"This is my element"
firstParameter 1.2
subelement MySubelement
end Element
Subelement MySubelement
"This is my subelement"
secondparameter = 3.5
end Subelement
In my Validator I want to reference the name=ID, so the string "MyElement". I am trying to do the following:
String PREFIX = "my.language.";
String UNCAPITALIZED_ENTITY_NAME = "UncapitalizedEntityName";
public void checkElementNameStartsWithCapital(Element element) {
if (!Character.isUpperCase(element.getName().charAt(0))) {
warning("Uncapitalized name",
MyLaguagePackage.Literals.ELEMENT__NAME,
IssueCodes.UNCAPITALIZED_ENTITY_NAME,
element.getName());
}
}
But ELEMENT__NAME is not visible, only ELEMENT__SUBELEMENT.
Is it possible to reference the name? What am I doing wrong?
|
|
|
|
|
Re: Curious Error while using QuickFix [message #1712348 is a reply to message #1712345] |
Fri, 23 October 2015 04:59   |
Eclipse User |
|
|
|
Christian Dietrich wrote on Fri, 23 October 2015 08:35Depending on your grammar it might be ANCESTOR_OF_ELEMENT__NAME (have a look at the Element interface, where is the getName method in the type hierarchy)
True, it works if I want to reference name=ID of Element but how can I reference Subelement? And in case Subelement has an SubSubElement, and so on?
This is the Grammer starting from root element:
Model:
components+=Component*
;
Component:
Element | Subelement
;
Element:
'Element' name=ID
description=STRING?
('firstParameter' firstParameter=DOUBLE)
('subelement' subelement=[Subelement])
'end' 'Element'
;
Subelement:
'Subelement' name=ID
description=STRING?
('secondparameter' secondparameter=DOUBLE)
'end' 'Subelement'
;
... and the extended validator:
String PREFIX = "my.language.";
String UNCAPITALIZED_ENTITY_NAME = "UncapitalizedEntityName";
public void checkElementNameStartsWithCapital(Element element) {
if (!Character.isUpperCase(element.getName().charAt(0))) {
warning("Uncapitalized name",
MyLaguagePackage.Literals.COMPONENT__NAME,
IssueCodes.UNCAPITALIZED_ENTITY_NAME,
element.getName());
}
if (!Character.isUpperCase(element.getSubelement().getName().charAt(0))) {
warning("Uncapitalized name",
MyLaguagePackage.Literals.COMPONENT__NAME, // ???
IssueCodes.UNCAPITALIZED_ENTITY_NAME,
element.getSubelement().getName());
}
}
I am sure, I will be able to apply awareness on my whole dsl, if you could help me referencing subelements.
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.54099 seconds