当前位置: 首页>>代码示例>>Java>>正文


Java FindReplaceDocumentAdapter类代码示例

本文整理汇总了Java中org.eclipse.jface.text.FindReplaceDocumentAdapter的典型用法代码示例。如果您正苦于以下问题:Java FindReplaceDocumentAdapter类的具体用法?Java FindReplaceDocumentAdapter怎么用?Java FindReplaceDocumentAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FindReplaceDocumentAdapter类属于org.eclipse.jface.text包,在下文中一共展示了FindReplaceDocumentAdapter类的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);
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:27,代码来源:JavaToCFGHandler.java

示例2: testHoverThrowable

import org.eclipse.jface.text.FindReplaceDocumentAdapter; //导入依赖的package包/类
@Test
public void testHoverThrowable() throws Exception {
	String uriString = ClassFileUtil.getURI(project, "java.lang.Exception");
	IClassFile classFile = JDTUtils.resolveClassFile(uriString);
	String contents = JavaLanguageServerPlugin.getContentProviderManager().getSource(classFile, monitor);
	IDocument document = new Document(contents);
	IRegion region = new FindReplaceDocumentAdapter(document).find(0, "Throwable", true, false, false, false);
	int offset = region.getOffset();
	int line = document.getLineOfOffset(offset);
	int character = offset - document.getLineOffset(line);
	TextDocumentIdentifier textDocument = new TextDocumentIdentifier(uriString);
	Position position = new Position(line, character);
	TextDocumentPositionParams params = new TextDocumentPositionParams(textDocument, position);
	Hover hover = handler.hover(params, monitor);
	assertNotNull(hover);
	assertTrue("Unexpected hover ", !hover.getContents().isEmpty());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:18,代码来源:HoverHandlerTest.java

示例3: 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;
}
 
开发者ID:piiiiq,项目名称:Black,代码行数:22,代码来源:blackAction.java

示例4: 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));
    }
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:29,代码来源:ModelHelper.java

示例5: 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;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:24,代码来源:TextSelectionUtils.java

示例6: initializePatternControl

import org.eclipse.jface.text.FindReplaceDocumentAdapter; //导入依赖的package包/类
private boolean initializePatternControl() {
  ISelection selection = getSelection();
  if (selection instanceof ITextSelection && !selection.isEmpty()
      && ((ITextSelection) selection).getLength() > 0) {
    String text = ((ITextSelection) selection).getText();
    if (text != null) {
      if (fIsRegExSearch) {
        fPattern.setText(FindReplaceDocumentAdapter.escapeForRegExPattern(text));
      } else {
        fPattern.setText(insertEscapeChars(text));
      }
      return true;
    }
  }
  return false;
}
 
开发者ID:GoClipse,项目名称:goclipse,代码行数:17,代码来源:GoSearchPage.java

示例7: 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;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:34,代码来源:SourceViewer.java

示例8: 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);
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:11,代码来源:ToggleJimpleBreakpointsTarget.java

示例9: 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);
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:21,代码来源:NavigationHandler.java

示例10: 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;
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:19,代码来源:NavigationHandler.java

示例11: 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;

}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:14,代码来源:DataModelImpl.java

示例12: 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;
}
 
开发者ID:nextinterfaces,项目名称:http4e,代码行数:12,代码来源:DocumentUtils.java

示例13: 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;
}
 
开发者ID:piiiiq,项目名称:Black,代码行数:43,代码来源:blackTextArea.java

示例14: replace

import org.eclipse.jface.text.FindReplaceDocumentAdapter; //导入依赖的package包/类
private @Nullable IRegion replace(FindReplaceDocumentAdapter adapter)
    throws BadLocationException, PatternSyntaxException {
  disableReplaceButtons(true);

  updateHistory(replaceComboBox);
  String replaceString = nullToEmpty(replaceComboBox.getValue());
  return adapter.replace(replaceString, isSet(regularExpression));
}
 
开发者ID:Adrodoc55,项目名称:MPL,代码行数:9,代码来源:FindReplaceController.java

示例15: 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);
}
 
开发者ID:Adrodoc55,项目名称:MPL,代码行数:10,代码来源:FindReplaceController.java


注:本文中的org.eclipse.jface.text.FindReplaceDocumentAdapter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。