Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Auto-completion outside an Eclipse editor, API reuse
Auto-completion outside an Eclipse editor, API reuse [message #1386179] Sat, 14 June 2014 08:04 Go to next message
Mathieu Acher is currently offline Mathieu AcherFriend
Messages: 1
Registered: June 2014
Junior Member
Hi,

I am seeking a function for completing a portion of code (mainly outside Eclipse).
Roughly speaking, the function will take as input the content of the code and a position (offset) stating where we are in the code.
The function will return a set of possible completions.

Collection<String> complete (String content, int offset) 


So far I have investigated how auto-completion is implemented with Eclipse editors generated by Xtext.
Everything is in org.eclipse.xtext.ui.editor.contentassist.
In particular, in CompletionProposalComputer, there is

public ICompletionProposal[] exec(XtextResource resource) throws Exception 


and there is a field "offset" (among others).

Everything seems to be fine but unfortunately the code is highly coupled to an Eclipse editor (for instance, ITextViewer).
Same after with the interface IContentProposalProvider (an interface implemented by the generated class of Xtext)

void createProposals(ContentAssistContext context, ICompletionProposalAcceptor acceptor);


Basically part of the API related to content assist (even the class generated by Xtext for exploiting the grammar of a DSL) is highly coupled to an Eclipse editor, precluding a direct reuse in other settings. It does make sense of course, but here are my question.

Are you aware of a simple function (like the one described at the very beginning of the post) for supporting auto-completion?
Is there any attempt to provide such function (e.g., outside Eclipse)?

Re: Auto-completion outside an Eclipse editor, API reuse [message #1720940 is a reply to message #1386179] Fri, 22 January 2016 03:39 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Hello,

I am looking for answer for the same question. Please let me know ,if you know the solution.
Re: Auto-completion outside an Eclipse editor, API reuse [message #1720943 is a reply to message #1720940] Fri, 22 January 2016 05:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
Am not getting this point. The new web api for xtext should fulfill comes with a own completion Api different from eclipse. You can have a look at that one

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
icon7.gif  Re: Auto-completion outside an Eclipse editor, API reuse [message #1721129 is a reply to message #1720943] Mon, 25 January 2016 04:34 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
I mean that ,I wish to invoke core api . Rather than the one being invoked.

For example ,

I have a grammar that understands "Hello ABC" as a message that matches pattern "Greeting Person" .

When I try to do content assist , I see that the web UI makes a call like this

http://localhost:8080/xtext-service/assist?resource=c919a1d.mydsl&caretOffset=1&requiredStateId=-7fffffec

However , I wish to understand a possibility of using anther UI . And use api only with text and not state information .

For example

List <String> getProposal (String partialSentence)

Such that I can call the api using the english text.

In the above example ,

I wish to call api using the partial word
"hel"

while the content assist should provide

"hello ABC"
"hello PQR"

if ABC and PQR are the names of persons.

So ,In summary can I make use of core xtext api by calling using partial text and not state information. ("requiredStateId=-7fffffec") .




Re: Auto-completion outside an Eclipse editor, API reuse [message #1721135 is a reply to message #1721129] Mon, 25 January 2016 06:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
Hi,

i dont get that. have a look at org.eclipse.xtext.web.server.XtextServiceDispatcher.getContentAssistService(IServiceContext)
and the different options to send a fullText as well


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto-completion outside an Eclipse editor, API reuse [message #1721140 is a reply to message #1721135] Mon, 25 January 2016 07:19 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
OK Thank You. Which is the class for web ServiceContext ?
Re: Auto-completion outside an Eclipse editor, API reuse [message #1721141 is a reply to message #1721140] Mon, 25 January 2016 07:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
i dont get this question. HttpServiceContext ?!?
my point was that there is a parameter fullText as well if you do not want to use detatext


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto-completion outside an Eclipse editor, API reuse [message #1721142 is a reply to message #1721141] Mon, 25 January 2016 07:34 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
OK Thank you . I was referring to https://github.com/eclipse/xtext/blob/master/web/org.eclipse.xtext.web.servlet/src/main/java/org/eclipse/xtext/web/servlet/HttpServiceContext.xtend which is used currently.

Re: Auto-completion outside an Eclipse editor, API reuse [message #1722462 is a reply to message #1721142] Fri, 05 February 2016 04:37 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Hi , Thank you for the help on this.

I am trying to use a different web UI (not provided by Xtext). Could you please guide me to the right classes .

For example , I have a text area . What changes (on extending and overriding the current behaviour) do I need to make in the Xtext to successfully have this text area as my new editor apart from the ace editor which is already provided. I want to understand how the web UI is binded to the core xtext.

Is calling with the state information necessary. Can I have a stateless api and use Xtext like a library .

Could you please direct me to any good resources and documents.

Thank You.
Re: Auto-completion outside an Eclipse editor, API reuse [message #1722463 is a reply to message #1722462] Fri, 05 February 2016 05:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
Hi,

if i understand you correct, you have to points
- you dont want to use xtext client side api at all but directly talk to the xtext server
- you want to run the server in stateless mode

you can always send the fulltext to the server if you want to run stateless

Here is a simple example that exactly does this

<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="xtext/2.9.2-SNAPSHOT/xtext-ace.css"/>
	<link rel="stylesheet" type="text/css" href="style.css"/>
	<script src="webjars/requirejs/2.1.20/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: {
				"jquery": "webjars/jquery/2.1.4/jquery.min"
			}
		});
		require(["../webjars/jquery/2.1.4/jquery.min"], function() {
			jQuery(document).ready(function() {
				jQuery("#generate-button").click(function(e){
					var text = "Hello World!";
					var data = {
						resource : "example1.mydsl2",
						fullText : $("#mytextarea").val()
					};
					jQuery.post('http://' + location.host + '/xtext-service/generate', data, function(result){
						jQuery("#generator-result").text(result);	
					});
				});
			});
		});
		
	</script>
</head>
<body>
<textarea id="mytextarea">
Hello Christian!
Hello Roy!
</textarea>
<button id="generate-button" value="Generate" title="Generate">Generate</button>
<div id="generator-result">
</div>
</body>
</html>



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto-completion outside an Eclipse editor, API reuse [message #1722481 is a reply to message #1722463] Fri, 05 February 2016 09:00 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Yes. That works. Smile

Is it also possible to call xtext as jar and not as service. (like generate/content assist). Any setup change required for that?
Re: Auto-completion outside an Eclipse editor, API reuse [message #1722484 is a reply to message #1722481] Fri, 05 February 2016 09:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
hi, i do not understand this.

xtext works perfectly standalone, but you will not get these services pretailored.

=> you load a xtext model from a string, call the generator or validator and process the results.
the xtext server basically does this and offers an http interface for that.
but if you dont need that ...


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto-completion outside an Eclipse editor, API reuse [message #1722487 is a reply to message #1722484] Fri, 05 February 2016 09:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
p.s. calling standalone for content assist makes no sense though

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto-completion outside an Eclipse editor, API reuse [message #1722495 is a reply to message #1722487] Fri, 05 February 2016 09:45 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Could you elaborate on " calling standalone for content assist makes no sense though"
I would like to just call content assist on a string . I do not intend intend to host server separately.
For example, for a string say "hel" I wish to call content assist and get "hello" .

[Updated on: Fri, 05 February 2016 09:46]

Report message to a moderator

Re: Auto-completion outside an Eclipse editor, API reuse [message #1722501 is a reply to message #1722495] Fri, 05 February 2016 10:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
hi then you have to factor out the content assist service from the web example and call it yourself from the standalone java app.
it should not be too much work


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto-completion outside an Eclipse editor, API reuse [message #1722884 is a reply to message #1722501] Wed, 10 February 2016 03:38 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Could you please direct me to the code for content assist for web.
Re: Auto-completion outside an Eclipse editor, API reuse [message #1722885 is a reply to message #1722501] Wed, 10 February 2016 03:46 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Hi I have found this ,

https://github.com/eclipse/xtext/blob/master/web/org.eclipse.xtext.web/src/main/js/xtext/services/ContentAssistService.js

Do you suggest to implement similarly and call using standalone app.

I see that it requires serverstate and resource. Is there a version where it accepts partial text and returns completed text.? Is there an example for content assist used in standalone app?

[Updated on: Wed, 10 February 2016 04:54]

Report message to a moderator

Re: Auto-completion outside an Eclipse editor, API reuse [message #1722887 is a reply to message #1722885] Wed, 10 February 2016 05:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
hi i do not understand this question.
the task of the content assist is to give the user a list of proposals to pick.
then the user decides for one (or none) and this one is applied.
so can you be a bit more specific on what you try to do?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto-completion outside an Eclipse editor, API reuse [message #1722891 is a reply to message #1722887] Wed, 10 February 2016 06:56 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Ok. So, in summary . I would like to call the content assist library and not use the content assist js service as I wish to use xtext as a jar . As you said , I might have to look out for the javascript implementation and replicate. Is there an example which uses the content assist for a standalone app. For example , I have created a java based project https://wiki.eclipse.org/Xtext/FAQ#How_do_I_load_my_model_in_a_standalone_Java_application.C2.A0.3F to use the core APIs .

So , for example mentioned there is a parse method which is demonstrated. Likewise can I also use the content assist directly to support something like this.

Collection<String> complete (String content, int offset)
Re: Auto-completion outside an Eclipse editor, API reuse [message #1722892 is a reply to message #1722891] Wed, 10 February 2016 07:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
hi,

no there is nothing. you have to have a look at the server side code XtextServlet, XtextServiceDispatcher, ContentAssistService and the dependencies they use and build up "your" service as well.
as a starting point you may use this quick hack.
(all beyond that you have to build up and find out how to use the api yourself)

import com.google.common.base.Charsets
import com.google.inject.Injector
import java.io.ByteArrayInputStream
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import org.eclipse.emf.common.util.URI
import org.eclipse.emf.ecore.resource.ResourceSet
import org.eclipse.xtext.util.TextRegion
import org.eclipse.xtext.web.server.IServiceContext
import org.eclipse.xtext.web.server.contentassist.ContentAssistService
import org.eclipse.xtext.web.server.model.IWebDocumentProvider
import org.eclipse.xtext.web.server.model.XtextWebDocumentAccess
import com.google.inject.Provider
import org.eclipse.xtext.web.server.ISession
import org.eclipse.xtext.web.server.model.XtextWebDocument
import org.eclipse.xtext.resource.XtextResource

class Main {
	
	def static void main(String[] args) {
		val s = new ISession.NullImpl
		val IServiceContext sc = new IServiceContext() {
			
			override getParameter(String key) {
				throw new UnsupportedOperationException("TODO: auto-generated method stub")
			}
			
			override getParameterKeys() {
				throw new UnsupportedOperationException("TODO: auto-generated method stub")
			}
			
			override getSession() {
				s
			}
			
		}
		val Provider<ExecutorService> executorServiceProvider = [Executors.newCachedThreadPool]
		val Injector i = new MyDslWebSetup(executorServiceProvider).createInjectorAndDoEMFRegistration()
		val rs = i.getInstance(ResourceSet);
		val r = rs.createResource(URI.createURI("test.mydsl2")) as XtextResource
		r.load(new ByteArrayInputStream('''Hello Hello Christian! Hello Roy!'''.toString.getBytes(Charsets.UTF_8)), null)
		val  pp = i.getInstance(ContentAssistService)
		val dp = i.getInstance(IWebDocumentProvider)
		
		val XtextWebDocument doc = dp.get("dummy.mydsl2", sc)
		doc.input = r
		
		val da = i.getInstance(XtextWebDocumentAccess.Factory).create(doc, "-80000000" , true)
		val selection = new TextRegion(6, 0)
		val result = pp.createProposals(da, selection, 6, 100)
		println(result)
		
	}
	
}





Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto-completion outside an Eclipse editor, API reuse [message #1722925 is a reply to message #1722892] Wed, 10 February 2016 10:39 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Thank you for this . I wish to clarify :
Why do we need to refer to web and do the MyDslWebSetup and refer to WebDocument when we are using ContentAssist ?

As I understand , Content Assist should take in partial text and provide possible completions. I do not understand the reference to web and session,etc.
Does it mean that ,even for editor for IDE (say eclipse editor ) the content assist is internally called like this.
Re: Auto-completion outside an Eclipse editor, API reuse [message #1722927 is a reply to message #1722925] Wed, 10 February 2016 10:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
As I said: you have to have a look at the code and extract (copy paste
adapt) what you need. This is nothing that works out of the box nor
something that is done in a few minutes.

=> my code is just a starting point


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto-completion outside an Eclipse editor, API reuse [message #1722929 is a reply to message #1722925] Wed, 10 February 2016 10:46 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
Xtext ships eclipse idea and web glue code for content assist you need a
forth kind that is not shipped. My code makes the web glue code runnable
standalone


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto-completion outside an Eclipse editor, API reuse [message #1722935 is a reply to message #1722927] Wed, 10 February 2016 11:16 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Ok. Thanks for the reply.I did as you said.I meant to say that I need to set up something like this for standalone setup

https://github.com/eclipse/xtext/blob/master/web/org.eclipse.xtext.web.example.statemachine.ide/src/org/eclipse/xtext/web/example/statemachine/ide/StatemachineWebContentProposalProvider.xtend


I wish to modify the behaviour of content assist provider exactly like the example above. For web editor ,it was just creating a class as above and adding the binding I am able to do it . I am trying to replicate the same with standalone setup .

Re: Auto-completion outside an Eclipse editor, API reuse [message #1722936 is a reply to message #1722935] Wed, 10 February 2016 11:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
simply execute my example and go for it

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto-completion outside an Eclipse editor, API reuse [message #1722938 is a reply to message #1722936] Wed, 10 February 2016 11:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
(adding the binding in the webmodule as well)

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto-completion outside an Eclipse editor, API reuse [message #1722942 is a reply to message #1722938] Wed, 10 February 2016 12:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
e.g. something like

import com.google.common.base.Charsets
import com.google.inject.Binder
import com.google.inject.Guice
import com.google.inject.Injector
import com.google.inject.Module
import com.google.inject.Provider
import com.google.inject.name.Names
import com.google.inject.util.Modules
import java.io.ByteArrayInputStream
import java.util.Arrays
import java.util.HashSet
import java.util.List
import javax.inject.Inject
import org.eclipse.emf.common.util.URI
import org.eclipse.emf.ecore.resource.ResourceSet
import org.eclipse.xtend.lib.annotations.Data
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
import org.eclipse.xtend.lib.annotations.ToString
import org.eclipse.xtext.ide.LexerIdeBindings
import org.eclipse.xtext.ide.editor.contentassist.ContentAssistContext
import org.eclipse.xtext.ide.editor.contentassist.ContentAssistEntry
import org.eclipse.xtext.ide.editor.contentassist.IIdeContentProposalAcceptor
import org.eclipse.xtext.ide.editor.contentassist.IdeContentProposalProvider
import org.eclipse.xtext.ide.editor.contentassist.antlr.ContentAssistContextFactory
import org.eclipse.xtext.ide.editor.contentassist.antlr.IContentAssistParser
import org.eclipse.xtext.ide.editor.contentassist.antlr.internal.Lexer
import org.eclipse.xtext.resource.XtextResource
import org.eclipse.xtext.util.ITextRegion
import org.eclipse.xtext.util.TextRegion
import org.xtext.example.mydsl2.MyDslRuntimeModule
import org.xtext.example.mydsl2.MyDslStandaloneSetup
import org.xtext.example.mydsl2.ide.StatemachineWebContentProposalProvider
import org.xtext.example.mydsl2.ide.contentassist.antlr.MyDslParser
import org.xtext.example.mydsl2.ide.contentassist.antlr.internal.InternalMyDslLexer
import java.util.concurrent.Executors

class Main {

	def static void main(String[] args) {

		try {
			val Injector i = new MyDslStandloneCASetup().createInjectorAndDoEMFRegistration()
			val rs = i.getInstance(ResourceSet);
			val r = rs.createResource(URI.createURI("test.mydsl2")) as XtextResource
			r.load(new ByteArrayInputStream('''Hello Hello Christian! Hello Roy!'''.toString.getBytes(Charsets.UTF_8)),
				null)
			val sca = i.getInstance(StandaloneContentAssistService)
			val selection = new TextRegion(6, 0)
			val result2 = sca.createProposals(r, r.parseResult.rootNode.text, selection, 6, 1000)
			println(result2)

		} catch (Exception e) {
			e.printStackTrace
		}
	}

}

class MyDslCAModule implements Module {
	override configure(Binder binder) {
		binder.bind(IdeContentProposalProvider).to(StatemachineWebContentProposalProvider)
		binder.bind(IContentAssistParser).to(MyDslParser)

		binder.bind(Lexer).annotatedWith(Names.named(LexerIdeBindings.CONTENT_ASSIST)).to(InternalMyDslLexer);
	}
}

@FinalFieldsConstructor
class MyDslStandloneCASetup extends MyDslStandaloneSetup {

	override Injector createInjector() {
		val runtimeModule = new MyDslRuntimeModule()
		return Guice.createInjector(Modules.override(runtimeModule).with(new MyDslCAModule))
	}

}

class StandaloneContentAssistService {

	@Inject Provider<ContentAssistContextFactory> contextFactoryProvider

	@Inject IdeContentProposalProvider proposalProvider

	def createProposals(XtextResource resource, String text, ITextRegion selection, int caretOffset, int limit) {
		val contexts = getContexts(resource, text, selection, caretOffset)
		return createProposals(Arrays.asList(contexts), limit)
	}

	def private ContentAssistContext[] getContexts(XtextResource resource, String text, ITextRegion selection,
		int caretOffset) {
		if (caretOffset > text.length)
			return #[]
		val contextFactory = contextFactoryProvider.get() => [pool = Executors.newCachedThreadPool]
		contextFactory.create(text, selection, caretOffset, resource)
	}

	def private createProposals(List<ContentAssistContext> contexts, int proposalsLimit) {
		val result = new ContentAssistResult()
		if (!contexts.empty) {
			val proposals = new HashSet<Pair<Integer, ContentAssistEntry>>
			val acceptor = new IIdeContentProposalAcceptor {
				override accept(ContentAssistEntry entry, int priority) {
					if (entry.proposal === null)
						throw new IllegalArgumentException('proposal must not be null.')
					proposals.add(priority -> entry)
				}

				override canAcceptMoreProposals() {
					proposals.size < proposalsLimit
				}
			}

			proposalProvider.createProposals(contexts, acceptor)

			result.entries.addAll(proposals.sortWith [ p1, p2 |
				val prioResult = p2.key.compareTo(p1.key)
				if (prioResult != 0)
					return prioResult
				val s1 = p1.value.label ?: p1.value.proposal
				val s2 = p2.value.label ?: p2.value.proposal
				return s1.compareTo(s2)
			].map[value])
		}
		return result
	}
}

@Data
@ToString(skipNulls=true)
class ContentAssistResult {

	val List<ContentAssistEntry> entries = newArrayList

}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto-completion outside an Eclipse editor, API reuse [message #1723027 is a reply to message #1722942] Thu, 11 February 2016 06:48 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
No Message Body

[Updated on: Thu, 11 February 2016 07:08]

Report message to a moderator

Re: Auto-completion outside an Eclipse editor, API reuse [message #1723033 is a reply to message #1723027] Thu, 11 February 2016 07:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
The content assist parser is in ide of course

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto-completion outside an Eclipse editor, API reuse [message #1723041 is a reply to message #1723033] Thu, 11 February 2016 08:51 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
This is useful .I would like to understand the meaning of selection and caretOffSet here.
Re: Auto-completion outside an Eclipse editor, API reuse [message #1723045 is a reply to message #1723041] Thu, 11 February 2016 08:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
?!?

selection is if the user selects a range of tokens
offset is where the cusor is


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto-completion outside an Eclipse editor, API reuse [message #1723051 is a reply to message #1723045] Thu, 11 February 2016 09:45 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
I understand that the caretOffSet is the position of the text from where completion is called.

For example ,

hello Christain with caretOffSet 6 will give completions for "hello C"

However, I wish to understand what is the use of "selection".
val selection = new TextRegion(6, 0)
Re: Auto-completion outside an Eclipse editor, API reuse [message #1723059 is a reply to message #1723051] Thu, 11 February 2016 10:23 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
it is simpy: the caret is 0 chars long

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:An internal error occurred during: "XtextReconcilerJob".
Next Topic:invalid tokenType with the content assist parser
Goto Forum:
  


Current Time: Fri Apr 26 22:01:55 GMT 2024

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

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

Back to the top