Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Curious Error while using QuickFix(IDocumentExtension3 cannot be resolved (is indirectly referenced from required .class files))
Curious Error while using QuickFix [message #1712227] Thu, 22 October 2015 09:04 Go to next message
John Cole is currently offline John ColeFriend
Messages: 66
Registered: June 2013
Member
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 #1712228 is a reply to message #1712227] Thu, 22 October 2015 09:08 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi John,

please make sure that you have the bundle org.eclipse.text on your
classpath.

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Find help at http://xtext.itemis.com or xtext(@)itemis.com
Blog: zarnekow.blogspot.com
Twitter: @szarnekow
Google+: https://www.google.com/+SebastianZarnekow
Re: Curious Error while using QuickFix [message #1712229 is a reply to message #1712228] Thu, 22 October 2015 09:37 Go to previous messageGo to next message
John Cole is currently offline John ColeFriend
Messages: 66
Registered: June 2013
Member
Hi Sebastian,

thank you very much for the quick response!
Fixed it! Many thanks!

[Updated on: Thu, 22 October 2015 09:38]

Report message to a moderator

Re: Curious Error while using QuickFix [message #1712249 is a reply to message #1712229] Thu, 22 October 2015 11:21 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
On 22.10.15 11:37, John Cole wrote:
> Hi Sebastian,
>
> thank you very much for the quick response!
> org.eclipse.text is inside the Plug-in Dependencies of my plugin
> project. The error is still there. Am I missing something else?

Hmm not that I'm aware of. Which version of eclipse.text is on your
classpath?

Cheers,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Find help at http://xtext.itemis.com or xtext(@)itemis.com
Blog: zarnekow.blogspot.com
Twitter: @szarnekow
Google+: https://www.google.com/+SebastianZarnekow
Re: Curious Error while using QuickFix [message #1712281 is a reply to message #1712249] Thu, 22 October 2015 15:47 Go to previous messageGo to next message
Prakyath Jaladhar is currently offline Prakyath JaladharFriend
Messages: 15
Registered: July 2015
Junior Member
Hi Sebastian,

Christian suggested that I ask this question to you. The language I am working on contains entry methods, so the rule for an entry method may look like this:

Entry:
	  'entry' 'void' entryName=ID ep=EParameters code=CCode
;

CCode:  '[' -> ']' 
	| '{' -> '}' 
	| '(' -> ')' 
	;


The CCode can also contain braces as well. So basically whatever comes after EParameters which can be inside one of the three braces should be treated as CCode (which can include braces inside as well). How can I achieve this?
Re: Curious Error while using QuickFix [message #1712344 is a reply to message #1712249] Fri, 23 October 2015 08:22 Go to previous messageGo to next message
John Cole is currently offline John ColeFriend
Messages: 66
Registered: June 2013
Member
Sebastian Zarnekow wrote on Thu, 22 October 2015 11:21
Hmm 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 #1712345 is a reply to message #1712344] Fri, 23 October 2015 08:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Depending 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)

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 23 October 2015 08:41]

Report message to a moderator

Re: Curious Error while using QuickFix [message #1712346 is a reply to message #1712345] Fri, 23 October 2015 08:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
p.s.: please open new topics for ne question (especially for you (->) problem

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Curious Error while using QuickFix [message #1712348 is a reply to message #1712345] Fri, 23 October 2015 08:59 Go to previous messageGo to next message
John Cole is currently offline John ColeFriend
Messages: 66
Registered: June 2013
Member
Christian Dietrich wrote on Fri, 23 October 2015 08:35
Depending 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. Smile
Re: Curious Error while using QuickFix [message #1712355 is a reply to message #1712348] Fri, 23 October 2015 09:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
yes component__name looks right.

please note that ref=[Type] is short for ref=[Type|ID] which means an ID will be parsed.
so you may want to

ref=[Type|FQN]
with
FQN:ID ("." ID)*;


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Curious Error while using QuickFix [message #1712364 is a reply to message #1712355] Fri, 23 October 2015 10:17 Go to previous messageGo to next message
John Cole is currently offline John ColeFriend
Messages: 66
Registered: June 2013
Member
Hm... but COMPONENT_NAME doesn't seem to be right while using subcomponents. So the second if-statement has no effects:

if (!Character.isUpperCase(element.getSubelement().getName().charAt(0))) {
	warning("Uncapitalized name",
			MyLaguagePackage.Literals.COMPONENT__NAME,	// ???
			IssueCodes.UNCAPITALIZED_ENTITY_NAME,
			element.getSubelement().getName());
}


So if I say...

Element MyElement
	"This is my element"
	firstParameter 1.2
	subelement mysubelement
end Element

Subelement mysubelement
	"This is my subelement"
	secondparameter = 3.5
end Subelement


... mysubelement is not underlined and no warning appears.
Re: Curious Error while using QuickFix [message #1712367 is a reply to message #1712364] Fri, 23 October 2015 10:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i dont know your complete grammar. simply underline the thing you want to underline.

the name of the feature is always

NAME_OF_THE_CLASS_THAT_HOLDS_THE_FEATURE__NAME_OF_THE_FEATURE

so have a look which java class contains the feature and use the corresponding feature.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Curious Error while using QuickFix [message #1712368 is a reply to message #1712367] Fri, 23 October 2015 10:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
and as i said:

you should ever ever ever ever specify the object as well !!!!
if you dont the object will implcitely the parameter of the check method


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Curious Error while using QuickFix [message #1712371 is a reply to message #1712368] Fri, 23 October 2015 10:39 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
p.p.s: and what do you actually want to underline.
and shouldnt that check be defined for subelement instead?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Generate multiple new project wizards
Next Topic:strange eclipse behavior in multi module project
Goto Forum:
  


Current Time: Thu Apr 25 04:34:06 GMT 2024

Powered by FUDForum. Page generated in 0.03516 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top