本文整理汇总了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;
}
示例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();
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例7: setEndPosition
import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
public void setEndPosition(ITrackedNodePosition position) {
setEndPosition(LinkedProposalPositionGroup.createPositionInformation(position, 1));
}
示例8: createPositionInformation
import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
public static PositionInformation createPositionInformation(ITrackedNodePosition pos, int sequenceRank) {
return new TrackedNodePosition(pos, sequenceRank);
}
示例9: TrackedNodePosition
import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
public TrackedNodePosition(ITrackedNodePosition pos, int sequenceRank) {
fPos= pos;
fSequenceRank= sequenceRank;
}
示例10: addPosition
import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
public void addPosition(ITrackedNodePosition position, int sequenceRank) {
addPosition(createPositionInformation(position, sequenceRank));
}
示例11: setEndPosition
import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
public void setEndPosition(ITrackedNodePosition position) {
setEndPosition(LinkedProposalPositionGroup.createPositionInformation(position, 1));
}
示例12: createPositionInformation
import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
public static PositionInformation createPositionInformation(
ITrackedNodePosition pos, int sequenceRank) {
return new TrackedNodePosition(pos, sequenceRank);
}
示例13: TrackedNodePosition
import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
public TrackedNodePosition(ITrackedNodePosition pos, int sequenceRank) {
fPos = pos;
fSequenceRank = sequenceRank;
}
示例14: addPosition
import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; //导入依赖的package包/类
public void addPosition(ITrackedNodePosition position, int sequenceRank) {
addPosition(createPositionInformation(position, sequenceRank));
}
示例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);
}