當前位置: 首頁>>代碼示例>>Java>>正文


Java IDocument.replace方法代碼示例

本文整理匯總了Java中org.eclipse.jface.text.IDocument.replace方法的典型用法代碼示例。如果您正苦於以下問題:Java IDocument.replace方法的具體用法?Java IDocument.replace怎麽用?Java IDocument.replace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jface.text.IDocument的用法示例。


在下文中一共展示了IDocument.replace方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: apply

import org.eclipse.jface.text.IDocument; //導入方法依賴的package包/類
@Override
public void apply(IDocument document) {
	// the proposal shall enter always a space after applyment...
	String proposal = word;
	if (isAddingSpaceAtEnd()) {
		proposal += " ";
	}
	int zeroOffset = offset - textBefore.length();
	try {
		document.replace(zeroOffset, textBefore.length(), proposal);
		nextSelection = zeroOffset + proposal.length();
	} catch (BadLocationException e) {
		BatchEditorUtil.logError("Not able to replace by proposal:" + word +", zero offset:"+zeroOffset+", textBefore:"+textBefore, e);
	}

}
 
開發者ID:de-jcup,項目名稱:eclipse-batch-editor,代碼行數:17,代碼來源:BatchEditorSimpleWordContentAssistProcessor.java

示例2: apply

import org.eclipse.jface.text.IDocument; //導入方法依賴的package包/類
@Override
public void apply(IDocument document) {
	// the proposal shall enter always a space after applyment...
	String proposal = word;
	if (isAddingSpaceAtEnd()) {
		proposal += " ";
	}
	int zeroOffset = offset - textBefore.length();
	try {
		document.replace(zeroOffset, textBefore.length(), proposal);
		nextSelection = zeroOffset + proposal.length();
	} catch (BadLocationException e) {
		BashEditorUtil.logError("Not able to replace by proposal:" + word +", zero offset:"+zeroOffset+", textBefore:"+textBefore, e);
	}

}
 
開發者ID:de-jcup,項目名稱:eclipse-bash-editor,代碼行數:17,代碼來源:BashEditorSimpleWordContentAssistProcessor.java

示例3: simpleApply

import org.eclipse.jface.text.IDocument; //導入方法依賴的package包/類
/**
 * Just insert the string at the replacement offset. Everything else is fine.
 */
private void simpleApply(IDocument document, String string, ConfigurableCompletionProposal proposal)
		throws BadLocationException {
	proposal.setCursorPosition(string.length());
	document.replace(proposal.getReplacementOffset(), proposal.getReplacementLength(),
			string);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:10,代碼來源:FQNImporter.java

示例4: insertClosingBrackets

import org.eclipse.jface.text.IDocument; //導入方法依賴的package包/類
@Override
protected void insertClosingBrackets(IDocument document, ISelectionProvider selectionProvider, int offset)
		throws BadLocationException {
	document.replace(offset - 1, 1, "[ ]");
	selectionProvider.setSelection(new TextSelection(offset + 1, 0));

}
 
開發者ID:de-jcup,項目名稱:eclipse-batch-editor,代碼行數:8,代碼來源:BatchBracketInsertionCompleter.java

示例5: apply

import org.eclipse.jface.text.IDocument; //導入方法依賴的package包/類
public void apply(IDocument document) {
    try {
        document.replace(fReplacementOffset, fReplacementLength, fReplacementString);
    } catch (BadLocationException e) {
        
    }
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:8,代碼來源:HydrographCompletionProposal.java

示例6: apply

import org.eclipse.jface.text.IDocument; //導入方法依賴的package包/類
public void apply(IDocument document) {
	try {
		document.replace(fReplacementPosition.getOffset(),
				fReplacementPosition.getLength(), fReplacementString);
	} catch (BadLocationException x) {
		// ignore
	}
}
 
開發者ID:angelozerr,項目名稱:ec4e,代碼行數:9,代碼來源:PositionBasedCompletionProposal.java

示例7: apply

import org.eclipse.jface.text.IDocument; //導入方法依賴的package包/類
@Override
public void apply(IDocument document) throws BadLocationException {
	document.replace(getOffset(), getLength(), getText());
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:5,代碼來源:Replacement.java

示例8: computeCompletionProposals

import org.eclipse.jface.text.IDocument; //導入方法依賴的package包/類
@Override
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
	final List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
	try {
		final IDocument document = viewer.getDocument();
		Character c = document.getChar(offset - 1);
		int temp = offset - 1;
		String s = "";

		if (Character.isAlphabetic(c)) {
			while (Character.isAlphabetic(c)) {
				s += c;
				temp--;
				c = document.getChar(temp);
			}
			s = new StringBuilder(s).reverse().toString();

			for (int i = 0; i < FormulasScanner.formulasKeywords.length; i++) {
				if (FormulasScanner.formulasKeywords[i].startsWith(s)) {
					proposals.add(new CompletionProposal(FormulasScanner.formulasKeywords[i], temp + 1, s.length(),
							FormulasScanner.formulasKeywords[i].length()));
				}
			}
		} else if (c == '(') {
			document.replace(temp, 1, "()");
		} else if (c == '[') {
			document.replace(temp, 1, "[]");
		}

		if (proposals.isEmpty() && s == "") {
			for (int i = 0; i < FormulasScanner.formulasKeywords.length; i++) {
				proposals.add(new CompletionProposal(FormulasScanner.formulasKeywords[i], temp + 1, s.length(),
						FormulasScanner.formulasKeywords[i].length()));
			}
		}

	} catch (final BadLocationException e) {
		e.printStackTrace();
	}
	final ICompletionProposal[] result = new ICompletionProposal[proposals.size()];
	proposals.toArray(result);
	return result;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:44,代碼來源:CodeCompletionProcessor.java

示例9: computeCompletionProposals

import org.eclipse.jface.text.IDocument; //導入方法依賴的package包/類
@Override
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer,
    final int offset) {
  final List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
  try {
    final IDocument document = viewer.getDocument();
    Character c = document.getChar(offset - 1);
    int temp = offset - 1;
    String s = "";

    if (Character.isAlphabetic(c)) {
      while (Character.isAlphabetic(c)) {
        s += c;
        temp--;
        c = document.getChar(temp);
      }
      s = new StringBuilder(s).reverse().toString();

      for (int i = 0; i < CodeScanner.keywords.length; i++) {
        if (CodeScanner.keywords[i].startsWith(s)) {
          proposals.add(new CompletionProposal(CodeScanner.keywords[i], temp + 1, s.length(),
              CodeScanner.keywords[i].length()));
        }
      }
    } else if (c == '(') {
      document.replace(temp, 1, "()");
    } else if (c == '{') {
      document.replace(temp, 1, "{\n\n}");
    }

    if (proposals.isEmpty() && s == "") {
      for (int i = 0; i < CodeScanner.keywords.length; i++) {
        proposals.add(new CompletionProposal(CodeScanner.keywords[i], temp + 1, s.length(),
            CodeScanner.keywords[i].length()));
      }
    }

  } catch (final BadLocationException e) {
    e.printStackTrace();
  }
  final ICompletionProposal[] result = new ICompletionProposal[proposals.size()];
  proposals.toArray(result);
  return result;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:45,代碼來源:CodeCompletionProcessor.java


注:本文中的org.eclipse.jface.text.IDocument.replace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。