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


Java ITrackedNodePosition类代码示例

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


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

示例1: getOffset

import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
@Override
public int getOffset() {
	int minStart= Integer.MAX_VALUE;
	for (ITrackedNodePosition node : fPos) {
		minStart= Math.min(minStart, node.getStartPosition());
	}
	return minStart == Integer.MAX_VALUE ? -1 : minStart;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:9,代码来源:LinkedProposalPositionGroup.java

示例2: getLength

import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
@Override
public int getLength() {
	int minStart= Integer.MAX_VALUE;
	int maxEnd= 0;
	for (ITrackedNodePosition node : fPos) {
		minStart= Math.min(minStart, node.getStartPosition());
		maxEnd= Math.max(maxEnd, node.getStartPosition() + node.getLength());
	}
	return minStart == Integer.MAX_VALUE ? 0 : maxEnd - getOffset();
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:11,代码来源:LinkedProposalPositionGroup.java

示例3: getOffset

import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
@Override
public int getOffset() {
  int minStart = Integer.MAX_VALUE;
  for (ITrackedNodePosition node : fPos) {
    minStart = Math.min(minStart, node.getStartPosition());
  }
  return minStart == Integer.MAX_VALUE ? -1 : minStart;
}
 
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:LinkedProposalPositionGroup.java

示例4: getLength

import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
@Override
public int getLength() {
  int minStart = Integer.MAX_VALUE;
  int maxEnd = 0;
  for (ITrackedNodePosition node : fPos) {
    minStart = Math.min(minStart, node.getStartPosition());
    maxEnd = Math.max(maxEnd, node.getStartPosition() + node.getLength());
  }
  return minStart == Integer.MAX_VALUE ? 0 : maxEnd - getOffset();
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:LinkedProposalPositionGroup.java

示例5: createPlaceholderForProtectedTypeDeclaration

import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
protected static BodyDeclaration createPlaceholderForProtectedTypeDeclaration(final BodyDeclaration bodyDeclaration, final CompilationUnit declaringCuNode, final ICompilationUnit declaringCu, final ASTRewrite rewrite, final boolean removeIndentation) throws JavaModelException {
	String text= null;
	try {
		final ASTRewrite rewriter= ASTRewrite.create(bodyDeclaration.getAST());
		ModifierRewrite.create(rewriter, bodyDeclaration).setVisibility(Modifier.PROTECTED, null);
		final ITrackedNodePosition position= rewriter.track(bodyDeclaration);
		final IDocument document= new Document(declaringCu.getBuffer().getText(declaringCuNode.getStartPosition(), declaringCuNode.getLength()));
		rewriter.rewriteAST(document, declaringCu.getJavaProject().getOptions(true)).apply(document, TextEdit.UPDATE_REGIONS);
		text= document.get(position.getStartPosition(), position.getLength());
	} catch (BadLocationException exception) {
		text= getNewText(bodyDeclaration, declaringCu, removeIndentation);
	}
	return (BodyDeclaration) rewrite.createStringPlaceholder(text, ASTNode.TYPE_DECLARATION);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:HierarchyProcessor.java

示例6: updateReplacementString

import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
public String updateReplacementString(IDocument document, int offset, ImportRewrite importRewrite,
		boolean snippetStringSupport)
				throws CoreException, BadLocationException {
	Document recoveredDocument= new Document();
	CompilationUnit unit= getRecoveredAST(document, offset, recoveredDocument);
	ImportRewriteContext context = new ContextSensitiveImportRewriteContext(unit, offset, importRewrite);

	ITypeBinding declaringType= null;
	ChildListPropertyDescriptor descriptor= null;
	ASTNode node= NodeFinder.perform(unit, offset, 1);
	node= ASTResolving.findParentType(node);
	String result = null;
	if (node instanceof AnonymousClassDeclaration) {
		declaringType= ((AnonymousClassDeclaration) node).resolveBinding();
		descriptor= AnonymousClassDeclaration.BODY_DECLARATIONS_PROPERTY;
	} else if (node instanceof AbstractTypeDeclaration) {
		AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) node;
		descriptor= declaration.getBodyDeclarationsProperty();
		declaringType= declaration.resolveBinding();
	}
	if (declaringType != null) {
		ASTRewrite rewrite= ASTRewrite.create(unit.getAST());
		IMethodBinding methodToOverride= Bindings.findMethodInHierarchy(declaringType, fMethodName, fParamTypes);
		if (methodToOverride == null && declaringType.isInterface()) {
			methodToOverride= Bindings.findMethodInType(node.getAST().resolveWellKnownType("java.lang.Object"), fMethodName, fParamTypes); //$NON-NLS-1$
		}
		if (methodToOverride != null) {
			CodeGenerationSettings settings = PreferenceManager.getCodeGenerationSettings(fJavaProject.getProject());
			MethodDeclaration stub = StubUtility2.createImplementationStub(fCompilationUnit, rewrite, importRewrite,
					context, methodToOverride, declaringType, settings, declaringType.isInterface(), declaringType,
					snippetStringSupport);
			ListRewrite rewriter= rewrite.getListRewrite(node, descriptor);
			rewriter.insertFirst(stub, null);

			ITrackedNodePosition position= rewrite.track(stub);
			try {
				Map<String, String> options = fJavaProject.getOptions(true);

				rewrite.rewriteAST(recoveredDocument, options).apply(recoveredDocument);

				String generatedCode = recoveredDocument.get(position.getStartPosition(), position.getLength());

				String indentAt = getIndentAt(recoveredDocument, position.getStartPosition(), settings);
				int generatedIndent = IndentManipulation.measureIndentUnits(indentAt, settings.tabWidth,
						settings.indentWidth);
				// Kinda fishy but empirical data shows Override needs to change indent by at
				// least 1
				generatedIndent = Math.max(1, generatedIndent);

				// Cancel generated code indent
				String delimiter = TextUtilities.getDefaultLineDelimiter(document);
				result = IndentManipulation.changeIndent(generatedCode, generatedIndent, settings.tabWidth,
						settings.indentWidth, "", delimiter);

			} catch (MalformedTreeException | BadLocationException exception) {
				JavaLanguageServerPlugin.logException("Unable to compute override proposal", exception);
			}
		}
	}
	return result;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:62,代码来源:OverrideCompletionProposal.java

示例7: setEndPosition

import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
public void setEndPosition(ITrackedNodePosition position) {
	setEndPosition(LinkedProposalPositionGroup.createPositionInformation(position, 1));
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:4,代码来源:LinkedProposalModel.java

示例8: createPositionInformation

import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
public static PositionInformation createPositionInformation(ITrackedNodePosition pos, int sequenceRank) {
	return new TrackedNodePosition(pos, sequenceRank);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:4,代码来源:LinkedProposalPositionGroup.java

示例9: TrackedNodePosition

import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
public TrackedNodePosition(ITrackedNodePosition pos, int sequenceRank) {
	fPos= pos;
	fSequenceRank= sequenceRank;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:5,代码来源:LinkedProposalPositionGroup.java

示例10: addPosition

import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
public void addPosition(ITrackedNodePosition position, int sequenceRank) {
	addPosition(createPositionInformation(position, sequenceRank));
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:4,代码来源:LinkedProposalPositionGroup.java

示例11: setEndPosition

import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
public void setEndPosition(ITrackedNodePosition position) {
  setEndPosition(LinkedProposalPositionGroup.createPositionInformation(position, 1));
}
 
开发者ID:eclipse,项目名称:che,代码行数:4,代码来源:LinkedProposalModel.java

示例12: createPositionInformation

import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
public static PositionInformation createPositionInformation(
    ITrackedNodePosition pos, int sequenceRank) {
  return new TrackedNodePosition(pos, sequenceRank);
}
 
开发者ID:eclipse,项目名称:che,代码行数:5,代码来源:LinkedProposalPositionGroup.java

示例13: TrackedNodePosition

import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
public TrackedNodePosition(ITrackedNodePosition pos, int sequenceRank) {
  fPos = pos;
  fSequenceRank = sequenceRank;
}
 
开发者ID:eclipse,项目名称:che,代码行数:5,代码来源:LinkedProposalPositionGroup.java

示例14: addPosition

import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
public void addPosition(ITrackedNodePosition position, int sequenceRank) {
  addPosition(createPositionInformation(position, sequenceRank));
}
 
开发者ID:eclipse,项目名称:che,代码行数:4,代码来源:LinkedProposalPositionGroup.java

示例15: getUpdatedMember

import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
private String getUpdatedMember(IDocument document, BodyDeclaration declaration) throws BadLocationException {
	ITrackedNodePosition trackedPosition= (ITrackedNodePosition) declaration.getProperty(TRACKED_POSITION_PROPERTY);
	return Strings.trimIndentation(document.get(trackedPosition.getStartPosition(), trackedPosition.getLength()), fPreferences.tabWidth, fPreferences.indentWidth, false);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:5,代码来源:MoveStaticMembersProcessor.java


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