当前位置: 首页>>代码示例>>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;未经允许,请勿转载。