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


Java IDocument.get方法代码示例

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


在下文中一共展示了IDocument.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPartitionsInfoByType

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
public static HashMap<String, IRegion> getPartitionsInfoByType(IDocument document,
    String partitionType) {
  HashMap<String, IRegion> lines = new HashMap<String, IRegion>();
  final Scanner scanner = new Scanner(document.get());
  int lineNumber = 0;
  try {
    while (scanner.hasNextLine()) {
      final String line = scanner.nextLine();
      final int offset = document.getLineOffset(lineNumber);
      if (document.getPartition(offset).getType().equals(partitionType)) {
        lines.put(line, document.getLineInformation(lineNumber));
      }
      lineNumber++;
    }
  } catch (BadLocationException e) {
    e.printStackTrace();
  } finally {
    if (scanner != null)
      scanner.close();
  }

  return lines;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:24,代码来源:EditorUtilities.java

示例2: executeOnActiveJenkinsEditor

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
protected void executeOnActiveJenkinsEditor(JenkinsEditor editor) {
	if (editor == null) {
		return;
	}
	IDocument document = editor.getDocument();
	if (document == null) {
		return;
	}
	String code = document.get();

	try {
		executeLinterFor(code, editor);
	} catch (IOException e) {
		JenkinsEditorUtil.logError("Lint call not possible", e);
	}
}
 
开发者ID:de-jcup,项目名称:eclipse-jenkins-editor,代码行数:18,代码来源:CallLinterHandler.java

示例3: computeCompletionProposals

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
	IDocument document = viewer.getDocument();
	if (document == null) {
		return null;
	}
	String source = document.get();

	Set<String> words = simpleWordCompletion.calculate(source, offset);

	ICompletionProposal[] result = new ICompletionProposal[words.size()];
	int i = 0;
	for (String word : words) {
		result[i++] = new SimpleWordProposal(document, offset, word);
	}

	return result;
}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:19,代码来源:BatchEditorSimpleWordContentAssistProcessor.java

示例4: getLineByOffset

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
public static String getLineByOffset(IDocument document, int offset) {
  final Scanner scanner = new Scanner(document.get());
  int lineNumber = 0;
  try {
    while (scanner.hasNextLine()) {
      final String line = scanner.nextLine();
      if (lineNumber == document.getLineOfOffset(offset)) {
        return line;
      }
      lineNumber++;
    }
  } catch (BadLocationException e) {
    e.printStackTrace();
  } finally {
    if (scanner != null)
      scanner.close();
  }
  return "";
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:20,代码来源:EditorUtilities.java

示例5: moveTo

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
public void moveTo(String handlerName) {
	
	IEditorPart editor =  PlatformUI
								.getWorkbench()
								.getActiveWorkbenchWindow()
								.getActivePage()
								.getActiveEditor();
	
	if (editor instanceof JscriptTransactionEditor) {
		JscriptTransactionEditor myEditor = (JscriptTransactionEditor) editor;
		MyJScriptEditor jsEditor = myEditor.getEditor();
		IDocumentProvider provider = jsEditor.getDocumentProvider();
		IDocument document = provider.getDocument(editor.getEditorInput());
		String content = document.get();
		int index = content.indexOf(handlerName);
		jsEditor.selectAndReveal(index, handlerName.length());
	}
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:19,代码来源:HandlersDeclarationTreeObject.java

示例6: extractPrefix

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
protected String extractPrefix(ITextViewer viewer, int offset) {
    int i = offset;
    IDocument document = viewer.getDocument();
    if (i > document.getLength()) {
        return ""; //$NON-NLS-1$
    }
    try {
        while (i > 0) {
            char ch = document.getChar(i - 1);
            if (!PgDiffUtils.isValidIdChar(ch)) {
                break;
            }
            i--;
        }
        if (i > 0) {
            int j = i;
            if (document.getChar(j - 1) == '<') {
                i--;
            }
        }
        return document.get(i, offset - i);
    } catch (BadLocationException e) {
        return ""; //$NON-NLS-1$
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:27,代码来源:SQLEditorTemplateAssistProcessor.java

示例7: getIndent

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
/**
 * Returns indentation, i.e. leading white space characters, of the line at the given region. Argument for
 * 'lineRegion' must cover the entire line excluding any line delimiters (i.e. exactly as returned by
 * {@link IDocument#getLineInformationOfOffset(int)}.
 */
public static String getIndent(IDocument doc, IRegion lineRegion) throws BadLocationException {
	final String currLine = doc.get(lineRegion.getOffset(), lineRegion.getLength());
	int idx = 0;
	while (idx < currLine.length() && Character.isWhitespace(currLine.charAt(idx))) {
		idx++;
	}
	return currLine.substring(0, idx);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:14,代码来源:DocumentUtilN4.java

示例8: getCurrentCode

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
/**
 * Obtains the current contents of a file under recording.
 * @return the contents of source code, or <code>null</code> if source code does not exist
 */
protected String getCurrentCode() {
    IDocument doc = EditorUtilities.getDocument(editor);
    if (doc != null) {
        return doc.get();
    }
    return null;
}
 
开发者ID:liaoziyang,项目名称:ContentAssist,代码行数:12,代码来源:DocMacroRecorderOnEdit.java

示例9: getCurrentCode

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
/**
 * Obtains the current contents of a file under recording.
 * @return the contents of source code, or <code>null</code> if source code does not exist
 */
protected String getCurrentCode() {
    IDocument doc = EditorUtilities.getDocument(file);
    if (doc != null) {
        return doc.get();
    }
    return null;
}
 
开发者ID:liaoziyang,项目名称:ContentAssist,代码行数:12,代码来源:DocMacroRecorderOffEdit.java

示例10: getSourceCode

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
/**
 * Obtains the contents of source code appearing in an editor.
 * @param editor the editor
 * @return the contents of the source code, or <code>null</code> if the source code is not valid
 */
public static String getSourceCode(IEditorPart editor) {
    IDocument doc = getDocument(editor);
    if (doc != null) {
        return doc.get();
    }
    return null;
}
 
开发者ID:liaoziyang,项目名称:ContentAssist,代码行数:13,代码来源:EditorUtilities.java

示例11: computeCompletionProposals

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer,
    final int offset) {
  final List<ICompletionProposal> proposals = new ArrayList<>();
  final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

  try {
    allFiles.clear();
    allEcoreFiles.clear();
    findAllEMFFiles(root);
    findAllXMIFiles(root);
  } catch (final Exception e) {
    e.printStackTrace();
    return null;
  }

  final IDocument document = viewer.getDocument();
  try {
    IRegion lineInfo = document.getLineInformationOfOffset(offset);
    String line = document.get(lineInfo.getOffset(), lineInfo.getLength());

    int activationIndex = line.indexOf(activationChar);
    if (activationIndex != -1) {
      String prefix = line.substring(line.indexOf("@") + 1);
      String type = document.getPartition(offset - 1).getType();
      int replacementOffset = offset - prefix.length();
      addProposals(proposals, prefix, replacementOffset, type);
    }
  } catch (BadLocationException e1) {
    e1.printStackTrace();
  }

  final ICompletionProposal[] result = new ICompletionProposal[proposals.size()];
  proposals.toArray(result);
  return result;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:37,代码来源:LoadCompletionProcessor.java

示例12: getDocumentText

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
/**
 * Get document text - safe way.
 * 
 * @return string, never <code>null</code>
 */
String getDocumentText() {
	IDocument doc = getDocument();
	if (doc == null) {
		return "";
	}
	return doc.get();
}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:13,代码来源:BatchEditor.java

示例13: SimpleWordProposal

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
SimpleWordProposal(IDocument document, int offset, String word) {
	this.offset = offset;
	this.word = word;

	String source = document.get();
	textBefore = simpleWordCompletion.getTextbefore(source, offset);
}
 
开发者ID:de-jcup,项目名称:eclipse-bash-editor,代码行数:8,代码来源:BashEditorSimpleWordContentAssistProcessor.java

示例14: getOffsetAtLine

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
protected int getOffsetAtLine(int lineIndex) {
	IDocument document = getTextViewer().getDocument();
	try {
		int lo = document.getLineOffset(lineIndex);
		int ll = document.getLineLength(lineIndex);
		String line = document.get(lo, ll);
		return super.getOffsetAtLine(lineIndex) + getLeadingSpaces(line);
	} catch (BadLocationException e) {
		return -1;
	}
}
 
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:13,代码来源:CodeLensViewZone.java

示例15: getLineText

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
private static String getLineText(IDocument document, int line, boolean withLineDelimiter) {
	try {
		int lo = document.getLineOffset(line);
		int ll = document.getLineLength(line);
		if (!withLineDelimiter) {
			String delim = document.getLineDelimiter(line);
			ll = ll - (delim != null ? delim.length() : 0);
		}
		return document.get(lo, ll);
	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:15,代码来源:ClassReferencesCodeLensProvider.java


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