mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Cosmetics.
This commit is contained in:
parent
fc976f6d9f
commit
8ab95e93b5
16 changed files with 200 additions and 285 deletions
|
@ -30,21 +30,18 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation;
|
import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation;
|
||||||
|
|
||||||
|
|
||||||
public class ChooserComposite extends Composite {
|
public class ChooserComposite extends Composite {
|
||||||
|
|
||||||
private static final String COLUMN_RETURN = Messages.ChooserComposite_Return;
|
private static final String COLUMN_RETURN = Messages.ChooserComposite_Return;
|
||||||
private static final String COLUMN_REFERENCE = Messages.ChooserComposite_CallByRef;
|
private static final String COLUMN_REFERENCE = Messages.ChooserComposite_CallByRef;
|
||||||
private static final String COLUMN_NAME = Messages.ChooserComposite_Name;
|
private static final String COLUMN_NAME = Messages.ChooserComposite_Name;
|
||||||
private static final String COLUMN_TYPE = Messages.ChooserComposite_Type;
|
private static final String COLUMN_TYPE = Messages.ChooserComposite_Type;
|
||||||
|
|
||||||
|
|
||||||
private Button voidReturn;
|
private Button voidReturn;
|
||||||
|
|
||||||
private final ExtractFunctionInputPage ip;
|
private final ExtractFunctionInputPage ip;
|
||||||
|
|
||||||
public ChooserComposite(Composite parent,
|
public ChooserComposite(Composite parent, final ExtractFunctionInformation info,
|
||||||
final ExtractFunctionInformation info, ExtractFunctionInputPage ip) {
|
ExtractFunctionInputPage ip) {
|
||||||
super(parent, SWT.NONE);
|
super(parent, SWT.NONE);
|
||||||
|
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
|
@ -93,8 +90,7 @@ public class ChooserComposite extends Composite {
|
||||||
// Button
|
// Button
|
||||||
editor = new TableEditor(table);
|
editor = new TableEditor(table);
|
||||||
final Button referenceButton = new Button(table, SWT.CHECK);
|
final Button referenceButton = new Button(table, SWT.CHECK);
|
||||||
if(name.hasReferenceOperartor((IASTDeclarator) name.getDeclaration().getParent()))
|
if (name.hasReferenceOperartor((IASTDeclarator) name.getDeclaration().getParent())) {
|
||||||
{
|
|
||||||
referenceButton.setSelection(true);
|
referenceButton.setSelection(true);
|
||||||
referenceButton.setEnabled(false);
|
referenceButton.setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -102,17 +98,16 @@ public class ChooserComposite extends Composite {
|
||||||
}
|
}
|
||||||
referenceButton.setBackground(table.getBackground());
|
referenceButton.setBackground(table.getBackground());
|
||||||
referenceButton.addSelectionListener(new SelectionListener() {
|
referenceButton.addSelectionListener(new SelectionListener() {
|
||||||
|
@Override
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
name.setUserSetIsReference(referenceButton
|
name.setUserSetIsReference(referenceButton.getSelection());
|
||||||
.getSelection());
|
|
||||||
onVisibilityOrReturnChange(info.getAllUsedNames());
|
onVisibilityOrReturnChange(info.getAllUsedNames());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
widgetDefaultSelected(e);
|
widgetDefaultSelected(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
referenceButton.pack();
|
referenceButton.pack();
|
||||||
editor.minimumWidth = referenceButton.getSize().x;
|
editor.minimumWidth = referenceButton.getSize().x;
|
||||||
|
@ -129,17 +124,16 @@ public class ChooserComposite extends Composite {
|
||||||
|
|
||||||
constButton.setBackground(table.getBackground());
|
constButton.setBackground(table.getBackground());
|
||||||
constButton.addSelectionListener(new SelectionListener() {
|
constButton.addSelectionListener(new SelectionListener() {
|
||||||
|
@Override
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
name.setConst(constButton
|
name.setConst(constButton.getSelection());
|
||||||
.getSelection());
|
|
||||||
onVisibilityOrReturnChange(info.getAllUsedNames());
|
onVisibilityOrReturnChange(info.getAllUsedNames());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
widgetDefaultSelected(e);
|
widgetDefaultSelected(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
constButton.pack();
|
constButton.pack();
|
||||||
editor.minimumWidth = constButton.getSize().x;
|
editor.minimumWidth = constButton.getSize().x;
|
||||||
|
@ -147,7 +141,6 @@ public class ChooserComposite extends Composite {
|
||||||
// referenceButtons.add(referenceButton);
|
// referenceButtons.add(referenceButton);
|
||||||
editor.setEditor(constButton, item, columnIndex++);
|
editor.setEditor(constButton, item, columnIndex++);
|
||||||
|
|
||||||
|
|
||||||
if (info.isExtractExpression())
|
if (info.isExtractExpression())
|
||||||
continue; // Skip the return radiobutton
|
continue; // Skip the return radiobutton
|
||||||
|
|
||||||
|
@ -159,28 +152,23 @@ public class ChooserComposite extends Composite {
|
||||||
returnButton.setEnabled(hasNoPredefinedReturnValue);
|
returnButton.setEnabled(hasNoPredefinedReturnValue);
|
||||||
returnButton.setBackground(table.getBackground());
|
returnButton.setBackground(table.getBackground());
|
||||||
returnButton.addSelectionListener(new SelectionListener() {
|
returnButton.addSelectionListener(new SelectionListener() {
|
||||||
|
@Override
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
name.setUserSetIsReturnValue(returnButton
|
name.setUserSetIsReturnValue(returnButton.getSelection());
|
||||||
.getSelection());
|
|
||||||
if (returnButton.getSelection()) {
|
if (returnButton.getSelection()) {
|
||||||
referenceButton.setSelection(false);
|
referenceButton.setSelection(false);
|
||||||
referenceButton.notifyListeners(SWT.Selection,
|
referenceButton.notifyListeners(SWT.Selection, new Event());
|
||||||
new Event());
|
} else if (name.isReference()) {
|
||||||
} else {
|
|
||||||
if (name.isReference()) {
|
|
||||||
referenceButton.setSelection(true);
|
referenceButton.setSelection(true);
|
||||||
referenceButton.notifyListeners(SWT.Selection,
|
referenceButton.notifyListeners(SWT.Selection, new Event());
|
||||||
new Event());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
onVisibilityOrReturnChange(info.getAllUsedNames());
|
onVisibilityOrReturnChange(info.getAllUsedNames());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
widgetDefaultSelected(e);
|
widgetDefaultSelected(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
returnButton.pack();
|
returnButton.pack();
|
||||||
editor.minimumWidth = returnButton.getSize().x;
|
editor.minimumWidth = returnButton.getSize().x;
|
||||||
|
@ -195,7 +183,7 @@ public class ChooserComposite extends Composite {
|
||||||
voidReturn.setText(Messages.ChooserComposite_NoReturnValue);
|
voidReturn.setText(Messages.ChooserComposite_NoReturnValue);
|
||||||
voidReturn.setEnabled(hasNoPredefinedReturnValue);
|
voidReturn.setEnabled(hasNoPredefinedReturnValue);
|
||||||
voidReturn.addSelectionListener(new SelectionListener() {
|
voidReturn.addSelectionListener(new SelectionListener() {
|
||||||
|
@Override
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
info.setReturnVariable(null);
|
info.setReturnVariable(null);
|
||||||
|
|
||||||
|
@ -205,14 +193,13 @@ public class ChooserComposite extends Composite {
|
||||||
button.notifyListeners(SWT.Selection, new Event());
|
button.notifyListeners(SWT.Selection, new Event());
|
||||||
}
|
}
|
||||||
button.setEnabled(!voidReturn.getSelection());
|
button.setEnabled(!voidReturn.getSelection());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
widgetDefaultSelected(e);
|
widgetDefaultSelected(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,6 +222,5 @@ public class ChooserComposite extends Composite {
|
||||||
}
|
}
|
||||||
|
|
||||||
ip.errorWithAfterUsedVariable(variableUsedAfterBlock);
|
ip.errorWithAfterUsedVariable(variableUsedAfterBlock);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,13 +26,13 @@ import org.eclipse.cdt.internal.ui.refactoring.dialogs.NameAndVisibilityComposit
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
|
import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
|
||||||
|
|
||||||
public class ExtractFunctionComposite extends Composite {
|
public class ExtractFunctionComposite extends Composite {
|
||||||
|
|
||||||
private Button replaceSimilar;
|
private Button replaceSimilar;
|
||||||
private ChooserComposite comp;
|
private ChooserComposite comp;
|
||||||
private NameAndVisibilityComposite nameVisiComp;
|
private NameAndVisibilityComposite nameVisiComp;
|
||||||
private final ExtractFunctionInformation info;
|
private final ExtractFunctionInformation info;
|
||||||
|
|
||||||
public ExtractFunctionComposite(Composite parent, ExtractFunctionInformation info, ExtractFunctionInputPage ip) {
|
public ExtractFunctionComposite(Composite parent, ExtractFunctionInformation info,
|
||||||
|
ExtractFunctionInputPage ip) {
|
||||||
super(parent, SWT.NONE);
|
super(parent, SWT.NONE);
|
||||||
this.info = info;
|
this.info = info;
|
||||||
setLayout(new GridLayout());
|
setLayout(new GridLayout());
|
||||||
|
@ -52,7 +52,6 @@ public class ExtractFunctionComposite extends Composite {
|
||||||
layout();
|
layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Group createReturnGroup(Composite parent) {
|
private Group createReturnGroup(Composite parent) {
|
||||||
Group returnGroup = new Group(parent,SWT.NONE);
|
Group returnGroup = new Group(parent,SWT.NONE);
|
||||||
|
|
||||||
|
@ -65,19 +64,16 @@ public class ExtractFunctionComposite extends Composite {
|
||||||
return returnGroup;
|
return returnGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createReturnValueChooser(Composite parent, ExtractFunctionInformation info,
|
||||||
private void createReturnValueChooser(Composite parent, ExtractFunctionInformation info, ExtractFunctionInputPage ip) {
|
ExtractFunctionInputPage ip) {
|
||||||
|
|
||||||
GridData gridData = new GridData();
|
GridData gridData = new GridData();
|
||||||
gridData.horizontalAlignment = GridData.FILL;
|
gridData.horizontalAlignment = GridData.FILL;
|
||||||
gridData.grabExcessHorizontalSpace = true;
|
gridData.grabExcessHorizontalSpace = true;
|
||||||
comp = new ChooserComposite(parent, info, ip);
|
comp = new ChooserComposite(parent, info, ip);
|
||||||
comp.setLayoutData(gridData);
|
comp.setLayoutData(gridData);
|
||||||
comp.redraw();
|
comp.redraw();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Text getMethodNameText() {
|
public Text getMethodNameText() {
|
||||||
return nameVisiComp.getConstantNameText();
|
return nameVisiComp.getConstantNameText();
|
||||||
}
|
}
|
||||||
|
@ -91,7 +87,6 @@ public class ExtractFunctionComposite extends Composite {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createNewMethodNameComposite(Composite parent) {
|
private void createNewMethodNameComposite(Composite parent) {
|
||||||
|
|
||||||
String label;
|
String label;
|
||||||
if (info.getMethodContext().getType() == MethodContext.ContextType.METHOD) {
|
if (info.getMethodContext().getType() == MethodContext.ContextType.METHOD) {
|
||||||
label = Messages.ExtractFunctionComposite_MethodName;
|
label = Messages.ExtractFunctionComposite_MethodName;
|
||||||
|
@ -106,16 +101,13 @@ public class ExtractFunctionComposite extends Composite {
|
||||||
final Button virtual = new Button(nameVisiComp, SWT.CHECK);
|
final Button virtual = new Button(nameVisiComp, SWT.CHECK);
|
||||||
virtual.setText(Messages.ExtractFunctionComposite_Virtual);
|
virtual.setText(Messages.ExtractFunctionComposite_Virtual);
|
||||||
virtual.addSelectionListener(new SelectionAdapter() {
|
virtual.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
info.setVirtual(virtual.getSelection());
|
info.setVirtual(virtual.getSelection());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void createReplaceCheckBox(Composite parent) {
|
private void createReplaceCheckBox(Composite parent) {
|
||||||
replaceSimilar = new Button(parent, SWT.CHECK | SWT.LEFT);
|
replaceSimilar = new Button(parent, SWT.CHECK | SWT.LEFT);
|
||||||
GridData buttonLayoutData = new GridData(SWT.None);
|
GridData buttonLayoutData = new GridData(SWT.None);
|
||||||
|
@ -124,7 +116,6 @@ public class ExtractFunctionComposite extends Composite {
|
||||||
replaceSimilar.setText(Messages.ExtractFunctionComposite_ReplaceDuplicates);
|
replaceSimilar.setText(Messages.ExtractFunctionComposite_ReplaceDuplicates);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ChooserComposite getReturnChooser() {
|
public ChooserComposite getReturnChooser() {
|
||||||
return comp;
|
return comp;
|
||||||
}
|
}
|
||||||
|
@ -133,9 +124,7 @@ public class ExtractFunctionComposite extends Composite {
|
||||||
return nameVisiComp.getConstantNameText().getText();
|
return nameVisiComp.getConstantNameText().getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Composite getVisibiltyGroup() {
|
public Composite getVisibiltyGroup() {
|
||||||
|
|
||||||
return nameVisiComp.getVisibiltyGroup();
|
return nameVisiComp.getVisibiltyGroup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,7 @@ import org.eclipse.cdt.internal.ui.refactoring.MethodContext;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation;
|
import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
|
import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
|
||||||
|
|
||||||
|
|
||||||
public class ExtractFunctionInformation {
|
public class ExtractFunctionInformation {
|
||||||
|
|
||||||
public final int VISIBILITY_PRIVATE = 1;
|
public final int VISIBILITY_PRIVATE = 1;
|
||||||
public final int VISIBILITY_PROTECTED = 3;
|
public final int VISIBILITY_PROTECTED = 3;
|
||||||
public final int VISIBILITY_PUBLIC = 2;
|
public final int VISIBILITY_PUBLIC = 2;
|
||||||
|
|
|
@ -27,35 +27,30 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierHelper;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierResult;
|
import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierResult;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
|
import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
|
||||||
|
|
||||||
|
|
||||||
public class ExtractFunctionInputPage extends UserInputWizardPage {
|
public class ExtractFunctionInputPage extends UserInputWizardPage {
|
||||||
|
|
||||||
private final ExtractFunctionInformation info;
|
private final ExtractFunctionInformation info;
|
||||||
private ExtractFunctionComposite comp;
|
private ExtractFunctionComposite comp;
|
||||||
protected final String NO_NAME_ERROR_LABEL = Messages.ExtractFunctionInputPage_EnterName;
|
protected final String NO_NAME_ERROR_LABEL = Messages.ExtractFunctionInputPage_EnterName;
|
||||||
|
|
||||||
|
|
||||||
public ExtractFunctionInputPage(String name, ExtractFunctionInformation info) {
|
public ExtractFunctionInputPage(String name, ExtractFunctionInformation info) {
|
||||||
super(name);
|
super(name);
|
||||||
this.info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void createControl(final Composite parent) {
|
public void createControl(final Composite parent) {
|
||||||
|
|
||||||
comp = new ExtractFunctionComposite(parent, info, this);
|
comp = new ExtractFunctionComposite(parent, info, this);
|
||||||
|
|
||||||
setPageComplete(false);
|
setPageComplete(false);
|
||||||
|
|
||||||
comp.getMethodNameText().addModifyListener(new ModifyListener() {
|
comp.getMethodNameText().addModifyListener(new ModifyListener() {
|
||||||
|
@Override
|
||||||
public void modifyText(ModifyEvent e) {
|
public void modifyText(ModifyEvent e) {
|
||||||
info.setMethodName(comp.getMethodName());
|
info.setMethodName(comp.getMethodName());
|
||||||
checkName();
|
checkName();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
for (Control buttons : comp.getVisibiltyGroup().getChildren()) {
|
for (Control buttons : comp.getVisibiltyGroup().getChildren()) {
|
||||||
buttons.addMouseListener(new MouseAdapter() {
|
buttons.addMouseListener(new MouseAdapter() {
|
||||||
|
|
||||||
|
@ -68,35 +63,31 @@ public class ExtractFunctionInputPage extends UserInputWizardPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
comp.getReplaceSimilarButton().addSelectionListener(new SelectionListener() {
|
comp.getReplaceSimilarButton().addSelectionListener(new SelectionListener() {
|
||||||
|
@Override
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
info.setReplaceDuplicates(comp.getReplaceSimilarButton().isEnabled());
|
info.setReplaceDuplicates(comp.getReplaceSimilarButton().isEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
widgetDefaultSelected(e);
|
widgetDefaultSelected(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
setControl(comp);
|
setControl(comp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void visibilityChange(String text) {
|
protected void visibilityChange(String text) {
|
||||||
info.setVisibility(VisibilityEnum.getEnumForStringRepresentation(text));
|
info.setVisibility(VisibilityEnum.getEnumForStringRepresentation(text));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkName() {
|
private void checkName() {
|
||||||
|
|
||||||
String methodName = comp.getMethodName();
|
String methodName = comp.getMethodName();
|
||||||
IdentifierResult result = IdentifierHelper.checkIdentifierName(methodName);
|
IdentifierResult result = IdentifierHelper.checkIdentifierName(methodName);
|
||||||
if (result.isCorrect()) {
|
if (result.isCorrect()) {
|
||||||
setErrorMessage(null);
|
setErrorMessage(null);
|
||||||
setPageComplete(true);
|
setPageComplete(true);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
setErrorMessage(Messages.ExtractFunctionInputPage_CheckFunctionName + " " + result.getMessage()); //$NON-NLS-1$
|
setErrorMessage(Messages.ExtractFunctionInputPage_CheckFunctionName + " " + result.getMessage()); //$NON-NLS-1$
|
||||||
setPageComplete(false);
|
setPageComplete(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,9 +95,9 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNodeFactory;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWriteFlags;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWriteFlags;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.ClassMemberInserter;
|
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.CRefactoring;
|
import org.eclipse.cdt.internal.ui.refactoring.CRefactoring;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription;
|
import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription;
|
||||||
|
import org.eclipse.cdt.internal.ui.refactoring.ClassMemberInserter;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.Container;
|
import org.eclipse.cdt.internal.ui.refactoring.Container;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.MethodContext;
|
import org.eclipse.cdt.internal.ui.refactoring.MethodContext;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.MethodContext.ContextType;
|
import org.eclipse.cdt.internal.ui.refactoring.MethodContext.ContextType;
|
||||||
|
@ -412,10 +412,10 @@ public class ExtractFunctionRefactoring extends CRefactoring {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createMethodDeclaration(final IASTName astMethodName,
|
private void createMethodDeclaration(final IASTName astMethodName, MethodContext context,
|
||||||
MethodContext context, ModificationCollector collector) {
|
ModificationCollector collector) {
|
||||||
ICPPASTCompositeTypeSpecifier classDeclaration = (ICPPASTCompositeTypeSpecifier) context
|
ICPPASTCompositeTypeSpecifier classDeclaration =
|
||||||
.getMethodDeclaration().getParent();
|
(ICPPASTCompositeTypeSpecifier) context.getMethodDeclaration().getParent();
|
||||||
|
|
||||||
IASTSimpleDeclaration methodDeclaration = getDeclaration(collector, astMethodName);
|
IASTSimpleDeclaration methodDeclaration = getDeclaration(collector, astMethodName);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContribution;
|
||||||
* @author Emanuel Graf IFS
|
* @author Emanuel Graf IFS
|
||||||
*/
|
*/
|
||||||
public class ExtractFunctionRefactoringContribution extends CRefactoringContribution {
|
public class ExtractFunctionRefactoringContribution extends CRefactoringContribution {
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
@Override
|
@Override
|
||||||
public RefactoringDescriptor createDescriptor(String id, String project, String description,
|
public RefactoringDescriptor createDescriptor(String id, String project, String description,
|
||||||
|
|
|
@ -27,16 +27,16 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emanuel Graf IFS
|
* @author Emanuel Graf IFS
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ExtractFunctionRefactoringDescription extends CRefactoringDescription {
|
public class ExtractFunctionRefactoringDescription extends CRefactoringDescription {
|
||||||
protected static final String NAME = "name"; //$NON-NLS-1$
|
protected static final String NAME = "name"; //$NON-NLS-1$
|
||||||
protected static final String VISIBILITY = "visibility"; //$NON-NLS-1$
|
protected static final String VISIBILITY = "visibility"; //$NON-NLS-1$
|
||||||
protected static final String REPLACE_DUPLICATES = "replaceDuplicates"; //$NON-NLS-1$
|
protected static final String REPLACE_DUPLICATES = "replaceDuplicates"; //$NON-NLS-1$
|
||||||
|
|
||||||
public ExtractFunctionRefactoringDescription(String project, String description,
|
public ExtractFunctionRefactoringDescription(String project, String description, String comment,
|
||||||
String comment, Map<String, String> arguments) {
|
Map<String, String> arguments) {
|
||||||
super(ExtractFunctionRefactoring.ID, project, description, comment, RefactoringDescriptor.MULTI_CHANGE, arguments);
|
super(ExtractFunctionRefactoring.ID, project, description, comment,
|
||||||
|
RefactoringDescriptor.MULTI_CHANGE, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,5 +55,4 @@ public class ExtractFunctionRefactoringDescription extends CRefactoringDescripti
|
||||||
ISelection selection = getSelection();
|
ISelection selection = getSelection();
|
||||||
return new ExtractFunctionRefactoring(file, selection, info, proj);
|
return new ExtractFunctionRefactoring(file, selection, info, proj);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,7 @@ import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
|
||||||
import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
|
import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
|
||||||
|
|
||||||
public class ExtractFunctionRefactoringWizard extends RefactoringWizard {
|
public class ExtractFunctionRefactoringWizard extends RefactoringWizard {
|
||||||
|
private final ExtractFunctionInformation info;
|
||||||
private ExtractFunctionInformation info;
|
|
||||||
|
|
||||||
public ExtractFunctionRefactoringWizard(Refactoring refactoring, ExtractFunctionInformation info) {
|
public ExtractFunctionRefactoringWizard(Refactoring refactoring, ExtractFunctionInformation info) {
|
||||||
super(refactoring, WIZARD_BASED_USER_INTERFACE);
|
super(refactoring, WIZARD_BASED_USER_INTERFACE);
|
||||||
|
@ -26,11 +25,10 @@ public class ExtractFunctionRefactoringWizard extends RefactoringWizard {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addUserInputPages() {
|
protected void addUserInputPages() {
|
||||||
UserInputWizardPage page = new ExtractFunctionInputPage(Messages.ExtractFunctionRefactoringWizard_FunctionName,info);
|
UserInputWizardPage page = new ExtractFunctionInputPage(
|
||||||
|
Messages.ExtractFunctionRefactoringWizard_FunctionName,info);
|
||||||
page.setTitle(Messages.ExtractFunctionRefactoringWizard_FunctionName);
|
page.setTitle(Messages.ExtractFunctionRefactoringWizard_FunctionName);
|
||||||
addPage(page);
|
addPage(page);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,14 +31,11 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.ASTHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mirko Stocker
|
* @author Mirko Stocker
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ExtractStatement extends ExtractedFunctionConstructionHelper {
|
public class ExtractStatement extends ExtractedFunctionConstructionHelper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void constructMethodBody(IASTCompoundStatement compound,
|
public void constructMethodBody(IASTCompoundStatement compound, List<IASTNode> list,
|
||||||
List<IASTNode> list, ASTRewrite rewrite, TextEditGroup group) {
|
ASTRewrite rewrite, TextEditGroup group) {
|
||||||
|
|
||||||
for (IASTNode each : list) {
|
for (IASTNode each : list) {
|
||||||
rewrite.insertBefore(compound, null, each, group);
|
rewrite.insertBefore(compound, null, each, group);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +43,6 @@ public class ExtractStatement extends ExtractedFunctionConstructionHelper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTDeclSpecifier determineReturnType(IASTNode extractedNode, NameInformation returnVariable) {
|
public IASTDeclSpecifier determineReturnType(IASTNode extractedNode, NameInformation returnVariable) {
|
||||||
|
|
||||||
if (returnVariable != null) {
|
if (returnVariable != null) {
|
||||||
IASTNode decl = ASTHelper.getDeclarationForNode(returnVariable.getDeclaration());
|
IASTNode decl = ASTHelper.getDeclarationForNode(returnVariable.getDeclaration());
|
||||||
return ASTHelper.getDeclarationSpecifier(decl).copy(CopyStyle.withLocations);
|
return ASTHelper.getDeclarationSpecifier(decl).copy(CopyStyle.withLocations);
|
||||||
|
@ -57,7 +53,8 @@ public class ExtractStatement extends ExtractedFunctionConstructionHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTNode createReturnAssignment(IASTNode node, IASTExpressionStatement stmt, IASTExpression callExpression) {
|
public IASTNode createReturnAssignment(IASTNode node, IASTExpressionStatement stmt,
|
||||||
|
IASTExpression callExpression) {
|
||||||
stmt.setExpression(callExpression);
|
stmt.setExpression(callExpression);
|
||||||
return stmt;
|
return stmt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,6 @@ import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mirko Stocker
|
* @author Mirko Stocker
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class ExtractedFunctionConstructionHelper {
|
public abstract class ExtractedFunctionConstructionHelper {
|
||||||
|
|
||||||
|
@ -47,21 +46,26 @@ public abstract class ExtractedFunctionConstructionHelper {
|
||||||
return new ExtractStatement();
|
return new ExtractStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void constructMethodBody(IASTCompoundStatement compound,
|
public abstract void constructMethodBody(IASTCompoundStatement compound, List<IASTNode> list,
|
||||||
List<IASTNode> list, ASTRewrite rewrite, TextEditGroup group);
|
ASTRewrite rewrite, TextEditGroup group);
|
||||||
|
|
||||||
public abstract IASTDeclSpecifier determineReturnType(IASTNode extractedNode, NameInformation returnVariable);
|
public abstract IASTDeclSpecifier determineReturnType(IASTNode extractedNode,
|
||||||
|
NameInformation returnVariable);
|
||||||
|
|
||||||
public abstract IASTNode createReturnAssignment(IASTNode node, IASTExpressionStatement stmt, IASTExpression callExpression);
|
public abstract IASTNode createReturnAssignment(IASTNode node, IASTExpressionStatement stmt,
|
||||||
|
IASTExpression callExpression);
|
||||||
|
|
||||||
protected boolean isReturnTypeAPointer(IASTNode node) {
|
protected boolean isReturnTypeAPointer(IASTNode node) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTStandardFunctionDeclarator createFunctionDeclarator(IASTName name, IASTStandardFunctionDeclarator functionDeclarator, NameInformation returnVariable, List<IASTNode> nodesToWrite, Collection<NameInformation> allUsedNames, INodeFactory nodeFactory) {
|
IASTStandardFunctionDeclarator createFunctionDeclarator(IASTName name,
|
||||||
|
IASTStandardFunctionDeclarator functionDeclarator, NameInformation returnVariable,
|
||||||
|
List<IASTNode> nodesToWrite, Collection<NameInformation> allUsedNames, INodeFactory nodeFactory) {
|
||||||
IASTStandardFunctionDeclarator declarator = nodeFactory.newFunctionDeclarator(name);
|
IASTStandardFunctionDeclarator declarator = nodeFactory.newFunctionDeclarator(name);
|
||||||
|
|
||||||
if (functionDeclarator instanceof ICPPASTFunctionDeclarator && declarator instanceof ICPPASTFunctionDeclarator) {
|
if (functionDeclarator instanceof ICPPASTFunctionDeclarator &&
|
||||||
|
declarator instanceof ICPPASTFunctionDeclarator) {
|
||||||
if (((ICPPASTFunctionDeclarator) functionDeclarator).isConst()) {
|
if (((ICPPASTFunctionDeclarator) functionDeclarator).isConst()) {
|
||||||
((ICPPASTFunctionDeclarator) declarator).setConst(true);
|
((ICPPASTFunctionDeclarator) declarator).setConst(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,10 @@ import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emanuel Graf IFS
|
* @author Emanuel Graf IFS
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class NonExtractableStmtFinder extends ASTVisitor{
|
class NonExtractableStmtFinder extends ASTVisitor{
|
||||||
|
private boolean containsContinueStmt;
|
||||||
private boolean containsContinueStmt = false;
|
private boolean containsBreakStmt;
|
||||||
private boolean containsBreakStmt = false;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
shouldVisitStatements = true;
|
shouldVisitStatements = true;
|
||||||
|
|
|
@ -17,12 +17,9 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emanuel Graf IFS
|
* @author Emanuel Graf IFS
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class ReturnStatementFinder extends ASTVisitor{
|
class ReturnStatementFinder extends ASTVisitor{
|
||||||
|
private boolean containsReturnStmt;
|
||||||
private boolean containsReturnStmt = false;
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
shouldVisitStatements = true;
|
shouldVisitStatements = true;
|
||||||
|
@ -40,5 +37,4 @@ class ReturnStatementFinder extends ASTVisitor{
|
||||||
public boolean containsReturn() {
|
public boolean containsReturn() {
|
||||||
return containsReturnStmt;
|
return containsReturnStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@ package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.text.edits.TextEditGroup;
|
import org.eclipse.text.edits.TextEditGroup;
|
||||||
|
@ -34,52 +34,49 @@ final class SimilarFinderVisitor extends ASTVisitor {
|
||||||
|
|
||||||
private final Vector<IASTNode> trail;
|
private final Vector<IASTNode> trail;
|
||||||
private final IASTName name;
|
private final IASTName name;
|
||||||
private final List<IASTNode> stmts;
|
private final List<IASTNode> statements;
|
||||||
private int i;
|
private int statementCount;
|
||||||
private NodeContainer similarContainer;
|
private NodeContainer similarContainer;
|
||||||
private final List<IASTStatement> stmtToReplace = new ArrayList<IASTStatement>();
|
private final List<IASTStatement> stmtToReplace = new ArrayList<IASTStatement>();
|
||||||
|
|
||||||
private final ModificationCollector collector;
|
private final ModificationCollector collector;
|
||||||
|
|
||||||
SimilarFinderVisitor(ExtractFunctionRefactoring refactoring,
|
SimilarFinderVisitor(ExtractFunctionRefactoring refactoring, ModificationCollector collector,
|
||||||
ModificationCollector collector, Vector<IASTNode> trail, IFile file, IASTName name,
|
Vector<IASTNode> trail, IFile file, IASTName name, List<IASTNode> statements,
|
||||||
List<IASTNode> stmts, String title) {
|
String title) {
|
||||||
this.refactoring = refactoring;
|
this.refactoring = refactoring;
|
||||||
this.trail = trail;
|
this.trail = trail;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.stmts = stmts;
|
this.statements = statements;
|
||||||
this.collector = collector;
|
this.collector = collector;
|
||||||
this.similarContainer = new NodeContainer();
|
this.similarContainer = new NodeContainer();
|
||||||
shouldVisitStatements = true;
|
shouldVisitStatements = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTStatement stmt) {
|
public int visit(IASTStatement statement) {
|
||||||
boolean isAllreadyInMainRefactoring = isInSelection(stmt);
|
if (!isInSelection(statement) &&
|
||||||
|
refactoring.isStatementInTrail(statement, trail, refactoring.getIndex())) {
|
||||||
|
stmtToReplace.add(statement);
|
||||||
|
similarContainer.add(statement);
|
||||||
|
++statementCount;
|
||||||
|
|
||||||
if ((!isAllreadyInMainRefactoring)
|
if (statementCount == statements.size()) {
|
||||||
&& this.refactoring.isStatementInTrail(stmt, trail, this.refactoring.getIndex())) {
|
|
||||||
stmtToReplace.add(stmt);
|
|
||||||
similarContainer.add(stmt);
|
|
||||||
++i;
|
|
||||||
|
|
||||||
if (i == stmts.size()) {
|
|
||||||
// Found similar code
|
// Found similar code
|
||||||
|
|
||||||
boolean similarOnReturnWays = true;
|
boolean similarOnReturnWays = true;
|
||||||
for (NameInformation nameInfo : similarContainer.getAllAfterUsedNames()) {
|
for (NameInformation nameInfo : similarContainer.getAllAfterUsedNames()) {
|
||||||
if (this.refactoring.names.containsKey(nameInfo.getDeclaration().getRawSignature())) {
|
if (refactoring.names.containsKey(nameInfo.getDeclaration().getRawSignature())) {
|
||||||
Integer nameOrderNumber = this.refactoring.names.get(nameInfo.getDeclaration().getRawSignature());
|
Integer nameOrderNumber = refactoring.names.get(nameInfo.getDeclaration().getRawSignature());
|
||||||
if (this.refactoring.nameTrail.containsValue(nameOrderNumber)) {
|
if (refactoring.nameTrail.containsValue(nameOrderNumber)) {
|
||||||
String orgName = null;
|
String orgName = null;
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (Entry<String, Integer> entry : this.refactoring.nameTrail.entrySet()) {
|
for (Entry<String, Integer> entry : refactoring.nameTrail.entrySet()) {
|
||||||
if (entry.getValue().equals(nameOrderNumber)) {
|
if (entry.getValue().equals(nameOrderNumber)) {
|
||||||
orgName = entry.getKey();
|
orgName = entry.getKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (orgName != null) {
|
if (orgName != null) {
|
||||||
for (NameInformation orgNameInfo : this.refactoring.container.getAllAfterUsedNamesChoosenByUser()) {
|
for (NameInformation orgNameInfo : refactoring.container.getAllAfterUsedNamesChoosenByUser()) {
|
||||||
if (orgName.equals(orgNameInfo.getDeclaration().getRawSignature())) {
|
if (orgName.equals(orgNameInfo.getDeclaration().getRawSignature())) {
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
@ -95,8 +92,8 @@ final class SimilarFinderVisitor extends ASTVisitor {
|
||||||
|
|
||||||
if (similarOnReturnWays) {
|
if (similarOnReturnWays) {
|
||||||
IASTNode call = refactoring.getMethodCall(name,
|
IASTNode call = refactoring.getMethodCall(name,
|
||||||
this.refactoring.nameTrail, this.refactoring.names,
|
refactoring.nameTrail, refactoring.names,
|
||||||
this.refactoring.container, similarContainer);
|
refactoring.container, similarContainer);
|
||||||
ASTRewrite rewrite =
|
ASTRewrite rewrite =
|
||||||
collector.rewriterForTranslationUnit(stmtToReplace.get(0).getTranslationUnit());
|
collector.rewriterForTranslationUnit(stmtToReplace.get(0).getTranslationUnit());
|
||||||
TextEditGroup editGroup = new TextEditGroup(Messages.SimilarFinderVisitor_replaceDuplicateCode);
|
TextEditGroup editGroup = new TextEditGroup(Messages.SimilarFinderVisitor_replaceDuplicateCode);
|
||||||
|
@ -112,12 +109,12 @@ final class SimilarFinderVisitor extends ASTVisitor {
|
||||||
return PROCESS_SKIP;
|
return PROCESS_SKIP;
|
||||||
} else {
|
} else {
|
||||||
clear();
|
clear();
|
||||||
return super.visit(stmt);
|
return super.visit(statement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInSelection(IASTStatement stmt) {
|
private boolean isInSelection(IASTStatement stmt) {
|
||||||
List<IASTNode>nodes = this.refactoring.container.getNodesToWrite();
|
List<IASTNode>nodes = refactoring.container.getNodesToWrite();
|
||||||
for (IASTNode node : nodes) {
|
for (IASTNode node : nodes) {
|
||||||
if (node.equals(stmt)) {
|
if (node.equals(stmt)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -127,11 +124,11 @@ final class SimilarFinderVisitor extends ASTVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clear() {
|
private void clear() {
|
||||||
i = 0;
|
statementCount = 0;
|
||||||
this.refactoring.names.clear();
|
refactoring.names.clear();
|
||||||
similarContainer = new NodeContainer();
|
similarContainer = new NodeContainer();
|
||||||
this.refactoring.namesCounter.setObject(ExtractFunctionRefactoring.NULL_INTEGER);
|
refactoring.namesCounter.setObject(ExtractFunctionRefactoring.NULL_INTEGER);
|
||||||
this.refactoring.trailPos.setObject(ExtractFunctionRefactoring.NULL_INTEGER);
|
refactoring.trailPos.setObject(ExtractFunctionRefactoring.NULL_INTEGER);
|
||||||
stmtToReplace.clear();
|
stmtToReplace.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -23,9 +23,8 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.utils.ASTHelper;
|
import org.eclipse.cdt.internal.ui.refactoring.utils.ASTHelper;
|
||||||
|
|
||||||
class TrailName extends ASTNode {
|
class TrailName extends ASTNode {
|
||||||
|
|
||||||
private int nameNumber;
|
private int nameNumber;
|
||||||
private IASTNode declaration = null;
|
private final IASTNode declaration = null;
|
||||||
private IASTName realName = null;
|
private IASTName realName = null;
|
||||||
|
|
||||||
public TrailName(IASTName realName) {
|
public TrailName(IASTName realName) {
|
||||||
|
@ -61,10 +60,12 @@ class TrailName extends ASTNode{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode copy() {
|
public IASTNode copy() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode copy(CopyStyle style) {
|
public IASTNode copy(CopyStyle style) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,10 +66,9 @@ import org.eclipse.cdt.internal.ui.refactoring.Container;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.EqualityChecker;
|
import org.eclipse.cdt.internal.ui.refactoring.EqualityChecker;
|
||||||
|
|
||||||
public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
||||||
|
|
||||||
private final Map<String, Integer> names;
|
private final Map<String, Integer> names;
|
||||||
private final Container<Integer> namesCounter;
|
private final Container<Integer> namesCounter;
|
||||||
private IIndex index;
|
private final IIndex index;
|
||||||
|
|
||||||
public TrailNodeEqualityChecker(Map<String, Integer> names, Container<Integer> namesCounter, IIndex index) {
|
public TrailNodeEqualityChecker(Map<String, Integer> names, Container<Integer> namesCounter, IIndex index) {
|
||||||
super();
|
super();
|
||||||
|
@ -78,6 +77,7 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isEquals(IASTNode trailNode, IASTNode node) {
|
public boolean isEquals(IASTNode trailNode, IASTNode node) {
|
||||||
if ((trailNode instanceof TrailName && node instanceof IASTName)
|
if ((trailNode instanceof TrailName && node instanceof IASTName)
|
||||||
|| Arrays.equals(getInterfaces(node), getInterfaces(trailNode))) {
|
|| Arrays.equals(getInterfaces(node), getInterfaces(trailNode))) {
|
||||||
|
@ -105,8 +105,6 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isNameEquals(IASTNode trailNode, IASTNode node) {
|
private boolean isNameEquals(IASTNode trailNode, IASTNode node) {
|
||||||
|
@ -115,12 +113,10 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
||||||
} else if (trailNode instanceof ICPPASTOperatorName) {
|
} else if (trailNode instanceof ICPPASTOperatorName) {
|
||||||
ICPPASTOperatorName trailName= (ICPPASTOperatorName) trailNode;
|
ICPPASTOperatorName trailName= (ICPPASTOperatorName) trailNode;
|
||||||
ICPPASTOperatorName name = (ICPPASTOperatorName) node;
|
ICPPASTOperatorName name = (ICPPASTOperatorName) node;
|
||||||
|
|
||||||
return trailName.equals(name);
|
return trailName.equals(name);
|
||||||
} else if (trailNode instanceof TrailName && node instanceof IASTName) {
|
} else if (trailNode instanceof TrailName && node instanceof IASTName) {
|
||||||
TrailName trailName = (TrailName) trailNode;
|
TrailName trailName = (TrailName) trailNode;
|
||||||
IASTName name = (IASTName)node;
|
IASTName name = (IASTName)node;
|
||||||
|
|
||||||
return isNameEquals(trailName, name);
|
return isNameEquals(trailName, name);
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
@ -131,13 +127,10 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
||||||
if (trailNode instanceof IASTSimpleDeclSpecifier) {
|
if (trailNode instanceof IASTSimpleDeclSpecifier) {
|
||||||
IASTSimpleDeclSpecifier trailDecl = (IASTSimpleDeclSpecifier) trailNode;
|
IASTSimpleDeclSpecifier trailDecl = (IASTSimpleDeclSpecifier) trailNode;
|
||||||
IASTSimpleDeclSpecifier decl = (IASTSimpleDeclSpecifier) node;
|
IASTSimpleDeclSpecifier decl = (IASTSimpleDeclSpecifier) node;
|
||||||
|
|
||||||
return isSimpleDeclSpecifierEquals(trailDecl, decl);
|
return isSimpleDeclSpecifierEquals(trailDecl, decl);
|
||||||
} else if (trailNode instanceof ICPPASTNamedTypeSpecifier) {
|
} else if (trailNode instanceof ICPPASTNamedTypeSpecifier) {
|
||||||
ICPPASTNamedTypeSpecifier trailDecl = (ICPPASTNamedTypeSpecifier) trailNode;
|
ICPPASTNamedTypeSpecifier trailDecl = (ICPPASTNamedTypeSpecifier) trailNode;
|
||||||
ICPPASTNamedTypeSpecifier decl = (ICPPASTNamedTypeSpecifier) node;
|
ICPPASTNamedTypeSpecifier decl = (ICPPASTNamedTypeSpecifier) node;
|
||||||
|
|
||||||
|
|
||||||
return isDeclSpecifierEquals(trailDecl, decl)
|
return isDeclSpecifierEquals(trailDecl, decl)
|
||||||
&& isSameNamedTypeSpecifierName(trailDecl, decl)
|
&& isSameNamedTypeSpecifierName(trailDecl, decl)
|
||||||
&& trailDecl.isTypename() == decl.isTypename()
|
&& trailDecl.isTypename() == decl.isTypename()
|
||||||
|
@ -147,25 +140,21 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
||||||
} else if (trailNode instanceof IASTNamedTypeSpecifier) {
|
} else if (trailNode instanceof IASTNamedTypeSpecifier) {
|
||||||
IASTNamedTypeSpecifier trailDecl = (IASTNamedTypeSpecifier) trailNode;
|
IASTNamedTypeSpecifier trailDecl = (IASTNamedTypeSpecifier) trailNode;
|
||||||
IASTNamedTypeSpecifier decl = (IASTNamedTypeSpecifier) node;
|
IASTNamedTypeSpecifier decl = (IASTNamedTypeSpecifier) node;
|
||||||
|
|
||||||
return isDeclSpecifierEquals(trailDecl, decl)
|
return isDeclSpecifierEquals(trailDecl, decl)
|
||||||
&& isSameNamedTypeSpecifierName(trailDecl, decl);
|
&& isSameNamedTypeSpecifierName(trailDecl, decl);
|
||||||
} else if (trailNode instanceof IASTElaboratedTypeSpecifier) {
|
} else if (trailNode instanceof IASTElaboratedTypeSpecifier) {
|
||||||
IASTElaboratedTypeSpecifier trailDecl = (IASTElaboratedTypeSpecifier) trailNode;
|
IASTElaboratedTypeSpecifier trailDecl = (IASTElaboratedTypeSpecifier) trailNode;
|
||||||
IASTElaboratedTypeSpecifier decl = (IASTElaboratedTypeSpecifier) node;
|
IASTElaboratedTypeSpecifier decl = (IASTElaboratedTypeSpecifier) node;
|
||||||
|
|
||||||
return isDeclSpecifierEquals(trailDecl, decl)
|
return isDeclSpecifierEquals(trailDecl, decl)
|
||||||
&& trailDecl.getKind() == decl.getKind();
|
&& trailDecl.getKind() == decl.getKind();
|
||||||
} else if (trailNode instanceof IASTCompositeTypeSpecifier) {
|
} else if (trailNode instanceof IASTCompositeTypeSpecifier) {
|
||||||
IASTCompositeTypeSpecifier trailDecl = (IASTCompositeTypeSpecifier) trailNode;
|
IASTCompositeTypeSpecifier trailDecl = (IASTCompositeTypeSpecifier) trailNode;
|
||||||
IASTCompositeTypeSpecifier decl = (IASTCompositeTypeSpecifier) node;
|
IASTCompositeTypeSpecifier decl = (IASTCompositeTypeSpecifier) node;
|
||||||
|
|
||||||
return isDeclSpecifierEquals(trailDecl, decl)
|
return isDeclSpecifierEquals(trailDecl, decl)
|
||||||
&& trailDecl.getKey() == decl.getKey();
|
&& trailDecl.getKey() == decl.getKey();
|
||||||
} else if (trailNode instanceof ICPPASTDeclSpecifier) {
|
} else if (trailNode instanceof ICPPASTDeclSpecifier) {
|
||||||
ICPPASTDeclSpecifier trailDecl = (ICPPASTDeclSpecifier) trailNode;
|
ICPPASTDeclSpecifier trailDecl = (ICPPASTDeclSpecifier) trailNode;
|
||||||
ICPPASTDeclSpecifier decl = (ICPPASTDeclSpecifier) node;
|
ICPPASTDeclSpecifier decl = (ICPPASTDeclSpecifier) node;
|
||||||
|
|
||||||
return isDeclSpecifierEquals(trailDecl, decl)
|
return isDeclSpecifierEquals(trailDecl, decl)
|
||||||
&& trailDecl.isExplicit() == decl.isExplicit()
|
&& trailDecl.isExplicit() == decl.isExplicit()
|
||||||
&& trailDecl.isFriend() == decl.isFriend()
|
&& trailDecl.isFriend() == decl.isFriend()
|
||||||
|
@ -173,13 +162,11 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
||||||
} else if (trailNode instanceof ICASTDeclSpecifier) {
|
} else if (trailNode instanceof ICASTDeclSpecifier) {
|
||||||
ICASTDeclSpecifier trailDecl = (ICASTDeclSpecifier) trailNode;
|
ICASTDeclSpecifier trailDecl = (ICASTDeclSpecifier) trailNode;
|
||||||
ICASTDeclSpecifier decl = (ICASTDeclSpecifier) node;
|
ICASTDeclSpecifier decl = (ICASTDeclSpecifier) node;
|
||||||
|
|
||||||
return isDeclSpecifierEquals(trailDecl, decl)
|
return isDeclSpecifierEquals(trailDecl, decl)
|
||||||
&& trailDecl.isRestrict() == decl.isRestrict();
|
&& trailDecl.isRestrict() == decl.isRestrict();
|
||||||
} else if (trailNode instanceof IASTDeclSpecifier) {
|
} else if (trailNode instanceof IASTDeclSpecifier) {
|
||||||
IASTDeclSpecifier trailDecl = (IASTDeclSpecifier) trailNode;
|
IASTDeclSpecifier trailDecl = (IASTDeclSpecifier) trailNode;
|
||||||
IASTDeclSpecifier decl = (IASTDeclSpecifier) node;
|
IASTDeclSpecifier decl = (IASTDeclSpecifier) node;
|
||||||
|
|
||||||
return isDeclSpecifierEquals(trailDecl, decl);
|
return isDeclSpecifierEquals(trailDecl, decl);
|
||||||
} else {
|
} else {
|
||||||
//is same
|
//is same
|
||||||
|
@ -191,12 +178,10 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
||||||
if (trailNode instanceof IASTStandardFunctionDeclarator) {
|
if (trailNode instanceof IASTStandardFunctionDeclarator) {
|
||||||
IASTStandardFunctionDeclarator trailFunc = (IASTStandardFunctionDeclarator) trailNode;
|
IASTStandardFunctionDeclarator trailFunc = (IASTStandardFunctionDeclarator) trailNode;
|
||||||
IASTStandardFunctionDeclarator func = (IASTStandardFunctionDeclarator) node;
|
IASTStandardFunctionDeclarator func = (IASTStandardFunctionDeclarator) node;
|
||||||
|
|
||||||
return trailFunc.takesVarArgs() == func.takesVarArgs();
|
return trailFunc.takesVarArgs() == func.takesVarArgs();
|
||||||
} else if (trailNode instanceof ICPPASTFunctionDeclarator) {
|
} else if (trailNode instanceof ICPPASTFunctionDeclarator) {
|
||||||
ICPPASTFunctionDeclarator trailFunc = (ICPPASTFunctionDeclarator) trailNode;
|
ICPPASTFunctionDeclarator trailFunc = (ICPPASTFunctionDeclarator) trailNode;
|
||||||
ICPPASTFunctionDeclarator func = (ICPPASTFunctionDeclarator) node;
|
ICPPASTFunctionDeclarator func = (ICPPASTFunctionDeclarator) node;
|
||||||
|
|
||||||
return trailFunc.isConst() == func.isConst()
|
return trailFunc.isConst() == func.isConst()
|
||||||
&& trailFunc.isPureVirtual() == func.isPureVirtual()
|
&& trailFunc.isPureVirtual() == func.isPureVirtual()
|
||||||
&& trailFunc.isVolatile() == func.isVolatile();
|
&& trailFunc.isVolatile() == func.isVolatile();
|
||||||
|
@ -210,32 +195,26 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
||||||
if (trailNode instanceof IASTASMDeclaration) {
|
if (trailNode instanceof IASTASMDeclaration) {
|
||||||
IASTASMDeclaration trailASMDecl = (IASTASMDeclaration) trailNode;
|
IASTASMDeclaration trailASMDecl = (IASTASMDeclaration) trailNode;
|
||||||
IASTASMDeclaration asmDecl = (IASTASMDeclaration) node;
|
IASTASMDeclaration asmDecl = (IASTASMDeclaration) node;
|
||||||
|
|
||||||
return trailASMDecl.getAssembly().equals(asmDecl.getAssembly());
|
return trailASMDecl.getAssembly().equals(asmDecl.getAssembly());
|
||||||
} else if (trailNode instanceof ICPPASTExplicitTemplateInstantiation) {
|
} else if (trailNode instanceof ICPPASTExplicitTemplateInstantiation) {
|
||||||
ICPPASTExplicitTemplateInstantiation trailTempl = (ICPPASTExplicitTemplateInstantiation) trailNode;
|
ICPPASTExplicitTemplateInstantiation trailTempl = (ICPPASTExplicitTemplateInstantiation) trailNode;
|
||||||
ICPPASTExplicitTemplateInstantiation templ = (ICPPASTExplicitTemplateInstantiation) node;
|
ICPPASTExplicitTemplateInstantiation templ = (ICPPASTExplicitTemplateInstantiation) node;
|
||||||
|
|
||||||
return trailTempl.getModifier() == templ.getModifier();
|
return trailTempl.getModifier() == templ.getModifier();
|
||||||
} else if (trailNode instanceof ICPPASTLinkageSpecification) {
|
} else if (trailNode instanceof ICPPASTLinkageSpecification) {
|
||||||
ICPPASTLinkageSpecification trailLink = (ICPPASTLinkageSpecification) trailNode;
|
ICPPASTLinkageSpecification trailLink = (ICPPASTLinkageSpecification) trailNode;
|
||||||
ICPPASTLinkageSpecification link = (ICPPASTLinkageSpecification) node;
|
ICPPASTLinkageSpecification link = (ICPPASTLinkageSpecification) node;
|
||||||
|
|
||||||
return trailLink.getLiteral().equals(link.getLiteral());
|
return trailLink.getLiteral().equals(link.getLiteral());
|
||||||
} else if (trailNode instanceof ICPPASTTemplateDeclaration) {
|
} else if (trailNode instanceof ICPPASTTemplateDeclaration) {
|
||||||
ICPPASTTemplateDeclaration trailTempl = (ICPPASTTemplateDeclaration) trailNode;
|
ICPPASTTemplateDeclaration trailTempl = (ICPPASTTemplateDeclaration) trailNode;
|
||||||
ICPPASTTemplateDeclaration templ = (ICPPASTTemplateDeclaration) node;
|
ICPPASTTemplateDeclaration templ = (ICPPASTTemplateDeclaration) node;
|
||||||
|
|
||||||
return trailTempl.isExported() == templ.isExported();
|
return trailTempl.isExported() == templ.isExported();
|
||||||
} else if (trailNode instanceof ICPPASTUsingDeclaration) {
|
} else if (trailNode instanceof ICPPASTUsingDeclaration) {
|
||||||
ICPPASTUsingDeclaration trailUsing = (ICPPASTUsingDeclaration) trailNode;
|
ICPPASTUsingDeclaration trailUsing = (ICPPASTUsingDeclaration) trailNode;
|
||||||
ICPPASTUsingDeclaration using = (ICPPASTUsingDeclaration) node;
|
ICPPASTUsingDeclaration using = (ICPPASTUsingDeclaration) node;
|
||||||
|
|
||||||
return trailUsing.isTypename() == using.isTypename();
|
return trailUsing.isTypename() == using.isTypename();
|
||||||
} else if (trailNode instanceof ICPPASTVisibilityLabel) {
|
} else if (trailNode instanceof ICPPASTVisibilityLabel) {
|
||||||
ICPPASTVisibilityLabel trailVisibility = (ICPPASTVisibilityLabel) trailNode;
|
ICPPASTVisibilityLabel trailVisibility = (ICPPASTVisibilityLabel) trailNode;
|
||||||
ICPPASTVisibilityLabel visibility = (ICPPASTVisibilityLabel) node;
|
ICPPASTVisibilityLabel visibility = (ICPPASTVisibilityLabel) node;
|
||||||
|
|
||||||
return trailVisibility.getVisibility() == visibility.getVisibility();
|
return trailVisibility.getVisibility() == visibility.getVisibility();
|
||||||
} else {
|
} else {
|
||||||
//same type
|
//same type
|
||||||
|
@ -247,7 +226,6 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
||||||
if (trailNode instanceof IASTPointer) {
|
if (trailNode instanceof IASTPointer) {
|
||||||
IASTPointer trailGPointer = (IASTPointer) trailNode;
|
IASTPointer trailGPointer = (IASTPointer) trailNode;
|
||||||
IASTPointer gPointer = (IASTPointer) node;
|
IASTPointer gPointer = (IASTPointer) node;
|
||||||
|
|
||||||
return trailGPointer.isConst() == gPointer.isConst()
|
return trailGPointer.isConst() == gPointer.isConst()
|
||||||
&& trailGPointer.isRestrict() == gPointer.isRestrict()
|
&& trailGPointer.isRestrict() == gPointer.isRestrict()
|
||||||
&& trailGPointer.isVolatile() == gPointer.isVolatile();
|
&& trailGPointer.isVolatile() == gPointer.isVolatile();
|
||||||
|
@ -261,7 +239,6 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
||||||
if (trailNode instanceof ICPPASTCatchHandler) {
|
if (trailNode instanceof ICPPASTCatchHandler) {
|
||||||
ICPPASTCatchHandler trailCatch = (ICPPASTCatchHandler) trailNode;
|
ICPPASTCatchHandler trailCatch = (ICPPASTCatchHandler) trailNode;
|
||||||
ICPPASTCatchHandler nodeCatch = (ICPPASTCatchHandler) node;
|
ICPPASTCatchHandler nodeCatch = (ICPPASTCatchHandler) node;
|
||||||
|
|
||||||
return trailCatch.isCatchAll() == nodeCatch.isCatchAll();
|
return trailCatch.isCatchAll() == nodeCatch.isCatchAll();
|
||||||
}
|
}
|
||||||
//same type
|
//same type
|
||||||
|
@ -272,48 +249,39 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
||||||
if (trailNode instanceof IASTBinaryExpression) {
|
if (trailNode instanceof IASTBinaryExpression) {
|
||||||
IASTBinaryExpression trailExpr = (IASTBinaryExpression) trailNode;
|
IASTBinaryExpression trailExpr = (IASTBinaryExpression) trailNode;
|
||||||
IASTBinaryExpression expr = (IASTBinaryExpression) node;
|
IASTBinaryExpression expr = (IASTBinaryExpression) node;
|
||||||
|
|
||||||
return trailExpr.getOperator() == expr.getOperator();
|
return trailExpr.getOperator() == expr.getOperator();
|
||||||
} else if (trailNode instanceof ICPPASTFieldReference) {
|
} else if (trailNode instanceof ICPPASTFieldReference) {
|
||||||
ICPPASTFieldReference trailFieldRef = (ICPPASTFieldReference) trailNode;
|
ICPPASTFieldReference trailFieldRef = (ICPPASTFieldReference) trailNode;
|
||||||
ICPPASTFieldReference fieldRef = (ICPPASTFieldReference) node;
|
ICPPASTFieldReference fieldRef = (ICPPASTFieldReference) node;
|
||||||
|
|
||||||
return trailFieldRef.isPointerDereference() == fieldRef.isPointerDereference()
|
return trailFieldRef.isPointerDereference() == fieldRef.isPointerDereference()
|
||||||
&& trailFieldRef.isTemplate() == fieldRef.isTemplate();
|
&& trailFieldRef.isTemplate() == fieldRef.isTemplate();
|
||||||
} else if (trailNode instanceof IASTFieldReference) {
|
} else if (trailNode instanceof IASTFieldReference) {
|
||||||
IASTFieldReference trailFieldRef = (IASTFieldReference) trailNode;
|
IASTFieldReference trailFieldRef = (IASTFieldReference) trailNode;
|
||||||
IASTFieldReference fieldRef = (IASTFieldReference) node;
|
IASTFieldReference fieldRef = (IASTFieldReference) node;
|
||||||
|
|
||||||
return trailFieldRef.isPointerDereference() == fieldRef.isPointerDereference();
|
return trailFieldRef.isPointerDereference() == fieldRef.isPointerDereference();
|
||||||
} else if (trailNode instanceof IASTLiteralExpression) {
|
} else if (trailNode instanceof IASTLiteralExpression) {
|
||||||
IASTLiteralExpression trailLiteral = (IASTLiteralExpression) trailNode;
|
IASTLiteralExpression trailLiteral = (IASTLiteralExpression) trailNode;
|
||||||
IASTLiteralExpression literal = (IASTLiteralExpression) node;
|
IASTLiteralExpression literal = (IASTLiteralExpression) node;
|
||||||
|
|
||||||
return trailLiteral.getKind() == literal.getKind() && trailLiteral.toString().equals(literal.toString());
|
return trailLiteral.getKind() == literal.getKind() && trailLiteral.toString().equals(literal.toString());
|
||||||
} else if (trailNode instanceof IASTUnaryExpression) {
|
} else if (trailNode instanceof IASTUnaryExpression) {
|
||||||
IASTUnaryExpression trailExpr = (IASTUnaryExpression) trailNode;
|
IASTUnaryExpression trailExpr = (IASTUnaryExpression) trailNode;
|
||||||
IASTUnaryExpression expr = (IASTUnaryExpression) node;
|
IASTUnaryExpression expr = (IASTUnaryExpression) node;
|
||||||
|
|
||||||
return trailExpr.getOperator() == expr.getOperator();
|
return trailExpr.getOperator() == expr.getOperator();
|
||||||
} else if (trailNode instanceof IASTTypeIdExpression) {
|
} else if (trailNode instanceof IASTTypeIdExpression) {
|
||||||
IASTTypeIdExpression trailIdExpr = (IASTTypeIdExpression) trailNode;
|
IASTTypeIdExpression trailIdExpr = (IASTTypeIdExpression) trailNode;
|
||||||
IASTTypeIdExpression idExpr = (IASTTypeIdExpression) node;
|
IASTTypeIdExpression idExpr = (IASTTypeIdExpression) node;
|
||||||
|
|
||||||
return trailIdExpr.getTypeId() == idExpr.getTypeId();
|
return trailIdExpr.getTypeId() == idExpr.getTypeId();
|
||||||
} else if (trailNode instanceof ICPPASTDeleteExpression) {
|
} else if (trailNode instanceof ICPPASTDeleteExpression) {
|
||||||
ICPPASTDeleteExpression trailDelete = (ICPPASTDeleteExpression) trailNode;
|
ICPPASTDeleteExpression trailDelete = (ICPPASTDeleteExpression) trailNode;
|
||||||
ICPPASTDeleteExpression delete = (ICPPASTDeleteExpression) node;
|
ICPPASTDeleteExpression delete = (ICPPASTDeleteExpression) node;
|
||||||
|
|
||||||
return trailDelete.isGlobal() == delete.isGlobal() && trailDelete.isVectored() == delete.isVectored();
|
return trailDelete.isGlobal() == delete.isGlobal() && trailDelete.isVectored() == delete.isVectored();
|
||||||
} else if (trailNode instanceof ICPPASTNewExpression) {
|
} else if (trailNode instanceof ICPPASTNewExpression) {
|
||||||
ICPPASTNewExpression trailNew = (ICPPASTNewExpression) trailNode;
|
ICPPASTNewExpression trailNew = (ICPPASTNewExpression) trailNode;
|
||||||
ICPPASTNewExpression nodeNew = (ICPPASTNewExpression) node;
|
ICPPASTNewExpression nodeNew = (ICPPASTNewExpression) node;
|
||||||
|
|
||||||
return trailNew.isGlobal() == nodeNew.isGlobal() && trailNew.isNewTypeId() == nodeNew.isNewTypeId();
|
return trailNew.isGlobal() == nodeNew.isGlobal() && trailNew.isNewTypeId() == nodeNew.isNewTypeId();
|
||||||
} else if (trailNode instanceof ICPPASTSimpleTypeConstructorExpression) {
|
} else if (trailNode instanceof ICPPASTSimpleTypeConstructorExpression) {
|
||||||
ICPPASTSimpleTypeConstructorExpression trailConsExpr = (ICPPASTSimpleTypeConstructorExpression) trailNode;
|
ICPPASTSimpleTypeConstructorExpression trailConsExpr = (ICPPASTSimpleTypeConstructorExpression) trailNode;
|
||||||
ICPPASTSimpleTypeConstructorExpression consExpr = (ICPPASTSimpleTypeConstructorExpression) node;
|
ICPPASTSimpleTypeConstructorExpression consExpr = (ICPPASTSimpleTypeConstructorExpression) node;
|
||||||
|
|
||||||
return isDeclSpecifierEquals(trailConsExpr.getDeclSpecifier(), consExpr.getDeclSpecifier());
|
return isDeclSpecifierEquals(trailConsExpr.getDeclSpecifier(), consExpr.getDeclSpecifier());
|
||||||
} else {
|
} else {
|
||||||
// same type
|
// same type
|
||||||
|
@ -336,11 +304,9 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
||||||
if (trailDeclSpeci instanceof ICPPASTDeclSpecifier) {
|
if (trailDeclSpeci instanceof ICPPASTDeclSpecifier) {
|
||||||
ICPPASTDeclSpecifier trailCppDecl= (ICPPASTDeclSpecifier) trailDeclSpeci;
|
ICPPASTDeclSpecifier trailCppDecl= (ICPPASTDeclSpecifier) trailDeclSpeci;
|
||||||
ICPPASTDeclSpecifier cppDecl= (ICPPASTDeclSpecifier) declSpeci;
|
ICPPASTDeclSpecifier cppDecl= (ICPPASTDeclSpecifier) declSpeci;
|
||||||
if (trailCppDecl.isExplicit() == cppDecl.isExplicit()
|
if (trailCppDecl.isExplicit() != cppDecl.isExplicit()
|
||||||
&& trailCppDecl.isFriend() == cppDecl.isFriend()
|
|| trailCppDecl.isFriend() != cppDecl.isFriend()
|
||||||
&& trailCppDecl.isVirtual() == cppDecl.isVirtual()) {
|
|| trailCppDecl.isVirtual() != cppDecl.isVirtual()) {
|
||||||
// ok
|
|
||||||
} else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -389,19 +355,16 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
||||||
for (int i = 0; i < realDecs.length; ++i) {
|
for (int i = 0; i < realDecs.length; ++i) {
|
||||||
IASTFileLocation rfl = realDecs[i].getFileLocation();
|
IASTFileLocation rfl = realDecs[i].getFileLocation();
|
||||||
IASTFileLocation nfl = nameDecs[i].getFileLocation();
|
IASTFileLocation nfl = nameDecs[i].getFileLocation();
|
||||||
if(rfl.getNodeOffset() == nfl.getNodeOffset() && rfl.getFileName().equals(nfl.getFileName())) {
|
if (rfl.getNodeOffset() != nfl.getNodeOffset() || !rfl.getFileName().equals(nfl.getFileName()))
|
||||||
continue;
|
|
||||||
}else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {}
|
} catch (InterruptedException e) {
|
||||||
catch (CoreException e) {}
|
} catch (CoreException e) {
|
||||||
finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -410,10 +373,9 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
||||||
if (oType == null || nType == null)
|
if (oType == null || nType == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(oType.isSameType(nType)) {
|
if (oType.isSameType(nType))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue