CompletionProposal offset [message #210177] |
Tue, 11 March 2008 11:41 |
Eclipse User |
|
|
|
Originally posted by: alexjaquet.gmail.com
Can you explain me what mean the replacement offset of a
CompletionProposal ?
I've the following code yet that pop up the content assist but once a
select one item one list I'm getting an exception (code is after the
stack trace)
java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException
at
org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocu ment.replaceText(JobSafeStructuredDocument.java:117)
at
org.eclipse.wst.sse.core.internal.text.BasicStructuredDocume nt.replaceText(BasicStructuredDocument.java:2390)
at
org.eclipse.wst.sse.core.internal.text.BasicStructuredDocume nt.replace(BasicStructuredDocument.java:2353)
at
org.eclipse.jface.text.contentassist.CompletionProposal.appl y(CompletionProposal.java:90)
at
org.eclipse.jface.text.contentassist.CompletionProposalPopup .insertProposal(CompletionProposalPopup.java:811)
at
org.eclipse.jface.text.contentassist.CompletionProposalPopup .insertSelectedProposalWithMask(CompletionProposalPopup.java :757)
at
org.eclipse.jface.text.contentassist.CompletionProposalPopup .verifyKey(CompletionProposalPopup.java:1164)
at
org.eclipse.jface.text.contentassist.ContentAssistant$Intern alListener.verifyKey(ContentAssistant.java:787)
at
org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager. verifyKey(TextViewer.java:460)
at
org.eclipse.swt.custom.StyledTextListener.handleEvent(Styled TextListener.java:60)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:962)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:947)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:7 06)
at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.j ava:5052)
at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.j ava:4800)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:962)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:947)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:975)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:971)
at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1285)
at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3772)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3672 )
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:291)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4351 )
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:22 64)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3291)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 19)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:289)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:153)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:363)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 504)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:443)
at org.eclipse.equinox.launcher.Main.run(Main.java:1169)
at org.eclipse.equinox.launcher.Main.main(Main.java:1144)
Caused by: java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at org.eclipse.jface.text.GapTextStore.arrayCopy(GapTextStore.j ava:348)
at org.eclipse.jface.text.GapTextStore.reallocate(GapTextStore. java:320)
at org.eclipse.jface.text.GapTextStore.adjustGap(GapTextStore.j ava:222)
at org.eclipse.jface.text.GapTextStore.replace(GapTextStore.jav a:195)
at
org.eclipse.wst.sse.core.internal.text.StructuredDocumentTex tStore.replace(StructuredDocumentTextStore.java:168)
at
org.eclipse.wst.sse.core.internal.text.BasicStructuredDocume nt.updateDocumentData(BasicStructuredDocument.java:2662)
at
org.eclipse.wst.sse.core.internal.text.StructuredDocumentReP arser.reparse(StructuredDocumentReParser.java:1350)
at
org.eclipse.wst.sse.core.internal.text.StructuredDocumentReP arser.reparse(StructuredDocumentReParser.java:1284)
at
org.eclipse.wst.sse.core.internal.text.BasicStructuredDocume nt.updateModel(BasicStructuredDocument.java:2685)
at
org.eclipse.wst.sse.core.internal.text.BasicStructuredDocume nt.internalReplaceText(BasicStructuredDocument.java:1918)
at
org.eclipse.wst.sse.core.internal.text.BasicStructuredDocume nt.replaceText(BasicStructuredDocument..java:2394)
at
org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocu ment.access$0(JobSafeStructuredDocument.java:1)
at
org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocu ment$1.run(JobSafeStructuredDocument.java:98)
at
org.eclipse.wst.sse.ui.EditorExecutionContext.execute(Editor ExecutionContext.java:42)
at
org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocu ment.replaceText(JobSafeStructuredDocument.java:109)
... 51 more
Here is my code
/**
* Constructor
*/
public CustomContentAssistProcessor () {
IPath path = Path.fromPortableString(XGUI_DTD);;
try {
InputStreamReader reader = new
InputStreamReader(FileLocator.find(PageUIPlugin.getDefault() .getBundle(),
path,null).openStream());
tags = loadDtd(reader);
}catch (Exception ex) {
}
}
/**
* Compute the completion proposals
*
* @param viewer
* The viewer
* @param offset
* The offset of the element typed
* @return ICompletionProposal [] returns an array of proposal
*/
public ICompletionProposal[] computeCompletionProposals(ITextViewer
viewer, int offset) {
List<ICompletionProposal> result = new ArrayList<ICompletionProposal>();
ICompletionProposal[] completionProposals = new
ICompletionProposal[tags.size()];
for (int i = 0; i < tags.size();i++) {
String tag = tags.get(i);
completionProposals[i]=new CompletionProposal(tag,tag.length(),1,5);
}
result.addAll(Arrays.asList(completionProposals));
return result.toArray(new ICompletionProposal[result.size()]);
}
/**
* Loads a list of element from a dtd file from the given path.
* @param path
* The path to the file
* @return List<String> returns a list of element included inside the dtd
*/
private List<String> loadDtd(InputStreamReader input) {
List<String> result = new ArrayList<String>();
try {
DTDParser parser = new DTDParser(input, true);
DTD dtd = parser.parse();
Enumeration e = dtd.elements.elements();
while (e.hasMoreElements()) {
DTDElement elem = (DTDElement) e.nextElement();
result.add(elem.name);
}
}catch (IOException ex) {
System.out.println(ex);
}
return result;
}
/**
* Compute the context information.
*
* @param viewer
* The viewer
* @param offset
* The offset of the element typed
* @return IContextInformation [] returns an array of contextual
information
*/
public IContextInformation[] computeContextInformation(ITextViewer
viewer, int offset) {
return null;
}
/**
* Gets the compute activation charachters.
*
* @return char [] returns an array of activation characters
*/
public char[] getCompletionProposalAutoActivationCharacters() {
return new char[] {'<'};
}
/**
* Gets the context information auto activation characters.
*
* @return char [] returns an array of activation characters
*
*/
public char[] getContextInformationAutoActivationCharacters() {
return null;
}
/**
* Gets the error message.
*
* @return String returns the error message
*/
public String getErrorMessage() {
return null;
}
/**
* Gets the context information validator.
*
* @return IContextInformationValidator returns the context
information validator
*/
public IContextInformationValidator getContextInformationValidator() {
// TODO Auto-generated method stub
return null;
}
|
|
|
|
|
Re: CompletionProposal offset [message #210217 is a reply to message #210211] |
Tue, 11 March 2008 15:24 |
Eclipse User |
|
|
|
Originally posted by: dcarver.starstandard.org
Alexandre:
The first issue we need to figure out is why your DTD isn't being
included correctly, because if the DTD is loaded, you should already
receive this information from the built in XML editor.
As for the templates, that is for getting the information from the
Templates that are stored in the XML->Editor->Templates preference page.
What you more than likely want is the CustomProposal class from the
org.eclipse.wst.sse.ui.internal.contentassist package.
Dave
Alexandre Jaquet wrote:
> do I need to rewrite the addTemplate method from
> XMLContentAssistProcessor ? I have no idea what is method serve.
>
> thx ...
|
|
|
Re: CompletionProposal offset [message #210233 is a reply to message #210177] |
Wed, 12 March 2008 06:36 |
|
Alexandre Jaquet wrote:
> Can you explain me what mean the replacement offset of a
> CompletionProposal ?
It the start offset within the text document where the proposal will
be applied. It must be a valid offset greater than zero and less
than the document's length. The cursor position value must also be
a valid, after insertion, when added to the replacement offset.
---
Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational
_
Nitin Dahyabhai
Eclipse Web Tools Platform
|
|
|
Powered by
FUDForum. Page generated in 0.04244 seconds