Java 类org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition 实例源码

项目:eclipse.jdt.ls    文件:LinkedProposalPositionGroup.java   
@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;
}
项目:eclipse.jdt.ls    文件:LinkedProposalPositionGroup.java   
@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();
}
项目:che    文件:LinkedProposalPositionGroup.java   
@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;
}
项目:che    文件:LinkedProposalPositionGroup.java   
@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();
}
项目:Eclipse-Postfix-Code-Completion    文件:HierarchyProcessor.java   
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);
}
项目:Eclipse-Postfix-Code-Completion    文件:LinkedProposalPositionGroup.java   
@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;
}
项目:Eclipse-Postfix-Code-Completion    文件:LinkedProposalPositionGroup.java   
@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();
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:HierarchyProcessor.java   
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);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:LinkedProposalPositionGroup.java   
@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;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:LinkedProposalPositionGroup.java   
@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();
}
项目:eclipse.jdt.ls    文件:OverrideCompletionProposal.java   
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;
}
项目:eclipse.jdt.ls    文件:LinkedProposalModel.java   
public void setEndPosition(ITrackedNodePosition position) {
    setEndPosition(LinkedProposalPositionGroup.createPositionInformation(position, 1));
}
项目:eclipse.jdt.ls    文件:LinkedProposalPositionGroup.java   
public static PositionInformation createPositionInformation(ITrackedNodePosition pos, int sequenceRank) {
    return new TrackedNodePosition(pos, sequenceRank);
}
项目:eclipse.jdt.ls    文件:LinkedProposalPositionGroup.java   
public TrackedNodePosition(ITrackedNodePosition pos, int sequenceRank) {
    fPos= pos;
    fSequenceRank= sequenceRank;
}
项目:eclipse.jdt.ls    文件:LinkedProposalPositionGroup.java   
public void addPosition(ITrackedNodePosition position, int sequenceRank) {
    addPosition(createPositionInformation(position, sequenceRank));
}
项目:eclipse.jdt.ls    文件:LinkedProposalPositionGroup.java   
public void addPosition(ITrackedNodePosition position, boolean isFirst) {
    addPosition(position, isFirst ? 0 : 1);
}
项目:che    文件:LinkedProposalModel.java   
public void setEndPosition(ITrackedNodePosition position) {
  setEndPosition(LinkedProposalPositionGroup.createPositionInformation(position, 1));
}
项目:che    文件:LinkedProposalPositionGroup.java   
public static PositionInformation createPositionInformation(
    ITrackedNodePosition pos, int sequenceRank) {
  return new TrackedNodePosition(pos, sequenceRank);
}
项目:che    文件:LinkedProposalPositionGroup.java   
public TrackedNodePosition(ITrackedNodePosition pos, int sequenceRank) {
  fPos = pos;
  fSequenceRank = sequenceRank;
}
项目:che    文件:LinkedProposalPositionGroup.java   
public void addPosition(ITrackedNodePosition position, int sequenceRank) {
  addPosition(createPositionInformation(position, sequenceRank));
}
项目:che    文件:LinkedProposalPositionGroup.java   
public void addPosition(ITrackedNodePosition position, boolean isFirst) {
  addPosition(position, isFirst ? 0 : 1);
}
项目:Eclipse-Postfix-Code-Completion    文件:MoveStaticMembersProcessor.java   
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);
}
项目:Eclipse-Postfix-Code-Completion    文件:LinkedProposalModel.java   
public void setEndPosition(ITrackedNodePosition position) {
    setEndPosition(LinkedProposalPositionGroup.createPositionInformation(position, 1));
}
项目:Eclipse-Postfix-Code-Completion    文件:LinkedProposalPositionGroup.java   
public static PositionInformation createPositionInformation(ITrackedNodePosition pos, int sequenceRank) {
    return new TrackedNodePosition(pos, sequenceRank);
}
项目:Eclipse-Postfix-Code-Completion    文件:LinkedProposalPositionGroup.java   
public TrackedNodePosition(ITrackedNodePosition pos, int sequenceRank) {
    fPos= pos;
    fSequenceRank= sequenceRank;
}
项目:Eclipse-Postfix-Code-Completion    文件:LinkedProposalPositionGroup.java   
public void addPosition(ITrackedNodePosition position, int sequenceRank) {
    addPosition(createPositionInformation(position, sequenceRank));
}
项目:Eclipse-Postfix-Code-Completion    文件:LinkedProposalPositionGroup.java   
public void addPosition(ITrackedNodePosition position, boolean isFirst) {
    addPosition(position, isFirst ? 0 : 1);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:MoveStaticMembersProcessor.java   
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);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:LinkedProposalModel.java   
public void setEndPosition(ITrackedNodePosition position) {
    setEndPosition(LinkedProposalPositionGroup.createPositionInformation(position, 1));
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:LinkedProposalPositionGroup.java   
public static PositionInformation createPositionInformation(ITrackedNodePosition pos, int sequenceRank) {
    return new TrackedNodePosition(pos, sequenceRank);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:LinkedProposalPositionGroup.java   
public TrackedNodePosition(ITrackedNodePosition pos, int sequenceRank) {
    fPos= pos;
    fSequenceRank= sequenceRank;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:LinkedProposalPositionGroup.java   
public void addPosition(ITrackedNodePosition position, int sequenceRank) {
    addPosition(createPositionInformation(position, sequenceRank));
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:LinkedProposalPositionGroup.java   
public void addPosition(ITrackedNodePosition position, boolean isFirst) {
    addPosition(position, isFirst ? 0 : 1);
}
项目:eclipse.jdt.ls    文件:LinkedProposalPositionGroup.java   
/**
 * A position that contains all of the given tracked node positions.
 *
 * @param pos the positions
 */
public TrackedNodesPosition(Collection<ITrackedNodePosition> pos) {
    fPos= pos;
}
项目:eclipse.jdt.ls    文件:LinkedProposalPositionGroup.java   
/**
 * A position for the start of the given tracked node position.
 *
 * @param pos the position
 */
public StartPositionInformation(ITrackedNodePosition pos) {
    fPos= pos;
}
项目:eclipse.jdt.ls    文件:LinkedCorrectionProposal.java   
/**
 * Adds a linked position to be shown when the proposal is applied. All
 * positions with the same group id are linked.
 *
 * @param position
 *            The position to add.
 * @param isFirst
 *            If set, the proposal is jumped to first.
 * @param groupID
 *            The id of the group the proposal belongs to. All proposals in
 *            the same group are linked.
 */
public void addLinkedPosition(ITrackedNodePosition position, boolean isFirst, String groupID) {
    getLinkedProposalModel().getPositionGroup(groupID, true).addPosition(position, isFirst);
}
项目:eclipse.jdt.ls    文件:LinkedCorrectionProposal.java   
/**
 * Adds a linked position to be shown when the proposal is applied. All
 * positions with the same group id are linked.
 *
 * @param position
 *            The position to add.
 * @param sequenceRank
 *            The sequence rank, see TODO.
 * @param groupID
 *            The id of the group the proposal belongs to. All proposals in
 *            the same group are linked.
 */
public void addLinkedPosition(ITrackedNodePosition position, int sequenceRank, String groupID) {
    getLinkedProposalModel().getPositionGroup(groupID, true).addPosition(position, sequenceRank);
}
项目:eclipse.jdt.ls    文件:LinkedCorrectionProposal.java   
/**
 * Sets the end position of the linked mode to the end of the passed range.
 *
 * @param position
 *            The position that describes the end position of the linked
 *            mode.
 */
public void setEndPosition(ITrackedNodePosition position) {
    getLinkedProposalModel().setEndPosition(position);
}
项目:che    文件:LinkedProposalPositionGroup.java   
/**
 * A position that contains all of the given tracked node positions.
 *
 * @param pos the positions
 */
public TrackedNodesPosition(Collection<ITrackedNodePosition> pos) {
  fPos = pos;
}
项目:che    文件:LinkedProposalPositionGroup.java   
/**
 * A position for the start of the given tracked node position.
 *
 * @param pos the position
 */
public StartPositionInformation(ITrackedNodePosition pos) {
  fPos = pos;
}