Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext: How to active hyperlink?(Xtext: How to active hyperlink?)
Xtext: How to active hyperlink? [message #1741010] Mon, 22 August 2016 11:25 Go to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Hi,

Can anybody tell me how to activate hyperlink for mydsl editor?
Re: Xtext: How to active hyperlink? [message #1741012 is a reply to message #1741010] Mon, 22 August 2016 11:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
dont get this question. hyperlinking is on by default (crtl+click / f3)

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: How to active hyperlink? [message #1741014 is a reply to message #1741012] Mon, 22 August 2016 11:31 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Yes. (crtl+click / f3) or ctrl+mouseclick. I read the document but I could not understand. Could you please provide any help?
Re: Xtext: How to active hyperlink? [message #1741018 is a reply to message #1741014] Mon, 22 August 2016 11:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
please describe your problem

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: How to active hyperlink? [message #1741019 is a reply to message #1741010] Mon, 22 August 2016 11:47 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Hyperlinking is only active for cross-references. Maybe a stupid question, but does your DSL have cross-references?
Re: Xtext: How to active hyperlink? [message #1741028 is a reply to message #1741019] Mon, 22 August 2016 12:56 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Hi,

I am new to xtext. I have cross-references in my grammar. But in my editor if I do ctrl+mouse click it is not going to that method.
Re: Xtext: How to active hyperlink? [message #1741029 is a reply to message #1741028] Mon, 22 August 2016 12:57 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
If possible can you please provide an example for cross referencing?
Re: Xtext: How to active hyperlink? [message #1741033 is a reply to message #1741029] Mon, 22 August 2016 13:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
https://www.eclipse.org/Xtext/documentation/102_domainmodelwalkthrough.html

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: How to active hyperlink? [message #1741039 is a reply to message #1741033] Mon, 22 August 2016 13:55 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Hi Christian,

I have written below code:

class JPLLinkHelper extends HyperlinkHelper {

override public void createHyperlinksByOffset(XtextResource resource, int offset,IHyperlinkAcceptor acceptor) {

val INode node = NodeModelUtils.findLeafNodeAtOffset(resource.getParseResult().getRootNode(), offset);
val EObjectAtOffsetHelper eObjectAtOffsetHelper = new EObjectAtOffsetHelper();
val EObject eObject = eObjectAtOffsetHelper.resolveElementAt(resource, offset);

if (eObject instanceof JPLIDImpl) {

val JPLIDImpl variableName = eObject as JPLIDImpl;
val CompositeNode adapter = NodeModelUtils.getNode(variableName) as CompositeNode;

val Region region = new Region(adapter.getOffset(), adapter.getLength());

val URIConverter uriConverter = resource.getResourceSet().getURIConverter();
val String hyperlinkText = "ID";
val JPLIDImpl iimport = node.getSemanticElement() as JPLIDImpl;
val String uriString = iimport.getImportURI();
val URI uri = EcoreUtil.getURI(uriString);
val URI normalized = uri.isPlatformResource() ? uri : uriConverter.normalize(uri);

val XtextHyperlink result = new XtextHyperlink(); // Does not show link with getHyperlinkProvider().get()
result.setHyperlinkRegion(region);
result.setURI(normalized);
result.setHyperlinkText(hyperlinkText);
acceptor.accept(result);
}
}
}

How can I get target uri?
Re: Xtext: How to active hyperlink? [message #1741040 is a reply to message #1741039] Mon, 22 August 2016 13:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
EcoreUtil.getUri(object)

i have no idea what and why you need to do anything at all.

val EObject eObject = eObjectAtOffsetHelper.resolveElementAt(resource, offset); should already done everything (in the default impl)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: How to active hyperlink? [message #1741068 is a reply to message #1741040] Mon, 22 August 2016 16:03 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
I just copied it from google.

Now all after I am getting error when I clicking on hyperlink
java.lang.NullPointerException
at org.eclipse.xtext.ui.editor.hyperlinking.XtextHyperlink.open(XtextHyperlink.java:27)
at org.eclipse.jface.text.hyperlink.HyperlinkManager.mouseUp(HyperlinkManager.java:436)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:220)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)

why this error?

[Updated on: Mon, 22 August 2016 16:03]

Report message to a moderator

Re: Xtext: How to active hyperlink? [message #1741069 is a reply to message #1741068] Mon, 22 August 2016 16:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
you should create the hyperlink not with new. otherwise injection will not work.
here is what the default impl does

@Inject
private Provider<XtextHyperlink> hyperlinkProvider;

.....

XtextHyperlink result = hyperlinkProvider.get();


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: How to active hyperlink? [message #1741127 is a reply to message #1741069] Tue, 23 August 2016 09:02 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Thanks Christian. It is working.
Re: Xtext: How to active hyperlink? [message #1741463 is a reply to message #1741127] Thu, 25 August 2016 11:12 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Hi,

Why this code is not going to its reference?

class JPLLinkHelper extends HyperlinkHelper {
@Inject
private Provider<XtextHyperlink> hyperlinkProvider;
override public void createHyperlinksByOffset(XtextResource resource, int offset,IHyperlinkAcceptor acceptor) {

val EObjectAtOffsetHelper eObjectAtOffsetHelper = new EObjectAtOffsetHelper()
val EObject eObject = eObjectAtOffsetHelper.resolveElementAt(resource, offset)
if (eObject instanceof JPLIDImpl) {

val JPLIDImpl variableName = eObject as JPLIDImpl;

val CompositeNode adapter = NodeModelUtils.getNode(variableName) as CompositeNode;

val Region region = new Region(adapter.getOffset(), adapter.getLength());

val URIConverter uriConverter = resource.getResourceSet().getURIConverter();

val String hyperlinkText = "ID";

val URI uri = EcoreUtil.getURI(eObject)
var URI normalized
if(uri.isPlatformResource()) {
normalized = uri
} else {
normalized = uriConverter.normalize(uri)
}

val XtextHyperlink result = hyperlinkProvider.get();
result.setHyperlinkRegion(region);
result.setURI(normalized);
result.setHyperlinkText(hyperlinkText);
acceptor.accept(result);
}
}
}

It is showing hyperlinks but not moving to its reference.

[Updated on: Thu, 25 August 2016 11:15]

Report message to a moderator

Re: Xtext: How to active hyperlink? [message #1741466 is a reply to message #1741463] Thu, 25 August 2016 11:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
first i still do not understand why you do that at all. this should work out of the box if you dont have wired stuff in your grammar.
then how does the uri look like you calculate? are you sure it points to the target you wish? hoiw does the grammar potion for that look like?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: How to active hyperlink? [message #1741469 is a reply to message #1741466] Thu, 25 August 2016 12:27 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Yes it is pointing the target.
It showed me offset: 109, and reference. But not moving to the reference

[Updated on: Thu, 25 August 2016 12:28]

Report message to a moderator

Re: Xtext: How to active hyperlink? [message #1741472 is a reply to message #1741469] Thu, 25 August 2016 13:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
please give me more context.

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: How to active hyperlink? [message #1741474 is a reply to message #1741472] Thu, 25 August 2016 13:08 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
More context means?
Re: Xtext: How to active hyperlink? [message #1741476 is a reply to message #1741474] Thu, 25 August 2016 13:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
grammar at the place com completions.
how does the uri look like?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: How to active hyperlink? [message #1741477 is a reply to message #1741476] Thu, 25 August 2016 13:21 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
URI ::::::::::: platform:/resource/Panther/Sample.lib/src/s1111b.jpl#//@statements.1/@exp.0/@JPLID

Grammar:

Variables: name=('vars'|'global') ((exp+=Expression) (','? ('vars'|'global')? (exp+=Expression))*) ','?;

Expression:
LogicalOr
;
LogicalOr returns Expression:
BitwiseOr ({LogicalOr.left=current} '||' right=BitwiseOr)*
;
BitwiseOr returns Expression:
LogicalAnd ({BitwiseOr.left=current} '|' right=LogicalAnd)*
;
LogicalAnd returns Expression:
BitwiseAnd ({LogicalAnd.left=current} '&&' right=BitwiseAnd)*
;
BitwiseAnd returns Expression:
Equivalency ({BitwiseAnd.left=current} '&' right=Equivalency)*
;
Equivalency returns Expression:
Relational ({Equivalency.left=current} ('=='|'!='|'=') right=Relational)*
;
Relational returns Expression:
PlusMinus ({Relational.left=current} ('>='|'<='|'>'|'<') right=PlusMinus)*
;
PlusMinus returns Expression:
//DivMult ({PlusMinus.left=current} ('+'|'-') right=DivMult)*
DivMult | ({PlusMinus} ('-'|'+') expr=DivMult)
;
DivMult returns Expression:
LogicalNot ({DivMult.left=current} ('/'|'*') right=LogicalNot)*
;
LogicalNot returns Expression:
OnesComplement | ({LogicalNot} '!' expr=OnesComplement)
;
OnesComplement returns Expression:
Exponentiation ({OnesComplement.left=current} ('~') right=Exponentiation)*
;
Exponentiation returns Expression:
ColonOperator ({Exponentialtion.left=current} '^' right=ColonOperator)*
;
ColonOperator returns Expression:
PercentOperator | ({ColonOperator} (':'('+')?) expr=PercentOperator)
;
PercentOperator returns Expression:
ArrowExpression | ({PercentOperator} ('%'|'%t'|'%.'|'%:') expr=ArrowExpression)
;
ArrowExpression returns Expression:
Concatenation | ({ArrowExpression} ('->') expr=Concatenation)
;
//SignedNumber returns Expression:
// Concatenation | ({SignedNumber} ('-'|'+') expr=Concatenation)
//;
Concatenation returns Expression:
Primary ({Concatenation.left=current} '##' right=Primary)*
;
Primary returns Expression: {Expression}
Annotation=Annotation| Widget=Widget | lengthNew=lengthNew | Date=Date | ScreenNum=ScreenNum | FieldNum=FieldNum | JPLID=JPLID | Sm_library=Sm_library|Dm_library=Dm_library|
NUMBER=NUMBER | STRING=STRING | RANGE=RANGE | Sum=Sum | Ldb=Ldb | IdObject=IdObject | TpReq=TpReq |
('[' LogicalOr+=LogicalOr (','? LogicalOr+=LogicalOr)* ']') |
('(' (LogicalOr+=LogicalOr (','? LogicalOr+=LogicalOr)*)? ')') |
('{' LogicalOr+=LogicalOr (','? LogicalOr+=LogicalOr)* '}')
;
Re: Xtext: How to active hyperlink? [message #1741478 is a reply to message #1741477] Thu, 25 August 2016 13:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
and how does the model look like you do the hyperlinking at

from the grammar JPLID does not look like a cross reference (grammar not complete)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: How to active hyperlink? [message #1741492 is a reply to message #1741478] Thu, 25 August 2016 14:14 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
JPLID is part of expression right? It is not cross reference?
Re: Xtext: How to active hyperlink? [message #1741493 is a reply to message #1741492] Thu, 25 August 2016 14:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
You did not post that part of the grammar.
What is the specific grammar element you execute the hyperlink at


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: How to active hyperlink? [message #1741497 is a reply to message #1741493] Thu, 25 August 2016 14:23 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
My complete grammar is attached.

My code seems ambiguous but syntax of my language is of that kind. I tried many ways o sharpen my grammar but no luck

[Updated on: Thu, 25 August 2016 14:25]

Report message to a moderator

Re: Xtext: How to active hyperlink? [message #1741499 is a reply to message #1741497] Thu, 25 August 2016 14:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
sad to tell, but you have exactly ZERO 0 .... cross references

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: How to active hyperlink? [message #1741508 is a reply to message #1741499] Thu, 25 August 2016 14:41 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Can you please provide an example?
Re: Xtext: How to active hyperlink? [message #1741511 is a reply to message #1741508] Thu, 25 August 2016 14:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
myref=[ReferencedType|RuleToParseAtThatPlace]

e.g. entityRef=[Entity|ID] or short entityRef=[Entity]


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: How to active hyperlink? [message #1741522 is a reply to message #1741511] Thu, 25 August 2016 15:03 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Is cross reference is correct for below?

Statement:
Variables|Expression|JPLID
;
Variables: name='vars' refName=[JPLID];

JPLID: (name=ID);

Expression:
LogicalOr
;
LogicalOr returns Expression:
BitwiseOr ({LogicalOr.left=current} '||' right=BitwiseOr)*
;
BitwiseOr returns Expression:
LogicalAnd ({BitwiseOr.left=current} '|' right=LogicalAnd)*
;
LogicalAnd returns Expression:
BitwiseAnd ({LogicalAnd.left=current} '&&' right=BitwiseAnd)*
;
BitwiseAnd returns Expression:
Equivalency ({BitwiseAnd.left=current} '&' right=Equivalency)*
;
Equivalency returns Expression:
Relational ({Equivalency.left=current} ('=='|'!='|'=') right=Relational)*
;
Relational returns Expression:
PlusMinus ({Relational.left=current} ('>='|'<='|'>'|'<') right=PlusMinus)*
;
PlusMinus returns Expression:
//DivMult ({PlusMinus.left=current} ('+'|'-') right=DivMult)*
DivMult | ({PlusMinus} ('-'|'+') expr=DivMult)
;
DivMult returns Expression:
LogicalNot ({DivMult.left=current} ('/'|'*') right=LogicalNot)*
;
LogicalNot returns Expression:
OnesComplement | ({LogicalNot} '!' expr=OnesComplement)
;
OnesComplement returns Expression:
Exponentiation ({OnesComplement.left=current} ('~') right=Exponentiation)*
;
Exponentiation returns Expression:
ColonOperator ({Exponentialtion.left=current} '^' right=ColonOperator)*
;
ColonOperator returns Expression:
PercentOperator | ({ColonOperator} (':'('+')?) expr=PercentOperator)
;
PercentOperator returns Expression:
ArrowExpression | ({PercentOperator} ('%'|'%t'|'%.'|'%:') expr=ArrowExpression)
;
ArrowExpression returns Expression:
Concatenation | ({ArrowExpression} ('->') expr=Concatenation)
;
//SignedNumber returns Expression:
// Concatenation | ({SignedNumber} ('-'|'+') expr=Concatenation)
//;
Concatenation returns Expression:
Primary ({Concatenation.left=current} '##' right=Primary)*
;
Primary returns Expression: {Expression}
NUMBER=NUMBER | STRING=STRING
;

//GSD returns Expression: JPLID {GSD.left=current} ('[' occurence=(NUMBER|STRING) ']')?('(' m=NUMBER (',' (n=NUMBER))? ')')? '->' right=JPLID;

terminal DBMS: ('DBMS'|'Dbms'|'dbms') (('\\'((' '|'\t')* '\r'? '\n')) | !('\n' | '\r'))*;

terminal ID : ('a'..'z'|'A'..'Z'|'$'|'.'|'@'|'_')('a'..'z'|'A'..'Z'|'$'|'.'|'0'..'9'|'@'|'*'|'_')*;

terminal STRING : '"' ( '\\'('"'|('\r'? '\n')) | !('\n'|'"') )* '"' |
"'" ( '\\'("'"|('\r'? '\n')) | !('\n'|"'") )* "'";

terminal SL_COMMENT: '//' !('\n' | '\r')*;

terminal HASH_COMMENT : ('#'('\r'? '\n')?) | ('#' !('#'|'\n'|'\r')+ ('\r'? '\n')?) | (('#''#''#') !('\n'|'\r')* ('\r'? '\n')?);

terminal WS : (' '|'\t'| ('\\'((' '|'\t')* '\r'? '\n')))+;

//terminal NL : ('\r'? '\n')+;

terminal NUMBER: (OCTAL|FLOAT|INT|BINARY|HEX);

terminal OCTAL returns ecore::EInt: ('0') ('0'..'7')+;

terminal FLOAT returns ecore::EFloat: ('0'..'9' ('0'..'9')*) '.' ('0'..'9')*;

terminal INT returns ecore::EInt: '0'..'9' ('0'..'9')*;

terminal RANGE: '0'..'9' '..' ('0'..'9')*;

terminal BINARY returns ecore::EInt: ('0b'|'0B') ('0'|'1')+;

terminal HEX returns ecore::EInt:('0x'|'0X')('0'..'9'|'a'..'f'|'A'..'F')+;
Re: Xtext: How to active hyperlink? [message #1741534 is a reply to message #1741522] Thu, 25 August 2016 16:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
on a first sight yes

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: How to active hyperlink? [message #1741540 is a reply to message #1741534] Thu, 25 August 2016 17:36 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Ok but

when I ckick on variable name it is not going to location.

My code in editor is

vars myvalue=null

myvalue = "test"

When I click on F3 at myvalue it is not taking me to vars myvalue.

My code in Hyperlink helper is:

class JPLLinkHelper extends HyperlinkHelper {
@Inject
private Provider<XtextHyperlink> hyperlinkProvider;
override public void createHyperlinksByOffset(XtextResource resource, int offset,IHyperlinkAcceptor acceptor) {

val EObjectAtOffsetHelper eObjectAtOffsetHelper = new EObjectAtOffsetHelper()
val EObject eObject = eObjectAtOffsetHelper.resolveElementAt(resource, offset)
if (eObject instanceof JPLIDImpl) {

val JPLIDImpl variableName = eObject as JPLIDImpl;

val CompositeNode adapter = NodeModelUtils.getNode(variableName) as CompositeNode;

val Region region = new Region(adapter.getOffset(), adapter.getLength());
println("Region ::::::: "+region)
val URIConverter uriConverter = resource.getResourceSet().getURIConverter();

val String hyperlinkText = "ID";

val URI uri = EcoreUtil.getURI(eObject)
println("URI ::::::::::: "+uri)
var URI normalized
if(uri.isPlatformResource()) {
normalized = uri
} else {
normalized = uriConverter.normalize(uri)
}

val XtextHyperlink result = hyperlinkProvider.get(); // Does not show link with getHyperlinkProvider().get()
result.setHyperlinkRegion(region);
result.setURI(normalized);
result.setHyperlinkText(hyperlinkText);
acceptor.accept(result);
}
}
}

Could you please tell me is there any thing wrong in my code?
Re: Xtext: How to active hyperlink? [message #1741545 is a reply to message #1741540] Thu, 25 August 2016 17:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
I don't see in your big grammar how that model fits to the grammar.
This is once more caused by you always posting that big grammar instead of creating a small example reproducing the Problem
This helps neither me Nor you to Unterstand and solve the Problem


I would inspect a grammar like

Thing: "vars" name=ID "=" value=Expression;

Assignment : left=[Thing] "=" right=Expression

What does happen if you simply use the default impl?



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: How to active hyperlink? [message #1741607 is a reply to message #1741545] Fri, 26 August 2016 09:38 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Yes, I got the solution.

My grammar:

Model:
greetings+=Statements*;

Statements:
Greeting|Definition|Usage
;

Greeting:
'Hello' name=ID '!';

Definition:
"define" name=ID
;

Usage:
"use" usage=[Definition]
;

class MyDslUiModule extends AbstractMyDslUiModule {

def Class<? extends DefaultHyperlinkDetector> bindDefaultHyperlinkDetector() {
return JPLLinkDetector;
}

def Class<? extends IHyperlinkHelper> bindIHyperlinkHelper() {
return JPLLinkHelper;
}
}

public class JPLLinkDetector extends DefaultHyperlinkDetector {
override public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultiplehyperlinks) {
//this.setHelper(new MyDslLinkHelper());
return super.detectHyperlinks(textViewer, region, canShowMultiplehyperlinks);
}
}

class JPLLinkHelper extends HyperlinkHelper {

}

But When I am using in editor like :

defintion test

use test

working fine but when I am using

definition test

use mytest

it is showing error like index.php/fa/26884/0/
Re: Xtext: How to active hyperlink? [message #1741608 is a reply to message #1741607] Fri, 26 August 2016 09:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
that is an actual feature. you cannot use (reference) something that is not there.
this is why you get an error about an "unresolved" cross reference.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: How to active hyperlink? [message #1741609 is a reply to message #1741608] Fri, 26 August 2016 09:48 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
how to solve this kind of issue?
Re: Xtext: How to active hyperlink? [message #1741611 is a reply to message #1741609] Fri, 26 August 2016 10:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
what is your semantic

if you have

definition test

use mytest

where should mytest point to ?!?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: How to active hyperlink? [message #1741613 is a reply to message #1741611] Fri, 26 August 2016 10:20 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
yes yes I understood. I am trying to call a method actually it is not defined. That is how reference works.
Re: Xtext: How to active hyperlink? [message #1741620 is a reply to message #1741613] Fri, 26 August 2016 11:04 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Hi,
I have written grammar like:

Call: 'call' ref=[Proc];

Proc: ('string'|'double')? ('proc') name=ID('('exp+=Expression (','? exp+=Expression)')'*)?;

In editor:
I have code like

proc test(a+1,b+2,c+3)

call test(a+1,b+2,c+3) is throwing an error extraneous input '(' expecting RULE_ID

but

call test

is working fine. Could you please tell me what's the problem?
Re: Xtext: How to active hyperlink? [message #1741622 is a reply to message #1741620] Fri, 26 August 2016 11:07 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Call: 'call' ref=[Proc]('('exp+=Expression (','? exp+=Expression)')'*)?; solved the problem
Re: Xtext: How to active hyperlink? [message #1741623 is a reply to message #1741620] Fri, 26 August 2016 11:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
from a parser point of view your grammar looks like

Call: 'call' nameOfTheProc=ID;

mabye you want to have

Call: 'call' ref=[Proc] '(' (params+=Expression (","params+=Expression )*)? ')'
or something like that?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: How to active hyperlink? [message #1741631 is a reply to message #1741623] Fri, 26 August 2016 12:42 Go to previous message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
yes I did
Previous Topic:ProposalProvider in IDEA
Next Topic:xtext cross-reference from another location
Goto Forum:
  


Current Time: Thu Mar 28 15:48:18 GMT 2024

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

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

Back to the top