本文整理汇总了Java中org.eclipse.jface.text.FindReplaceDocumentAdapter.find方法的典型用法代码示例。如果您正苦于以下问题:Java FindReplaceDocumentAdapter.find方法的具体用法?Java FindReplaceDocumentAdapter.find怎么用?Java FindReplaceDocumentAdapter.find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.FindReplaceDocumentAdapter
的用法示例。
在下文中一共展示了FindReplaceDocumentAdapter.find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMethodLineNumbers
import org.eclipse.jface.text.FindReplaceDocumentAdapter; //导入方法依赖的package包/类
/**
* This method returns the line numbers of all the methods passed to it.
* @param document The document with which the user is interacting.
* @param vfMethods The list of methods for which the line numbers are required.
* @return Map containing method names and their starting line numbers.
*/
private Map<String, Integer> getMethodLineNumbers(IDocument document, List<VFMethod> vfMethods) {
FindReplaceDocumentAdapter findReplaceDocumentAdapter = new FindReplaceDocumentAdapter(document);
TreeMap<String, Integer> result = new TreeMap<String, Integer>();
for (VFMethod method : vfMethods) {
try {
method.getSootMethod().getBytecodeSignature();
IRegion region = findReplaceDocumentAdapter.find(0,
method.getSootMethod().getDeclaration().substring(0, method.getSootMethod().getDeclaration().indexOf('(')), true, true, false, false);
if (region != null) {
result.put(method.getSootMethod().getDeclaration(), document.getLineOfOffset(region.getOffset()));
}
} catch (BadLocationException e) {
e.printStackTrace();
}
}
return MapUtil.sortByValue(result);
}
示例2: findwordInAllFiles
import org.eclipse.jface.text.FindReplaceDocumentAdapter; //导入方法依赖的package包/类
public ArrayList<IRegion> findwordInAllFiles(IDocument doc, String word, boolean forwardSearch,
boolean caseSensitive, boolean wholeWord, boolean regularExpressions) {
ArrayList<IRegion> al = null;
if (doc != null) {
al = new ArrayList<>();
FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(doc);
int start = 0;
IRegion ir;
try {
while ((ir = frda.find(start, word, forwardSearch, caseSensitive, wholeWord,
regularExpressions)) != null) {
al.add(ir);
start = ir.getOffset() + ir.getLength();
}
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return al;
}
示例3: calculateCoordinates
import org.eclipse.jface.text.FindReplaceDocumentAdapter; //导入方法依赖的package包/类
/**
* For an given id that is used in the document retrieves the four coordinates of it's first occurrence.
* @param document
* @param searchAdapter
* @param idRegion
* @return location coordinates in the sense of {@link Location} class (bl, bc, el, ec).
* @throws CoreException on errors
*/
public static int[] calculateCoordinates(IDocument document, FindReplaceDocumentAdapter searchAdapter, String id)
throws CoreException
{
try
{
IRegion foundId = searchAdapter.find(0, id, true, true, false, false);
if (foundId == null)
{
return EMPTY_LOCATION;
} else
{
// return the coordinates
return regionToLocation(document, foundId, true);
}
} catch (BadLocationException e)
{
throw new CoreException(new Status(IStatus.ERROR, TLCActivator.PLUGIN_ID,
"Error during detection of the id position in MC.tla.", e));
}
}
示例4: searchOccurrences
import org.eclipse.jface.text.FindReplaceDocumentAdapter; //导入方法依赖的package包/类
public List<IRegion> searchOccurrences(String searchFor) {
ArrayList<IRegion> lst = new ArrayList<IRegion>();
FindReplaceDocumentAdapter adapter = new FindReplaceDocumentAdapter(this.doc);
boolean regExSearch = false;
boolean wholeWord = true;
boolean caseSensitive = true;
boolean forwardSearch = true;
int startOffset = 0;
try {
while (true) {
IRegion found = adapter.find(startOffset, searchFor, forwardSearch, caseSensitive, wholeWord,
regExSearch);
if (found == null) {
break;
}
lst.add(found);
startOffset = found.getOffset() + found.getLength();
}
} catch (BadLocationException e) {
Log.log(e);
}
return lst;
}
示例5: getAllSnippetsAnnotations
import org.eclipse.jface.text.FindReplaceDocumentAdapter; //导入方法依赖的package包/类
private Map<ProjectionAnnotation, Position> getAllSnippetsAnnotations() {
Map<ProjectionAnnotation, Position> annotations = new HashMap<ProjectionAnnotation, Position>();
IDocument document = getDocument();
int curOffset = 0;
FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
try {
IRegion startRegion = frda.find(curOffset, "SNIPPET_START", true, false, false, false); //$NON-NLS-1$
while (startRegion != null && startRegion.getOffset() >= curOffset) {
int startLine = document.getLineOfOffset(startRegion.getOffset());
int startOffset = document.getLineOffset(startLine);
curOffset = startOffset + document.getLineLength(startLine);
IRegion endRegion = frda.find(startRegion.getOffset(), "SNIPPET_END", true, false, false, false); //$NON-NLS-1$
if (endRegion != null) {
int endLine = document.getLineOfOffset(endRegion.getOffset());
int endOffset = document.getLineOffset(endLine);
endOffset += document.getLineLength(endLine);
curOffset = endOffset;
String text = document.get(startOffset, endOffset - startOffset);
ProjectionAnnotation annotation = new ProjectionAnnotation(true);
annotation.setText(text);
annotation.setRangeIndication(true);
annotations.put(annotation, new Position(startOffset, endOffset - startOffset));
}
if (curOffset < document.getLength()) {
startRegion = frda.find(curOffset, "SNIPPET_START", true, false, false, false); //$NON-NLS-1$
}
}
} catch (BadLocationException e) {
}
return annotations;
}
示例6: getMethodLineNumbers
import org.eclipse.jface.text.FindReplaceDocumentAdapter; //导入方法依赖的package包/类
private Map<String, Integer> getMethodLineNumbers(IDocument document, List<VFMethod> vfMethods) throws BadLocationException {
FindReplaceDocumentAdapter findReplaceDocumentAdapter = new FindReplaceDocumentAdapter(document);
TreeMap<String, Integer> result = new TreeMap<>();
for (VFMethod method : vfMethods) {
method.getSootMethod().getBytecodeSignature();
IRegion region = findReplaceDocumentAdapter.find(0, method.getSootMethod().getDeclaration(), true, true, false, false);
result.put(method.getSootMethod().getDeclaration(), document.getLineOfOffset(region.getOffset()));
}
return MapUtil.sortByValue(result);
}
示例7: getMethodLineNumbers
import org.eclipse.jface.text.FindReplaceDocumentAdapter; //导入方法依赖的package包/类
/**
* This method returns the line numbers of all the methods passed to it.
* @param document The document with which the user is interacting.
* @param vfMethods The list of methods for which the line numbers are required.
* @return Map containing method names and their starting line numbers.
*/
private Map<String, Integer> getMethodLineNumbers(IDocument document, List<VFMethod> vfMethods) {
FindReplaceDocumentAdapter findReplaceDocumentAdapter = new FindReplaceDocumentAdapter(document);
TreeMap<String, Integer> result = new TreeMap<>();
for (VFMethod method : vfMethods) {
try {
method.getSootMethod().getBytecodeSignature();
IRegion region = findReplaceDocumentAdapter.find(0, method.getSootMethod().getDeclaration(), true, true, false, false);
result.put(method.getSootMethod().getDeclaration(), document.getLineOfOffset(region.getOffset()));
} catch (BadLocationException e) {
e.printStackTrace();
}
}
return MapUtil.sortByValue(result);
}
示例8: getMethodOffset
import org.eclipse.jface.text.FindReplaceDocumentAdapter; //导入方法依赖的package包/类
/**
* This method returns the offset of the method passed to it.
* @param document The document user is interacting with.
* @param method The method whose offset is required.
* @return The offset of the method.
*/
private Integer getMethodOffset(IDocument document, VFMethod method) {
FindReplaceDocumentAdapter findReplaceDocumentAdapter = new FindReplaceDocumentAdapter(document);
try {
IRegion region = findReplaceDocumentAdapter.find(0, FindReplaceDocumentAdapter.escapeForRegExPattern(method.getSootMethod().getDeclaration()), true,
true, false, true);
return region.getOffset();
} catch (BadLocationException e) {
e.printStackTrace();
}
return 0;
}
示例9: getMethodLineNumber
import org.eclipse.jface.text.FindReplaceDocumentAdapter; //导入方法依赖的package包/类
private int getMethodLineNumber(IDocument document, VFMethod method) {
FindReplaceDocumentAdapter findReplaceDocumentAdapter = new FindReplaceDocumentAdapter(document);
try {
method.getSootMethod().getBytecodeSignature();
IRegion region = findReplaceDocumentAdapter.find(0, method.getSootMethod().getDeclaration(), true, true, false, false);
return document.getLineOfOffset(region.getOffset());
} catch (BadLocationException e) {
e.printStackTrace();
}
return -1;
}
示例10: getDelimRegion
import org.eclipse.jface.text.FindReplaceDocumentAdapter; //导入方法依赖的package包/类
public static IRegion getDelimRegion( IDocument doc, int offset) throws BadLocationException{
IRegion regLine = doc.getLineInformationOfOffset(offset);
FindReplaceDocumentAdapter finder = new FindReplaceDocumentAdapter(doc);
int lineOff = regLine.getOffset();
IRegion regDelim = null;
try {
regDelim = finder.find(lineOff, AssistConstants.S_EQUAL, true, true, false, false);
} catch (Exception ignore) {}
return regDelim;
}
示例11: replace
import org.eclipse.jface.text.FindReplaceDocumentAdapter; //导入方法依赖的package包/类
/**
* �滻�ı�
*
* @param word1
* Ҫ�滻���ַ���
* @param word2
* �滻Ϊ
*/
public int replace(IDocument doc, String word1, String word2, boolean forwardSearch, boolean caseSensitive,
boolean wholeWord, boolean showmessage, boolean regularExpressions) {
int i = 0;
try {
FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(doc);
IRegion ir = new IRegion() {
@Override
public int getOffset() {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getLength() {
// TODO Auto-generated method stub
return 0;
}
};
while ((ir = frda.find(ir.getOffset() + 1, word1, true, caseSensitive, wholeWord,
regularExpressions)) != null) {
frda.replace(word2, regularExpressions);
i++;
}
if (showmessage)
black.ba.getMessageBox("����/�滻��Ϣ", "�滻��" + i + "��");
black.ba.setFileChanged();
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return i;
}
示例12: findStartingAt
import org.eclipse.jface.text.FindReplaceDocumentAdapter; //导入方法依赖的package包/类
private IRegion findStartingAt(int startOffset, String findString,
FindReplaceDocumentAdapter adapter) throws BadLocationException, PatternSyntaxException {
boolean forwardSearch = true;
boolean caseSensitive = isSet(this.caseSensitive);
boolean wholeWord = isSet(this.wholeWord);
boolean regExSearch = isSet(regularExpression);
return adapter.find(startOffset, findString, forwardSearch, caseSensitive, wholeWord,
regExSearch);
}
示例13: documentChanged
import org.eclipse.jface.text.FindReplaceDocumentAdapter; //导入方法依赖的package包/类
@Override
public void documentChanged(DocumentEvent event) {
if (hyperlinks != null) {
try {
IDocument doc = event.getDocument();
Iterator<String> itr = hyperlinks.keySet().iterator();
int lastOffset = startingOffset;
while (itr.hasNext()) {
String txt = itr.next();
FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(doc);
IRegion region = frda.find(lastOffset, txt, true, true, false, false);
if (region != null) {
HyperlinkInfo info = hyperlinks.get(txt);
int linkOffset = region.getOffset();
int linkLength = region.getLength();
if (info.getOffsetInLink() > 0) {
linkOffset += info.getOffsetInLink();
linkLength -= info.getOffsetInLink();
}
if (info.getLinkLength() > 0) {
linkLength = info.getLinkLength();
}
if (linkOffset >= 0 && linkLength > 0 && info.getFileOffset() >= 0 && info.getFileLength() > 0) {
FileLink fileLink = new FileLink(info.getFile(), null, info.getFileOffset(), info.getFileLength(), info.getFileLineNumber());
mc.addHyperlink(fileLink, linkOffset, linkLength);
}
// if (linkOffset > lastOffset) {
// lastOffset = linkOffset;
// }
}
}
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally {
hyperlinks = null;
}
}
}
示例14: isPositionInClosureContext
import org.eclipse.jface.text.FindReplaceDocumentAdapter; //导入方法依赖的package包/类
/**
* Check if the given position is in the context of the given closure. This is done by checking
* the braces balance, basically the number of braces when { means + 1 and } means -1 should not
* become 0 before reaching the position.
*
* @param document
* @param closureName
* @param position
* @return
* @throws BadLocationException
*/
public static boolean isPositionInClosureContext(IDocument document, String closureName, int position) throws BadLocationException {
FindReplaceDocumentAdapter searchAdapter = new FindReplaceDocumentAdapter(document);
//we need the first occurrence searching backwards from the position.
IRegion region = searchAdapter.find(position, closureName, false, true, true, false);
//fail fast
if (region == null) {
return false;
}
//start looking at the contents.
int currentPosition = region.getOffset() + region.getLength();
int balance = 0;
while(currentPosition < position) {
//get and increase the counter.
char currentCharacter = searchAdapter.charAt(currentPosition++);
if (currentCharacter == SCOPE_OPEN.charValue()) {
balance++;
}
if (currentCharacter == SCOPE_CLOSE) {
balance--;
if (balance == 0) {
//scope has ended or the script is not correctly formed.
return false;
}
}
}
return true;
}
示例15: find
import org.eclipse.jface.text.FindReplaceDocumentAdapter; //导入方法依赖的package包/类
private IRegion find( String text, String findString, int offset, boolean searchForward, boolean caseSensitive, boolean wholeWord, boolean regExSearch ) {
Document document = new Document(text);
FindReplaceDocumentAdapter documentAdapter = new FindReplaceDocumentAdapter(document);
try {
return documentAdapter.find(offset, findString, searchForward, caseSensitive, wholeWord, regExSearch);
}
catch ( BadLocationException argh ) {
return null;
}
}