mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Method name adjustment.
This commit is contained in:
parent
168e1f4460
commit
b1be2dbaac
3 changed files with 7 additions and 7 deletions
|
@ -448,7 +448,7 @@ public class StatementWriter extends NodeWriter{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int writeMixedStatement(IASTStatement statement) {
|
protected int writeMixedStatement(IASTStatement statement) {
|
||||||
IFile file = FileHelper.getIFilefromIASTNode(statement);
|
IFile file = FileHelper.getFileFromNode(statement);
|
||||||
int offset = statement.getFileLocation().getNodeOffset();
|
int offset = statement.getFileLocation().getNodeOffset();
|
||||||
int length = statement.getFileLocation().getNodeLength();
|
int length = statement.getFileLocation().getNodeLength();
|
||||||
String code =FileContentHelper.getContent(file, offset, length);
|
String code =FileContentHelper.getContent(file, offset, length);
|
||||||
|
|
|
@ -211,11 +211,11 @@ public class ChangeGenerator extends ASTVisitor {
|
||||||
if (modification.getTargetNode() instanceof IASTTranslationUnit &&
|
if (modification.getTargetNode() instanceof IASTTranslationUnit &&
|
||||||
((IASTTranslationUnit)modification.getTargetNode()).getDeclarations().length > 0) {
|
((IASTTranslationUnit)modification.getTargetNode()).getDeclarations().length > 0) {
|
||||||
IASTTranslationUnit tu = (IASTTranslationUnit)modification.getTargetNode();
|
IASTTranslationUnit tu = (IASTTranslationUnit)modification.getTargetNode();
|
||||||
IASTDeclaration lastDecl = tu.getDeclarations()[tu.getDeclarations().length -1];
|
IASTDeclaration lastDecl = tu.getDeclarations()[tu.getDeclarations().length - 1];
|
||||||
targetLocation = lastDecl.getFileLocation();
|
targetLocation = lastDecl.getFileLocation();
|
||||||
}
|
}
|
||||||
String lineDelimiter = FileHelper.determineLineDelimiter(
|
String lineDelimiter = FileHelper.determineLineDelimiter(
|
||||||
FileHelper.getIFilefromIASTNode(modification.getTargetNode()));
|
FileHelper.getFileFromNode(modification.getTargetNode()));
|
||||||
edit.addChild(new InsertEdit(targetLocation.getNodeOffset() + targetLocation.getNodeLength(),
|
edit.addChild(new InsertEdit(targetLocation.getNodeOffset() + targetLocation.getNodeLength(),
|
||||||
lineDelimiter + lineDelimiter + newNodeCode));
|
lineDelimiter + lineDelimiter + newNodeCode));
|
||||||
break;
|
break;
|
||||||
|
@ -224,7 +224,7 @@ public class ChangeGenerator extends ASTVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createChange(IASTNode synthNode, String synthSource) {
|
private void createChange(IASTNode synthNode, String synthSource) {
|
||||||
IFile relevantFile = FileHelper.getIFilefromIASTNode(synthNode);
|
IFile relevantFile = FileHelper.getFileFromNode(synthNode);
|
||||||
|
|
||||||
String originalCode = originalCodeOfNode(synthNode);
|
String originalCode = originalCodeOfNode(synthNode);
|
||||||
CodeComparer codeComparer = new CodeComparer(originalCode, synthSource);
|
CodeComparer codeComparer = new CodeComparer(originalCode, synthSource);
|
||||||
|
@ -242,7 +242,7 @@ public class ChangeGenerator extends ASTVisitor {
|
||||||
|
|
||||||
public String originalCodeOfNode(IASTNode node) {
|
public String originalCodeOfNode(IASTNode node) {
|
||||||
if (node.getFileLocation() != null) {
|
if (node.getFileLocation() != null) {
|
||||||
IFile sourceFile = FileHelper.getIFilefromIASTNode(node);
|
IFile sourceFile = FileHelper.getFileFromNode(node);
|
||||||
int nodeOffset = getOffsetIncludingComments(node);
|
int nodeOffset = getOffsetIncludingComments(node);
|
||||||
int nodeLength = getNodeLengthIncludingComments(node);
|
int nodeLength = getNodeLengthIncludingComments(node);
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ public class ChangeGenerator extends ASTVisitor {
|
||||||
IASTFileLocation fileLocation = nextNode.getFileLocation();
|
IASTFileLocation fileLocation = nextNode.getFileLocation();
|
||||||
int length = fileLocation.getNodeOffset() - getOffsetForNodeFile(nextNode);
|
int length = fileLocation.getNodeOffset() - getOffsetForNodeFile(nextNode);
|
||||||
|
|
||||||
String originalSource = FileContentHelper.getContent(FileHelper.getIFilefromIASTNode(nextNode),
|
String originalSource = FileContentHelper.getContent(FileHelper.getFileFromNode(nextNode),
|
||||||
getOffsetForNodeFile(nextNode), length);
|
getOffsetForNodeFile(nextNode), length);
|
||||||
StringBuilder indent = new StringBuilder(originalSource);
|
StringBuilder indent = new StringBuilder(originalSource);
|
||||||
indent.reverse();
|
indent.reverse();
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.eclipse.jface.text.TextUtilities;
|
||||||
public class FileHelper {
|
public class FileHelper {
|
||||||
private static final String DEFAULT_LINE_DELIMITTER = "\n"; //$NON-NLS-1$
|
private static final String DEFAULT_LINE_DELIMITTER = "\n"; //$NON-NLS-1$
|
||||||
|
|
||||||
public static IFile getIFilefromIASTNode(IASTNode node) {
|
public static IFile getFileFromNode(IASTNode node) {
|
||||||
IPath implPath = new Path(node.getContainingFilename());
|
IPath implPath = new Path(node.getContainingFilename());
|
||||||
return ResourceLookup.selectFileForLocation(implPath, null);
|
return ResourceLookup.selectFileForLocation(implPath, null);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue