mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
Cosmetics.
This commit is contained in:
parent
88f9c72b6a
commit
c1a3773622
1 changed files with 10 additions and 8 deletions
|
@ -12,6 +12,7 @@
|
||||||
package org.eclipse.cdt.internal.ui.refactoring.utils;
|
package org.eclipse.cdt.internal.ui.refactoring.utils;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
@ -68,24 +69,25 @@ public class SelectionHelper {
|
||||||
|
|
||||||
public static boolean isSelectionOnExpression(Region textSelection, IASTNode expression) {
|
public static boolean isSelectionOnExpression(Region textSelection, IASTNode expression) {
|
||||||
Region exprPos = createExpressionPosition(expression);
|
Region exprPos = createExpressionPosition(expression);
|
||||||
|
int exprStart = exprPos.getOffset();
|
||||||
int selStart = textSelection.getOffset();
|
int selStart = textSelection.getOffset();
|
||||||
int selEnd = textSelection.getLength() + selStart;
|
int selEnd = selStart + textSelection.getLength();
|
||||||
return exprPos.getOffset() + exprPos.getLength() >= selStart && exprPos.getOffset() <= selEnd;
|
return exprStart + exprPos.getLength() >= selStart && exprStart <= selEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isExpressionWhollyInSelection(Region textSelection, IASTNode expression) {
|
public static boolean isExpressionWhollyInSelection(Region textSelection, IASTNode expression) {
|
||||||
Region exprPos = createExpressionPosition(expression);
|
Region exprPos = createExpressionPosition(expression);
|
||||||
|
int exprStart = exprPos.getOffset();
|
||||||
int selStart = textSelection.getOffset();
|
int selStart = textSelection.getOffset();
|
||||||
int selEnd = textSelection.getLength() + selStart;
|
int selEnd = selStart + textSelection.getLength();
|
||||||
|
return exprStart >= selStart && exprStart + exprPos.getLength() <= selEnd;
|
||||||
return exprPos.getOffset() >= selStart && exprPos.getOffset() + exprPos.getLength() <= selEnd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInSameFile(IASTNode node, IFile file) {
|
public static boolean isInSameFile(IASTNode node, IFile file) {
|
||||||
IPath path = new Path(node.getContainingFilename());
|
IPath path = new Path(node.getContainingFilename());
|
||||||
IFile locFile = ResourcesPlugin.getWorkspace().getRoot().getFile(file.getLocation());
|
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
IFile tmpFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
|
IFile locFile = workspaceRoot.getFile(file.getLocation());
|
||||||
|
IFile tmpFile = workspaceRoot.getFile(path);
|
||||||
return locFile.equals(tmpFile);
|
return locFile.equals(tmpFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue