Bug 275911 - [find/replace] Provide utility method for interpreting escaped characters.
Summary: [find/replace] Provide utility method for interpreting escaped characters.
Status: CLOSED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks: 296053
  Show dependency tree
 
Reported: 2009-05-12 12:49 EDT by Paul Slauenwhite CLA
Modified: 2009-12-01 09:54 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Slauenwhite CLA 2009-05-12 12:49:31 EDT
Provide utility method for interpreting escaped characters.

Extenders of the org.eclipse.jface.text.IFindReplaceTargetExtension3 interface must interpret escaped characters from their implementation of the org.eclipse.jface.text.IFindReplaceTargetExtension3.replaceSelection(String, boolean) method.  The code to interpret escaped characters is quite involved so it would be helpful to all extenders to have public access to the org.eclipse.jface.text.FindReplaceDocumentAdapter.interpretReplaceEscapes(String, String) method.
Comment 1 Paul Slauenwhite CLA 2009-09-08 09:07:53 EDT
Any update on this enhancement for Eclipse 3.6?
Comment 2 Markus Keller CLA 2009-09-08 10:10:56 EDT
interpretReplaceEscapes(String, String) is tightly coupled to the concrete implementation of regular expressions in FindReplaceDocumentAdapter, which is only implicitly specified through the FindReplaceDocumentAdapterContentProposalProvider. The implementation may change in incompatible ways in the future if we add new features (like e.g. the addition of Retain Case in 3.4).

Is there a special reason why you can't use FindReplaceDocumentAdapter#replace(..) directly?

interpretReplaceEscapes(String, String) is in fact just a wrapper around the java.util.regex.Pattern API. It would be strange if we made this helper API, but not the other tweaks we add in findReplace(..), e.g. substituteLinebreak(..).
Comment 3 Paul Slauenwhite CLA 2009-09-08 10:54:50 EDT
(In reply to comment #2)
> interpretReplaceEscapes(String, String) is tightly coupled to the concrete
> implementation of regular expressions in FindReplaceDocumentAdapter, which is
> only implicitly specified through the
> FindReplaceDocumentAdapterContentProposalProvider. The implementation may
> change in incompatible ways in the future if we add new features (like e.g. the
> addition of Retain Case in 3.4).
> 
> Is there a special reason why you can't use
> FindReplaceDocumentAdapter#replace(..) directly?

No, this may work.  Once the current maintenance release ships, we will investigate using this API.

> interpretReplaceEscapes(String, String) is in fact just a wrapper around the
> java.util.regex.Pattern API. It would be strange if we made this helper API,
> but not the other tweaks we add in findReplace(..), e.g.
> substituteLinebreak(..).
Comment 4 Markus Keller CLA 2009-09-08 12:05:32 EDT
Thanks, closing for now. Please reopen if it turns out you need anything.
Comment 5 Paul Slauenwhite CLA 2009-11-24 15:37:28 EST
(In reply to comment #3)
> (In reply to comment #2)
> > interpretReplaceEscapes(String, String) is tightly coupled to the concrete
> > implementation of regular expressions in FindReplaceDocumentAdapter, which is
> > only implicitly specified through the
> > FindReplaceDocumentAdapterContentProposalProvider. The implementation may
> > change in incompatible ways in the future if we add new features (like e.g. the
> > addition of Retain Case in 3.4).
> > 
> > Is there a special reason why you can't use
> > FindReplaceDocumentAdapter#replace(..) directly?
> 
> No, this may work.  Once the current maintenance release ships, we will
> investigate using this API.

After reviewing our code, this may not work.  Our implementation the of the
org.eclipse.jface.text.IFindReplaceTargetExtension3 interface is providing
search/replace function for a SWT table.  Is there a 'table document' that
could be used to map the text in cells to a region of a document or are you
proposing to use a org.eclipse.jface.text.Document for each table cell?
Comment 6 Dani Megert CLA 2009-11-25 02:21:36 EST
Paul,

the support is in the JFace Text package and designed for the JFace Text widgets and components. If you need support for SWT then you have to do one of this:
- wrap the text in a document
- place your request at another component (e.g. SWT)
Comment 7 Paul Slauenwhite CLA 2009-11-25 06:45:43 EST
(In reply to comment #6)
> Paul,
> 
> the support is in the JFace Text package and designed for the JFace Text
> widgets and components. If you need support for SWT then you have to do one of
> this:
> - wrap the text in a document
> - place your request at another component (e.g. SWT)

Thanks Dani for your suggestions.  We have opted for wrapping the text in a document.
Comment 8 Dani Megert CLA 2009-11-25 08:28:41 EST
Actually, for your use case it would be better to simply copy the following three methods:

FindReplaceDocumentAdapter.interpretRetainCase(*)
FindReplaceDocumentAdapter.interpretReplaceEscape(*)
FindReplaceDocumentAdapter.interpretReplaceEscapes(*)
Comment 9 Paul Slauenwhite CLA 2009-12-01 09:54:29 EST
(In reply to comment #8)
> Actually, for your use case it would be better to simply copy the following
> three methods:
> 
> FindReplaceDocumentAdapter.interpretRetainCase(*)
> FindReplaceDocumentAdapter.interpretReplaceEscape(*)
> FindReplaceDocumentAdapter.interpretReplaceEscapes(*)

Thanks Dani.  We will copy these methods.