mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Cosmetics.
This commit is contained in:
parent
9c5bcf4e4f
commit
a84636dec5
2 changed files with 8 additions and 10 deletions
|
@ -413,7 +413,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
||||||
copy.setLocationResolver(fLocationResolver);
|
copy.setLocationResolver(fLocationResolver);
|
||||||
copy.setIsForContentAssist(fForContentAssist);
|
copy.setIsForContentAssist(fForContentAssist);
|
||||||
|
|
||||||
for(IASTDeclaration declaration : getDeclarations())
|
for (IASTDeclaration declaration : getDeclarations())
|
||||||
copy.addDeclaration(declaration == null ? null : declaration.copy());
|
copy.addDeclaration(declaration == null ? null : declaration.copy());
|
||||||
|
|
||||||
copy.setOffsetAndLength(this);
|
copy.setOffsetAndLength(this);
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.eclipse.cdt.internal.ui.refactoring.Container;
|
||||||
* Helper class to support operations concerning a selection.
|
* Helper class to support operations concerning a selection.
|
||||||
*
|
*
|
||||||
* @author Mirko Stocker, Lukas Felber
|
* @author Mirko Stocker, Lukas Felber
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class SelectionHelper {
|
public class SelectionHelper {
|
||||||
|
|
||||||
|
@ -46,8 +45,8 @@ public class SelectionHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IASTSimpleDeclaration findFirstSelectedDeclaration(final Region textSelection, IASTTranslationUnit translationUnit) {
|
public static IASTSimpleDeclaration findFirstSelectedDeclaration(final Region textSelection,
|
||||||
|
IASTTranslationUnit translationUnit) {
|
||||||
final Container<IASTSimpleDeclaration> container = new Container<IASTSimpleDeclaration>();
|
final Container<IASTSimpleDeclaration> container = new Container<IASTSimpleDeclaration>();
|
||||||
|
|
||||||
translationUnit.accept(new ASTVisitor() {
|
translationUnit.accept(new ASTVisitor() {
|
||||||
|
@ -90,21 +89,20 @@ public class SelectionHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInSameFileSelection(Region textSelection, IASTNode node, IFile file) {
|
public static boolean isInSameFileSelection(Region textSelection, IASTNode node, IFile file) {
|
||||||
if( isInSameFile(node, file) ) {
|
if (isInSameFile(node, file)) {
|
||||||
return SelectionHelper.isSelectionOnExpression(textSelection, node);
|
return SelectionHelper.isSelectionOnExpression(textSelection, node);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSelectedFile(Region textSelection, IASTNode node, IFile file) {
|
public static boolean isSelectedFile(Region textSelection, IASTNode node, IFile file) {
|
||||||
if( isInSameFile(node, file) ) {
|
if (isInSameFile(node, file)) {
|
||||||
return isExpressionWhollyInSelection(textSelection, node);
|
return isExpressionWhollyInSelection(textSelection, node);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Region createExpressionPosition(IASTNode expression) {
|
protected static Region createExpressionPosition(IASTNode expression) {
|
||||||
|
|
||||||
int start = Integer.MAX_VALUE;
|
int start = Integer.MAX_VALUE;
|
||||||
int nodeLength = 0;
|
int nodeLength = 0;
|
||||||
IASTNodeLocation[] nodeLocations = expression.getNodeLocations();
|
IASTNodeLocation[] nodeLocations = expression.getNodeLocations();
|
||||||
|
@ -113,14 +111,14 @@ public class SelectionHelper {
|
||||||
if (location instanceof IASTMacroExpansionLocation) {
|
if (location instanceof IASTMacroExpansionLocation) {
|
||||||
IASTMacroExpansionLocation macroLoc = (IASTMacroExpansionLocation) location;
|
IASTMacroExpansionLocation macroLoc = (IASTMacroExpansionLocation) location;
|
||||||
int nodeOffset = macroLoc.asFileLocation().getNodeOffset();
|
int nodeOffset = macroLoc.asFileLocation().getNodeOffset();
|
||||||
if(nodeOffset < start) {
|
if (nodeOffset < start) {
|
||||||
start = nodeOffset;
|
start = nodeOffset;
|
||||||
}
|
}
|
||||||
nodeLength += macroLoc.asFileLocation().getNodeLength();
|
nodeLength += macroLoc.asFileLocation().getNodeLength();
|
||||||
}else {
|
} else {
|
||||||
IASTFileLocation loc = expression.getFileLocation();
|
IASTFileLocation loc = expression.getFileLocation();
|
||||||
int nodeOffset = loc.getNodeOffset();
|
int nodeOffset = loc.getNodeOffset();
|
||||||
if(nodeOffset < start) {
|
if (nodeOffset < start) {
|
||||||
start = nodeOffset;
|
start = nodeOffset;
|
||||||
}
|
}
|
||||||
nodeLength = loc.getNodeLength();
|
nodeLength = loc.getNodeLength();
|
||||||
|
|
Loading…
Add table
Reference in a new issue