mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Cosmetics.
This commit is contained in:
parent
60214efa55
commit
0d4d66ec6e
12 changed files with 67 additions and 125 deletions
|
@ -63,13 +63,13 @@ public abstract class ChangeGeneratorTest extends BaseTestFramework {
|
||||||
assertTrue("The indexing operation of the test CProject has not finished jet. This should not happen...", joined);
|
assertTrue("The indexing operation of the test CProject has not finished jet. This should not happen...", joined);
|
||||||
|
|
||||||
IASTTranslationUnit unit = CoreModelUtil.findTranslationUnit(testFile).getAST();
|
IASTTranslationUnit unit = CoreModelUtil.findTranslationUnit(testFile).getAST();
|
||||||
final ChangeGenerator changegenartor = new ChangeGenerator(modStore,
|
final ChangeGenerator changeGenerator = new ChangeGenerator(modStore,
|
||||||
ASTCommenter.getCommentedNodeMap(unit));
|
ASTCommenter.getCommentedNodeMap(unit));
|
||||||
unit.accept(visitor);
|
unit.accept(visitor);
|
||||||
|
|
||||||
changegenartor.generateChange(unit);
|
changeGenerator.generateChange(unit);
|
||||||
Document doc = new Document(source);
|
Document doc = new Document(source);
|
||||||
for (Change curChange : ((CompositeChange) changegenartor.getChange()).getChildren()) {
|
for (Change curChange : ((CompositeChange) changeGenerator.getChange()).getChildren()) {
|
||||||
if (curChange instanceof TextFileChange) {
|
if (curChange instanceof TextFileChange) {
|
||||||
TextFileChange textChange = (TextFileChange) curChange;
|
TextFileChange textChange = (TextFileChange) curChange;
|
||||||
textChange.getEdit().apply(doc);
|
textChange.getEdit().apply(doc);
|
||||||
|
|
|
@ -24,7 +24,7 @@ public interface IName {
|
||||||
/**
|
/**
|
||||||
* @since 5.2
|
* @since 5.2
|
||||||
*/
|
*/
|
||||||
IName[] EMPTY_ARRAY= {};
|
public static final IName[] EMPTY_ARRAY= {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name without qualification and without template arguments.
|
* Returns the name without qualification and without template arguments.
|
||||||
|
|
|
@ -26,7 +26,7 @@ public interface IASTName extends IASTNode, IName {
|
||||||
/**
|
/**
|
||||||
* Constant sentinel.
|
* Constant sentinel.
|
||||||
*/
|
*/
|
||||||
public static final IASTName[] EMPTY_NAME_ARRAY = new IASTName[0];
|
public static final IASTName[] EMPTY_NAME_ARRAY = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name including qualification and template arguments.
|
* Returns the name including qualification and template arguments.
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.eclipse.cdt.core.parser.IToken;
|
||||||
* @noextend This interface is not intended to be extended by clients.
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
*/
|
*/
|
||||||
public interface IASTNode {
|
public interface IASTNode {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
|
@ -42,7 +41,7 @@ public interface IASTNode {
|
||||||
withLocations
|
withLocations
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final IASTNode[] EMPTY_NODE_ARRAY = new IASTNode[0];
|
public static final IASTNode[] EMPTY_NODE_ARRAY = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the translation unit (master) node that is the ancestor of all nodes
|
* Get the translation unit (master) node that is the ancestor of all nodes
|
||||||
|
|
|
@ -1207,14 +1207,15 @@ public class CVisitor extends ASTQueries {
|
||||||
node = node.getParent();
|
node = node.getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node instanceof IASTParameterDeclaration)
|
if (node instanceof IASTSimpleDeclaration) {
|
||||||
declSpec = ((IASTParameterDeclaration) node).getDeclSpecifier();
|
|
||||||
else if (node instanceof IASTSimpleDeclaration)
|
|
||||||
declSpec = ((IASTSimpleDeclaration) node).getDeclSpecifier();
|
declSpec = ((IASTSimpleDeclaration) node).getDeclSpecifier();
|
||||||
else if (node instanceof IASTFunctionDefinition)
|
} else if (node instanceof IASTParameterDeclaration) {
|
||||||
|
declSpec = ((IASTParameterDeclaration) node).getDeclSpecifier();
|
||||||
|
} else if (node instanceof IASTFunctionDefinition) {
|
||||||
declSpec = ((IASTFunctionDefinition) node).getDeclSpecifier();
|
declSpec = ((IASTFunctionDefinition) node).getDeclSpecifier();
|
||||||
else if (node instanceof IASTTypeId)
|
} else if (node instanceof IASTTypeId) {
|
||||||
declSpec = ((IASTTypeId) node).getDeclSpecifier();
|
declSpec = ((IASTTypeId) node).getDeclSpecifier();
|
||||||
|
}
|
||||||
|
|
||||||
boolean isParameter = (node instanceof IASTParameterDeclaration || node.getParent() instanceof ICASTKnRFunctionDeclarator);
|
boolean isParameter = (node instanceof IASTParameterDeclaration || node.getParent() instanceof ICASTKnRFunctionDeclarator);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software (IFS)- initial API and implementation
|
* Institute for Software (IFS)- initial API and implementation
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.refactoring;
|
package org.eclipse.cdt.internal.ui.refactoring;
|
||||||
|
|
||||||
|
@ -18,10 +18,8 @@ import org.eclipse.ltk.core.refactoring.RefactoringChangeDescriptor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emanuel Graf IFS
|
* @author Emanuel Graf IFS
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class CCompositeChange extends CompositeChange {
|
public class CCompositeChange extends CompositeChange {
|
||||||
|
|
||||||
private RefactoringChangeDescriptor desc;
|
private RefactoringChangeDescriptor desc;
|
||||||
|
|
||||||
public CCompositeChange(String name, Change[] children) {
|
public CCompositeChange(String name, Change[] children) {
|
||||||
|
@ -38,12 +36,9 @@ public class CCompositeChange extends CompositeChange {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChangeDescriptor getDescriptor() {
|
public ChangeDescriptor getDescriptor() {
|
||||||
if(desc == null) {
|
if (desc != null) {
|
||||||
return super.getDescriptor();
|
|
||||||
}else {
|
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
return super.getDescriptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,14 +22,12 @@ import org.eclipse.swt.widgets.Group;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
|
import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 3 radio buttons in a group, labeled according to the corresponding visibility name (public, private, protected).
|
* Three radio buttons in a group, labeled according to the corresponding visibility name
|
||||||
|
* (public, private, protected).
|
||||||
*
|
*
|
||||||
* @author Thomas Corbat
|
* @author Thomas Corbat
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class VisibilitySelectionPanel extends Composite {
|
public class VisibilitySelectionPanel extends Composite {
|
||||||
|
|
||||||
|
|
||||||
private Button publicAccessRadioButton;
|
private Button publicAccessRadioButton;
|
||||||
private Button protectedAccessRadioButton;
|
private Button protectedAccessRadioButton;
|
||||||
private Button privateAccessRadioButton;
|
private Button privateAccessRadioButton;
|
||||||
|
@ -46,12 +44,10 @@ public class VisibilitySelectionPanel extends Composite {
|
||||||
|
|
||||||
createAccessModifierComposite(this);
|
createAccessModifierComposite(this);
|
||||||
setSelected(defaultVisibility);
|
setSelected(defaultVisibility);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createAccessModifierComposite(Composite control) {
|
private void createAccessModifierComposite(Composite control) {
|
||||||
|
accessModifierGroup = new Group(this, SWT.SHADOW_NONE);
|
||||||
accessModifierGroup = new Group(this, SWT.SHADOW_NONE );
|
|
||||||
RowLayout groupLayout = new RowLayout(SWT.HORIZONTAL);
|
RowLayout groupLayout = new RowLayout(SWT.HORIZONTAL);
|
||||||
groupLayout.fill = true;
|
groupLayout.fill = true;
|
||||||
accessModifierGroup.setLayout(groupLayout);
|
accessModifierGroup.setLayout(groupLayout);
|
||||||
|
@ -65,11 +61,10 @@ public class VisibilitySelectionPanel extends Composite {
|
||||||
|
|
||||||
privateAccessRadioButton = new Button(accessModifierGroup, SWT.RADIO | SWT.LEFT);
|
privateAccessRadioButton = new Button(accessModifierGroup, SWT.RADIO | SWT.LEFT);
|
||||||
privateAccessRadioButton.setText(VisibilityEnum.v_private.toString());
|
privateAccessRadioButton.setText(VisibilityEnum.v_private.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSelected(VisibilityEnum defaultVisibility) {
|
private void setSelected(VisibilityEnum defaultVisibility) {
|
||||||
switch (defaultVisibility){
|
switch (defaultVisibility) {
|
||||||
case v_public:
|
case v_public:
|
||||||
publicAccessRadioButton.setSelection(true);
|
publicAccessRadioButton.setSelection(true);
|
||||||
break;
|
break;
|
||||||
|
@ -79,7 +74,7 @@ public class VisibilitySelectionPanel extends Composite {
|
||||||
case v_private:
|
case v_private:
|
||||||
privateAccessRadioButton.setSelection(true);
|
privateAccessRadioButton.setSelection(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Group getGroup() {
|
public Group getGroup() {
|
||||||
|
@ -87,12 +82,11 @@ public class VisibilitySelectionPanel extends Composite {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setEnabled(boolean enabled){
|
public void setEnabled(boolean enabled) {
|
||||||
accessModifierGroup.setEnabled(enabled);
|
accessModifierGroup.setEnabled(enabled);
|
||||||
publicAccessRadioButton.setEnabled(enabled);
|
publicAccessRadioButton.setEnabled(enabled);
|
||||||
protectedAccessRadioButton.setEnabled(enabled);
|
protectedAccessRadioButton.setEnabled(enabled);
|
||||||
privateAccessRadioButton.setEnabled(enabled);
|
privateAccessRadioButton.setEnabled(enabled);
|
||||||
super.setEnabled(enabled);
|
super.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
|
package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
|
||||||
|
|
||||||
|
@ -21,16 +21,15 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.NameHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Lukas Felber
|
* @author Lukas Felber
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ParameterInfo {
|
public class ParameterInfo {
|
||||||
private IASTParameterDeclaration parameter;
|
private IASTParameterDeclaration parameter;
|
||||||
private boolean hasNewName;
|
private boolean hasNewName;
|
||||||
private String parameterName;
|
private String parameterName;
|
||||||
|
|
||||||
public ParameterInfo(IASTParameterDeclaration parameter, String parameterName, boolean HasNewName) {
|
public ParameterInfo(IASTParameterDeclaration parameter, String parameterName, boolean hasNewName) {
|
||||||
this.parameter = parameter;
|
this.parameter = parameter;
|
||||||
this.hasNewName = HasNewName;
|
this.hasNewName = hasNewName;
|
||||||
this.parameterName = parameterName;
|
this.parameterName = parameterName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.refactoring.utils;
|
package org.eclipse.cdt.internal.ui.refactoring.utils;
|
||||||
|
|
||||||
|
@ -78,7 +78,8 @@ public class ASTHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean samePointers(IASTPointerOperator[] pointerOperators1, IASTPointerOperator[] pointerOperators2, TrailNodeEqualityChecker checker) {
|
public static boolean samePointers(IASTPointerOperator[] pointerOperators1,
|
||||||
|
IASTPointerOperator[] pointerOperators2, TrailNodeEqualityChecker checker) {
|
||||||
if (pointerOperators2.length == pointerOperators1.length) {
|
if (pointerOperators2.length == pointerOperators1.length) {
|
||||||
for (int i = 0; i < pointerOperators2.length; i++) {
|
for (int i = 0; i < pointerOperators2.length; i++) {
|
||||||
IASTPointerOperator operator1 = pointerOperators1[i];
|
IASTPointerOperator operator1 = pointerOperators1[i];
|
||||||
|
@ -110,7 +111,7 @@ public class ASTHelper {
|
||||||
for (IASTNode aktNode = node; aktNode != null; aktNode = aktNode.getParent()) {
|
for (IASTNode aktNode = node; aktNode != null; aktNode = aktNode.getParent()) {
|
||||||
if (aktNode instanceof ICPPASTNamespaceDefinition) {
|
if (aktNode instanceof ICPPASTNamespaceDefinition) {
|
||||||
namespaces.add(0, (ICPPASTNamespaceDefinition) aktNode);
|
namespaces.add(0, (ICPPASTNamespaceDefinition) aktNode);
|
||||||
} else if(aktNode instanceof ICPPASTQualifiedName) {
|
} else if (aktNode instanceof ICPPASTQualifiedName) {
|
||||||
namespaces.addAll(getNamespaces((ICPPASTQualifiedName) aktNode));
|
namespaces.addAll(getNamespaces((ICPPASTQualifiedName) aktNode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,10 +120,10 @@ public class ASTHelper {
|
||||||
|
|
||||||
public static ArrayList<ICPPASTNamespaceDefinition> getNamespaces(ICPPASTQualifiedName qualifiedName) {
|
public static ArrayList<ICPPASTNamespaceDefinition> getNamespaces(ICPPASTQualifiedName qualifiedName) {
|
||||||
ArrayList<ICPPASTNamespaceDefinition> namespaces = new ArrayList<ICPPASTNamespaceDefinition>();
|
ArrayList<ICPPASTNamespaceDefinition> namespaces = new ArrayList<ICPPASTNamespaceDefinition>();
|
||||||
for(IASTName aktQualifiedPartName : qualifiedName.getNames()) {
|
for (IASTName aktQualifiedPartName : qualifiedName.getNames()) {
|
||||||
IBinding binding = aktQualifiedPartName.resolveBinding();
|
IBinding binding = aktQualifiedPartName.resolveBinding();
|
||||||
for(IASTName aktResolvedName : qualifiedName.getTranslationUnit().getDefinitionsInAST(binding)) {
|
for (IASTName aktResolvedName : qualifiedName.getTranslationUnit().getDefinitionsInAST(binding)) {
|
||||||
if(aktResolvedName.getParent() instanceof ICPPASTNamespaceDefinition) {
|
if (aktResolvedName.getParent() instanceof ICPPASTNamespaceDefinition) {
|
||||||
namespaces.add((ICPPASTNamespaceDefinition) aktResolvedName.getParent());
|
namespaces.add((ICPPASTNamespaceDefinition) aktResolvedName.getParent());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -146,10 +147,11 @@ public class ASTHelper {
|
||||||
return specifiers;
|
return specifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<IASTPreprocessorStatement> getAllInFilePreprocessorStatements(IASTTranslationUnit unit, String aktFileName) {
|
public static Collection<IASTPreprocessorStatement> getAllInFilePreprocessorStatements(
|
||||||
|
IASTTranslationUnit unit, String aktFileName) {
|
||||||
Collection<IASTPreprocessorStatement> statements = new ArrayList<IASTPreprocessorStatement>();
|
Collection<IASTPreprocessorStatement> statements = new ArrayList<IASTPreprocessorStatement>();
|
||||||
for(IASTPreprocessorStatement aktStatement : unit.getAllPreprocessorStatements()) {
|
for (IASTPreprocessorStatement aktStatement : unit.getAllPreprocessorStatements()) {
|
||||||
if(aktStatement.getFileLocation() == null) {
|
if (aktStatement.getFileLocation() == null) {
|
||||||
continue;
|
continue;
|
||||||
} else if (aktStatement.getFileLocation().getFileName().equals(aktFileName)) {
|
} else if (aktStatement.getFileLocation().getFileName().equals(aktFileName)) {
|
||||||
statements.add(aktStatement);
|
statements.add(aktStatement);
|
||||||
|
@ -160,10 +162,10 @@ public class ASTHelper {
|
||||||
|
|
||||||
public static Collection<IASTDeclaration> getAllInFileDeclarations(IASTTranslationUnit unit, String aktFileName) {
|
public static Collection<IASTDeclaration> getAllInFileDeclarations(IASTTranslationUnit unit, String aktFileName) {
|
||||||
Collection<IASTDeclaration> decls = new ArrayList<IASTDeclaration>();
|
Collection<IASTDeclaration> decls = new ArrayList<IASTDeclaration>();
|
||||||
for(IASTDeclaration aktDecl: unit.getDeclarations()) {
|
for (IASTDeclaration aktDecl: unit.getDeclarations()) {
|
||||||
if(aktDecl.getFileLocation() == null) {
|
if (aktDecl.getFileLocation() == null) {
|
||||||
continue;
|
continue;
|
||||||
} else if(aktDecl.getFileLocation().getFileName().equals(aktFileName)) {
|
} else if (aktDecl.getFileLocation().getFileName().equals(aktFileName)) {
|
||||||
decls.add(aktDecl);
|
decls.add(aktDecl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,11 +174,11 @@ public class ASTHelper {
|
||||||
|
|
||||||
public static ICPPASTUsingDirective getActiveUsingDirecitveForNode(IASTNode node, IASTTranslationUnit unit) {
|
public static ICPPASTUsingDirective getActiveUsingDirecitveForNode(IASTNode node, IASTTranslationUnit unit) {
|
||||||
ICPPASTUsingDirective activeDirective = null;
|
ICPPASTUsingDirective activeDirective = null;
|
||||||
for(IASTDeclaration aktDeclaration : getAllInFileDeclarations(unit, node.getFileLocation().getFileName())) {
|
for (IASTDeclaration aktDeclaration : getAllInFileDeclarations(unit, node.getFileLocation().getFileName())) {
|
||||||
if(aktDeclaration.getFileLocation().getNodeOffset() >= node.getFileLocation().getNodeOffset()) {
|
if (aktDeclaration.getFileLocation().getNodeOffset() >= node.getFileLocation().getNodeOffset()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(aktDeclaration instanceof ICPPASTUsingDirective) {
|
if (aktDeclaration instanceof ICPPASTUsingDirective) {
|
||||||
activeDirective = (ICPPASTUsingDirective) aktDeclaration;
|
activeDirective = (ICPPASTUsingDirective) aktDeclaration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,7 +187,7 @@ public class ASTHelper {
|
||||||
|
|
||||||
public static Collection<ICPPASTUsingDeclaration> getUsingDeclarations(IASTTranslationUnit unit) {
|
public static Collection<ICPPASTUsingDeclaration> getUsingDeclarations(IASTTranslationUnit unit) {
|
||||||
Collection<ICPPASTUsingDeclaration> usingDecls = new ArrayList<ICPPASTUsingDeclaration>();
|
Collection<ICPPASTUsingDeclaration> usingDecls = new ArrayList<ICPPASTUsingDeclaration>();
|
||||||
for(IASTDeclaration aktDecl : unit.getDeclarations()) {
|
for (IASTDeclaration aktDecl : unit.getDeclarations()) {
|
||||||
if (aktDecl instanceof ICPPASTUsingDeclaration) {
|
if (aktDecl instanceof ICPPASTUsingDeclaration) {
|
||||||
usingDecls.add((ICPPASTUsingDeclaration) aktDecl);
|
usingDecls.add((ICPPASTUsingDeclaration) aktDecl);
|
||||||
}
|
}
|
||||||
|
@ -193,33 +195,10 @@ public class ASTHelper {
|
||||||
return usingDecls;
|
return usingDecls;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isClassDefinitionName(IASTName name) {
|
|
||||||
try {
|
|
||||||
if(!(name.getParent().getParent().getParent() instanceof IASTFunctionDefinition)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ICPPASTQualifiedName qName = (ICPPASTQualifiedName) name.getParent();
|
|
||||||
IASTName secondLastName = qName.getNames()[qName.getNames().length-2];
|
|
||||||
if(!(name.equals(secondLastName))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
IBinding binding = name.resolveBinding();
|
|
||||||
for(IASTName aktName : name.getTranslationUnit().getDeclarationsInAST(binding)) {
|
|
||||||
if(!isClassDeclarationName(aktName)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IASTCompositeTypeSpecifier getCompositeTypeSpecifierForName(IASTName name) {
|
public static IASTCompositeTypeSpecifier getCompositeTypeSpecifierForName(IASTName name) {
|
||||||
IBinding binding = name.resolveBinding();
|
IBinding binding = name.resolveBinding();
|
||||||
for(IASTName aktName : name.getTranslationUnit().getDefinitionsInAST(binding)) {
|
for (IASTName aktName : name.getTranslationUnit().getDefinitionsInAST(binding)) {
|
||||||
if(aktName.getParent() instanceof IASTCompositeTypeSpecifier) {
|
if (aktName.getParent() instanceof IASTCompositeTypeSpecifier) {
|
||||||
return (IASTCompositeTypeSpecifier) aktName.getParent();
|
return (IASTCompositeTypeSpecifier) aktName.getParent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,10 +207,10 @@ public class ASTHelper {
|
||||||
|
|
||||||
public static Collection<IASTFunctionDeclarator> getFunctionDeclaratorsForClass(IASTCompositeTypeSpecifier klass) {
|
public static Collection<IASTFunctionDeclarator> getFunctionDeclaratorsForClass(IASTCompositeTypeSpecifier klass) {
|
||||||
Collection<IASTFunctionDeclarator> declarators = new ArrayList<IASTFunctionDeclarator>();
|
Collection<IASTFunctionDeclarator> declarators = new ArrayList<IASTFunctionDeclarator>();
|
||||||
for(IASTDeclaration aktDeclaration : klass.getMembers()) {
|
for (IASTDeclaration aktDeclaration : klass.getMembers()) {
|
||||||
if(aktDeclaration instanceof IASTSimpleDeclaration) {
|
if (aktDeclaration instanceof IASTSimpleDeclaration) {
|
||||||
for(IASTDeclarator aktDeclarator : ((IASTSimpleDeclaration) aktDeclaration).getDeclarators()) {
|
for (IASTDeclarator aktDeclarator : ((IASTSimpleDeclaration) aktDeclaration).getDeclarators()) {
|
||||||
if(aktDeclarator instanceof IASTFunctionDeclarator) {
|
if (aktDeclarator instanceof IASTFunctionDeclarator) {
|
||||||
declarators.add((IASTFunctionDeclarator) aktDeclarator);
|
declarators.add((IASTFunctionDeclarator) aktDeclarator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,13 +218,13 @@ public class ASTHelper {
|
||||||
}
|
}
|
||||||
return declarators;
|
return declarators;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<IASTFunctionDefinition> getFunctionDefinitionsForClass(IASTCompositeTypeSpecifier klass) {
|
public static Collection<IASTFunctionDefinition> getFunctionDefinitionsForClass(IASTCompositeTypeSpecifier klass) {
|
||||||
Collection<IASTFunctionDefinition> definitions = new ArrayList<IASTFunctionDefinition>();
|
Collection<IASTFunctionDefinition> definitions = new ArrayList<IASTFunctionDefinition>();
|
||||||
for(IASTFunctionDeclarator aktDeclarator : getFunctionDeclaratorsForClass(klass)) {
|
for (IASTFunctionDeclarator aktDeclarator : getFunctionDeclaratorsForClass(klass)) {
|
||||||
IBinding binding = aktDeclarator.getName().resolveBinding();
|
IBinding binding = aktDeclarator.getName().resolveBinding();
|
||||||
for(IASTName aktName : aktDeclarator.getTranslationUnit().getDefinitionsInAST(binding)) {
|
for (IASTName aktName : aktDeclarator.getTranslationUnit().getDefinitionsInAST(binding)) {
|
||||||
if(aktName.getParent().getParent().getParent() instanceof IASTFunctionDefinition) {
|
if (aktName.getParent().getParent().getParent() instanceof IASTFunctionDefinition) {
|
||||||
definitions.add((IASTFunctionDefinition) aktName.getParent().getParent().getParent());
|
definitions.add((IASTFunctionDefinition) aktName.getParent().getParent().getParent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,15 +10,14 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.wizards.classwizard;
|
package org.eclipse.cdt.internal.ui.wizards.classwizard;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
|
||||||
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
|
|
||||||
import org.eclipse.jface.viewers.ILabelProviderListener;
|
import org.eclipse.jface.viewers.ILabelProviderListener;
|
||||||
import org.eclipse.jface.viewers.ITableLabelProvider;
|
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
|
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
|
||||||
|
|
||||||
public final class BaseClassesLabelProvider implements ITableLabelProvider {
|
public final class BaseClassesLabelProvider implements ITableLabelProvider {
|
||||||
|
|
||||||
private static final String YES_VALUE = NewClassWizardMessages.BaseClassesLabelProvider_boolean_yes_label;
|
private static final String YES_VALUE = NewClassWizardMessages.BaseClassesLabelProvider_boolean_yes_label;
|
||||||
private static final String NO_VALUE = NewClassWizardMessages.BaseClassesLabelProvider_boolean_no_label;
|
private static final String NO_VALUE = NewClassWizardMessages.BaseClassesLabelProvider_boolean_no_label;
|
||||||
private static final String ACCESS_PUBLIC = NewClassWizardMessages.BaseClassesLabelProvider_access_public_label;
|
private static final String ACCESS_PUBLIC = NewClassWizardMessages.BaseClassesLabelProvider_access_public_label;
|
||||||
|
@ -34,7 +33,7 @@ public final class BaseClassesLabelProvider implements ITableLabelProvider {
|
||||||
return ACCESS_PRIVATE;
|
return ACCESS_PRIVATE;
|
||||||
if (access == ASTAccessVisibility.PROTECTED)
|
if (access == ASTAccessVisibility.PROTECTED)
|
||||||
return ACCESS_PROTECTED;
|
return ACCESS_PROTECTED;
|
||||||
return ACCESS_PUBLIC;
|
return ACCESS_PUBLIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TypeInfoLabelProvider fTypeInfoLabelProvider = new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_FULLY_QUALIFIED);
|
private static TypeInfoLabelProvider fTypeInfoLabelProvider = new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_FULLY_QUALIFIED);
|
||||||
|
@ -59,42 +58,30 @@ public final class BaseClassesLabelProvider implements ITableLabelProvider {
|
||||||
IBaseClassInfo info = (IBaseClassInfo) element;
|
IBaseClassInfo info = (IBaseClassInfo) element;
|
||||||
|
|
||||||
switch (columnIndex) {
|
switch (columnIndex) {
|
||||||
case 0:
|
case 0:
|
||||||
return fTypeInfoLabelProvider.getText(info.getType());
|
return fTypeInfoLabelProvider.getText(info.getType());
|
||||||
case 1:
|
case 1:
|
||||||
return getAccessText(info.getAccess());
|
return getAccessText(info.getAccess());
|
||||||
case 2:
|
case 2:
|
||||||
return getYesNoText(info.isVirtual());
|
return getYesNoText(info.isVirtual());
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IBaseLabelProvider#addListener(ILabelProviderListener)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void addListener(ILabelProviderListener listener) {
|
public void addListener(ILabelProviderListener listener) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IBaseLabelProvider#dispose()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IBaseLabelProvider#isLabelProperty(Object, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLabelProperty(Object element, String property) {
|
public boolean isLabelProperty(Object element, String property) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IBaseLabelProvider#removeListener(ILabelProviderListener)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void removeListener(ILabelProviderListener listener) {
|
public void removeListener(ILabelProviderListener listener) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
|
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
|
||||||
|
|
||||||
public class MethodStubsListDialogField extends CheckedListDialogField<IMethodStub> {
|
public class MethodStubsListDialogField extends CheckedListDialogField<IMethodStub> {
|
||||||
|
|
||||||
// column properties
|
// column properties
|
||||||
private static final String CP_NAME = "name"; //$NON-NLS-1$
|
private static final String CP_NAME = "name"; //$NON-NLS-1$
|
||||||
private static final String CP_ACCESS = "access"; //$NON-NLS-1$
|
private static final String CP_ACCESS = "access"; //$NON-NLS-1$
|
||||||
|
@ -154,7 +153,7 @@ public class MethodStubsListDialogField extends CheckedListDialogField<IMethodSt
|
||||||
new AccessibleAdapter() {
|
new AccessibleAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void getName(AccessibleEvent e) {
|
public void getName(AccessibleEvent e) {
|
||||||
e.result = NewClassWizardMessages.NewClassCreationWizardPage_methodStubs_label;
|
e.result = NewClassWizardMessages.NewClassCreationWizardPage_methodStubs_label;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -64,11 +64,7 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
|
||||||
Assert.isTrue(uncheckButtonIndex < fButtonLabels.length);
|
Assert.isTrue(uncheckButtonIndex < fButtonLabels.length);
|
||||||
fUncheckAllButtonIndex= uncheckButtonIndex;
|
fUncheckAllButtonIndex= uncheckButtonIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see ListDialogField#createTableViewer
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected TableViewer createTableViewer(Composite parent) {
|
protected TableViewer createTableViewer(Composite parent) {
|
||||||
Table table= new Table(parent, SWT.CHECK + getListStyle());
|
Table table= new Table(parent, SWT.CHECK + getListStyle());
|
||||||
|
@ -81,11 +77,7 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
|
||||||
});
|
});
|
||||||
return tableViewer;
|
return tableViewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see ListDialogField#getListControl
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Control getListControl(Composite parent) {
|
public Control getListControl(Composite parent) {
|
||||||
Control control= super.getListControl(parent);
|
Control control= super.getListControl(parent);
|
||||||
|
@ -110,7 +102,7 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkStateChanged() {
|
private void checkStateChanged() {
|
||||||
//call super and do not update check model
|
// Call super and do not update check model
|
||||||
super.dialogFieldChanged();
|
super.dialogFieldChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +158,7 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
|
||||||
fCheckElements.remove(object);
|
fCheckElements.remove(object);
|
||||||
}
|
}
|
||||||
if (fTable != null) {
|
if (fTable != null) {
|
||||||
((CheckboxTableViewer)fTable).setChecked(object, state);
|
((CheckboxTableViewer) fTable).setChecked(object, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,9 +188,6 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
|
||||||
checkStateChanged();
|
checkStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField#replaceElement(java.lang.Object, java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void replaceElement(T oldElement, T newElement) throws IllegalArgumentException {
|
public void replaceElement(T oldElement, T newElement) throws IllegalArgumentException {
|
||||||
boolean wasChecked= isChecked(oldElement);
|
boolean wasChecked= isChecked(oldElement);
|
||||||
|
|
Loading…
Add table
Reference in a new issue