mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Merge remote branch 'cdt/master' into sd90
This commit is contained in:
commit
6b8862e5c0
106 changed files with 3513 additions and 2796 deletions
|
@ -11,6 +11,7 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>org.eclipse.cdt.gnu.build-feature</artifactId>
|
<groupId>org.eclipse.cdt.features</groupId>
|
||||||
|
<artifactId>org.eclipse.cdt.gnu.build</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>org.eclipse.cdt.gnu.build.source-feature</artifactId>
|
<groupId>org.eclipse.cdt.features</groupId>
|
||||||
|
<artifactId>org.eclipse.cdt.gnu.build.source</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.internal.core.resources.ResourceLookup;
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
||||||
|
import org.eclipse.cdt.utils.EFSExtensionManager;
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -220,7 +221,7 @@ public class ScannerInfoConsoleParserUtility extends AbstractGCCBOPConsoleParser
|
||||||
// appending fileName to cwd should yield file path
|
// appending fileName to cwd should yield file path
|
||||||
filePath = cwd.append(fileName);
|
filePath = cwd.append(fileName);
|
||||||
}
|
}
|
||||||
if (!filePath.toString().equalsIgnoreCase(file.getLocation().toString())) {
|
if (!filePath.toString().equalsIgnoreCase(EFSExtensionManager.getDefault().getPathFromURI(file.getLocationURI()))) {
|
||||||
// must be the cwd is wrong
|
// must be the cwd is wrong
|
||||||
// check if file name starts with ".."
|
// check if file name starts with ".."
|
||||||
if (fileName.startsWith("..")) { //$NON-NLS-1$
|
if (fileName.startsWith("..")) { //$NON-NLS-1$
|
||||||
|
@ -237,7 +238,7 @@ public class ScannerInfoConsoleParserUtility extends AbstractGCCBOPConsoleParser
|
||||||
tPath = tPath.removeFirstSegments(1);
|
tPath = tPath.removeFirstSegments(1);
|
||||||
}
|
}
|
||||||
// get the file path from the file
|
// get the file path from the file
|
||||||
filePath = file.getLocation();
|
filePath = new Path(EFSExtensionManager.getDefault().getPathFromURI(file.getLocationURI()));
|
||||||
IPath lastFileSegment = filePath.removeFirstSegments(filePath.segmentCount() - tPath.segmentCount());
|
IPath lastFileSegment = filePath.removeFirstSegments(filePath.segmentCount() - tPath.segmentCount());
|
||||||
if (lastFileSegment.matchingFirstSegments(tPath) == tPath.segmentCount()) {
|
if (lastFileSegment.matchingFirstSegments(tPath) == tPath.segmentCount()) {
|
||||||
cwd = filePath.removeLastSegments(tPath.segmentCount());
|
cwd = filePath.removeLastSegments(tPath.segmentCount());
|
||||||
|
|
|
@ -12,7 +12,8 @@ Require-Bundle: org.eclipse.ui,
|
||||||
org.eclipse.cdt.core,
|
org.eclipse.cdt.core,
|
||||||
org.eclipse.cdt.codan.core.cxx,
|
org.eclipse.cdt.codan.core.cxx,
|
||||||
org.eclipse.cdt.codan.ui.cxx,
|
org.eclipse.cdt.codan.ui.cxx,
|
||||||
org.eclipse.cdt.codan.core
|
org.eclipse.cdt.codan.core,
|
||||||
|
org.eclipse.cdt.codan.checkers
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||||
Bundle-Vendor: %Bundle-Vendor
|
Bundle-Vendor: %Bundle-Vendor
|
||||||
|
|
|
@ -37,6 +37,15 @@
|
||||||
class="org.eclipse.cdt.codan.internal.checkers.ui.quickfix.QuickFixCreateParameter"
|
class="org.eclipse.cdt.codan.internal.checkers.ui.quickfix.QuickFixCreateParameter"
|
||||||
problemId="org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem">
|
problemId="org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem">
|
||||||
</resolution>
|
</resolution>
|
||||||
|
<resolution
|
||||||
|
class="org.eclipse.cdt.codan.internal.checkers.ui.quickfix.CaseBreakQuickFixBreak"
|
||||||
|
problemId="org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem">
|
||||||
|
</resolution>
|
||||||
|
<resolution
|
||||||
|
class="org.eclipse.cdt.codan.internal.checkers.ui.quickfix.CaseBreakQuickFixComment"
|
||||||
|
problemId="org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem">
|
||||||
|
</resolution>
|
||||||
|
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -0,0 +1,112 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2011 Gil Barash
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Gil Barash - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.codan.internal.checkers.ui.quickfix;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.codan.core.cxx.CxxAstUtils;
|
||||||
|
import org.eclipse.cdt.codan.internal.checkers.ui.CheckersUiActivator;
|
||||||
|
import org.eclipse.cdt.codan.ui.AbstractAstRewriteQuickFix;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
|
||||||
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.core.resources.IMarker;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
|
import org.eclipse.jface.text.IRegion;
|
||||||
|
import org.eclipse.ltk.core.refactoring.Change;
|
||||||
|
|
||||||
|
public class CaseBreakQuickFixBreak extends AbstractAstRewriteQuickFix {
|
||||||
|
@Override
|
||||||
|
public boolean isApplicable(IMarker marker) {
|
||||||
|
int line = marker.getAttribute(IMarker.LINE_NUMBER, -1) - 1;
|
||||||
|
if (line < 0)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return Messages.CaseBreakQuickFixBreak_Label;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IASTStatement getStmtBeforeBreak(IMarker marker, IASTTranslationUnit ast) throws BadLocationException {
|
||||||
|
int line = marker.getAttribute(IMarker.LINE_NUMBER, -1) - 1;
|
||||||
|
if (line < 0)
|
||||||
|
return null;
|
||||||
|
IRegion lineInformation = getDocument().getLineInformation(line);
|
||||||
|
IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
|
||||||
|
IASTNode containedNode = nodeSelector.findFirstContainedNode(lineInformation.getOffset(), lineInformation.getLength());
|
||||||
|
IASTNode beforeBreakNode = null;
|
||||||
|
if (containedNode != null)
|
||||||
|
beforeBreakNode = CxxAstUtils.getInstance().getEnclosingStatement(containedNode);
|
||||||
|
else
|
||||||
|
beforeBreakNode = nodeSelector.findEnclosingNode(lineInformation.getOffset(), lineInformation.getLength());
|
||||||
|
if (beforeBreakNode instanceof IASTCompoundStatement) {
|
||||||
|
while (beforeBreakNode != null) {
|
||||||
|
if (beforeBreakNode.getParent() instanceof IASTCompoundStatement
|
||||||
|
&& beforeBreakNode.getParent().getParent() instanceof IASTSwitchStatement) {
|
||||||
|
if (beforeBreakNode instanceof IASTCompoundStatement) {
|
||||||
|
IASTStatement[] statements = ((IASTCompoundStatement) beforeBreakNode).getStatements();
|
||||||
|
return statements[statements.length - 1]; // return last one
|
||||||
|
}
|
||||||
|
return (IASTStatement) beforeBreakNode;
|
||||||
|
}
|
||||||
|
beforeBreakNode = beforeBreakNode.getParent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (beforeBreakNode instanceof IASTStatement)
|
||||||
|
return (IASTStatement) beforeBreakNode;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void modifyAST(IIndex index, IMarker marker) {
|
||||||
|
try {
|
||||||
|
IASTTranslationUnit ast = getTranslationUnitViaEditor(marker).getAST(index, ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
|
||||||
|
IASTStatement beforeBreak = getStmtBeforeBreak(marker, ast);
|
||||||
|
if (beforeBreak.getParent() instanceof IASTCompoundStatement) {
|
||||||
|
IASTCompoundStatement enclosingStatement = (IASTCompoundStatement) beforeBreak.getParent();
|
||||||
|
IASTStatement after = getAfterStatement(beforeBreak);
|
||||||
|
ASTRewrite r = ASTRewrite.create(enclosingStatement.getTranslationUnit());
|
||||||
|
IASTBreakStatement breakStatement = ast.getASTNodeFactory().newBreakStatement();
|
||||||
|
r.insertBefore(enclosingStatement, after, breakStatement, null);
|
||||||
|
Change c = r.rewriteAST();
|
||||||
|
c.perform(new NullProgressMonitor());
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CheckersUiActivator.log(e);
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
CheckersUiActivator.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IASTStatement getAfterStatement(IASTStatement beforeBreak) {
|
||||||
|
IASTCompoundStatement enclosingStatement = (IASTCompoundStatement) beforeBreak.getParent();
|
||||||
|
IASTStatement after = null;
|
||||||
|
IASTStatement[] statements = enclosingStatement.getStatements();
|
||||||
|
for (int i = 0; i < statements.length; i++) {
|
||||||
|
IASTStatement st = statements[i];
|
||||||
|
if (st == beforeBreak) {
|
||||||
|
if (i < statements.length - 1) {
|
||||||
|
after = statements[i + 1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return after;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package org.eclipse.cdt.codan.internal.checkers.ui.quickfix;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.codan.core.model.IProblem;
|
||||||
|
import org.eclipse.cdt.codan.core.param.RootProblemPreference;
|
||||||
|
import org.eclipse.cdt.codan.internal.checkers.CaseBreakChecker;
|
||||||
|
import org.eclipse.cdt.codan.ui.AbstractCodanCMarkerResolution;
|
||||||
|
import org.eclipse.core.resources.IMarker;
|
||||||
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
|
import org.eclipse.jface.text.IDocument;
|
||||||
|
import org.eclipse.jface.text.IRegion;
|
||||||
|
import org.eclipse.text.edits.InsertEdit;
|
||||||
|
import org.eclipse.text.edits.MalformedTreeException;
|
||||||
|
|
||||||
|
public class CaseBreakQuickFixComment extends AbstractCodanCMarkerResolution {
|
||||||
|
public String getLabel() {
|
||||||
|
return Messages.CaseBreakQuickFixComment_Label;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply(IMarker marker, IDocument document) {
|
||||||
|
try {
|
||||||
|
int line = marker.getAttribute(IMarker.LINE_NUMBER, -1);
|
||||||
|
if (line < 0)
|
||||||
|
return;
|
||||||
|
int offset = document.getLineOffset(line);
|
||||||
|
String indent = getIndentationStr(document, line);
|
||||||
|
String comment = getNoBreakComment(marker);
|
||||||
|
String editStr = String.format("%s/* %s */\n", indent, comment);//$NON-NLS-1$
|
||||||
|
InsertEdit edit = new InsertEdit(offset, editStr);
|
||||||
|
edit.apply(document);
|
||||||
|
} catch (MalformedTreeException e) {
|
||||||
|
return;
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getIndentationStr(IDocument document, int line) throws BadLocationException {
|
||||||
|
int prevLine = line - 1;
|
||||||
|
IRegion lineInformation = document.getLineInformation(prevLine);
|
||||||
|
String prevLineStr = document.get(lineInformation.getOffset(), lineInformation.getLength());
|
||||||
|
int nonSpace = prevLineStr.indexOf(prevLineStr.trim());
|
||||||
|
String indent = prevLineStr.substring(0, nonSpace);
|
||||||
|
return indent;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getNoBreakComment(IMarker marker) {
|
||||||
|
IProblem problem = getProblem(marker);
|
||||||
|
RootProblemPreference map = (RootProblemPreference) problem.getPreference();
|
||||||
|
String comment = (String) map.getChildValue(CaseBreakChecker.PARAM_NO_BREAK_COMMENT);
|
||||||
|
if (comment == null || comment.trim().length() == 0)
|
||||||
|
comment = "no break"; //$NON-NLS-1$
|
||||||
|
return comment;
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,8 @@ import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
public class Messages extends NLS {
|
public class Messages extends NLS {
|
||||||
private static final String BUNDLE_NAME = "org.eclipse.cdt.codan.internal.checkers.ui.quickfix.messages"; //$NON-NLS-1$
|
private static final String BUNDLE_NAME = "org.eclipse.cdt.codan.internal.checkers.ui.quickfix.messages"; //$NON-NLS-1$
|
||||||
|
public static String CaseBreakQuickFixBreak_Label;
|
||||||
|
public static String CaseBreakQuickFixComment_Label;
|
||||||
public static String QuickFixCreateField_0;
|
public static String QuickFixCreateField_0;
|
||||||
public static String QuickFixCreateLocalVariable_0;
|
public static String QuickFixCreateLocalVariable_0;
|
||||||
public static String QuickFixCreateParameter_0;
|
public static String QuickFixCreateParameter_0;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
CaseBreakQuickFixBreak_Label=Add break statement
|
||||||
|
CaseBreakQuickFixComment_Label=Add supressing comment
|
||||||
QuickFixCreateField_0=Create field
|
QuickFixCreateField_0=Create field
|
||||||
QuickFixCreateLocalVariable_0=Create local variable
|
QuickFixCreateLocalVariable_0=Create local variable
|
||||||
QuickFixCreateParameter_0=Create parameter
|
QuickFixCreateParameter_0=Create parameter
|
|
@ -52,7 +52,7 @@ problem.name.FormatString = Format String Vulnerability
|
||||||
checker.name.AssignmentToItself = Assignment to itself
|
checker.name.AssignmentToItself = Assignment to itself
|
||||||
problem.messagePattern.AssignmentToItself = Assignment to itself ''{0}''
|
problem.messagePattern.AssignmentToItself = Assignment to itself ''{0}''
|
||||||
problem.name.AssignmentToItself = Assignment to itself
|
problem.name.AssignmentToItself = Assignment to itself
|
||||||
problem.description.AssignmentToItself = Finds expression where left and right side of the assignment is the same, i.e. 'var = var'
|
problem.description.AssignmentToItself = Finds expression where left and right sides of the assignment are the same, i.e. 'var = var'
|
||||||
checker.name.ReturnStyle = Return with parenthesis
|
checker.name.ReturnStyle = Return with parenthesis
|
||||||
problem.name.ReturnStyle = Return with parenthesis
|
problem.name.ReturnStyle = Return with parenthesis
|
||||||
problem.messagePattern.ReturnStyle = Return statement has invalid style. Return value should be surrounded by parenthesis
|
problem.messagePattern.ReturnStyle = Return statement has invalid style. Return value should be surrounded by parenthesis
|
||||||
|
@ -60,10 +60,10 @@ problem.description.ReturnStyle = Checks for return statements that do no return
|
||||||
checker.name.SuspiciousSemicolon = Suspicious semicolon
|
checker.name.SuspiciousSemicolon = Suspicious semicolon
|
||||||
problem.name.SuspiciousSemicolon = Suspicious semicolon
|
problem.name.SuspiciousSemicolon = Suspicious semicolon
|
||||||
problem.messagePattern.SuspiciousSemicolon = Suspicious semicolon
|
problem.messagePattern.SuspiciousSemicolon = Suspicious semicolon
|
||||||
problem.description.SuspiciousSemicolon = A semicolon is used as a null statement in a condition. For example, 'if(expression);'
|
problem.description.SuspiciousSemicolon = A semicolon is used as a null statement in a condition. For example, 'if (expression);'
|
||||||
checker.name.CaseBreak = No break at end of case
|
checker.name.CaseBreak = No break at end of case
|
||||||
problem.description.CaseBreak = Looks for "case" statements which end without a "break" statement
|
problem.description.CaseBreak = Looks for "case" statements which end without a "break" statement
|
||||||
problem.messagePattern.CaseBreak = No break at the end of this case
|
problem.messagePattern.CaseBreak = No break at the end of case
|
||||||
binding.checker.name = Problem Binding Checker
|
binding.checker.name = Problem Binding Checker
|
||||||
problem.description.G = Name resolution problem found by the indexer
|
problem.description.G = Name resolution problem found by the indexer
|
||||||
problem.messagePattern.G = Symbol ''{0}'' could not be resolved
|
problem.messagePattern.G = Symbol ''{0}'' could not be resolved
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Anton Gorenkov - initial implementation
|
* Anton Gorenkov - initial implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.internal.checkers;
|
package org.eclipse.cdt.codan.internal.checkers;
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
||||||
|
@ -179,22 +181,23 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether specified type (class or typedef to the class) is abstract class.
|
* Checks whether specified type (class or typedef to the class) is an abstract class.
|
||||||
* If it is - reports violations on each pure virtual method
|
* If it is, reports violations on each pure virtual method
|
||||||
*/
|
*/
|
||||||
private void reportProblemsIfAbstract(IType typeToCheck, IASTNode problemNode ) {
|
private void reportProblemsIfAbstract(IType typeToCheck, IASTNode problemNode ) {
|
||||||
IType unwindedType = CxxAstUtils.getInstance().unwindTypedef(typeToCheck);
|
IType unwindedType = CxxAstUtils.getInstance().unwindTypedef(typeToCheck);
|
||||||
if (unwindedType instanceof ICPPClassType) {
|
if (!(unwindedType instanceof ICPPClassType) || unwindedType instanceof IProblemBinding) {
|
||||||
ICPPClassType classType = (ICPPClassType) unwindedType;
|
return;
|
||||||
ICPPMethod[] pureVirtualMethods = pureVirtualMethodsCache.get(classType);
|
}
|
||||||
if (pureVirtualMethods == null) {
|
ICPPClassType classType = (ICPPClassType) unwindedType;
|
||||||
pureVirtualMethods = ClassTypeHelper.getPureVirtualMethods(classType);
|
ICPPMethod[] pureVirtualMethods = pureVirtualMethodsCache.get(classType);
|
||||||
pureVirtualMethodsCache.put(classType, pureVirtualMethods);
|
if (pureVirtualMethods == null) {
|
||||||
}
|
pureVirtualMethods = ClassTypeHelper.getPureVirtualMethods(classType);
|
||||||
|
pureVirtualMethodsCache.put(classType, pureVirtualMethods);
|
||||||
for (ICPPMethod method : pureVirtualMethods) {
|
}
|
||||||
reportProblem(ER_ID, problemNode, resolveName(classType), resolveName(method));
|
|
||||||
}
|
for (ICPPMethod method : pureVirtualMethods) {
|
||||||
|
reportProblem(ER_ID, problemNode, resolveName(classType), resolveName(method));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,22 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2010,2011 Gil Barash
|
* Copyright (c) 2010, 2011 Gil Barash
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Gil Barash - Initial implementation
|
* Gil Barash - Initial implementation
|
||||||
* Elena laskavaia - Rewrote checker to reduce false positives in complex cases
|
* Elena laskavaia - Rewrote checker to reduce false positives in complex cases
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.internal.checkers;
|
package org.eclipse.cdt.codan.internal.checkers;
|
||||||
|
|
||||||
import org.eclipse.cdt.codan.core.cxx.CxxAstUtils;
|
import org.eclipse.cdt.codan.core.cxx.CxxAstUtils;
|
||||||
import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker;
|
import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker;
|
||||||
import org.eclipse.cdt.codan.core.model.ICheckerWithPreferences;
|
import org.eclipse.cdt.codan.core.model.ICheckerWithPreferences;
|
||||||
|
import org.eclipse.cdt.codan.core.model.IProblemLocation;
|
||||||
|
import org.eclipse.cdt.codan.core.model.IProblemLocationFactory;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
|
||||||
|
@ -23,9 +26,11 @@ import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTContinueStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTContinueStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTMacroExpansionLocation;
|
import org.eclipse.cdt.core.dom.ast.IASTMacroExpansionLocation;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
|
@ -40,11 +45,13 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
|
||||||
public static final String DEFAULT_NO_BREAK_COMMENT = "no break"; //$NON-NLS-1$
|
public static final String DEFAULT_NO_BREAK_COMMENT = "no break"; //$NON-NLS-1$
|
||||||
private Boolean _checkLastCase; // Should we check the last case in the switch?
|
private Boolean _checkLastCase; // Should we check the last case in the switch?
|
||||||
private Boolean _checkEmptyCase; // Should we check an empty case (a case without any statements within it)
|
private Boolean _checkEmptyCase; // Should we check an empty case (a case without any statements within it)
|
||||||
private String _noBreakComment; // The comment suppressing this warning
|
private String _noBreakComment; // The comment suppressing this warning
|
||||||
|
|
||||||
|
public CaseBreakChecker() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This visitor looks for "switch" statements and invokes "SwitchVisitor" on
|
* This visitor looks for "switch" statements and invokes "SwitchVisitor" on them.
|
||||||
* them.
|
|
||||||
*/
|
*/
|
||||||
class SwitchFindingVisitor extends ASTVisitor {
|
class SwitchFindingVisitor extends ASTVisitor {
|
||||||
SwitchFindingVisitor() {
|
SwitchFindingVisitor() {
|
||||||
|
@ -60,7 +67,7 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
|
||||||
* - "continue"
|
* - "continue"
|
||||||
* - "goto" (does not check that the goto actually exists the
|
* - "goto" (does not check that the goto actually exists the
|
||||||
* switch)
|
* switch)
|
||||||
* - "thorw"
|
* - "throw"
|
||||||
* - "exit"
|
* - "exit"
|
||||||
*/
|
*/
|
||||||
protected boolean isBreakOrExitStatement(IASTStatement statement) {
|
protected boolean isBreakOrExitStatement(IASTStatement statement) {
|
||||||
|
@ -72,11 +79,11 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTStatement statement) {
|
public int visit(IASTStatement statement) {
|
||||||
if (statement instanceof IASTSwitchStatement && !isProducedMyMacroExpansion(statement)) {
|
if (statement instanceof IASTSwitchStatement && !isProducedByMacroExpansion(statement)) {
|
||||||
IASTSwitchStatement switchStmt = (IASTSwitchStatement) statement;
|
IASTSwitchStatement switchStmt = (IASTSwitchStatement) statement;
|
||||||
IASTStatement body = switchStmt.getBody();
|
IASTStatement body = switchStmt.getBody();
|
||||||
if (body instanceof IASTCompoundStatement) {
|
if (body instanceof IASTCompoundStatement) {
|
||||||
// if not it is not really a switch
|
// If not it is not really a switch
|
||||||
IASTStatement[] statements = ((IASTCompoundStatement) body).getStatements();
|
IASTStatement[] statements = ((IASTCompoundStatement) body).getStatements();
|
||||||
IASTStatement prevCase = null;
|
IASTStatement prevCase = null;
|
||||||
for (int i = 0; i < statements.length; i++) {
|
for (int i = 0; i < statements.length; i++) {
|
||||||
|
@ -90,16 +97,16 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
|
||||||
if (isCaseStatement(curr)) {
|
if (isCaseStatement(curr)) {
|
||||||
prevCase = curr;
|
prevCase = curr;
|
||||||
}
|
}
|
||||||
// next is case or end of switch - means this one is the last
|
// Next is case or end of switch - means this one is the last
|
||||||
if (prevCase != null && (isCaseStatement(next) || next == null)) {
|
if (prevCase != null && (isCaseStatement(next) || next == null)) {
|
||||||
// check that current statement end with break or any other exit statement
|
// Check that current statement end with break or any other exit statement
|
||||||
if (!_checkEmptyCase && isCaseStatement(curr) && next != null) {
|
if (!_checkEmptyCase && isCaseStatement(curr) && next != null) {
|
||||||
continue; // empty case & we don't care
|
continue; // Empty case and we don't care
|
||||||
}
|
}
|
||||||
if (!_checkLastCase && next == null) {
|
if (!_checkLastCase && next == null) {
|
||||||
continue; // last case and we don't care
|
continue; // Last case and we don't care
|
||||||
}
|
}
|
||||||
if (isFallThroughStamement(curr)) {
|
if (!isProducedByMacroExpansion(prevCase) && isFallThroughStamement(curr)) {
|
||||||
IASTComment comment = null;
|
IASTComment comment = null;
|
||||||
if (next != null) {
|
if (next != null) {
|
||||||
comment = getLeadingComment(next);
|
comment = getLeadingComment(next);
|
||||||
|
@ -110,10 +117,10 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
|
||||||
}
|
}
|
||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
String str = getTrimmedComment(comment);
|
String str = getTrimmedComment(comment);
|
||||||
if (str.equalsIgnoreCase(_noBreakComment))
|
if (str.toLowerCase().contains(_noBreakComment.toLowerCase()))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
reportProblem(ER_ID, prevCase, (Object) null);
|
reportProblem(curr, prevCase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,17 +139,17 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param nextstatement
|
* @param body
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isFallThroughStamement(IASTStatement body) {
|
public boolean isFallThroughStamement(IASTStatement body) {
|
||||||
if (body == null) return true;
|
if (body == null)
|
||||||
|
return true;
|
||||||
if (body instanceof IASTCompoundStatement) {
|
if (body instanceof IASTCompoundStatement) {
|
||||||
IASTStatement[] statements = ((IASTCompoundStatement) body).getStatements();
|
IASTStatement[] statements = ((IASTCompoundStatement) body).getStatements();
|
||||||
if (statements.length > 0) {
|
if (statements.length > 0) {
|
||||||
return isFallThroughStamement(statements[statements.length - 1]);
|
return isFallThroughStamement(statements[statements.length - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if (isBreakOrExitStatement(body)) {
|
} else if (isBreakOrExitStatement(body)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -150,26 +157,34 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
|
||||||
return true;
|
return true;
|
||||||
} else if (body instanceof IASTIfStatement) {
|
} else if (body instanceof IASTIfStatement) {
|
||||||
IASTIfStatement ifs = (IASTIfStatement) body;
|
IASTIfStatement ifs = (IASTIfStatement) body;
|
||||||
return isFallThroughStamement(ifs.getThenClause()) || isFallThroughStamement(ifs.getElseClause()) ;
|
return isFallThroughStamement(ifs.getThenClause()) || isFallThroughStamement(ifs.getElseClause());
|
||||||
}
|
}
|
||||||
return true; // TODO
|
return true; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the given statement is a result of macro expansion with a possible
|
|
||||||
* exception for the trailing semicolon.
|
|
||||||
*
|
|
||||||
* @param statement the statement to check.
|
|
||||||
* @return <code>true</code> if the statement is a result of macro expansion
|
|
||||||
*/
|
|
||||||
private boolean isProducedMyMacroExpansion(IASTStatement statement) {
|
|
||||||
IASTNodeLocation[] locations = statement.getNodeLocations();
|
|
||||||
return locations.length > 0 && locations[0] instanceof IASTMacroExpansionLocation &&
|
|
||||||
(locations.length == 1 || locations.length == 2 && locations[1].getNodeLength() == 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CaseBreakChecker() {
|
public void reportProblem(IASTStatement curr, IASTStatement prevCase) {
|
||||||
|
reportProblem(ER_ID, getProblemLocationAtEndOfNode(curr));
|
||||||
|
}
|
||||||
|
|
||||||
|
private IProblemLocation getProblemLocationAtEndOfNode(IASTNode astNode) {
|
||||||
|
IASTFileLocation astLocation = astNode.getFileLocation();
|
||||||
|
int line = astLocation.getEndingLineNumber();
|
||||||
|
IProblemLocationFactory locFactory = getRuntime().getProblemLocationFactory();
|
||||||
|
return locFactory.createProblemLocation(getFile(), -1, -1, line);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the given statement is a result of macro expansion with a possible
|
||||||
|
* exception for the trailing semicolon.
|
||||||
|
*
|
||||||
|
* @param statement the statement to check.
|
||||||
|
* @return <code>true</code> if the statement is a result of macro expansion
|
||||||
|
*/
|
||||||
|
private boolean isProducedByMacroExpansion(IASTStatement statement) {
|
||||||
|
IASTNodeLocation[] locations = statement.getNodeLocations();
|
||||||
|
return locations.length > 0 && locations[0] instanceof IASTMacroExpansionLocation
|
||||||
|
&& (locations.length == 1 || locations.length == 2 && locations[1].getNodeLength() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
# Contributors:
|
# Contributors:
|
||||||
# Alena Laskavaia - initial API and implementation
|
# Alena Laskavaia - initial API and implementation
|
||||||
###############################################################################
|
###############################################################################
|
||||||
CaseBreakChecker_DefaultNoBreakCommentDescription=Comment text to suppress the problem (regular expression):
|
CaseBreakChecker_DefaultNoBreakCommentDescription=Comment text to suppress the problem:
|
||||||
CaseBreakChecker_EmptyCaseDescription=Check also empty case statement (except if last)
|
CaseBreakChecker_EmptyCaseDescription=Check also empty 'case' statement (except if last)
|
||||||
CaseBreakChecker_LastCaseDescription=Check also the last case statement
|
CaseBreakChecker_LastCaseDescription=Check also the last 'case' statement
|
||||||
ClassMembersInitializationChecker_SkipConstructorsWithFCalls=Skip constructors with initialization function calls
|
ClassMembersInitializationChecker_SkipConstructorsWithFCalls=Skip constructors with initialization function calls
|
||||||
CatchByReference_ReportForUnknownType=Report a problem if type cannot be resolved
|
CatchByReference_ReportForUnknownType=Report a problem if type cannot be resolved
|
||||||
NamingConventionFunctionChecker_LabelNamePattern=Name Pattern
|
NamingConventionFunctionChecker_LabelNamePattern=Name Pattern
|
||||||
|
@ -18,9 +18,9 @@ NamingConventionFunctionChecker_ParameterMethods=Also check C++ method names
|
||||||
ReturnChecker_Param0=Also check functions with implicit return value
|
ReturnChecker_Param0=Also check functions with implicit return value
|
||||||
GenericParameter_ParameterExceptions=Exceptions (value of the problem argument)
|
GenericParameter_ParameterExceptions=Exceptions (value of the problem argument)
|
||||||
GenericParameter_ParameterExceptionsItem=Value of the argument
|
GenericParameter_ParameterExceptionsItem=Value of the argument
|
||||||
StatementHasNoEffectChecker_ParameterMacro=Report problem in statements that comes from macro expansion
|
StatementHasNoEffectChecker_ParameterMacro=Report problem in statements that come from macro expansion
|
||||||
SuggestedParenthesisChecker_SuggestParanthesesAroundNot=Suggest parenthesis around not operator
|
SuggestedParenthesisChecker_SuggestParanthesesAroundNot=Suggest parenthesis around 'not' operator
|
||||||
SuspiciousSemicolonChecker_ParamAfterElse=Report an error if semicolon is right after else statement
|
SuspiciousSemicolonChecker_ParamAfterElse=Report an error if semicolon is right after 'else' statement
|
||||||
SuspiciousSemicolonChecker_ParamElse=Do not report an error after 'if' when 'else' exists
|
SuspiciousSemicolonChecker_ParamElse=Do not report an error after 'if' when 'else' exists
|
||||||
|
|
||||||
ProblemBindingChecker_Candidates=Candidates are:
|
ProblemBindingChecker_Candidates=Candidates are:
|
||||||
|
|
|
@ -57,9 +57,7 @@ public class StatementHasNoEffectChecker extends AbstractIndexAstChecker {
|
||||||
if (stmt instanceof IASTExpressionStatement) {
|
if (stmt instanceof IASTExpressionStatement) {
|
||||||
IASTExpression expression = ((IASTExpressionStatement) stmt).getExpression();
|
IASTExpression expression = ((IASTExpressionStatement) stmt).getExpression();
|
||||||
if (hasNoEffect(expression)) {
|
if (hasNoEffect(expression)) {
|
||||||
boolean inMacro = CxxAstUtils.getInstance().isInMacro(expression);
|
if (!shouldReportInMacro() && CxxAstUtils.isInMacro(expression))
|
||||||
boolean shouldReportInMacro = shouldReportInMacro();
|
|
||||||
if (inMacro && !shouldReportInMacro)
|
|
||||||
return PROCESS_SKIP;
|
return PROCESS_SKIP;
|
||||||
String arg = expression.getRawSignature();
|
String arg = expression.getRawSignature();
|
||||||
if (!isFilteredArg(arg))
|
if (!isFilteredArg(arg))
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Gvozdev - initial API and implementation
|
* Andrew Gvozdev - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.internal.checkers;
|
package org.eclipse.cdt.codan.internal.checkers;
|
||||||
|
|
||||||
|
@ -18,6 +19,7 @@ import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.eclipse.cdt.codan.checkers.CodanCheckersActivator;
|
import org.eclipse.cdt.codan.checkers.CodanCheckersActivator;
|
||||||
|
import org.eclipse.cdt.codan.core.cxx.CxxAstUtils;
|
||||||
import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker;
|
import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblem;
|
import org.eclipse.cdt.codan.core.model.IProblem;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
||||||
|
@ -54,6 +56,7 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
|
||||||
public static final String ER_UNUSED_VARIABLE_DECLARATION_ID = "org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem"; //$NON-NLS-1$
|
public static final String ER_UNUSED_VARIABLE_DECLARATION_ID = "org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem"; //$NON-NLS-1$
|
||||||
public static final String ER_UNUSED_FUNCTION_DECLARATION_ID = "org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem"; //$NON-NLS-1$
|
public static final String ER_UNUSED_FUNCTION_DECLARATION_ID = "org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem"; //$NON-NLS-1$
|
||||||
public static final String ER_UNUSED_STATIC_FUNCTION_ID = "org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem"; //$NON-NLS-1$
|
public static final String ER_UNUSED_STATIC_FUNCTION_ID = "org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem"; //$NON-NLS-1$
|
||||||
|
public static final String PARAM_MACRO_ID = "macro"; //$NON-NLS-1$
|
||||||
public static final String PARAM_EXCEPT_ARG_LIST = "exceptions"; //$NON-NLS-1$
|
public static final String PARAM_EXCEPT_ARG_LIST = "exceptions"; //$NON-NLS-1$
|
||||||
|
|
||||||
private Map<IBinding, IASTDeclarator> externFunctionDeclarations = new HashMap<IBinding, IASTDeclarator>();
|
private Map<IBinding, IASTDeclarator> externFunctionDeclarations = new HashMap<IBinding, IASTDeclarator>();
|
||||||
|
@ -71,6 +74,7 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
|
||||||
@Override
|
@Override
|
||||||
public void initPreferences(IProblemWorkingCopy problem) {
|
public void initPreferences(IProblemWorkingCopy problem) {
|
||||||
super.initPreferences(problem);
|
super.initPreferences(problem);
|
||||||
|
addPreference(problem, PARAM_MACRO_ID, CheckersMessages.StatementHasNoEffectChecker_ParameterMacro, Boolean.TRUE);
|
||||||
if (problem.getId().equals(ER_UNUSED_VARIABLE_DECLARATION_ID)) {
|
if (problem.getId().equals(ER_UNUSED_VARIABLE_DECLARATION_ID)) {
|
||||||
unusedVariableProblem = problem;
|
unusedVariableProblem = problem;
|
||||||
ListProblemPreference pref = addListPreference(problem, PARAM_EXCEPT_ARG_LIST,
|
ListProblemPreference pref = addListPreference(problem, PARAM_EXCEPT_ARG_LIST,
|
||||||
|
@ -90,11 +94,11 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAnyCandidate() {
|
private boolean isAnyCandidate() {
|
||||||
return externFunctionDeclarations.size() > 0 ||
|
return !externFunctionDeclarations.isEmpty() ||
|
||||||
staticFunctionDeclarations.size() > 0 ||
|
!staticFunctionDeclarations.isEmpty() ||
|
||||||
staticFunctionDefinitions.size() > 0 ||
|
!staticFunctionDefinitions.isEmpty() ||
|
||||||
externVariableDeclarations.size() > 0 ||
|
!externVariableDeclarations.isEmpty() ||
|
||||||
staticVariableDeclarations.size() > 0;
|
!staticVariableDeclarations.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processAst(IASTTranslationUnit ast) {
|
public void processAst(IASTTranslationUnit ast) {
|
||||||
|
@ -131,42 +135,51 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
|
||||||
int storageClass = simpleDeclaration.getDeclSpecifier().getStorageClass();
|
int storageClass = simpleDeclaration.getDeclSpecifier().getStorageClass();
|
||||||
|
|
||||||
if (binding instanceof IFunction) {
|
if (binding instanceof IFunction) {
|
||||||
if (storageClass == IASTDeclSpecifier.sc_extern || storageClass == IASTDeclSpecifier.sc_unspecified) {
|
if (storageClass == IASTDeclSpecifier.sc_extern ||
|
||||||
externFunctionDeclarations.put(binding, decl);
|
storageClass == IASTDeclSpecifier.sc_unspecified) {
|
||||||
} else if (storageClass == IASTDeclSpecifier.sc_static) {
|
if (shouldReportInMacro(ER_UNUSED_FUNCTION_DECLARATION_ID) ||
|
||||||
staticFunctionDeclarations.put(binding, decl);
|
!CxxAstUtils.isInMacro(astName)) {
|
||||||
}
|
externFunctionDeclarations.put(binding, decl);
|
||||||
} else if (binding instanceof IVariable) {
|
|
||||||
if (storageClass == IASTDeclSpecifier.sc_extern) {
|
|
||||||
IASTInitializer initializer = decl.getInitializer();
|
|
||||||
// initializer makes "extern" declaration to become definition do not count these
|
|
||||||
if (initializer==null) {
|
|
||||||
externVariableDeclarations.put(binding, decl);
|
|
||||||
}
|
}
|
||||||
} else if (storageClass == IASTDeclSpecifier.sc_static) {
|
} else if (storageClass == IASTDeclSpecifier.sc_static) {
|
||||||
IType type = ((IVariable) binding).getType();
|
if (shouldReportInMacro(ER_UNUSED_STATIC_FUNCTION_ID) ||
|
||||||
// account for class constructor and avoid possible false positive
|
!CxxAstUtils.isInMacro(astName)) {
|
||||||
if (!(type instanceof ICPPClassType) && !(type instanceof IProblemType)) {
|
staticFunctionDeclarations.put(binding, decl);
|
||||||
// check if initializer disqualifies it
|
}
|
||||||
IASTInitializer initializer = decl.getInitializer();
|
}
|
||||||
IASTInitializerClause clause = null;
|
} else if (binding instanceof IVariable) {
|
||||||
if (initializer instanceof IASTEqualsInitializer) {
|
if (shouldReportInMacro(ER_UNUSED_VARIABLE_DECLARATION_ID) ||
|
||||||
IASTEqualsInitializer equalsInitializer = (IASTEqualsInitializer) initializer;
|
!CxxAstUtils.isInMacro(astName)) {
|
||||||
clause = equalsInitializer.getInitializerClause();
|
if (storageClass == IASTDeclSpecifier.sc_extern) {
|
||||||
} else if (initializer instanceof ICPPASTConstructorInitializer) {
|
// Initializer makes "extern" declaration to become definition do not count these
|
||||||
ICPPASTConstructorInitializer constructorInitializer = (ICPPASTConstructorInitializer) initializer;
|
if (decl.getInitializer() == null) {
|
||||||
IASTInitializerClause[] args = constructorInitializer.getArguments();
|
externVariableDeclarations.put(binding, decl);
|
||||||
if (args.length==1)
|
|
||||||
clause = args[0];
|
|
||||||
}
|
}
|
||||||
if (clause instanceof IASTLiteralExpression) {
|
} else if (storageClass == IASTDeclSpecifier.sc_static) {
|
||||||
IASTLiteralExpression literalExpression = (IASTLiteralExpression) clause;
|
IType type = ((IVariable) binding).getType();
|
||||||
String literal = literalExpression.toString();
|
// Account for class constructor and avoid possible false positive
|
||||||
if (isFilteredOut(literal, unusedVariableProblem, PARAM_EXCEPT_ARG_LIST))
|
if (!(type instanceof ICPPClassType) && !(type instanceof IProblemType)) {
|
||||||
continue;
|
// Check if initializer disqualifies it
|
||||||
|
IASTInitializer initializer = decl.getInitializer();
|
||||||
|
IASTInitializerClause clause = null;
|
||||||
|
if (initializer instanceof IASTEqualsInitializer) {
|
||||||
|
IASTEqualsInitializer equalsInitializer = (IASTEqualsInitializer) initializer;
|
||||||
|
clause = equalsInitializer.getInitializerClause();
|
||||||
|
} else if (initializer instanceof ICPPASTConstructorInitializer) {
|
||||||
|
ICPPASTConstructorInitializer constructorInitializer = (ICPPASTConstructorInitializer) initializer;
|
||||||
|
IASTInitializerClause[] args = constructorInitializer.getArguments();
|
||||||
|
if (args.length == 1)
|
||||||
|
clause = args[0];
|
||||||
|
}
|
||||||
|
if (clause instanceof IASTLiteralExpression) {
|
||||||
|
IASTLiteralExpression literalExpression = (IASTLiteralExpression) clause;
|
||||||
|
String literal = literalExpression.toString();
|
||||||
|
if (isFilteredOut(literal, unusedVariableProblem, PARAM_EXCEPT_ARG_LIST))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
staticVariableDeclarations.put(binding, decl);
|
||||||
}
|
}
|
||||||
|
|
||||||
staticVariableDeclarations.put(binding, decl);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,7 +245,12 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
|
||||||
staticFunctionDefinitions.remove(binding);
|
staticFunctionDefinitions.remove(binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(parentNode instanceof IASTDeclarator)) {
|
if (parentNode instanceof IASTDeclarator) {
|
||||||
|
// Initializer makes "extern" declaration to become definition.
|
||||||
|
if (((IASTDeclarator) parentNode).getInitializer() != null) {
|
||||||
|
externVariableDeclarations.remove(binding);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
externVariableDeclarations.remove(binding);
|
externVariableDeclarations.remove(binding);
|
||||||
staticVariableDeclarations.remove(binding);
|
staticVariableDeclarations.remove(binding);
|
||||||
}
|
}
|
||||||
|
@ -310,7 +328,7 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
|
||||||
clearCandidates(); // release memory
|
clearCandidates(); // release memory
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFilteredOut(String arg, IProblem problem, String exceptionListParamId) {
|
private boolean isFilteredOut(String arg, IProblem problem, String exceptionListParamId) {
|
||||||
Object[] arr = (Object[]) getPreference(problem, exceptionListParamId);
|
Object[] arr = (Object[]) getPreference(problem, exceptionListParamId);
|
||||||
for (int i = 0; i < arr.length; i++) {
|
for (int i = 0; i < arr.length; i++) {
|
||||||
String str = (String) arr[i];
|
String str = (String) arr[i];
|
||||||
|
@ -320,4 +338,7 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean shouldReportInMacro(String errorId) {
|
||||||
|
return (Boolean) getPreference(getProblemById(errorId, getFile()), PARAM_MACRO_ID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ public final class CxxAstUtils {
|
||||||
return (IType) typeName;
|
return (IType) typeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInMacro(IASTNode node) {
|
public static boolean isInMacro(IASTNode node) {
|
||||||
IASTNodeSelector nodeSelector = node.getTranslationUnit().getNodeSelector(node.getTranslationUnit().getFilePath());
|
IASTNodeSelector nodeSelector = node.getTranslationUnit().getNodeSelector(node.getTranslationUnit().getFilePath());
|
||||||
IASTFileLocation fileLocation = node.getFileLocation();
|
IASTFileLocation fileLocation = node.getFileLocation();
|
||||||
IASTPreprocessorMacroExpansion macro = nodeSelector.findEnclosingMacroExpansion(fileLocation.getNodeOffset(),
|
IASTPreprocessorMacroExpansion macro = nodeSelector.findEnclosingMacroExpansion(fileLocation.getNodeOffset(),
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdt.codan.core.tests</artifactId>
|
<artifactId>org.eclipse.cdt.codan.core.test</artifactId>
|
||||||
<packaging>eclipse-test-plugin</packaging>
|
<packaging>eclipse-test-plugin</packaging>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Gil Barash - Initial implementation
|
* Gil Barash - Initial implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.core.internal.checkers;
|
package org.eclipse.cdt.codan.core.internal.checkers;
|
||||||
|
|
||||||
|
@ -62,7 +63,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
||||||
// }
|
// }
|
||||||
public void testLastCaseBad() {
|
public void testLastCaseBad() {
|
||||||
loadCodeAndRun(getAboveComment());
|
loadCodeAndRun(getAboveComment());
|
||||||
checkErrorLines(4);
|
checkErrorLines(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void foo(void) {
|
// void foo(void) {
|
||||||
|
@ -181,7 +182,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
||||||
// }
|
// }
|
||||||
public void testEmptyLastCaseTwoSwitches() {
|
public void testEmptyLastCaseTwoSwitches() {
|
||||||
loadCodeAndRun(getAboveComment());
|
loadCodeAndRun(getAboveComment());
|
||||||
checkErrorLines(3);
|
checkErrorLines(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void foo(void) {
|
// void foo(void) {
|
||||||
|
@ -222,7 +223,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
||||||
// }
|
// }
|
||||||
public void testLastCaseBadCommentNotLast() {
|
public void testLastCaseBadCommentNotLast() {
|
||||||
loadCodeAndRun(getAboveComment());
|
loadCodeAndRun(getAboveComment());
|
||||||
checkErrorLines(4);
|
checkErrorLines(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void foo(void) {
|
// void foo(void) {
|
||||||
|
@ -246,70 +247,74 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
||||||
// case 6:
|
// case 6:
|
||||||
// b = 2;
|
// b = 2;
|
||||||
// /* no break1 */
|
// /* no break1 */
|
||||||
|
// case 7:
|
||||||
|
// b = 2;
|
||||||
|
// /* fallthrough */
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
public void testDifferentComments() {
|
public void testDifferentComments() {
|
||||||
loadCodeAndRun(getAboveComment());
|
loadCodeAndRun(getAboveComment());
|
||||||
checkErrorLines(16, 19);
|
checkErrorLines(17,23);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void foo(void) {
|
// void foo(void) {
|
||||||
// int a, b;
|
// int a, b;
|
||||||
// switch( a ) {
|
// switch( a ) {
|
||||||
// case 1:
|
// case 1: //err
|
||||||
// // lolo
|
// // lolo
|
||||||
// case 2:
|
// case 2: //err
|
||||||
// case 3:
|
// case 3://err
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// switch( a ) {
|
// switch( a ) {
|
||||||
// case 1:
|
// case 1:
|
||||||
// b = 2;
|
// b = 2; // err
|
||||||
// // lolo
|
// // lolo
|
||||||
// case 2:
|
// case 2:
|
||||||
// b = 2;
|
// b = 2; // err
|
||||||
// case 3:
|
// case 3: // err
|
||||||
// case 4:
|
// case 4:
|
||||||
// break;
|
// break;
|
||||||
// case 5:
|
// case 5: // err
|
||||||
// case 6:
|
// case 6: // err
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// switch( a ) {
|
// switch( a ) {
|
||||||
// case 1:
|
// case 1:
|
||||||
// b = 2;
|
// b = 2; // err
|
||||||
// // lolo
|
// // lolo
|
||||||
// case 2:
|
// case 2:
|
||||||
// b = 2;
|
// b = 2; //err
|
||||||
// case 3:
|
// case 3:
|
||||||
// b = 2;
|
// b = 2;
|
||||||
// /* no break */
|
// /* no break */
|
||||||
// case 4:
|
// case 4:
|
||||||
// b = 2;
|
// b = 2; // err
|
||||||
// case 5:
|
// case 5:
|
||||||
// b = 2;
|
// b = 2;
|
||||||
// break;
|
// break;
|
||||||
// case 6:
|
// case 6:
|
||||||
// b = 2;
|
// b = 2;
|
||||||
// /* no break */
|
// /* no break */
|
||||||
// b = 2;
|
// b = 2; //err
|
||||||
// case 7:
|
// case 7:
|
||||||
// b = 2;
|
// b = 2;//err
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// switch( a ) {
|
// switch( a ) {
|
||||||
// case 1:
|
// case 1:
|
||||||
// b = 2;
|
// b = 2; // err
|
||||||
// // lolo
|
// // lolo
|
||||||
// case 2:
|
// case 2:
|
||||||
// b = 2;
|
// b = 2; // err
|
||||||
// default:
|
// default: //err
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
public void testGeneral1() {
|
public void testGeneral1() {
|
||||||
setEmpty(true);
|
setEmpty(true);
|
||||||
|
setLast(true);
|
||||||
loadCodeAndRun(getAboveComment());
|
loadCodeAndRun(getAboveComment());
|
||||||
checkErrorLines(4, 6, 7, 11, 14, 16, 19, 20, 24, 27, 32, 37, 41, 46, 49, 51);
|
checkErrorComments();
|
||||||
}
|
}
|
||||||
|
|
||||||
// void foo(void) {
|
// void foo(void) {
|
||||||
|
@ -339,7 +344,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
||||||
// }
|
// }
|
||||||
public void testGeneralComments1() {
|
public void testGeneralComments1() {
|
||||||
loadCodeAndRun(getAboveComment());
|
loadCodeAndRun(getAboveComment());
|
||||||
checkErrorLines(8, 12);
|
checkErrorLines(9, 14);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void foo(void) {
|
// void foo(void) {
|
||||||
|
@ -347,14 +352,14 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
||||||
// switch( a ) {
|
// switch( a ) {
|
||||||
// case 0:
|
// case 0:
|
||||||
// switch( b ) {
|
// switch( b ) {
|
||||||
// case 2:
|
// case 2: // err
|
||||||
// }
|
// } // err
|
||||||
//
|
//
|
||||||
// case 1:
|
// case 1:
|
||||||
// switch( b ) {
|
// switch( b ) {
|
||||||
// case 2:
|
// case 2:
|
||||||
// break;
|
// break;
|
||||||
// }
|
// } // err
|
||||||
// case 3:
|
// case 3:
|
||||||
// switch( b ) {
|
// switch( b ) {
|
||||||
// case 2:
|
// case 2:
|
||||||
|
@ -365,25 +370,25 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
||||||
// switch( b ) {
|
// switch( b ) {
|
||||||
// case 2:
|
// case 2:
|
||||||
// /* no break */
|
// /* no break */
|
||||||
// }
|
// } // err
|
||||||
// case 5:
|
// case 5:
|
||||||
// switch( b ) {
|
// switch( b ) {
|
||||||
// case 2:
|
// case 2: // err
|
||||||
// }
|
// }
|
||||||
// /* no break */
|
// /* no break */
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
public void testNestedSwitches() {
|
public void testNestedSwitches() {
|
||||||
loadCodeAndRun(getAboveComment());
|
loadCodeAndRun(getAboveComment());
|
||||||
checkErrorLines(4, 20, 6, 9, 27);
|
checkErrorComments();
|
||||||
}
|
}
|
||||||
|
|
||||||
// void foo(void) {
|
// void foo(void) {
|
||||||
// int a, b;
|
// int a, b;
|
||||||
// switch( a ) {
|
// switch( a ) {
|
||||||
// case 1:
|
// case 1:
|
||||||
// b = 2;
|
// b = 2;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
public void testLastCaseIgnore() {
|
public void testLastCaseIgnore() {
|
||||||
setLast(false);
|
setLast(false);
|
||||||
|
@ -441,16 +446,16 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
||||||
// switch( a ) {
|
// switch( a ) {
|
||||||
// case 1:
|
// case 1:
|
||||||
// while (a--)
|
// while (a--)
|
||||||
// break;
|
// break; // err
|
||||||
// case 2:
|
// case 2:
|
||||||
// while (a--) {
|
// while (a--) {
|
||||||
// break;
|
// break;
|
||||||
// }
|
// } // err
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
public void testEmptyCaseWithLoopBreak() {
|
public void testEmptyCaseWithLoopBreak() {
|
||||||
loadCodeAndRun(getAboveComment());
|
loadCodeAndRun(getAboveComment());
|
||||||
checkErrorLines(3, 6);
|
checkErrorComments();
|
||||||
}
|
}
|
||||||
|
|
||||||
// void foo(int a) {
|
// void foo(int a) {
|
||||||
|
@ -470,12 +475,12 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// void foo(void) {
|
// void foo(void) {
|
||||||
// int a;
|
// int a;
|
||||||
// switch( a ) {
|
// switch( a ) {
|
||||||
// case 2:
|
// case 2:
|
||||||
// break;
|
// break;
|
||||||
// case 1:
|
// case 1:
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
public void testEmptyLastCaseError() {
|
public void testEmptyLastCaseError() {
|
||||||
String code = getAboveComment();
|
String code = getAboveComment();
|
||||||
|
@ -489,85 +494,76 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// void foo(int a) {
|
// void foo(int a) {
|
||||||
// switch( a ) {
|
// switch( a ) {
|
||||||
// case 2:
|
// case 2:
|
||||||
// if (a*2<10)
|
// if (a*2<10)
|
||||||
// return;
|
// return;
|
||||||
// else
|
// else
|
||||||
// break;
|
// break;
|
||||||
// case 1:
|
// case 1:
|
||||||
// break;
|
// break;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
public void testIf() {
|
public void testIf() {
|
||||||
String code = getAboveComment();
|
String code = getAboveComment();
|
||||||
loadCodeAndRun(code);
|
loadCodeAndRun(code);
|
||||||
checkNoErrors();
|
checkNoErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
// void foo(int a) {
|
// void foo(int a) {
|
||||||
// switch( a ) {
|
// switch(a) {
|
||||||
// case 2:
|
// case 2:
|
||||||
// if (a*2<10)
|
// if (a*2<10)
|
||||||
// return;
|
// return;
|
||||||
// else
|
// else
|
||||||
// a++;
|
// a++;
|
||||||
// case 1:
|
// case 1:
|
||||||
// break;
|
// break;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
public void testIfErr() {
|
public void testIfErr() {
|
||||||
String code = getAboveComment();
|
String code = getAboveComment();
|
||||||
loadCodeAndRun(code);
|
loadCodeAndRun(code);
|
||||||
checkErrorLine(3);
|
checkErrorLine(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #define DEFINE_BREAK {break;}
|
// #define DEFINE_BREAK {break;}
|
||||||
// void foo ( int a )
|
// void foo(int a) {
|
||||||
// {
|
// switch (a) {
|
||||||
// switch ( a )
|
// case 1:
|
||||||
// {
|
// DEFINE_BREAK // No warning here
|
||||||
// case 1:
|
// }
|
||||||
// DEFINE_BREAK // <-- Warning: No break at the end of this case
|
// }
|
||||||
// }
|
|
||||||
// }
|
|
||||||
public void testBreakInBraces() {
|
public void testBreakInBraces() {
|
||||||
String code = getAboveComment();
|
String code = getAboveComment();
|
||||||
loadCodeAndRun(code);
|
loadCodeAndRun(code);
|
||||||
checkNoErrors();
|
checkNoErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #define MY_MACRO(i) \
|
||||||
// #define MY_MACRO(i) \
|
// case i: { \
|
||||||
// case i: \
|
// }
|
||||||
// { \
|
//
|
||||||
// break; \
|
// void f() {
|
||||||
// }
|
// int x;
|
||||||
//
|
// switch (x) {
|
||||||
// void f()
|
// MY_MACRO(1) // No warning here
|
||||||
// {
|
// }
|
||||||
// int x;
|
// }
|
||||||
// switch (x)
|
|
||||||
// {
|
|
||||||
// MY_MACRO(1) // WARNING HERE
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void testInMacro() {
|
public void testInMacro() {
|
||||||
String code = getAboveComment();
|
String code = getAboveComment();
|
||||||
loadCodeAndRun(code);
|
loadCodeAndRun(code);
|
||||||
checkNoErrors();
|
checkNoErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
//void foo()
|
// void foo() {
|
||||||
//{
|
// switch (0)
|
||||||
//switch(0)
|
// default: {
|
||||||
//default:
|
// }
|
||||||
//{
|
// }
|
||||||
//}
|
public void testEmptyCompoundStatement() {
|
||||||
//}
|
String code = getAboveComment();
|
||||||
public void testEmptyCompoundStatement() {
|
loadCodeAndRun(code);
|
||||||
String code = getAboveComment();
|
checkErrorLine(4);
|
||||||
loadCodeAndRun(code);
|
}
|
||||||
checkErrorLine(4);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Gvozdev - initial API and implementation
|
* Andrew Gvozdev - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.core.internal.checkers;
|
package org.eclipse.cdt.codan.core.internal.checkers;
|
||||||
|
|
||||||
|
@ -17,7 +18,6 @@ import org.eclipse.cdt.codan.internal.checkers.UnusedSymbolInFileScopeChecker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@see UnusedSymbolInFileScopeChecker} class
|
* Test for {@see UnusedSymbolInFileScopeChecker} class
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class UnusedSymbolInFileScopeCheckerTest extends CheckerTestCase {
|
public class UnusedSymbolInFileScopeCheckerTest extends CheckerTestCase {
|
||||||
@Override
|
@Override
|
||||||
|
@ -222,8 +222,15 @@ public class UnusedSymbolInFileScopeCheckerTest extends CheckerTestCase {
|
||||||
checkNoErrors();
|
checkNoErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
// extern int test_var=0; // not quite legal but some compilers allow that
|
// extern const int test_var=0; // not quite legal but some compilers allow that
|
||||||
public void testExternVariable_Definition() throws IOException {
|
public void testExternVariable_Definition1() throws IOException {
|
||||||
|
loadCodeAndRun(getAboveComment());
|
||||||
|
checkNoErrors();
|
||||||
|
}
|
||||||
|
|
||||||
|
// extern const int test_var;
|
||||||
|
// const int test_var = 0;
|
||||||
|
public void testExternVariable_Definition2() throws IOException {
|
||||||
loadCodeAndRun(getAboveComment());
|
loadCodeAndRun(getAboveComment());
|
||||||
checkNoErrors();
|
checkNoErrors();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.eclipse.cdt.codan.core.internal.checkers.StatementHasNoEffectCheckerT
|
||||||
import org.eclipse.cdt.codan.core.internal.checkers.SuggestedParenthesisCheckerTest;
|
import org.eclipse.cdt.codan.core.internal.checkers.SuggestedParenthesisCheckerTest;
|
||||||
import org.eclipse.cdt.codan.core.internal.checkers.SuspiciousSemicolonCheckerTest;
|
import org.eclipse.cdt.codan.core.internal.checkers.SuspiciousSemicolonCheckerTest;
|
||||||
import org.eclipse.cdt.codan.core.internal.checkers.UnusedSymbolInFileScopeCheckerTest;
|
import org.eclipse.cdt.codan.core.internal.checkers.UnusedSymbolInFileScopeCheckerTest;
|
||||||
|
import org.eclipse.cdt.codan.internal.checkers.ui.quickfix.CaseBreakQuickFixTest;
|
||||||
import org.eclipse.cdt.codan.internal.checkers.ui.quickfix.CatchByReferenceQuickFixTest;
|
import org.eclipse.cdt.codan.internal.checkers.ui.quickfix.CatchByReferenceQuickFixTest;
|
||||||
import org.eclipse.cdt.codan.internal.checkers.ui.quickfix.CreateLocalVariableQuickFixTest;
|
import org.eclipse.cdt.codan.internal.checkers.ui.quickfix.CreateLocalVariableQuickFixTest;
|
||||||
import org.eclipse.cdt.codan.internal.checkers.ui.quickfix.SuggestedParenthesisQuickFixTest;
|
import org.eclipse.cdt.codan.internal.checkers.ui.quickfix.SuggestedParenthesisQuickFixTest;
|
||||||
|
@ -74,6 +75,7 @@ public class AutomatedIntegrationSuite extends TestSuite {
|
||||||
suite.addTestSuite(CreateLocalVariableQuickFixTest.class);
|
suite.addTestSuite(CreateLocalVariableQuickFixTest.class);
|
||||||
suite.addTestSuite(SuggestedParenthesisQuickFixTest.class);
|
suite.addTestSuite(SuggestedParenthesisQuickFixTest.class);
|
||||||
suite.addTestSuite(CatchByReferenceQuickFixTest.class);
|
suite.addTestSuite(CatchByReferenceQuickFixTest.class);
|
||||||
|
suite.addTestSuite(CaseBreakQuickFixTest.class);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
* method to get source directory for the tests,
|
* method to get source directory for the tests,
|
||||||
* default is "src". To make it read comment from java class, you need to
|
* default is "src". To make it read comment from java class, you need to
|
||||||
* include this source directory (with test java files) into the build bundle.
|
* include this source directory (with test java files) into the build bundle.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("nls")
|
@SuppressWarnings("nls")
|
||||||
public class CheckerTestCase extends CodanTestCase {
|
public class CheckerTestCase extends CodanTestCase {
|
||||||
|
@ -50,6 +50,13 @@ public class CheckerTestCase extends CodanTestCase {
|
||||||
assertEquals(args.length, markers.length);
|
assertEquals(args.length, markers.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkErrorComments() {
|
||||||
|
for (Object i : errLines) {
|
||||||
|
checkErrorLine((Integer) i);
|
||||||
|
}
|
||||||
|
assertEquals("Expected number of errors "+errLines.size(),errLines.size(), markers.length);
|
||||||
|
}
|
||||||
|
|
||||||
public IMarker checkErrorLine(int i, String problemId) {
|
public IMarker checkErrorLine(int i, String problemId) {
|
||||||
return checkErrorLine(currentFile, i, problemId);
|
return checkErrorLine(currentFile, i, problemId);
|
||||||
}
|
}
|
||||||
|
@ -82,7 +89,7 @@ public class CheckerTestCase extends CodanTestCase {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertEquals(Integer.valueOf(expectedLine), line);
|
assertEquals("Error on line "+expectedLine+" is not found",Integer.valueOf(expectedLine), line);
|
||||||
if (file != null)
|
if (file != null)
|
||||||
assertEquals(file.getName(), mfile);
|
assertEquals(file.getName(), mfile);
|
||||||
assertTrue(found);
|
assertTrue(found);
|
||||||
|
|
|
@ -10,6 +10,12 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.core.test;
|
package org.eclipse.cdt.codan.core.test;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
@ -30,12 +36,6 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Plugin;
|
import org.eclipse.core.runtime.Plugin;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: add description
|
* TODO: add description
|
||||||
*/
|
*/
|
||||||
|
@ -47,6 +47,7 @@ public class CodanTestCase extends BaseTestCase {
|
||||||
protected File currentFile;
|
protected File currentFile;
|
||||||
protected ICElement currentCElem;
|
protected ICElement currentCElem;
|
||||||
protected IFile currentIFile;
|
protected IFile currentIFile;
|
||||||
|
protected ArrayList<Integer> errLines= new ArrayList<Integer>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -220,7 +221,9 @@ public class CodanTestCase extends BaseTestCase {
|
||||||
private File loadcode(String code, File testFile) {
|
private File loadcode(String code, File testFile) {
|
||||||
try {
|
try {
|
||||||
tempFiles.add(testFile);
|
tempFiles.add(testFile);
|
||||||
TestUtils.saveFile(new ByteArrayInputStream(code.trim().getBytes()), testFile);
|
String trim = code.trim();
|
||||||
|
loadErrorComments(trim);
|
||||||
|
TestUtils.saveFile(new ByteArrayInputStream(trim.getBytes()), testFile);
|
||||||
currentFile = testFile;
|
currentFile = testFile;
|
||||||
try {
|
try {
|
||||||
cproject.getProject().refreshLocal(1, null);
|
cproject.getProject().refreshLocal(1, null);
|
||||||
|
@ -240,6 +243,17 @@ public class CodanTestCase extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadErrorComments(String trim) {
|
||||||
|
String[] lines = trim.split("\n");
|
||||||
|
for (int i = 0; i < lines.length; i++) {
|
||||||
|
String string = lines[i];
|
||||||
|
if (string.matches(".*//\\s*err\\s*")) {
|
||||||
|
|
||||||
|
errLines.add(i+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public File loadcode_c(String code) {
|
public File loadcode_c(String code) {
|
||||||
return loadcode(code, true);
|
return loadcode(code, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package org.eclipse.cdt.codan.internal.checkers.ui.quickfix;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.codan.ui.AbstractCodanCMarkerResolution;
|
||||||
|
|
||||||
|
@SuppressWarnings("nls")
|
||||||
|
public class CaseBreakQuickFixTest extends QuickFixTestCase {
|
||||||
|
@SuppressWarnings("restriction")
|
||||||
|
@Override
|
||||||
|
protected AbstractCodanCMarkerResolution createQuickFix() {
|
||||||
|
return new CaseBreakQuickFixBreak();
|
||||||
|
}
|
||||||
|
|
||||||
|
// void func() {
|
||||||
|
// int a;
|
||||||
|
// switch(a) {
|
||||||
|
// case 1:
|
||||||
|
// hello();
|
||||||
|
// case 2:
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
public void testMiddleCase() {
|
||||||
|
loadcode(getAboveComment());
|
||||||
|
String result = runQuickFixOneFile();
|
||||||
|
assertContainedIn("break; case 2:", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// void func() {
|
||||||
|
// int a;
|
||||||
|
// switch(a) {
|
||||||
|
// case 1:
|
||||||
|
// hello();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
public void testLastCase() {
|
||||||
|
loadcode(getAboveComment());
|
||||||
|
String result = runQuickFixOneFile();
|
||||||
|
assertContainedIn("break; }", result);
|
||||||
|
}
|
||||||
|
// void func() {
|
||||||
|
// int a;
|
||||||
|
// switch(a) {
|
||||||
|
// case 1: {
|
||||||
|
// hello();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
public void testLastCaseComp() {
|
||||||
|
loadcode(getAboveComment());
|
||||||
|
String result = runQuickFixOneFile();
|
||||||
|
assertContainedIn("hello(); break;", result);
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,9 +8,9 @@
|
||||||
# Contributors:
|
# Contributors:
|
||||||
# IBM Corporation - initial API and implementation
|
# IBM Corporation - initial API and implementation
|
||||||
###############################################################################
|
###############################################################################
|
||||||
source.cdtaix.jar = src/
|
source.. = src/
|
||||||
bin.includes = fragment.xml,\
|
bin.includes = fragment.xml,\
|
||||||
cdtaix.jar,\
|
.,\
|
||||||
about.html,\
|
about.html,\
|
||||||
META-INF/,\
|
META-INF/,\
|
||||||
os/
|
os/
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
bin.includes = fragment.xml,\
|
bin.includes = fragment.xml,\
|
||||||
about.html,\
|
about.html,\
|
||||||
cdt_linux.jar,\
|
.,\
|
||||||
META-INF/
|
META-INF/
|
||||||
src.includes = about.html,\
|
src.includes = about.html,\
|
||||||
library/
|
library/
|
||||||
source.cdt_linux.jar = src/
|
source.. = src/
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
bin.includes = fragment.xml,\
|
bin.includes = fragment.xml,\
|
||||||
about.html,\
|
about.html,\
|
||||||
cdt_macosx.jar,\
|
.,\
|
||||||
os/,\
|
os/,\
|
||||||
META-INF/
|
META-INF/
|
||||||
src.includes = about.html,\
|
src.includes = about.html,\
|
||||||
library/
|
library/
|
||||||
source.cdt_macosx.jar = src/
|
source.. = src/
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
bin.includes = fragment.xml,\
|
bin.includes = fragment.xml,\
|
||||||
about.html,\
|
about.html,\
|
||||||
os/,\
|
os/,\
|
||||||
cdt_solaris.jar,\
|
.,\
|
||||||
META-INF/
|
META-INF/
|
||||||
src.includes = about.html,\
|
src.includes = about.html,\
|
||||||
library/
|
library/
|
||||||
source.cdt_solaris.jar = src/
|
source.. = src/
|
||||||
|
|
|
@ -36,8 +36,8 @@ import org.eclipse.core.runtime.Path;
|
||||||
/**
|
/**
|
||||||
* Tests for CModel identifier API.
|
* Tests for CModel identifier API.
|
||||||
*
|
*
|
||||||
* @see ICElement#getHandleIdentier()
|
* @see ICElement#getHandleIdentifier()
|
||||||
* @see CoreModel.create(String)
|
* @see CoreModel#create(String)
|
||||||
*
|
*
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
|
@ -105,7 +105,7 @@ public class CModelIdentifierTests extends BaseTestCase {
|
||||||
String identifier= (String) identifiers.get(i);
|
String identifier= (String) identifiers.get(i);
|
||||||
assertNotNull("Could not create identifier for element: "+ expected, identifier);
|
assertNotNull("Could not create identifier for element: "+ expected, identifier);
|
||||||
ICElement actual= CoreModel.create(identifier);
|
ICElement actual= CoreModel.create(identifier);
|
||||||
assertNotNull("Cannot create element '" + expected + "' from identifier: "+identifier, actual);
|
assertNotNull("Cannot create element '" + expected + "' from identifier: " + identifier, actual);
|
||||||
assertEquals(expected.getElementName(), actual.getElementName());
|
assertEquals(expected.getElementName(), actual.getElementName());
|
||||||
assertEquals(expected.getElementType(), actual.getElementType());
|
assertEquals(expected.getElementType(), actual.getElementType());
|
||||||
assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -5454,4 +5454,16 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
public void testTemplateTemplateParameterMatching_352859() throws Exception {
|
public void testTemplateTemplateParameterMatching_352859() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template<typename T> T f();
|
||||||
|
// template<> int f() {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
public void testArgumentDeductionFromReturnTypeOfExplicitSpecialization_355304() throws Exception {
|
||||||
|
parseAndCheckBindings();
|
||||||
|
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
||||||
|
ICPPFunctionTemplate template= bh.assertNonProblem("f();", 1);
|
||||||
|
ICPPTemplateInstance inst= bh.assertNonProblem("f() {", 1);
|
||||||
|
assertSame(template, inst.getTemplateDefinition());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7337,4 +7337,27 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertFalse(((IASTPreprocessorIfdefStatement) stmts[0]).taken());
|
assertFalse(((IASTPreprocessorIfdefStatement) stmts[0]).taken());
|
||||||
assertFalse(((IASTPreprocessorIfdefStatement) stmts[1]).taken());
|
assertFalse(((IASTPreprocessorIfdefStatement) stmts[1]).taken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// void a() {
|
||||||
|
// typedef float size_t;
|
||||||
|
// sizeof(10); // wrong - getExpressionType returns float
|
||||||
|
// sizeof(int); // wrong - getExpressionType returns float
|
||||||
|
// }
|
||||||
|
public void testTypeOfSizeof_Bug355052() throws Exception {
|
||||||
|
final String code = getAboveComment();
|
||||||
|
IASTTranslationUnit tu= parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||||
|
IASTFunctionDefinition a= getDeclaration(tu, 0);
|
||||||
|
IASTExpressionStatement es= getStatement(a, 1);
|
||||||
|
assertEquals("unsigned long int", ASTTypeUtil.getType(es.getExpression().getExpressionType()));
|
||||||
|
es= getStatement(a, 2);
|
||||||
|
assertEquals("unsigned long int", ASTTypeUtil.getType(es.getExpression().getExpressionType()));
|
||||||
|
|
||||||
|
tu= parseAndCheckBindings(code, ParserLanguage.C);
|
||||||
|
a= getDeclaration(tu, 0);
|
||||||
|
es= getStatement(a, 1);
|
||||||
|
assertEquals("unsigned long int", ASTTypeUtil.getType(es.getExpression().getExpressionType()));
|
||||||
|
es= getStatement(a, 2);
|
||||||
|
assertEquals("unsigned long int", ASTTypeUtil.getType(es.getExpression().getExpressionType()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.index.tests;
|
package org.eclipse.cdt.internal.index.tests;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
@ -116,28 +116,28 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
protected class BindingAssertionHelper {
|
protected class BindingAssertionHelper {
|
||||||
protected IASTTranslationUnit tu;
|
protected IASTTranslationUnit tu;
|
||||||
protected String contents;
|
protected String contents;
|
||||||
|
|
||||||
public BindingAssertionHelper(IFile file, String contents, IIndex index) throws CModelException, CoreException {
|
public BindingAssertionHelper(IFile file, String contents, IIndex index) throws CModelException, CoreException {
|
||||||
this.contents= contents;
|
this.contents= contents;
|
||||||
this.tu= TestSourceReader.createIndexBasedAST(index, fCProject, file);
|
this.tu= TestSourceReader.createIndexBasedAST(index, fCProject, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTTranslationUnit getTranslationUnit() {
|
public IASTTranslationUnit getTranslationUnit() {
|
||||||
return tu;
|
return tu;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding assertProblem(String section, int len) {
|
public IBinding assertProblem(String section, int len) {
|
||||||
IBinding binding= binding(section, len);
|
IBinding binding= binding(section, len);
|
||||||
assertTrue("Non-ProblemBinding for name: " + section.substring(0, len),
|
assertTrue("Non-ProblemBinding for name: " + section.substring(0, len),
|
||||||
binding instanceof IProblemBinding);
|
binding instanceof IProblemBinding);
|
||||||
return binding;
|
return binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends IBinding> T assertNonProblem(String section, int len) {
|
public <T extends IBinding> T assertNonProblem(String section, int len) {
|
||||||
IBinding binding= binding(section, len);
|
IBinding binding= binding(section, len);
|
||||||
if (binding instanceof IProblemBinding) {
|
if (binding instanceof IProblemBinding) {
|
||||||
IProblemBinding problem= (IProblemBinding) binding;
|
IProblemBinding problem= (IProblemBinding) binding;
|
||||||
fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID())+")");
|
fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID())+")");
|
||||||
}
|
}
|
||||||
if (binding == null) {
|
if (binding == null) {
|
||||||
fail("Null binding resolved for name: " + section.substring(0, len));
|
fail("Null binding resolved for name: " + section.substring(0, len));
|
||||||
|
@ -146,7 +146,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assertNoName(String section, int len) {
|
public void assertNoName(String section, int len) {
|
||||||
IASTName name= findName(section,len,false);
|
IASTName name= findName(section, len, false);
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
String selection = section.substring(0, len);
|
String selection = section.substring(0, len);
|
||||||
fail("Found unexpected \"" + selection + "\": " + name.resolveBinding());
|
fail("Found unexpected \"" + selection + "\": " + name.resolveBinding());
|
||||||
|
@ -158,15 +158,15 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
* it resolves to the given type of binding.
|
* it resolves to the given type of binding.
|
||||||
*/
|
*/
|
||||||
public IASTImplicitName assertImplicitName(String section, int len, Class<?> bindingClass) {
|
public IASTImplicitName assertImplicitName(String section, int len, Class<?> bindingClass) {
|
||||||
IASTName name = findName(section,len,true);
|
IASTName name = findName(section, len, true);
|
||||||
final String selection = section.substring(0, len);
|
final String selection = section.substring(0, len);
|
||||||
assertNotNull("did not find \""+selection+"\"", name);
|
assertNotNull("did not find \""+selection+"\"", name);
|
||||||
|
|
||||||
assertInstance(name, IASTImplicitName.class);
|
assertInstance(name, IASTImplicitName.class);
|
||||||
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
||||||
IASTImplicitName[] implicits = owner.getImplicitNames();
|
IASTImplicitName[] implicits = owner.getImplicitNames();
|
||||||
assertNotNull(implicits);
|
assertNotNull(implicits);
|
||||||
|
|
||||||
if (implicits.length > 1) {
|
if (implicits.length > 1) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (IASTImplicitName n : implicits) {
|
for (IASTImplicitName n : implicits) {
|
||||||
|
@ -177,27 +177,27 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
assertTrue(found);
|
assertTrue(found);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(selection, name.getRawSignature());
|
assertEquals(selection, name.getRawSignature());
|
||||||
IBinding binding = name.resolveBinding();
|
IBinding binding = name.resolveBinding();
|
||||||
assertNotNull(binding);
|
assertNotNull(binding);
|
||||||
assertInstance(binding, bindingClass);
|
assertInstance(binding, bindingClass);
|
||||||
return (IASTImplicitName) name;
|
return (IASTImplicitName) name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assertNoImplicitName(String section, int len) {
|
public void assertNoImplicitName(String section, int len) {
|
||||||
IASTName name = findName(section,len,true);
|
IASTName name = findName(section, len, true);
|
||||||
final String selection = section.substring(0, len);
|
final String selection = section.substring(0, len);
|
||||||
assertNull("found name \""+selection+"\"", name);
|
assertNull("found name \""+selection+"\"", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTImplicitName[] getImplicitNames(String section, int len) {
|
public IASTImplicitName[] getImplicitNames(String section, int len) {
|
||||||
IASTName name = findName(section,len,true);
|
IASTName name = findName(section, len, true);
|
||||||
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
||||||
IASTImplicitName[] implicits = owner.getImplicitNames();
|
IASTImplicitName[] implicits = owner.getImplicitNames();
|
||||||
return implicits;
|
return implicits;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTName findName(String section, int len, boolean implicit) {
|
private IASTName findName(String section, int len, boolean implicit) {
|
||||||
final int offset = contents.indexOf(section);
|
final int offset = contents.indexOf(section);
|
||||||
assertTrue(offset >= 0);
|
assertTrue(offset >= 0);
|
||||||
|
@ -222,7 +222,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
return "Unknown problem ID";
|
return "Unknown problem ID";
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends IBinding> T assertNonProblem(String section, int len, Class<T> type, Class... cs) {
|
public <T extends IBinding> T assertNonProblem(String section, int len, Class<T> type, Class... cs) {
|
||||||
IBinding binding= binding(section, len);
|
IBinding binding= binding(section, len);
|
||||||
assertTrue("ProblemBinding for name: " + section.substring(0, len),
|
assertTrue("ProblemBinding for name: " + section.substring(0, len),
|
||||||
|
@ -233,16 +233,16 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
return type.cast(binding);
|
return type.cast(binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IBinding binding(String section, int len) {
|
private IBinding binding(String section, int len) {
|
||||||
IASTName name = findName(section, len,false);
|
IASTName name = findName(section, len, false);
|
||||||
final String selection = section.substring(0, len);
|
final String selection = section.substring(0, len);
|
||||||
assertNotNull("Did not find \"" + selection + "\"", name);
|
assertNotNull("Did not find \"" + selection + "\"", name);
|
||||||
assertEquals(selection, name.getRawSignature());
|
assertEquals(selection, name.getRawSignature());
|
||||||
|
|
||||||
IBinding binding = name.resolveBinding();
|
IBinding binding = name.resolveBinding();
|
||||||
assertNotNull("No binding for " + name.getRawSignature(), binding);
|
assertNotNull("No binding for " + name.getRawSignature(), binding);
|
||||||
|
|
||||||
return name.resolveBinding();
|
return name.resolveBinding();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
|
fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
if (fCProject != null) {
|
if (fCProject != null) {
|
||||||
|
@ -269,11 +269,11 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IProject getProject() {
|
protected IProject getProject() {
|
||||||
return fCProject.getProject();
|
return fCProject.getProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String[] getContentsForTest(int blocks) throws IOException {
|
protected String[] getContentsForTest(int blocks) throws IOException {
|
||||||
CharSequence[] help= TestSourceReader.getContentsForTest(
|
CharSequence[] help= TestSourceReader.getContentsForTest(
|
||||||
CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), blocks);
|
CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), blocks);
|
||||||
|
@ -284,7 +284,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IFile createFile(IContainer container, String fileName, String contents) throws Exception {
|
protected IFile createFile(IContainer container, String fileName, String contents) throws Exception {
|
||||||
return TestSourceReader.createFile(container, new Path(fileName), contents);
|
return TestSourceReader.createFile(container, new Path(fileName), contents);
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
String[] parts= qname.split("::");
|
String[] parts= qname.split("::");
|
||||||
Pattern[] result= new Pattern[parts.length];
|
Pattern[] result= new Pattern[parts.length];
|
||||||
for (int i = 0; i < result.length; i++) {
|
for (int i = 0; i < result.length; i++) {
|
||||||
result[i]= Pattern.compile(parts[i]);
|
result[i]= Pattern.compile(parts[i]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -335,7 +335,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
IASTName name= ast.getNodeSelector(null).findName(source.indexOf(section), len);
|
IASTName name= ast.getNodeSelector(null).findName(source.indexOf(section), len);
|
||||||
assertNotNull("Name not found for \"" + section + "\"", name);
|
assertNotNull("Name not found for \"" + section + "\"", name);
|
||||||
assertEquals(section.substring(0, len), name.getRawSignature());
|
assertEquals(section.substring(0, len), name.getRawSignature());
|
||||||
|
|
||||||
IBinding binding = name.resolveBinding();
|
IBinding binding = name.resolveBinding();
|
||||||
assertNotNull("No binding for " + section.substring(0, len), binding);
|
assertNotNull("No binding for " + section.substring(0, len), binding);
|
||||||
assertTrue("ProblemBinding for name: " + section.substring(0, len),
|
assertTrue("ProblemBinding for name: " + section.substring(0, len),
|
||||||
|
@ -357,7 +357,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// public:
|
// public:
|
||||||
// void one() {}
|
// void one() {}
|
||||||
// void two() {}
|
// void two() {}
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// class A {
|
// class A {
|
||||||
// public:
|
// public:
|
||||||
|
@ -369,29 +369,29 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// Because of fix for http://bugs.eclipse.org/193779 this test case passes.
|
// Because of fix for http://bugs.eclipse.org/193779 this test case passes.
|
||||||
// However http://bugs.eclipse.org/154563 remains to be fixed.
|
// However http://bugs.eclipse.org/154563 remains to be fixed.
|
||||||
String[] content= getContentsForTest(2);
|
String[] content= getContentsForTest(2);
|
||||||
|
|
||||||
IFile file= createFile(getProject(), "header.h", content[0]);
|
IFile file= createFile(getProject(), "header.h", content[0]);
|
||||||
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
||||||
|
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IBinding[] bs= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
IBinding[] bs= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
||||||
assertEquals(1, bs.length);
|
assertEquals(1, bs.length);
|
||||||
assertTrue(bs[0] instanceof ICPPClassType);
|
assertTrue(bs[0] instanceof ICPPClassType);
|
||||||
assertEquals(2, ((ICPPClassType)bs[0]).getDeclaredMethods().length);
|
assertEquals(2, ((ICPPClassType)bs[0]).getDeclaredMethods().length);
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
file= createFile(getProject(), "header.h", content[1]);
|
file= createFile(getProject(), "header.h", content[1]);
|
||||||
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
||||||
|
|
||||||
index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IBinding[] bs= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
IBinding[] bs= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
||||||
assertEquals(1, bs.length);
|
assertEquals(1, bs.length);
|
||||||
assertTrue(bs[0] instanceof ICPPClassType);
|
assertTrue(bs[0] instanceof ICPPClassType);
|
||||||
assertEquals(3, ((ICPPClassType)bs[0]).getDeclaredMethods().length);
|
assertEquals(3, ((ICPPClassType)bs[0]).getDeclaredMethods().length);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -419,9 +419,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
try {
|
try {
|
||||||
IIndexBinding[] bindings= fIndex.findBindings(getPattern("arrayDataSize"), true, IndexFilter.ALL, npm());
|
IIndexBinding[] bindings= fIndex.findBindings(getPattern("arrayDataSize"), true, IndexFilter.ALL, npm());
|
||||||
assertEquals(1, bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
|
|
||||||
IIndexBinding binding= bindings[0];
|
IIndexBinding binding= bindings[0];
|
||||||
|
|
||||||
// check if we have the definition
|
// check if we have the definition
|
||||||
IIndexName[] decls= fIndex.findNames(binding, IIndex.FIND_DEFINITIONS);
|
IIndexName[] decls= fIndex.findNames(binding, IIndex.FIND_DEFINITIONS);
|
||||||
assertEquals(1, decls.length);
|
assertEquals(1, decls.length);
|
||||||
|
@ -504,7 +504,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
// namespace ns162011 {
|
// namespace ns162011 {
|
||||||
// class Class162011 {
|
// class Class162011 {
|
||||||
// friend void function162011(Class162011);
|
// friend void function162011(Class162011);
|
||||||
// };
|
// };
|
||||||
// void function162011(Class162011 x){};
|
// void function162011(Class162011 x){};
|
||||||
// }
|
// }
|
||||||
|
@ -517,7 +517,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
int indexOfDef = content.indexOf(funcName, indexOfDecl+1);
|
int indexOfDef = content.indexOf(funcName, indexOfDecl+1);
|
||||||
IFile file= createFile(getProject(), fileName, content);
|
IFile file= createFile(getProject(), fileName, content);
|
||||||
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
||||||
|
|
||||||
// make sure the ast is correct
|
// make sure the ast is correct
|
||||||
ITranslationUnit tu= (ITranslationUnit) fCProject.findElement(new Path(fileName));
|
ITranslationUnit tu= (ITranslationUnit) fCProject.findElement(new Path(fileName));
|
||||||
IASTTranslationUnit ast= tu.getAST();
|
IASTTranslationUnit ast= tu.getAST();
|
||||||
|
@ -535,9 +535,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
try {
|
try {
|
||||||
IIndexBinding[] bindings= fIndex.findBindings(getPattern("ns162011::function162011"), true, IndexFilter.ALL, npm());
|
IIndexBinding[] bindings= fIndex.findBindings(getPattern("ns162011::function162011"), true, IndexFilter.ALL, npm());
|
||||||
assertEquals(1, bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
|
|
||||||
IIndexBinding binding= bindings[0];
|
IIndexBinding binding= bindings[0];
|
||||||
|
|
||||||
// check if we have the declaration
|
// check if we have the declaration
|
||||||
IIndexName[] decls= fIndex.findNames(binding, IIndex.FIND_DECLARATIONS);
|
IIndexName[] decls= fIndex.findNames(binding, IIndex.FIND_DECLARATIONS);
|
||||||
assertEquals(1, decls.length);
|
assertEquals(1, decls.length);
|
||||||
|
@ -630,11 +630,11 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
// // header.h
|
// // header.h
|
||||||
// class E {};
|
// class E {};
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// E var;
|
// E var;
|
||||||
|
|
||||||
// // header.h
|
// // header.h
|
||||||
// enum E {A,B,C};
|
// enum E {A,B,C};
|
||||||
public void test171834() throws Exception {
|
public void test171834() throws Exception {
|
||||||
CModelListener.sSuppressUpdateOfLastRecentlyUsed= false;
|
CModelListener.sSuppressUpdateOfLastRecentlyUsed= false;
|
||||||
|
@ -659,7 +659,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
InputStream in = new ByteArrayInputStream(testData[2].getBytes());
|
InputStream in = new ByteArrayInputStream(testData[2].getBytes());
|
||||||
header.setContents(in, IResource.FORCE, null);
|
header.setContents(in, IResource.FORCE, null);
|
||||||
TestSourceReader.waitUntilFileIsIndexed(index, header, INDEX_WAIT_TIME);
|
TestSourceReader.waitUntilFileIsIndexed(index, header, INDEX_WAIT_TIME);
|
||||||
|
|
||||||
|
@ -692,7 +692,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
try {
|
try {
|
||||||
IBinding[] bindings= fIndex.findBindings("S20070201".toCharArray(), IndexFilter.getFilter(ILinkage.C_LINKAGE_ID), npm());
|
IBinding[] bindings= fIndex.findBindings("S20070201".toCharArray(), IndexFilter.getFilter(ILinkage.C_LINKAGE_ID), npm());
|
||||||
assertEquals(2, bindings.length);
|
assertEquals(2, bindings.length);
|
||||||
|
|
||||||
IBinding struct, typedef;
|
IBinding struct, typedef;
|
||||||
if (bindings[0] instanceof ICompositeType) {
|
if (bindings[0] instanceof ICompositeType) {
|
||||||
struct= bindings[0];
|
struct= bindings[0];
|
||||||
|
@ -701,7 +701,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
struct= bindings[1];
|
struct= bindings[1];
|
||||||
typedef= bindings[0];
|
typedef= bindings[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTrue(struct instanceof ICompositeType);
|
assertTrue(struct instanceof ICompositeType);
|
||||||
assertTrue(typedef instanceof ITypedef);
|
assertTrue(typedef instanceof ITypedef);
|
||||||
assertTrue(((ITypedef) typedef).getType() instanceof ICompositeType);
|
assertTrue(((ITypedef) typedef).getType() instanceof ICompositeType);
|
||||||
|
@ -725,7 +725,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
try {
|
try {
|
||||||
IBinding[] bindings= fIndex.findBindings("S20070201".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
|
IBinding[] bindings= fIndex.findBindings("S20070201".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
|
||||||
assertEquals(2, bindings.length);
|
assertEquals(2, bindings.length);
|
||||||
|
|
||||||
IBinding struct, typedef;
|
IBinding struct, typedef;
|
||||||
if (bindings[0] instanceof ICPPClassType) {
|
if (bindings[0] instanceof ICPPClassType) {
|
||||||
struct= bindings[0];
|
struct= bindings[0];
|
||||||
|
@ -734,7 +734,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
struct= bindings[1];
|
struct= bindings[1];
|
||||||
typedef= bindings[0];
|
typedef= bindings[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTrue(struct instanceof ICPPClassType);
|
assertTrue(struct instanceof ICPPClassType);
|
||||||
assertTrue(((ICPPClassType)struct).getKey()==ICompositeType.k_struct);
|
assertTrue(((ICPPClassType)struct).getKey()==ICompositeType.k_struct);
|
||||||
assertTrue(typedef instanceof ITypedef);
|
assertTrue(typedef instanceof ITypedef);
|
||||||
|
@ -768,7 +768,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
} finally {
|
} finally {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
long timestamp= file.getLocalTimeStamp();
|
long timestamp= file.getLocalTimeStamp();
|
||||||
content= "int UPDATED20070213;\n" + content.replaceFirst("int", "float");
|
content= "int UPDATED20070213;\n" + content.replaceFirst("int", "float");
|
||||||
file= TestSourceReader.createFile(fCProject.getProject(), "test173997.cpp", content);
|
file= TestSourceReader.createFile(fCProject.getProject(), "test173997.cpp", content);
|
||||||
|
@ -779,7 +779,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// double check if file was indexed
|
// double check if file was indexed
|
||||||
IBinding[] bindings= fIndex.findBindings("UPDATED20070213".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
|
IBinding[] bindings= fIndex.findBindings("UPDATED20070213".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
|
||||||
assertEquals(1, bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
|
|
||||||
bindings= fIndex.findBindings("T20070213".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
|
bindings= fIndex.findBindings("T20070213".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
|
||||||
assertEquals(1, bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
assertTrue(bindings[0] instanceof ITypedef);
|
assertTrue(bindings[0] instanceof ITypedef);
|
||||||
|
@ -797,36 +797,36 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// class A {};
|
// class A {};
|
||||||
// class B {};
|
// class B {};
|
||||||
// A var;
|
// A var;
|
||||||
|
|
||||||
// class A {};
|
// class A {};
|
||||||
// class B {};
|
// class B {};
|
||||||
// B var;
|
// B var;
|
||||||
public void test173997_2() throws Exception {
|
public void test173997_2() throws Exception {
|
||||||
String[] content= getContentsForTest(2);
|
String[] content= getContentsForTest(2);
|
||||||
|
|
||||||
IFile file= createFile(getProject(), "header.h", content[0]);
|
IFile file= createFile(getProject(), "header.h", content[0]);
|
||||||
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
||||||
|
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IBinding[] bs= index.findBindings("var".toCharArray(), IndexFilter.ALL, npm());
|
IBinding[] bs= index.findBindings("var".toCharArray(), IndexFilter.ALL, npm());
|
||||||
assertEquals(1, bs.length);
|
assertEquals(1, bs.length);
|
||||||
assertTrue(bs[0] instanceof ICPPVariable);
|
assertTrue(bs[0] instanceof ICPPVariable);
|
||||||
assertTrue(((ICPPVariable)bs[0]).getType() instanceof ICPPClassType);
|
assertTrue(((ICPPVariable)bs[0]).getType() instanceof ICPPClassType);
|
||||||
assertEquals("A", ((ICPPClassType)(((ICPPVariable)bs[0]).getType())).getName());
|
assertEquals("A", ((ICPPClassType)(((ICPPVariable)bs[0]).getType())).getName());
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
file= createFile(getProject(), "header.h", content[1]);
|
file= createFile(getProject(), "header.h", content[1]);
|
||||||
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
||||||
|
|
||||||
index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IBinding[] bs= index.findBindings("var".toCharArray(), IndexFilter.ALL, npm());
|
IBinding[] bs= index.findBindings("var".toCharArray(), IndexFilter.ALL, npm());
|
||||||
assertEquals(1, bs.length);
|
assertEquals(1, bs.length);
|
||||||
assertTrue(bs[0] instanceof ICPPVariable);
|
assertTrue(bs[0] instanceof ICPPVariable);
|
||||||
assertTrue(((ICPPVariable)bs[0]).getType() instanceof ICPPClassType);
|
assertTrue(((ICPPVariable)bs[0]).getType() instanceof ICPPClassType);
|
||||||
assertEquals("B", ((ICPPClassType)(((ICPPVariable)bs[0]).getType())).getName());
|
assertEquals("B", ((ICPPClassType)(((ICPPVariable)bs[0]).getType())).getName());
|
||||||
|
@ -838,7 +838,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// // header.h
|
// // header.h
|
||||||
// template <class T1> class Test {};
|
// template <class T1> class Test {};
|
||||||
// template <class T2> void f() {}
|
// template <class T2> void f() {}
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// struct A {};
|
// struct A {};
|
||||||
// Test<A> a;
|
// Test<A> a;
|
||||||
|
@ -956,7 +956,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
/* Check that when a project is deleted, its index contents do not
|
/* Check that when a project is deleted, its index contents do not
|
||||||
* appear in the initial index of a newly created project of the same name */
|
* appear in the initial index of a newly created project of the same name */
|
||||||
|
|
||||||
String pname = "deleteTest"+System.currentTimeMillis();
|
String pname = "deleteTest"+System.currentTimeMillis();
|
||||||
ICProject cproject = CProjectHelper.createCCProject(pname, "bin", IPDOMManager.ID_FAST_INDEXER);
|
ICProject cproject = CProjectHelper.createCCProject(pname, "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||||
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
|
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
|
||||||
|
@ -994,8 +994,8 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
File newLocation = CProjectHelper.freshDir();
|
File newLocation = CProjectHelper.freshDir();
|
||||||
IProjectDescription description = cproject.getProject().getDescription();
|
IProjectDescription description = cproject.getProject().getDescription();
|
||||||
description.setLocationURI(newLocation.toURI());
|
description.setLocationURI(newLocation.toURI());
|
||||||
cproject.getProject().move(description, IResource.FORCE | IResource.SHALLOW, new NullProgressMonitor());
|
cproject.getProject().move(description, IResource.FORCE | IResource.SHALLOW, new NullProgressMonitor());
|
||||||
|
|
||||||
index = CCorePlugin.getIndexManager().getIndex(cproject);
|
index = CCorePlugin.getIndexManager().getIndex(cproject);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
|
@ -1031,23 +1031,23 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
return !(binding instanceof IFunction);
|
return !(binding instanceof IFunction);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IBinding[] bindings= fIndex.findBindingsForPrefix(new char[] {'a'}, true, NON_FUNCTIONS, null);
|
IBinding[] bindings= fIndex.findBindingsForPrefix(new char[] {'a'}, true, NON_FUNCTIONS, null);
|
||||||
assertEquals(3,bindings.length);
|
assertEquals(3, bindings.length);
|
||||||
|
|
||||||
bindings= fIndex.findBindingsForPrefix(new char[] {'a'}, false, NON_FUNCTIONS, null);
|
bindings= fIndex.findBindingsForPrefix(new char[] {'a'}, false, NON_FUNCTIONS, null);
|
||||||
assertEquals(6,bindings.length);
|
assertEquals(6, bindings.length);
|
||||||
|
|
||||||
bindings= fIndex.findBindingsForPrefix(new char[] {'a','A'}, true, NON_FUNCTIONS, null);
|
bindings= fIndex.findBindingsForPrefix(new char[] {'a','A'}, true, NON_FUNCTIONS, null);
|
||||||
assertEquals(1,bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
|
|
||||||
bindings= fIndex.findBindingsForPrefix(new char[] {'a','A'}, false, NON_FUNCTIONS, null);
|
bindings= fIndex.findBindingsForPrefix(new char[] {'a','A'}, false, NON_FUNCTIONS, null);
|
||||||
assertEquals(2, bindings.length);
|
assertEquals(2, bindings.length);
|
||||||
} finally {
|
} finally {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// class a { class b { class c { void f(); }; }; };
|
// class a { class b { class c { void f(); }; }; };
|
||||||
public void testFilterFindBindingsFQCharArray() throws Exception {
|
public void testFilterFindBindingsFQCharArray() throws Exception {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
|
@ -1064,27 +1064,27 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
return !(binding instanceof ICPPClassType);
|
return !(binding instanceof ICPPClassType);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IBinding[] bindings= fIndex.findBindings(new char[][]{{'a'},{'b'},{'c'},{'f'}}, NON_CLASS, npm());
|
IBinding[] bindings= fIndex.findBindings(new char[][]{{'a'},{'b'},{'c'},{'f'}}, NON_CLASS, npm());
|
||||||
assertEquals(1,bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
} finally {
|
} finally {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// typedef struct {
|
// typedef struct {
|
||||||
// float fNumber;
|
// float fNumber;
|
||||||
// int iIdx;
|
// int iIdx;
|
||||||
// } StructA_T;
|
// } StructA_T;
|
||||||
|
|
||||||
// #include "../__bugsTest__/common.h"
|
// #include "../__bugsTest__/common.h"
|
||||||
// StructA_T gvar1;
|
// StructA_T gvar1;
|
||||||
|
|
||||||
// #include "../__bugsTest__/common.h"
|
// #include "../__bugsTest__/common.h"
|
||||||
// StructA_T gvar2;
|
// StructA_T gvar2;
|
||||||
public void testFileInMultipleFragments_bug192352() throws Exception {
|
public void testFileInMultipleFragments_bug192352() throws Exception {
|
||||||
String[] contents= getContentsForTest(3);
|
String[] contents= getContentsForTest(3);
|
||||||
|
|
||||||
ICProject p2 = CProjectHelper.createCCProject("__bugsTest_2_", "bin", IPDOMManager.ID_FAST_INDEXER);
|
ICProject p2 = CProjectHelper.createCCProject("__bugsTest_2_", "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||||
try {
|
try {
|
||||||
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "common.h", contents[0]);
|
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "common.h", contents[0]);
|
||||||
|
@ -1109,22 +1109,22 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
CProjectHelper.delete(p2);
|
CProjectHelper.delete(p2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #ifndef _h1
|
// #ifndef _h1
|
||||||
// #define _h1
|
// #define _h1
|
||||||
// #define M v
|
// #define M v
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifndef _h1
|
// #ifndef _h1
|
||||||
// #include "header1.h"
|
// #include "header1.h"
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #include "header1.h"
|
// #include "header1.h"
|
||||||
// #include "header2.h"
|
// #include "header2.h"
|
||||||
|
|
||||||
// #include "header2.h"
|
// #include "header2.h"
|
||||||
// int M;
|
// int M;
|
||||||
|
|
||||||
// #include "header2.h"
|
// #include "header2.h"
|
||||||
// #ifndef _h1
|
// #ifndef _h1
|
||||||
// #include "header1.h"
|
// #include "header1.h"
|
||||||
|
@ -1140,7 +1140,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
IFile f4= TestSourceReader.createFile(fCProject.getProject(), "src2.cpp", contents[3]);
|
IFile f4= TestSourceReader.createFile(fCProject.getProject(), "src2.cpp", contents[3]);
|
||||||
IFile f5= TestSourceReader.createFile(fCProject.getProject(), "src3.cpp", contents[4]);
|
IFile f5= TestSourceReader.createFile(fCProject.getProject(), "src3.cpp", contents[4]);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
|
|
||||||
IIndex index= indexManager.getIndex(fCProject);
|
IIndex index= indexManager.getIndex(fCProject);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
|
@ -1151,7 +1151,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
IIndexName[] names = index.findNames(binding, IIndex.FIND_ALL_OCCURRENCES);
|
IIndexName[] names = index.findNames(binding, IIndex.FIND_ALL_OCCURRENCES);
|
||||||
assertEquals(1, names.length);
|
assertEquals(1, names.length);
|
||||||
assertEquals(f4.getFullPath().toString(), names[0].getFile().getLocation().getFullPath());
|
assertEquals(f4.getFullPath().toString(), names[0].getFile().getLocation().getFullPath());
|
||||||
|
|
||||||
IIndexFile idxFile= index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(f5));
|
IIndexFile idxFile= index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(f5));
|
||||||
IIndexInclude[] includes= idxFile.getIncludes();
|
IIndexInclude[] includes= idxFile.getIncludes();
|
||||||
assertEquals(2, includes.length);
|
assertEquals(2, includes.length);
|
||||||
|
@ -1163,10 +1163,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #define MAC(...) Bug200239
|
// #define MAC(...) Bug200239
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// int MAC(1);
|
// int MAC(1);
|
||||||
// void func() {
|
// void func() {
|
||||||
|
@ -1190,9 +1189,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #define GMAC(x...) Bug200239
|
// #define GMAC(x...) Bug200239
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// int GMAC(1);
|
// int GMAC(1);
|
||||||
// void func() {
|
// void func() {
|
||||||
|
@ -1217,7 +1216,6 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// typedef bug200553_A bug200553_B;
|
// typedef bug200553_A bug200553_B;
|
||||||
// typedef bug200553_B bug200553_A;
|
// typedef bug200553_B bug200553_A;
|
||||||
public void testTypedefRecursionCpp_Bug200553() throws Exception {
|
public void testTypedefRecursionCpp_Bug200553() throws Exception {
|
||||||
|
@ -1266,7 +1264,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
assertTrue(maxDepth > 0);
|
assertTrue(maxDepth > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// typedef bug200553_A bug200553_B;
|
// typedef bug200553_A bug200553_B;
|
||||||
// typedef bug200553_B bug200553_A;
|
// typedef bug200553_B bug200553_A;
|
||||||
public void testTypedefRecursionC_Bug200553() throws Exception {
|
public void testTypedefRecursionC_Bug200553() throws Exception {
|
||||||
|
@ -1306,7 +1304,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #ifndef GUARD
|
// #ifndef GUARD
|
||||||
// #include "source.cpp"
|
// #include "source.cpp"
|
||||||
// #endif
|
// #endif
|
||||||
|
@ -1315,7 +1313,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[0]);
|
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[0]);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
|
|
||||||
final ITranslationUnit tu= (ITranslationUnit) fCProject.findElement(new Path("source.cpp"));
|
final ITranslationUnit tu= (ITranslationUnit) fCProject.findElement(new Path("source.cpp"));
|
||||||
Thread th= new Thread() {
|
Thread th= new Thread() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1324,7 +1322,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
tu.getAST(fIndex, ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT);
|
tu.getAST(fIndex, ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
|
@ -1357,9 +1355,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// static inline void staticInHeader() {};
|
// static inline void staticInHeader() {};
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// void f1() {
|
// void f1() {
|
||||||
// staticInHeader();
|
// staticInHeader();
|
||||||
|
@ -1384,9 +1382,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// static const int staticConstInHeader= 12;
|
// static const int staticConstInHeader= 12;
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// void f1() {
|
// void f1() {
|
||||||
// int a= staticConstInHeader;
|
// int a= staticConstInHeader;
|
||||||
|
@ -1413,7 +1411,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// static inline void staticInHeader() {};
|
// static inline void staticInHeader() {};
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// void f1() {
|
// void f1() {
|
||||||
// staticInHeader();
|
// staticInHeader();
|
||||||
|
@ -1438,9 +1436,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// static const int staticConstInHeader= 12;
|
// static const int staticConstInHeader= 12;
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// void f1() {
|
// void f1() {
|
||||||
// int a= staticConstInHeader;
|
// int a= staticConstInHeader;
|
||||||
|
@ -1467,7 +1465,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// int ok;
|
// int ok;
|
||||||
|
|
||||||
// #include "header.x"
|
// #include "header.x"
|
||||||
public void testNonStandardSuffix_Bug205778() throws Exception {
|
public void testNonStandardSuffix_Bug205778() throws Exception {
|
||||||
String[] contents= getContentsForTest(2);
|
String[] contents= getContentsForTest(2);
|
||||||
|
@ -1484,14 +1482,14 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// inline void MyClass::method() {}
|
// inline void MyClass::method() {}
|
||||||
|
|
||||||
// class MyClass {
|
// class MyClass {
|
||||||
// void method();
|
// void method();
|
||||||
// };
|
// };
|
||||||
// #include "MyClass_inline.h"
|
// #include "MyClass_inline.h"
|
||||||
|
|
||||||
// #include "MyClass.h"
|
// #include "MyClass.h"
|
||||||
public void testAddingMemberBeforeContainer_Bug203170() throws Exception {
|
public void testAddingMemberBeforeContainer_Bug203170() throws Exception {
|
||||||
String[] contents= getContentsForTest(3);
|
String[] contents= getContentsForTest(3);
|
||||||
|
@ -1512,14 +1510,13 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// typedef int unrelated;
|
// typedef int unrelated;
|
||||||
|
|
||||||
// class unrelated {
|
// class unrelated {
|
||||||
// public: int b;
|
// public: int b;
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// #include "h1.h"
|
// #include "h1.h"
|
||||||
// void test() {
|
// void test() {
|
||||||
// unrelated a;
|
// unrelated a;
|
||||||
|
@ -1546,7 +1543,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// #undef BBB
|
// #undef BBB
|
||||||
|
|
||||||
// #define BBB
|
// #define BBB
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// #ifdef BBB
|
// #ifdef BBB
|
||||||
|
@ -1574,9 +1571,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #define BUG ok
|
// #define BUG ok
|
||||||
|
|
||||||
// int BUG;
|
// int BUG;
|
||||||
|
|
||||||
// #include "common.h"
|
// #include "common.h"
|
||||||
|
@ -1601,7 +1598,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// #include "h2.h"
|
// #include "h2.h"
|
||||||
|
|
||||||
// int BUG;
|
// int BUG;
|
||||||
|
|
||||||
// #define BUG ok
|
// #define BUG ok
|
||||||
|
@ -1625,7 +1622,6 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #include <header.h>
|
// #include <header.h>
|
||||||
// #define _CONCAT(x,y) x##y
|
// #define _CONCAT(x,y) x##y
|
||||||
// #define CONCAT(x,y) _CONCAT(x,y)
|
// #define CONCAT(x,y) _CONCAT(x,y)
|
||||||
|
@ -1638,7 +1634,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "f1/g/source.cpp", contents + "int CONCAT(one, ID);\n");
|
TestSourceReader.createFile(fCProject.getProject(), "f1/g/source.cpp", contents + "int CONCAT(one, ID);\n");
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "f2/g/source.cpp", contents + "int CONCAT(two, ID);\n");
|
TestSourceReader.createFile(fCProject.getProject(), "f2/g/source.cpp", contents + "int CONCAT(two, ID);\n");
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "f1/g/h/source.cpp", contents + "int CONCAT(three, ID);\n");
|
TestSourceReader.createFile(fCProject.getProject(), "f1/g/h/source.cpp", contents + "int CONCAT(three, ID);\n");
|
||||||
|
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
|
@ -1652,7 +1648,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIncludeHeuristicsFlag_Bug213562() throws Exception {
|
public void testIncludeHeuristicsFlag_Bug213562() throws Exception {
|
||||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "f1/header.h", "");
|
TestSourceReader.createFile(fCProject.getProject(), "f1/header.h", "");
|
||||||
|
@ -1673,8 +1669,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #include "dir"
|
// #include "dir"
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
public void testInclusionOfFolders_Bug243682() throws Exception {
|
public void testInclusionOfFolders_Bug243682() throws Exception {
|
||||||
|
@ -1696,9 +1691,8 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
} finally {
|
} finally {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #ifndef B_H
|
// #ifndef B_H
|
||||||
// #include "b.h"
|
// #include "b.h"
|
||||||
// #endif
|
// #endif
|
||||||
|
@ -1760,7 +1754,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// namespace ns {
|
// namespace ns {
|
||||||
// template<typename T> class X {};
|
// template<typename T> class X {};
|
||||||
// }
|
// }
|
||||||
|
@ -1788,8 +1782,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #include "B.cpp"
|
// #include "B.cpp"
|
||||||
|
|
||||||
// static int STATIC;
|
// static int STATIC;
|
||||||
|
@ -1812,9 +1805,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// int a;
|
// int a;
|
||||||
|
|
||||||
// #include "a.h"
|
// #include "a.h"
|
||||||
// void test() {a=0;}
|
// void test() {a=0;}
|
||||||
public void testDeclarationForBinding_Bug254844() throws Exception {
|
public void testDeclarationForBinding_Bug254844() throws Exception {
|
||||||
|
@ -1857,7 +1850,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// int i;
|
// int i;
|
||||||
// };
|
// };
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// #include "a.h"
|
// #include "a.h"
|
||||||
// using ns::A;
|
// using ns::A;
|
||||||
// void test() {
|
// void test() {
|
||||||
|
@ -1870,7 +1863,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// struct A {
|
// struct A {
|
||||||
// int j;
|
// int j;
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// #include "b.h"
|
// #include "b.h"
|
||||||
// void test() {
|
// void test() {
|
||||||
// A a;
|
// A a;
|
||||||
|
@ -1908,14 +1901,14 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// namespace ns {
|
// namespace ns {
|
||||||
// enum E1 { e = 1 };
|
// enum E1 { e = 1 };
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// #include "a.h"
|
// #include "a.h"
|
||||||
// using namespace ns;
|
// using namespace ns;
|
||||||
// int i = e;
|
// int i = e;
|
||||||
|
|
||||||
// // b.h
|
// // b.h
|
||||||
// enum E2 { e = 2 };
|
// enum E2 { e = 2 };
|
||||||
|
|
||||||
// #include "b.h"
|
// #include "b.h"
|
||||||
// int i = e;
|
// int i = e;
|
||||||
public void testDisambiguationByReachability_268704_2() throws Exception {
|
public void testDisambiguationByReachability_268704_2() throws Exception {
|
||||||
|
@ -2016,7 +2009,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
// // header.h
|
// // header.h
|
||||||
// namespace ns2 { class A {}; }
|
// namespace ns2 { class A {}; }
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// namespace ns1 {
|
// namespace ns1 {
|
||||||
// class B : public ns2::A {};
|
// class B : public ns2::A {};
|
||||||
|
@ -2049,7 +2042,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
// // a.h
|
// // a.h
|
||||||
// #undef AAA
|
// #undef AAA
|
||||||
|
|
||||||
// // b.h
|
// // b.h
|
||||||
// #include "a.h"
|
// #include "a.h"
|
||||||
// #define AAA
|
// #define AAA
|
||||||
|
@ -2083,7 +2076,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
// // a.h
|
// // a.h
|
||||||
// #undef AAA
|
// #undef AAA
|
||||||
|
|
||||||
// // b.h
|
// // b.h
|
||||||
// #define AAA
|
// #define AAA
|
||||||
// #include "a.h"
|
// #include "a.h"
|
||||||
|
@ -2153,7 +2146,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// template<typename T> void f(T t) throw (T) {}
|
// template<typename T> void f(T t) throw (T) {}
|
||||||
public void testFunctionTemplateWithThrowsException_293021() throws Exception {
|
public void testFunctionTemplateWithThrowsException_293021() throws Exception {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
|
@ -2176,19 +2169,19 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// // a.h
|
// // a.h
|
||||||
// class P {};
|
// class P {};
|
||||||
|
|
||||||
// // b.h
|
// // b.h
|
||||||
// namespace P {class C {};}
|
// namespace P {class C {};}
|
||||||
|
|
||||||
// // source1.cpp
|
// // source1.cpp
|
||||||
// #include "a.h"
|
// #include "a.h"
|
||||||
// P p;
|
// P p;
|
||||||
|
|
||||||
// // source2.cpp
|
// // source2.cpp
|
||||||
// #include "b.h"
|
// #include "b.h"
|
||||||
// P::C c;
|
// P::C c;
|
||||||
public void testDisambiguateClassVsNamespace_297686() throws Exception {
|
public void testDisambiguateClassVsNamespace_297686() throws Exception {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
|
@ -2221,12 +2214,12 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
// // a.h
|
// // a.h
|
||||||
// struct Error{};
|
// struct Error{};
|
||||||
|
|
||||||
// // b.h
|
// // b.h
|
||||||
// void Error(int errCode) {}
|
// void Error(int errCode) {}
|
||||||
|
|
||||||
// // source1.cpp
|
// // source1.cpp
|
||||||
// #include "a.h"
|
// #include "a.h"
|
||||||
// Error d;
|
// Error d;
|
||||||
|
|
||||||
// // source2.cpp
|
// // source2.cpp
|
||||||
|
@ -2261,7 +2254,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
public void testUpdateNonSrcFolderHeader_283080() throws Exception {
|
public void testUpdateNonSrcFolderHeader_283080() throws Exception {
|
||||||
IIndexBinding[] r;
|
IIndexBinding[] r;
|
||||||
|
|
||||||
final IProject prj = fCProject.getProject();
|
final IProject prj = fCProject.getProject();
|
||||||
final IFolder src= prj.getFolder("src");
|
final IFolder src= prj.getFolder("src");
|
||||||
final IFolder h= prj.getFolder("h");
|
final IFolder h= prj.getFolder("h");
|
||||||
|
@ -2278,7 +2271,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
CCorePlugin.getDefault().setProjectDescription(prj, desc);
|
CCorePlugin.getDefault().setProjectDescription(prj, desc);
|
||||||
TestSourceReader.createFile(h, "a.h", "int version1;");
|
TestSourceReader.createFile(h, "a.h", "int version1;");
|
||||||
waitForIndexer(fCProject);
|
waitForIndexer(fCProject);
|
||||||
|
|
||||||
final IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
final IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
|
@ -2287,7 +2280,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
IFile s= TestSourceReader.createFile(h, "a.h", "int version2;");
|
IFile s= TestSourceReader.createFile(h, "a.h", "int version2;");
|
||||||
waitForIndexer(fCProject);
|
waitForIndexer(fCProject);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
|
@ -2307,7 +2300,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
s= TestSourceReader.createFile(h, "a.h", "int version3;");
|
s= TestSourceReader.createFile(h, "a.h", "int version3;");
|
||||||
waitUntilFileIsIndexed(s, INDEX_WAIT_TIME);
|
waitUntilFileIsIndexed(s, INDEX_WAIT_TIME);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
|
@ -2323,12 +2316,12 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
public void testUpdateForContentTypeChange_283080() throws Exception {
|
public void testUpdateForContentTypeChange_283080() throws Exception {
|
||||||
IIndexBinding[] r;
|
IIndexBinding[] r;
|
||||||
|
|
||||||
final IProject prj = fCProject.getProject();
|
final IProject prj = fCProject.getProject();
|
||||||
IFile file= TestSourceReader.createFile(prj, "a.cpp", "// \u0110 \n int a;");
|
IFile file= TestSourceReader.createFile(prj, "a.cpp", "// \u0110 \n int a;");
|
||||||
file.setCharset("US-ASCII", new NullProgressMonitor());
|
file.setCharset("US-ASCII", new NullProgressMonitor());
|
||||||
waitForIndexer(fCProject);
|
waitForIndexer(fCProject);
|
||||||
|
|
||||||
final IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
final IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
int offset1= 0;
|
int offset1= 0;
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
|
@ -2341,7 +2334,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
file.setCharset("UTF-8", new NullProgressMonitor());
|
file.setCharset("UTF-8", new NullProgressMonitor());
|
||||||
waitForIndexer(fCProject);
|
waitForIndexer(fCProject);
|
||||||
int offset2= 0;
|
int offset2= 0;
|
||||||
|
@ -2355,13 +2348,13 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTrue(offset1 != offset2);
|
assertTrue(offset1 != offset2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUpdateOnFolderRemove_343538() throws Exception {
|
public void testUpdateOnFolderRemove_343538() throws Exception {
|
||||||
IIndexBinding[] r;
|
IIndexBinding[] r;
|
||||||
|
|
||||||
final IProject prj = fCProject.getProject();
|
final IProject prj = fCProject.getProject();
|
||||||
final IFolder root= prj.getFolder("root");
|
final IFolder root= prj.getFolder("root");
|
||||||
root.create(true, false, null);
|
root.create(true, false, null);
|
||||||
|
@ -2376,7 +2369,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
TestSourceReader.createFile(child1, "a.c", "void bug343538() {}");
|
TestSourceReader.createFile(child1, "a.c", "void bug343538() {}");
|
||||||
TestSourceReader.createFile(child2, "b.c", "void bug343538();");
|
TestSourceReader.createFile(child2, "b.c", "void bug343538();");
|
||||||
waitForIndexer(fCProject);
|
waitForIndexer(fCProject);
|
||||||
|
|
||||||
final IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
final IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
|
@ -2387,7 +2380,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect files and folders
|
// Collect files and folders
|
||||||
final Set<IFile> files = new HashSet<IFile>();
|
final Set<IFile> files = new HashSet<IFile>();
|
||||||
final Set<IFolder> folders = new HashSet<IFolder>();
|
final Set<IFolder> folders = new HashSet<IFolder>();
|
||||||
|
@ -2430,5 +2423,4 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -11,18 +11,23 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.pdom.tests;
|
package org.eclipse.cdt.internal.pdom.tests;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||||
import org.eclipse.cdt.core.index.IndexFilter;
|
import org.eclipse.cdt.core.index.IndexFilter;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||||
|
@ -96,7 +101,15 @@ public class CPPFunctionTemplateTests extends PDOMTestBase {
|
||||||
ICPPFunctionTemplate fooX= (ICPPFunctionTemplate) bs[b ? 0 : 1];
|
ICPPFunctionTemplate fooX= (ICPPFunctionTemplate) bs[b ? 0 : 1];
|
||||||
ICPPFunctionTemplate fooAB= (ICPPFunctionTemplate) bs[b ? 1 : 0];
|
ICPPFunctionTemplate fooAB= (ICPPFunctionTemplate) bs[b ? 1 : 0];
|
||||||
|
|
||||||
assertNameCount(pdom, fooX, IIndexFragment.FIND_REFERENCES, 3);
|
List<ICPPTemplateInstance> instances= Arrays.asList(((ICPPInstanceCache) fooX).getAllInstances());
|
||||||
assertNameCount(pdom, fooAB, IIndexFragment.FIND_REFERENCES, 6);
|
assertEquals(3, instances.size());
|
||||||
|
for (ICPPTemplateInstance inst : instances) {
|
||||||
|
assertEquals(1, pdom.findNames(inst, IIndexFragment.FIND_REFERENCES).length);
|
||||||
|
}
|
||||||
|
instances= Arrays.asList(((ICPPInstanceCache) fooAB).getAllInstances());
|
||||||
|
assertEquals(6, instances.size());
|
||||||
|
for (ICPPTemplateInstance inst : instances) {
|
||||||
|
assertEquals(1, pdom.findNames(inst, IIndexFragment.FIND_REFERENCES).length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
bin.includes = fragment.xml,\
|
bin.includes = fragment.xml,\
|
||||||
about.html,\
|
about.html,\
|
||||||
cdt_win32.jar,\
|
.,\
|
||||||
META-INF/
|
META-INF/
|
||||||
src.includes = about.html,\
|
src.includes = about.html,\
|
||||||
library/
|
library/
|
||||||
source.cdt_win32.jar = src/
|
source.. = src/
|
||||||
|
|
|
@ -49,6 +49,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
||||||
|
|
||||||
private IRegion fRegion;
|
private IRegion fRegion;
|
||||||
private long fTimestamp;
|
private long fTimestamp;
|
||||||
|
private int fIndex;
|
||||||
|
|
||||||
public CElementHandle(ICElement parent, int type, String name) {
|
public CElementHandle(ICElement parent, int type, String name) {
|
||||||
fParent= parent;
|
fParent= parent;
|
||||||
|
@ -57,8 +58,8 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
||||||
// undo this here
|
// undo this here
|
||||||
if (name.length() > 0 && name.charAt(0)=='{') {
|
if (name.length() > 0 && name.charAt(0)=='{') {
|
||||||
fName= ""; //$NON-NLS-1$
|
fName= ""; //$NON-NLS-1$
|
||||||
}
|
fIndex= name.hashCode();
|
||||||
else {
|
} else {
|
||||||
fName= name;
|
fName= name;
|
||||||
}
|
}
|
||||||
fRegion= new Region(0,0);
|
fRegion= new Region(0,0);
|
||||||
|
@ -313,6 +314,6 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIndex() {
|
public int getIndex() {
|
||||||
return 0;
|
return fIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,7 +210,14 @@ public abstract class ArrayUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assumes that both arrays contain nulls at the end, only.
|
* Takes contents of the two arrays up to the first <code>null</code> element and concatenates
|
||||||
|
* them.
|
||||||
|
* @param c The type of the element of the returned array if there was not enough free space
|
||||||
|
* in the destination array.
|
||||||
|
* @param dest The destination array. The elements of the source array are added to this array
|
||||||
|
* if there is enough free space in it. May be <code>null</code>.
|
||||||
|
* @param source The source array. May not be <code>null</code>.
|
||||||
|
* @return The concatenated array, which may be the same as the first parameter.
|
||||||
*/
|
*/
|
||||||
public static Object[] addAll(Class<?> c, Object[] dest, Object[] source) {
|
public static Object[] addAll(Class<?> c, Object[] dest, Object[] source) {
|
||||||
if (source == null || source.length == 0)
|
if (source == null || source.length == 0)
|
||||||
|
@ -246,8 +253,12 @@ public abstract class ArrayUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Concatenates two arrays skipping <code>null</code> elements.
|
* Takes contents of the two arrays up to the first <code>null</code> element and concatenates
|
||||||
* Assumes that both arrays contain <code>null</code>s at the end, only.
|
* them.
|
||||||
|
* @param dest The destination array. The elements of the source array are added to this array
|
||||||
|
* if there is enough free space in it. May be <code>null</code>.
|
||||||
|
* @param source The source array. May not be <code>null</code>.
|
||||||
|
* @return The concatenated array, which may be the same as the first parameter.
|
||||||
* @since 5.2
|
* @since 5.2
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -264,7 +275,8 @@ public abstract class ArrayUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dest == null || dest.length == 0) {
|
if (dest == null || dest.length == 0) {
|
||||||
Class<? extends Object> c = dest != null ? dest.getClass().getComponentType() : source.getClass().getComponentType();
|
Class<? extends Object> c = dest != null ?
|
||||||
|
dest.getClass().getComponentType() : source.getClass().getComponentType();
|
||||||
dest = (T[]) Array.newInstance(c, numToAdd);
|
dest = (T[]) Array.newInstance(c, numToAdd);
|
||||||
System.arraycopy(source, 0, dest, 0, numToAdd);
|
System.arraycopy(source, 0, dest, 0, numToAdd);
|
||||||
return dest;
|
return dest;
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -25,7 +25,9 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
* Models a simple declaration.
|
* Models a simple declaration.
|
||||||
*/
|
*/
|
||||||
public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclaration, IASTAmbiguityParent {
|
public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclaration, IASTAmbiguityParent {
|
||||||
|
private IASTDeclarator[] declarators;
|
||||||
|
private int declaratorsPos = -1;
|
||||||
|
private IASTDeclSpecifier declSpecifier;
|
||||||
|
|
||||||
public CASTSimpleDeclaration() {
|
public CASTSimpleDeclaration() {
|
||||||
}
|
}
|
||||||
|
@ -42,7 +44,7 @@ public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclarat
|
||||||
CASTSimpleDeclaration copy = new CASTSimpleDeclaration();
|
CASTSimpleDeclaration copy = new CASTSimpleDeclaration();
|
||||||
copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style));
|
copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style));
|
||||||
|
|
||||||
for(IASTDeclarator declarator : getDeclarators())
|
for (IASTDeclarator declarator : getDeclarators())
|
||||||
copy.addDeclarator(declarator == null ? null : declarator.copy(style));
|
copy.addDeclarator(declarator == null ? null : declarator.copy(style));
|
||||||
|
|
||||||
copy.setOffsetAndLength(this);
|
copy.setOffsetAndLength(this);
|
||||||
|
@ -57,26 +59,21 @@ public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclarat
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTDeclarator[] getDeclarators() {
|
public IASTDeclarator[] getDeclarators() {
|
||||||
if( declarators == null ) return IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
if (declarators == null)
|
||||||
declarators = (IASTDeclarator[]) ArrayUtil.removeNullsAfter( IASTDeclarator.class, declarators, declaratorsPos );
|
return IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
||||||
|
declarators = (IASTDeclarator[]) ArrayUtil.removeNullsAfter(IASTDeclarator.class, declarators, declaratorsPos);
|
||||||
return declarators;
|
return declarators;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDeclarator( IASTDeclarator d ) {
|
public void addDeclarator(IASTDeclarator d) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
d.setParent(this);
|
d.setParent(this);
|
||||||
d.setPropertyInParent(DECLARATOR);
|
d.setPropertyInParent(DECLARATOR);
|
||||||
declarators = (IASTDeclarator[]) ArrayUtil.append( IASTDeclarator.class, declarators, ++declaratorsPos, d );
|
declarators = (IASTDeclarator[]) ArrayUtil.append(IASTDeclarator.class, declarators, ++declaratorsPos, d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private IASTDeclarator [] declarators = null;
|
|
||||||
private int declaratorsPos=-1;
|
|
||||||
private IASTDeclSpecifier declSpecifier;
|
|
||||||
|
|
||||||
|
|
||||||
public void setDeclSpecifier(IASTDeclSpecifier declSpecifier) {
|
public void setDeclSpecifier(IASTDeclSpecifier declSpecifier) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
this.declSpecifier = declSpecifier;
|
this.declSpecifier = declSpecifier;
|
||||||
|
@ -87,25 +84,28 @@ public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclarat
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitDeclarations ){
|
if (action.shouldVisitDeclarations) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( declSpecifier != null ) if( !declSpecifier.accept( action ) ) return false;
|
if (declSpecifier != null && !declSpecifier.accept(action))
|
||||||
IASTDeclarator [] dtors = getDeclarators();
|
return false;
|
||||||
for( int i = 0; i < dtors.length; i++ )
|
IASTDeclarator[] dtors = getDeclarators();
|
||||||
if( !dtors[i].accept( action ) ) return false;
|
for (int i = 0; i < dtors.length; i++) {
|
||||||
|
if (!dtors[i].accept(action))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( action.shouldVisitDeclarations ){
|
if (action.shouldVisitDeclarations) {
|
||||||
switch( action.leave( this ) ){
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -118,8 +118,8 @@ public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclarat
|
||||||
declSpecifier= (IASTDeclSpecifier) other;
|
declSpecifier= (IASTDeclSpecifier) other;
|
||||||
} else {
|
} else {
|
||||||
IASTDeclarator[] declarators = getDeclarators();
|
IASTDeclarator[] declarators = getDeclarators();
|
||||||
for(int i = 0; i < declarators.length; i++) {
|
for (int i = 0; i < declarators.length; i++) {
|
||||||
if(declarators[i] == child) {
|
if (declarators[i] == child) {
|
||||||
declarators[i] = (IASTDeclarator)other;
|
declarators[i] = (IASTDeclarator)other;
|
||||||
other.setParent(child.getParent());
|
other.setParent(child.getParent());
|
||||||
other.setPropertyInParent(child.getPropertyInParent());
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class CASTTypeIdExpression extends ASTNode implements IASTTypeIdExpressio
|
||||||
|
|
||||||
public IType getExpressionType() {
|
public IType getExpressionType() {
|
||||||
if (getOperator() == op_sizeof) {
|
if (getOperator() == op_sizeof) {
|
||||||
return CVisitor.getSize_T(this);
|
return CVisitor.get_SIZE_T(this);
|
||||||
}
|
}
|
||||||
return CVisitor.createType(typeId.getAbstractDeclarator());
|
return CVisitor.createType(typeId.getAbstractDeclarator());
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,9 +107,12 @@ public class CASTUnaryExpression extends ASTNode implements IASTUnaryExpression,
|
||||||
}
|
}
|
||||||
|
|
||||||
public IType getExpressionType() {
|
public IType getExpressionType() {
|
||||||
|
int op = getOperator();
|
||||||
|
if (op == op_sizeof) {
|
||||||
|
return CVisitor.get_SIZE_T(this);
|
||||||
|
}
|
||||||
final IType exprType = getOperand().getExpressionType();
|
final IType exprType = getOperand().getExpressionType();
|
||||||
IType type = CVisitor.unwrapTypedefs(exprType);
|
IType type = CVisitor.unwrapTypedefs(exprType);
|
||||||
int op = getOperator();
|
|
||||||
switch(op) {
|
switch(op) {
|
||||||
case op_star:
|
case op_star:
|
||||||
if (type instanceof IPointerType || type instanceof IArrayType) {
|
if (type instanceof IPointerType || type instanceof IArrayType) {
|
||||||
|
|
|
@ -104,6 +104,11 @@ import org.eclipse.cdt.internal.core.parser.util.ContentAssistMatcherFactory;
|
||||||
* Collection of methods to find information in an AST.
|
* Collection of methods to find information in an AST.
|
||||||
*/
|
*/
|
||||||
public class CVisitor extends ASTQueries {
|
public class CVisitor extends ASTQueries {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final CBasicType UNSIGNED_LONG_INT = new CBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED);
|
||||||
|
|
||||||
public static class CollectProblemsAction extends ASTVisitor {
|
public static class CollectProblemsAction extends ASTVisitor {
|
||||||
{
|
{
|
||||||
shouldVisitDeclarations = true;
|
shouldVisitDeclarations = true;
|
||||||
|
@ -646,19 +651,21 @@ public class CVisitor extends ASTQueries {
|
||||||
|
|
||||||
return new CBasicType(Kind.eInt, 0, expr);
|
return new CBasicType(Kind.eInt, 0, expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static IType getSize_T(IASTExpression expr) {
|
static IType get_SIZE_T(IASTExpression expr) {
|
||||||
IScope scope = getContainingScope(expr);
|
IASTTranslationUnit tu= expr.getTranslationUnit();
|
||||||
IBinding[] bs = scope.find(SIZE_T);
|
if (tu != null) {
|
||||||
for (IBinding b : bs) {
|
IBinding[] bs = tu.getScope().find(SIZE_T);
|
||||||
if (b instanceof IType) {
|
for (IBinding b : bs) {
|
||||||
if (!(b instanceof ICInternalBinding) ||
|
if (b instanceof IType) {
|
||||||
CVisitor.declaredBefore(((ICInternalBinding) b).getPhysicalNode(), expr)) {
|
if (!(b instanceof ICInternalBinding) ||
|
||||||
return (IType) b;
|
CVisitor.declaredBefore(((ICInternalBinding) b).getPhysicalNode(), expr)) {
|
||||||
|
return (IType) b;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new CBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED);
|
return UNSIGNED_LONG_INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static IType unwrapTypedefs(IType type) {
|
static IType unwrapTypedefs(IType type) {
|
||||||
|
|
|
@ -163,7 +163,7 @@ public class CPPTemplateParameterMap implements ICPPTemplateParameterMap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean mergeToExplicit(CPPTemplateParameterMap deducedMap) {
|
public boolean addDeducedArgs(CPPTemplateParameterMap deducedMap) {
|
||||||
Integer[] keys= deducedMap.getAllParameterPositions();
|
Integer[] keys= deducedMap.getAllParameterPositions();
|
||||||
for (Integer key : keys) {
|
for (Integer key : keys) {
|
||||||
Object explicit= fMap.get(key);
|
Object explicit= fMap.get(key);
|
||||||
|
|
|
@ -310,12 +310,13 @@ public class ClassTypeHelper {
|
||||||
/**
|
/**
|
||||||
* Returns methods either declared by the given class or generated by the compiler. Does not
|
* Returns methods either declared by the given class or generated by the compiler. Does not
|
||||||
* include methods declared in base classes.
|
* include methods declared in base classes.
|
||||||
* @param classType
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private static ObjectSet<ICPPMethod> getOwnMethods(ICPPClassType classType) {
|
private static ObjectSet<ICPPMethod> getOwnMethods(ICPPClassType classType) {
|
||||||
ObjectSet<ICPPMethod> set= new ObjectSet<ICPPMethod>(4);
|
ObjectSet<ICPPMethod> set= new ObjectSet<ICPPMethod>(4);
|
||||||
set.addAll(classType.getDeclaredMethods());
|
set.addAll(classType.getDeclaredMethods());
|
||||||
|
if (classType instanceof IProblemBinding) {
|
||||||
|
return set;
|
||||||
|
}
|
||||||
ICPPClassScope scope= (ICPPClassScope) classType.getCompositeScope();
|
ICPPClassScope scope= (ICPPClassScope) classType.getCompositeScope();
|
||||||
set.addAll(scope.getImplicitMethods());
|
set.addAll(scope.getImplicitMethods());
|
||||||
return set;
|
return set;
|
||||||
|
|
|
@ -22,7 +22,6 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
|
@ -56,8 +55,13 @@ class BaseClassLookup {
|
||||||
rootInfo.collectResultForContentAssist(data);
|
rootInfo.collectResultForContentAssist(data);
|
||||||
} else {
|
} else {
|
||||||
hideVirtualBases(rootInfo, infoMap);
|
hideVirtualBases(rootInfo, infoMap);
|
||||||
IBinding[] result= rootInfo.collectResult(data, true, null);
|
IBinding[] result= rootInfo.collectResult(data, true, IBinding.EMPTY_BINDING_ARRAY);
|
||||||
verifyResult(data, result);
|
if (data.problem == null) {
|
||||||
|
data.foundItems = ArrayUtil.addAll((Object[]) data.foundItems, result);
|
||||||
|
} else if (result.length > 0) {
|
||||||
|
data.problem.setCandidateBindings(result);
|
||||||
|
}
|
||||||
|
// verifyResult(data, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +327,7 @@ class BaseClassLookup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding[] collectResult(LookupData data, boolean asVirtualBase, IBinding[] result) {
|
private IBinding[] collectResult(LookupData data, boolean asVirtualBase, IBinding[] result) {
|
||||||
if (asVirtualBase) {
|
if (asVirtualBase) {
|
||||||
if (fHiddenAsVirtualBase)
|
if (fHiddenAsVirtualBase)
|
||||||
return result;
|
return result;
|
||||||
|
@ -337,41 +341,27 @@ class BaseClassLookup {
|
||||||
if (fCollected)
|
if (fCollected)
|
||||||
return result;
|
return result;
|
||||||
fCollected= true;
|
fCollected= true;
|
||||||
|
|
||||||
result= (IBinding[]) ArrayUtil.addAll(IBinding.class, result, fBindings);
|
int numBindingsToAdd = 0;
|
||||||
|
for (int i = 0; i < fBindings.length; i++) {
|
||||||
|
IBinding binding = fBindings[i];
|
||||||
|
if (binding == null)
|
||||||
|
break;
|
||||||
|
if (!ArrayUtil.contains(result, binding))
|
||||||
|
fBindings[numBindingsToAdd++] = binding;
|
||||||
|
}
|
||||||
|
if (numBindingsToAdd < fBindings.length)
|
||||||
|
fBindings[numBindingsToAdd] = null;
|
||||||
|
if (result.length > 0 && numBindingsToAdd > 0 && data.problem == null) {
|
||||||
|
// Matches are found in more than one base class - this is an indication of ambiguity.
|
||||||
|
data.problem= new ProblemBinding(data.astName,
|
||||||
|
IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, result);
|
||||||
|
}
|
||||||
|
result= ArrayUtil.addAll(result, fBindings);
|
||||||
for (int i= 0; i < fChildren.size(); i++) {
|
for (int i= 0; i < fChildren.size(); i++) {
|
||||||
BaseClassLookup child = fChildren.get(i);
|
BaseClassLookup child = fChildren.get(i);
|
||||||
result= child.collectResult(data, fVirtual.get(i), result);
|
result= child.collectResult(data, fVirtual.get(i), result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verifyResult(LookupData data, IBinding[] bindings) {
|
|
||||||
bindings= (IBinding[]) ArrayUtil.trim(IBinding.class, bindings);
|
|
||||||
if (bindings.length == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (data.problem != null) {
|
|
||||||
data.problem.setCandidateBindings(bindings);
|
|
||||||
} else {
|
|
||||||
ICPPClassType uniqueOwner= null;
|
|
||||||
for (IBinding b : bindings) {
|
|
||||||
if (!(b instanceof IType)) {
|
|
||||||
IBinding owner= b.getOwner();
|
|
||||||
if (owner instanceof ICPPClassType) {
|
|
||||||
final ICPPClassType classOwner = (ICPPClassType) owner;
|
|
||||||
if (uniqueOwner == null) {
|
|
||||||
uniqueOwner= classOwner;
|
|
||||||
} else if (!uniqueOwner.isSameType(classOwner)) {
|
|
||||||
data.problem= new ProblemBinding(data.astName,
|
|
||||||
IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, bindings);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data.foundItems = ArrayUtil.addAll(Object.class, (Object[]) data.foundItems, bindings);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -458,16 +458,12 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// explicit function specializations are found via name resolution, need to
|
// Some declarations are found via name resolution (e.g. when using a qualified name),
|
||||||
// add name as definition and check the declaration specifier.
|
// add name as definition and check the declaration specifier.
|
||||||
if (binding instanceof IFunction) {
|
final IASTDeclaration declaration = data.forDeclaration();
|
||||||
if (data.forFunctionDeclaration()) {
|
if (declaration != null) {
|
||||||
IASTNode declaration= data.astName;
|
// Functions
|
||||||
while (declaration instanceof IASTName)
|
if (binding instanceof IFunction) {
|
||||||
declaration= declaration.getParent();
|
|
||||||
while (declaration instanceof IASTDeclarator)
|
|
||||||
declaration= declaration.getParent();
|
|
||||||
|
|
||||||
binding= checkDeclSpecifier(binding, data.astName, declaration);
|
binding= checkDeclSpecifier(binding, data.astName, declaration);
|
||||||
if (!(binding instanceof IProblemBinding)) {
|
if (!(binding instanceof IProblemBinding)) {
|
||||||
if (declaration instanceof ICPPASTFunctionDefinition) {
|
if (declaration instanceof ICPPASTFunctionDefinition) {
|
||||||
|
@ -475,24 +471,17 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// Definitions of static fields.
|
||||||
|
if (binding instanceof ICPPField && data.astName.isDefinition()) {
|
||||||
// Definitions of static fields are found via name resolution, need to add name to
|
if (declaration.getPropertyInParent() != IASTCompositeTypeSpecifier.MEMBER_DECLARATION) {
|
||||||
// the binding to get the right type of arrays that may be declared incomplete.
|
ASTInternal.addDefinition(binding, data.astName);
|
||||||
if (binding instanceof ICPPField && data.astName.isDefinition()) {
|
}
|
||||||
IASTNode declaration= data.astName;
|
|
||||||
while (declaration instanceof IASTName)
|
|
||||||
declaration= declaration.getParent();
|
|
||||||
while (declaration instanceof IASTDeclarator)
|
|
||||||
declaration= declaration.getParent();
|
|
||||||
if (declaration.getPropertyInParent() != IASTCompositeTypeSpecifier.MEMBER_DECLARATION) {
|
|
||||||
ASTInternal.addDefinition(binding, data.astName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're still null...
|
// If we're still null...
|
||||||
if (binding == null) {
|
if (binding == null) {
|
||||||
if (name instanceof ICPPASTQualifiedName && data.forFunctionDeclaration()) {
|
if (name instanceof ICPPASTQualifiedName && declaration != null) {
|
||||||
binding = new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_MEMBER_DECLARATION_NOT_FOUND,
|
binding = new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_MEMBER_DECLARATION_NOT_FOUND,
|
||||||
data.getFoundBindings());
|
data.getFoundBindings());
|
||||||
} else {
|
} else {
|
||||||
|
@ -601,9 +590,7 @@ public class CPPSemantics {
|
||||||
data.forceQualified = true;
|
data.forceQualified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent instanceof ICPPASTFunctionDeclarator) {
|
if (parent instanceof IASTIdExpression) {
|
||||||
data.setFunctionParameters(((ICPPASTFunctionDeclarator) parent).getParameters());
|
|
||||||
} else if (parent instanceof IASTIdExpression) {
|
|
||||||
IASTNode grand= parent.getParent();
|
IASTNode grand= parent.getParent();
|
||||||
while (grand instanceof IASTUnaryExpression
|
while (grand instanceof IASTUnaryExpression
|
||||||
&& ((IASTUnaryExpression) grand).getOperator() == IASTUnaryExpression.op_bracketedPrimary) {
|
&& ((IASTUnaryExpression) grand).getOperator() == IASTUnaryExpression.op_bracketedPrimary) {
|
||||||
|
@ -2276,7 +2263,7 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ICPPFunction[] selectByArgumentCount(LookupData data, ICPPFunction[] functions) throws DOMException {
|
private static ICPPFunction[] selectByArgumentCount(LookupData data, ICPPFunction[] functions) throws DOMException {
|
||||||
assert !data.forFunctionDeclaration();
|
assert data.forDeclaration() == null;
|
||||||
|
|
||||||
int argumentCount = data.getFunctionArgumentCount();
|
int argumentCount = data.getFunctionArgumentCount();
|
||||||
|
|
||||||
|
@ -2328,16 +2315,6 @@ public class CPPSemantics {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isMatchingFunctionDeclaration(ICPPFunction candidate, LookupData data) {
|
|
||||||
IASTNode node = data.astName.getParent();
|
|
||||||
while (node instanceof IASTName)
|
|
||||||
node = node.getParent();
|
|
||||||
if (node instanceof IASTDeclarator) {
|
|
||||||
return isSameFunction(candidate, (IASTDeclarator) node);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static IBinding resolveFunction(LookupData data, ICPPFunction[] fns, boolean allowUDC) throws DOMException {
|
static IBinding resolveFunction(LookupData data, ICPPFunction[] fns, boolean allowUDC) throws DOMException {
|
||||||
fns= (ICPPFunction[]) ArrayUtil.trim(ICPPFunction.class, fns);
|
fns= (ICPPFunction[]) ArrayUtil.trim(ICPPFunction.class, fns);
|
||||||
if (fns == null || fns.length == 0)
|
if (fns == null || fns.length == 0)
|
||||||
|
@ -2348,17 +2325,18 @@ public class CPPSemantics {
|
||||||
if (data.forUsingDeclaration())
|
if (data.forUsingDeclaration())
|
||||||
return new CPPUsingDeclaration(data.astName, fns);
|
return new CPPUsingDeclaration(data.astName, fns);
|
||||||
|
|
||||||
// No arguments to resolve function
|
|
||||||
if (!data.hasFunctionArguments()) {
|
|
||||||
return createFunctionSet(data.astName, fns);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.astName instanceof ICPPASTConversionName) {
|
if (data.astName instanceof ICPPASTConversionName) {
|
||||||
return resolveUserDefinedConversion(data, fns);
|
return resolveUserDefinedConversion(data, fns);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.forFunctionDeclaration())
|
if (data.forDeclaration() != null) {
|
||||||
return resolveFunctionDeclaration(data, fns);
|
return resolveFunctionDeclaration(data, fns);
|
||||||
|
}
|
||||||
|
|
||||||
|
// No arguments to resolve function
|
||||||
|
if (!data.hasFunctionArguments()) {
|
||||||
|
return createFunctionSet(data.astName, fns);
|
||||||
|
}
|
||||||
|
|
||||||
// Reduce our set of candidate functions to only those who have the right number of parameters
|
// Reduce our set of candidate functions to only those who have the right number of parameters
|
||||||
final IType[] argTypes = data.getFunctionArgumentTypes();
|
final IType[] argTypes = data.getFunctionArgumentTypes();
|
||||||
|
@ -2519,38 +2497,77 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called for declarations with qualified name or template-id. Also for explicit function
|
||||||
|
* specializations or instantiations.
|
||||||
|
*/
|
||||||
private static IBinding resolveFunctionDeclaration(LookupData data, ICPPFunction[] fns) throws DOMException {
|
private static IBinding resolveFunctionDeclaration(LookupData data, ICPPFunction[] fns) throws DOMException {
|
||||||
if (data.forExplicitFunctionSpecialization()) {
|
final IASTDeclarator dtor= ASTQueries.findTypeRelevantDeclarator(data.getDeclarator());
|
||||||
fns = CPPTemplates.instantiateForFunctionCall(data.astName,
|
final IType t = CPPVisitor.createType(dtor);
|
||||||
fns,
|
if (!(t instanceof ICPPFunctionType))
|
||||||
Arrays.asList(data.getFunctionArgumentTypes()), Arrays.asList(data.getFunctionArgumentValueCategories()),
|
return null;
|
||||||
data.argsContainImpliedObject);
|
|
||||||
|
final ICPPFunctionType ft= (ICPPFunctionType) t;
|
||||||
|
|
||||||
|
IASTName templateID= data.astName;
|
||||||
|
if (templateID.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_NAME) {
|
||||||
|
templateID= (ICPPASTTemplateId) templateID.getParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 14.5.4 Friends with template ids require instantiation
|
||||||
|
boolean isFriend= CPPVisitor.isFriendDeclaration(data.forDeclaration());
|
||||||
|
if (!data.forExplicitFunctionSpecialization()
|
||||||
|
&& !(isFriend && templateID instanceof ICPPASTTemplateId)) {
|
||||||
|
// Search for a matching function
|
||||||
|
for (ICPPFunction fn : fns) {
|
||||||
|
if (fn != null && !(fn instanceof IProblemBinding) && !(fn instanceof ICPPUnknownBinding)) {
|
||||||
|
if (isSameFunction(fn, dtor)) {
|
||||||
|
return fn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 14.5.4 Friends with qualified ids allow for instantiation
|
||||||
|
if (!data.forExplicitFunctionInstantiation()
|
||||||
|
&& !(isFriend && templateID.getParent() instanceof ICPPASTQualifiedName)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to instantiate a template
|
||||||
|
IASTTranslationUnit tu= data.tu;
|
||||||
|
ICPPTemplateArgument[] tmplArgs= ICPPTemplateArgument.EMPTY_ARGUMENTS;
|
||||||
|
if (templateID instanceof ICPPASTTemplateId) {
|
||||||
|
tmplArgs = CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) templateID);
|
||||||
}
|
}
|
||||||
|
|
||||||
int argCount = data.getFunctionArgumentCount();
|
ICPPFunctionTemplate bestTemplate= null;
|
||||||
if (argCount == 1) {
|
ICPPFunction bestInst= null;
|
||||||
// check for parameter of type void
|
boolean isAmbiguous= false;
|
||||||
final IType[] argTypes = data.getFunctionArgumentTypes();
|
for (ICPPFunction fn : fns) {
|
||||||
if (argTypes.length == 1 && SemanticUtil.isVoidType(argTypes[0])) {
|
if (fn instanceof ICPPFunctionTemplate
|
||||||
argCount= 0;
|
&& !(fn instanceof IProblemBinding) && !(fn instanceof ICPPUnknownBinding)) {
|
||||||
}
|
ICPPFunctionTemplate template= (ICPPFunctionTemplate) fn;
|
||||||
}
|
ICPPFunction inst= CPPTemplates.instantiateForFunctionDeclaration(template, tmplArgs, ft);
|
||||||
|
if (inst != null) {
|
||||||
for (ICPPFunction fn : fns) {
|
int cmp= CPPTemplates.orderFunctionTemplates(bestTemplate, template, TypeSelection.PARAMETERS_AND_RETURN_TYPE);
|
||||||
if (fn != null && !(fn instanceof IProblemBinding) && !(fn instanceof ICPPUnknownBinding)) {
|
if (cmp == 0)
|
||||||
// The index is optimized to provide the function type, avoid using the parameters
|
cmp= compareByRelevance(tu, bestTemplate, template);
|
||||||
// as long as possible.
|
|
||||||
final IType[] parameterTypes = fn.getType().getParameterTypes();
|
if (cmp == 0)
|
||||||
int parCount = parameterTypes.length;
|
isAmbiguous= true;
|
||||||
if (parCount == 1 && SemanticUtil.isVoidType(parameterTypes[0]))
|
|
||||||
parCount= 0;
|
if (cmp < 0) {
|
||||||
|
isAmbiguous= false;
|
||||||
if (parCount == argCount && isMatchingFunctionDeclaration(fn, data)) {
|
bestTemplate= template;
|
||||||
return fn;
|
bestInst= inst;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
}
|
||||||
|
if (isAmbiguous)
|
||||||
|
return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, fns);
|
||||||
|
|
||||||
|
return bestInst;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sortAstBeforeIndex(IFunction[] fns) {
|
public static void sortAstBeforeIndex(IFunction[] fns) {
|
||||||
|
@ -2691,14 +2708,15 @@ public class CPPSemantics {
|
||||||
return new CPPReferenceType(implicitType, false);
|
return new CPPReferenceType(implicitType, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IBinding resolveUserDefinedConversion(LookupData data, IFunction[] fns) {
|
private static IBinding resolveUserDefinedConversion(LookupData data, ICPPFunction[] fns) {
|
||||||
ICPPASTConversionName astName= (ICPPASTConversionName) data.astName;
|
ICPPASTConversionName astName= (ICPPASTConversionName) data.astName;
|
||||||
IType t= CPPVisitor.createType(astName.getTypeId());
|
IType t= CPPVisitor.createType(astName.getTypeId());
|
||||||
if (t instanceof ISemanticProblem) {
|
if (t instanceof ISemanticProblem) {
|
||||||
return new ProblemBinding(astName, IProblemBinding.SEMANTIC_INVALID_TYPE, data.getFoundBindings());
|
return new ProblemBinding(astName, IProblemBinding.SEMANTIC_INVALID_TYPE, data.getFoundBindings());
|
||||||
}
|
}
|
||||||
if (!data.forFunctionDeclaration() || data.forExplicitFunctionSpecialization()) {
|
if (data.forDeclaration() == null ||
|
||||||
CPPTemplates.instantiateConversionTemplates(fns, t);
|
data.forExplicitFunctionSpecialization() || data.forExplicitFunctionInstantiation()) {
|
||||||
|
fns= CPPTemplates.instantiateConversionTemplates(fns, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
IFunction unknown= null;
|
IFunction unknown= null;
|
||||||
|
@ -2896,12 +2914,10 @@ public class CPPSemantics {
|
||||||
final ICPPFunctionTemplate template = (ICPPFunctionTemplate) fn;
|
final ICPPFunctionTemplate template = (ICPPFunctionTemplate) fn;
|
||||||
ICPPFunction inst= CPPTemplates.instantiateForAddressOfFunction(template, (ICPPFunctionType) targetType, name);
|
ICPPFunction inst= CPPTemplates.instantiateForAddressOfFunction(template, (ICPPFunctionType) targetType, name);
|
||||||
if (inst != null) {
|
if (inst != null) {
|
||||||
int cmp= -1;
|
int cmp= CPPTemplates.orderFunctionTemplates(resultTemplate, template, TypeSelection.PARAMETERS_AND_RETURN_TYPE);
|
||||||
if (result != null) {
|
if (cmp == 0)
|
||||||
cmp= CPPTemplates.orderFunctionTemplates(resultTemplate, template, TypeSelection.PARAMETERS_AND_RETURN_TYPE);
|
cmp= compareByRelevance(tu, resultTemplate, template);
|
||||||
if (cmp == 0)
|
|
||||||
cmp= compareByRelevance(tu, resultTemplate, template);
|
|
||||||
}
|
|
||||||
if (cmp == 0)
|
if (cmp == 0)
|
||||||
isAmbiguous= true;
|
isAmbiguous= true;
|
||||||
|
|
||||||
|
@ -3627,7 +3643,9 @@ public class CPPSemantics {
|
||||||
if (templateDecl != null) {
|
if (templateDecl != null) {
|
||||||
|
|
||||||
if (templateDecl instanceof ICPPASTTemplateSpecialization) {
|
if (templateDecl instanceof ICPPASTTemplateSpecialization) {
|
||||||
if (!(function instanceof ICPPSpecialization))
|
if (!(function instanceof ICPPTemplateInstance))
|
||||||
|
return false;
|
||||||
|
if (!((ICPPTemplateInstance) function).isExplicitSpecialization())
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (function instanceof ICPPTemplateDefinition) {
|
if (function instanceof ICPPTemplateDefinition) {
|
||||||
|
@ -3641,7 +3659,7 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
} else if (function instanceof ICPPTemplateDefinition) {
|
} else if (function instanceof ICPPTemplateDefinition) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
declarator= ASTQueries.findTypeRelevantDeclarator(declarator);
|
declarator= ASTQueries.findTypeRelevantDeclarator(declarator);
|
||||||
if (declarator instanceof ICPPASTFunctionDeclarator) {
|
if (declarator instanceof ICPPASTFunctionDeclarator) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
|
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
|
||||||
|
@ -51,6 +52,7 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
||||||
|
@ -706,10 +708,17 @@ public class CPPTemplates {
|
||||||
parentOfName= parentOfName.getParent();
|
parentOfName= parentOfName.getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
return parentOfName instanceof ICPPASTElaboratedTypeSpecifier ||
|
if (parentOfName instanceof ICPPASTElaboratedTypeSpecifier ||
|
||||||
parentOfName instanceof ICPPASTCompositeTypeSpecifier ||
|
parentOfName instanceof ICPPASTCompositeTypeSpecifier ||
|
||||||
parentOfName instanceof ICPPASTNamedTypeSpecifier ||
|
parentOfName instanceof ICPPASTNamedTypeSpecifier ||
|
||||||
parentOfName instanceof ICPPASTBaseSpecifier;
|
parentOfName instanceof ICPPASTBaseSpecifier)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (parentOfName instanceof IASTDeclarator) {
|
||||||
|
IASTDeclarator rel= ASTQueries.findTypeRelevantDeclarator((IASTDeclarator) parentOfName);
|
||||||
|
return !(rel instanceof IASTFunctionDeclarator);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1310,7 +1319,7 @@ public class CPPTemplates {
|
||||||
|
|
||||||
// determine nesting level of parent
|
// determine nesting level of parent
|
||||||
int level= missingTemplateDecls;
|
int level= missingTemplateDecls;
|
||||||
if (!CPPVisitor.isFriendFunctionDeclaration(innerMostTDecl.getDeclaration())) {
|
if (!isFriendFunctionDeclaration(innerMostTDecl.getDeclaration())) {
|
||||||
node= outerMostTDecl.getParent();
|
node= outerMostTDecl.getParent();
|
||||||
while (node != null) {
|
while (node != null) {
|
||||||
if (node instanceof ICPPASTInternalTemplateDeclaration) {
|
if (node instanceof ICPPASTInternalTemplateDeclaration) {
|
||||||
|
@ -1335,6 +1344,23 @@ public class CPPTemplates {
|
||||||
innerMostTDecl.setAssociatedWithLastName(lastIsTemplate);
|
innerMostTDecl.setAssociatedWithLastName(lastIsTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isFriendFunctionDeclaration(IASTDeclaration declaration) {
|
||||||
|
while (declaration instanceof ICPPASTTemplateDeclaration) {
|
||||||
|
declaration= ((ICPPASTTemplateDeclaration) declaration).getDeclaration();
|
||||||
|
}
|
||||||
|
if (declaration instanceof IASTSimpleDeclaration) {
|
||||||
|
IASTSimpleDeclaration sdecl = (IASTSimpleDeclaration) declaration;
|
||||||
|
ICPPASTDeclSpecifier declspec= (ICPPASTDeclSpecifier) sdecl.getDeclSpecifier();
|
||||||
|
if (declspec.isFriend()) {
|
||||||
|
IASTDeclarator[] dtors= sdecl.getDeclarators();
|
||||||
|
if (dtors.length == 1 && ASTQueries.findTypeRelevantDeclarator(dtors[0]) instanceof IASTFunctionDeclarator) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private static CharArraySet collectTemplateParameterNames(ICPPASTTemplateDeclaration tdecl) {
|
private static CharArraySet collectTemplateParameterNames(ICPPASTTemplateDeclaration tdecl) {
|
||||||
CharArraySet set= new CharArraySet(4);
|
CharArraySet set= new CharArraySet(4);
|
||||||
while(true) {
|
while(true) {
|
||||||
|
@ -1628,24 +1654,30 @@ public class CPPTemplates {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void instantiateConversionTemplates(IFunction[] functions, IType conversionType) {
|
/**
|
||||||
|
* 14.8.2.3 Deducing conversion function template arguments
|
||||||
|
*/
|
||||||
|
static ICPPFunction[] instantiateConversionTemplates(ICPPFunction[] functions, IType conversionType) {
|
||||||
boolean checkedForDependentType= false;
|
boolean checkedForDependentType= false;
|
||||||
for (int i = 0; i < functions.length; i++) {
|
ICPPFunction[] result= functions;
|
||||||
IFunction func = functions[i];
|
int i=0;
|
||||||
if (func instanceof ICPPFunctionTemplate) {
|
boolean done= false;
|
||||||
ICPPFunctionTemplate template= (ICPPFunctionTemplate) func;
|
for (ICPPFunction f : functions) {
|
||||||
functions[i]= null;
|
ICPPFunction inst = f;
|
||||||
|
if (f instanceof ICPPFunctionTemplate) {
|
||||||
|
ICPPFunctionTemplate template= (ICPPFunctionTemplate) f;
|
||||||
|
inst= null;
|
||||||
|
|
||||||
// extract template arguments and parameter types.
|
// Extract template arguments and parameter types.
|
||||||
if (!checkedForDependentType) {
|
if (!checkedForDependentType) {
|
||||||
try {
|
try {
|
||||||
if (isDependentType(conversionType)) {
|
if (isDependentType(conversionType)) {
|
||||||
functions[i]= CPPUnknownFunction.createForSample(template);
|
inst= CPPUnknownFunction.createForSample(template);
|
||||||
return;
|
done= true;
|
||||||
}
|
}
|
||||||
checkedForDependentType= true;
|
checkedForDependentType= true;
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
return;
|
return functions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CPPTemplateParameterMap map= new CPPTemplateParameterMap(1);
|
CPPTemplateParameterMap map= new CPPTemplateParameterMap(1);
|
||||||
|
@ -1653,16 +1685,48 @@ public class CPPTemplates {
|
||||||
ICPPTemplateArgument[] args= TemplateArgumentDeduction.deduceForConversion(template, conversionType, map);
|
ICPPTemplateArgument[] args= TemplateArgumentDeduction.deduceForConversion(template, conversionType, map);
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
IBinding instance= instantiateFunctionTemplate(template, args, map);
|
IBinding instance= instantiateFunctionTemplate(template, args, map);
|
||||||
if (instance instanceof IFunction) {
|
if (instance instanceof ICPPFunction) {
|
||||||
functions[i]= (IFunction) instance;
|
inst= (ICPPFunction) instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
// try next candidate
|
// try next candidate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (result != functions || f != inst) {
|
||||||
|
if (result == functions) {
|
||||||
|
result= new ICPPFunction[functions.length];
|
||||||
|
System.arraycopy(functions, 0, result, 0, i);
|
||||||
|
}
|
||||||
|
result[i++]= inst;
|
||||||
|
}
|
||||||
|
if (done)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 14.8.2.6 Deducing template arguments from a function declaration
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
static ICPPFunction instantiateForFunctionDeclaration(ICPPFunctionTemplate template,
|
||||||
|
ICPPTemplateArgument[] args, ICPPFunctionType functionType) {
|
||||||
|
CPPTemplateParameterMap map= new CPPTemplateParameterMap(1);
|
||||||
|
try {
|
||||||
|
args= TemplateArgumentDeduction.deduceForDeclaration(template, args, functionType, map);
|
||||||
|
if (args != null) {
|
||||||
|
IBinding instance= instantiateFunctionTemplate(template, args, map);
|
||||||
|
if (instance instanceof ICPPFunction) {
|
||||||
|
return (ICPPFunction) instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (DOMException e) {
|
||||||
|
// try next candidate
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 14.8.2.2 Deducing template arguments taking the address of a function template [temp.deduct.funcaddr]
|
* 14.8.2.2 Deducing template arguments taking the address of a function template [temp.deduct.funcaddr]
|
||||||
|
@ -1702,6 +1766,13 @@ public class CPPTemplates {
|
||||||
// 14.5.6.2 Partial ordering of function templates
|
// 14.5.6.2 Partial ordering of function templates
|
||||||
static int orderFunctionTemplates(ICPPFunctionTemplate f1, ICPPFunctionTemplate f2, TypeSelection mode)
|
static int orderFunctionTemplates(ICPPFunctionTemplate f1, ICPPFunctionTemplate f2, TypeSelection mode)
|
||||||
throws DOMException {
|
throws DOMException {
|
||||||
|
if (f1 == f2)
|
||||||
|
return 0;
|
||||||
|
if (f1 == null)
|
||||||
|
return -1;
|
||||||
|
if (f2 == null)
|
||||||
|
return 1;
|
||||||
|
|
||||||
int s1 = compareSpecialization(f1, f2, mode);
|
int s1 = compareSpecialization(f1, f2, mode);
|
||||||
int s2 = compareSpecialization(f2, f1, mode);
|
int s2 = compareSpecialization(f2, f1, mode);
|
||||||
|
|
||||||
|
|
|
@ -137,6 +137,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||||
|
@ -195,12 +196,15 @@ import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||||
* Collection of methods to extract information from a C++ translation unit.
|
* Collection of methods to extract information from a C++ translation unit.
|
||||||
*/
|
*/
|
||||||
public class CPPVisitor extends ASTQueries {
|
public class CPPVisitor extends ASTQueries {
|
||||||
public static final char[] SIZE_T = "size_t".toCharArray(); //$NON-NLS-1$
|
private static final CPPBasicType UNSIGNED_LONG = new CPPBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED);
|
||||||
public static final char[] PTRDIFF_T = "ptrdiff_t".toCharArray(); //$NON-NLS-1$
|
private static final CPPBasicType INT_TYPE = new CPPBasicType(Kind.eInt, 0);
|
||||||
|
|
||||||
static final char[] BEGIN = "begin".toCharArray(); //$NON-NLS-1$
|
static final char[] BEGIN = "begin".toCharArray(); //$NON-NLS-1$
|
||||||
public static final String STD = "std"; //$NON-NLS-1$
|
static final String STD = "std"; //$NON-NLS-1$
|
||||||
public static final String TYPE_INFO= "type_info"; //$NON-NLS-1$
|
private static final char[] SIZE_T = "size_t".toCharArray(); //$NON-NLS-1$
|
||||||
private static final String INITIALIZER_LIST = "initializer_list"; //$NON-NLS-1$
|
private static final char[] PTRDIFF_T = "ptrdiff_t".toCharArray(); //$NON-NLS-1$
|
||||||
|
private static final char[] TYPE_INFO= "type_info".toCharArray(); //$NON-NLS-1$
|
||||||
|
private static final char[] INITIALIZER_LIST = "initializer_list".toCharArray(); //$NON-NLS-1$
|
||||||
|
|
||||||
// Thread-local set of DeclSpecifiers for which auto types are being created.
|
// Thread-local set of DeclSpecifiers for which auto types are being created.
|
||||||
// Used to prevent infinite recursion while processing invalid self-referencing
|
// Used to prevent infinite recursion while processing invalid self-referencing
|
||||||
|
@ -633,13 +637,7 @@ public class CPPVisitor extends ASTQueries {
|
||||||
boolean isFriendDecl= false;
|
boolean isFriendDecl= false;
|
||||||
ICPPScope scope = (ICPPScope) getContainingNonTemplateScope(name);
|
ICPPScope scope = (ICPPScope) getContainingNonTemplateScope(name);
|
||||||
if (scope instanceof ICPPClassScope) {
|
if (scope instanceof ICPPClassScope) {
|
||||||
if (parent instanceof IASTSimpleDeclaration) {
|
isFriendDecl = isFriendDeclaration(parent);
|
||||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration) parent).getDeclSpecifier();
|
|
||||||
isFriendDecl= declSpec.isFriend();
|
|
||||||
} else if (parent instanceof IASTFunctionDefinition) {
|
|
||||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition) parent).getDeclSpecifier();
|
|
||||||
isFriendDecl= declSpec.isFriend();
|
|
||||||
}
|
|
||||||
if (isFriendDecl) {
|
if (isFriendDecl) {
|
||||||
try {
|
try {
|
||||||
while (scope.getKind() == EScopeKind.eClassType) {
|
while (scope.getKind() == EScopeKind.eClassType) {
|
||||||
|
@ -753,6 +751,18 @@ public class CPPVisitor extends ASTQueries {
|
||||||
return binding;
|
return binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isFriendDeclaration(IASTNode decl) {
|
||||||
|
IASTDeclSpecifier declSpec;
|
||||||
|
if (decl instanceof IASTSimpleDeclaration) {
|
||||||
|
declSpec = ((IASTSimpleDeclaration) decl).getDeclSpecifier();
|
||||||
|
} else if (decl instanceof IASTFunctionDefinition) {
|
||||||
|
declSpec = ((IASTFunctionDefinition) decl).getDeclSpecifier();
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return declSpec instanceof ICPPASTDeclSpecifier && ((ICPPASTDeclSpecifier) declSpec).isFriend();
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isConstructor(IScope containingScope, IASTDeclarator declarator) {
|
public static boolean isConstructor(IScope containingScope, IASTDeclarator declarator) {
|
||||||
if (containingScope == null || !(containingScope instanceof ICPPClassScope))
|
if (containingScope == null || !(containingScope instanceof ICPPClassScope))
|
||||||
return false;
|
return false;
|
||||||
|
@ -2085,53 +2095,21 @@ public class CPPVisitor extends ASTQueries {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IType getPointerDiffType(final IASTBinaryExpression binary) {
|
public static IType getPointerDiffType(final IASTBinaryExpression binary) {
|
||||||
CPPBasicType basicType;
|
IType t= getStdType(binary, PTRDIFF_T);
|
||||||
IScope scope = getContainingScope(binary);
|
return t != null ? t : INT_TYPE;
|
||||||
IBinding[] bs= CPPSemantics.findBindings(scope, PTRDIFF_T, false, binary);
|
|
||||||
if (bs.length > 0) {
|
|
||||||
for (IBinding b : bs) {
|
|
||||||
if (b instanceof IType && CPPSemantics.declaredBefore(b, binary, false)) {
|
|
||||||
return (IType) b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
basicType= new CPPBasicType(Kind.eInt, 0);
|
|
||||||
basicType.setFromExpression(binary);
|
|
||||||
return basicType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IType get_type_info(IASTExpression expression) {
|
private static IType getStdType(final IASTNode node, char[] name) {
|
||||||
IBinding[] std= expression.getTranslationUnit().getScope().find(STD);
|
|
||||||
for (IBinding binding : std) {
|
|
||||||
if (binding instanceof ICPPNamespace) {
|
|
||||||
IBinding[] typeInfo= ((ICPPNamespace) binding).getNamespaceScope().find(TYPE_INFO);
|
|
||||||
for (IBinding t : typeInfo) {
|
|
||||||
if (t instanceof ICPPClassType) {
|
|
||||||
return (ICPPClassType) t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new CPPBasicType(Kind.eInt, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IType get_SIZE_T(IASTNode sizeofExpr) {
|
|
||||||
IScope scope = getContainingScope(sizeofExpr);
|
|
||||||
IBinding[] bs = CPPSemantics.findBindings(scope, SIZE_T, false, sizeofExpr);
|
|
||||||
if (bs.length > 0 && bs[0] instanceof IType) {
|
|
||||||
return (IType) bs[0];
|
|
||||||
}
|
|
||||||
return new CPPBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ICPPClassTemplate get_initializer_list(IASTNode node) {
|
|
||||||
IBinding[] std= node.getTranslationUnit().getScope().find(STD);
|
IBinding[] std= node.getTranslationUnit().getScope().find(STD);
|
||||||
for (IBinding binding : std) {
|
for (IBinding binding : std) {
|
||||||
if (binding instanceof ICPPNamespace) {
|
if (binding instanceof ICPPNamespace) {
|
||||||
IBinding[] initializer_list= ((ICPPNamespace) binding).getNamespaceScope().find(INITIALIZER_LIST);
|
final ICPPNamespaceScope scope = ((ICPPNamespace) binding).getNamespaceScope();
|
||||||
for (IBinding t : initializer_list) {
|
IBinding[] bs= CPPSemantics.findBindings(scope, name, false, node);
|
||||||
if (t instanceof ICPPClassTemplate) {
|
if (bs.length > 0) {
|
||||||
return (ICPPClassTemplate) t;
|
for (IBinding b : bs) {
|
||||||
|
if (b instanceof IType && CPPSemantics.declaredBefore(b, node, false)) {
|
||||||
|
return (IType) b;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2139,6 +2117,23 @@ public class CPPVisitor extends ASTQueries {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IType get_type_info(IASTExpression expression) {
|
||||||
|
IType t= getStdType(expression, TYPE_INFO);
|
||||||
|
return t != null ? t : INT_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IType get_SIZE_T(IASTNode sizeofExpr) {
|
||||||
|
IType t= getStdType(sizeofExpr, SIZE_T);
|
||||||
|
return t != null ? t : UNSIGNED_LONG;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ICPPClassTemplate get_initializer_list(IASTNode node) {
|
||||||
|
IType t= getStdType(node, INITIALIZER_LIST);
|
||||||
|
if (t instanceof ICPPClassTemplate)
|
||||||
|
return (ICPPClassTemplate) t;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static IASTProblem[] getProblems(IASTTranslationUnit tu) {
|
public static IASTProblem[] getProblems(IASTTranslationUnit tu) {
|
||||||
CollectProblemsAction action = new CollectProblemsAction();
|
CollectProblemsAction action = new CollectProblemsAction();
|
||||||
tu.accept(action);
|
tu.accept(action);
|
||||||
|
@ -2340,7 +2335,6 @@ public class CPPVisitor extends ASTQueries {
|
||||||
*/
|
*/
|
||||||
public static IBinding findDeclarationOwner(IASTNode node, boolean allowFunction) {
|
public static IBinding findDeclarationOwner(IASTNode node, boolean allowFunction) {
|
||||||
// Search for declaration
|
// Search for declaration
|
||||||
boolean isFriend= false;
|
|
||||||
boolean isNonSimpleElabDecl= false;
|
boolean isNonSimpleElabDecl= false;
|
||||||
while (!(node instanceof IASTDeclaration)) {
|
while (!(node instanceof IASTDeclaration)) {
|
||||||
if (node == null)
|
if (node == null)
|
||||||
|
@ -2360,19 +2354,7 @@ public class CPPVisitor extends ASTQueries {
|
||||||
node= node.getParent();
|
node= node.getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node instanceof IASTSimpleDeclaration) {
|
boolean isFriend= isFriendDeclaration(node);
|
||||||
final IASTSimpleDeclaration sdecl = (IASTSimpleDeclaration) node;
|
|
||||||
ICPPASTDeclSpecifier declSpec= (ICPPASTDeclSpecifier) sdecl.getDeclSpecifier();
|
|
||||||
if (declSpec.isFriend()) {
|
|
||||||
isFriend= true;
|
|
||||||
}
|
|
||||||
} else if (node instanceof IASTFunctionDefinition) {
|
|
||||||
IASTFunctionDefinition funcDefinition = (IASTFunctionDefinition) node;
|
|
||||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) funcDefinition.getDeclSpecifier();
|
|
||||||
if (declSpec.isFriend()) {
|
|
||||||
isFriend= true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search for enclosing binding
|
// Search for enclosing binding
|
||||||
IASTName name= null;
|
IASTName name= null;
|
||||||
|
@ -2409,26 +2391,6 @@ public class CPPVisitor extends ASTQueries {
|
||||||
return name.resolveBinding();
|
return name.resolveBinding();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check whether a given declaration is a friend function declaration.
|
|
||||||
*/
|
|
||||||
public static boolean isFriendFunctionDeclaration(IASTDeclaration declaration) {
|
|
||||||
while (declaration instanceof ICPPASTTemplateDeclaration) {
|
|
||||||
declaration= ((ICPPASTTemplateDeclaration) declaration).getDeclaration();
|
|
||||||
}
|
|
||||||
if (declaration instanceof IASTSimpleDeclaration) {
|
|
||||||
IASTSimpleDeclaration sdecl = (IASTSimpleDeclaration) declaration;
|
|
||||||
ICPPASTDeclSpecifier declspec= (ICPPASTDeclSpecifier) sdecl.getDeclSpecifier();
|
|
||||||
if (declspec.isFriend()) {
|
|
||||||
IASTDeclarator[] dtors= sdecl.getDeclarators();
|
|
||||||
if (dtors.length == 1 && findTypeRelevantDeclarator(dtors[0]) instanceof IASTFunctionDeclarator) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean doesNotSpecifyType(IASTDeclSpecifier declspec) {
|
public static boolean doesNotSpecifyType(IASTDeclSpecifier declspec) {
|
||||||
if (declspec instanceof ICPPASTSimpleDeclSpecifier) {
|
if (declspec instanceof ICPPASTSimpleDeclSpecifier) {
|
||||||
ICPPASTSimpleDeclSpecifier ds= (ICPPASTSimpleDeclSpecifier) declspec;
|
ICPPASTSimpleDeclSpecifier ds= (ICPPASTSimpleDeclSpecifier) declspec;
|
||||||
|
|
|
@ -684,10 +684,11 @@ public class Conversions {
|
||||||
|
|
||||||
final IType uqSource= getNestedType(source, TDEF | REF | CVTYPE);
|
final IType uqSource= getNestedType(source, TDEF | REF | CVTYPE);
|
||||||
if (uqSource instanceof ICPPClassType) {
|
if (uqSource instanceof ICPPClassType) {
|
||||||
ICPPMethod[] ops = SemanticUtil.getConversionOperators((ICPPClassType) uqSource);
|
ICPPFunction[] ops = SemanticUtil.getConversionOperators((ICPPClassType) uqSource);
|
||||||
CPPTemplates.instantiateConversionTemplates(ops, t);
|
ops= CPPTemplates.instantiateConversionTemplates(ops, t);
|
||||||
for (final ICPPMethod op : ops) {
|
for (final ICPPFunction f : ops) {
|
||||||
if (op != null && !(op instanceof IProblemBinding)) {
|
if (f instanceof ICPPMethod && !(f instanceof IProblemBinding)) {
|
||||||
|
ICPPMethod op= (ICPPMethod) f;
|
||||||
if (op.isExplicit())
|
if (op.isExplicit())
|
||||||
continue;
|
continue;
|
||||||
final IType returnType = op.getType().getReturnType();
|
final IType returnType = op.getType().getReturnType();
|
||||||
|
@ -733,12 +734,13 @@ public class Conversions {
|
||||||
c.setDeferredUDC(DeferredUDC.INIT_BY_CONVERSION);
|
c.setDeferredUDC(DeferredUDC.INIT_BY_CONVERSION);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
ICPPMethod[] ops = SemanticUtil.getConversionOperators(uqSource);
|
ICPPFunction[] ops = SemanticUtil.getConversionOperators(uqSource);
|
||||||
CPPTemplates.instantiateConversionTemplates(ops, target);
|
ops= CPPTemplates.instantiateConversionTemplates(ops, target);
|
||||||
FunctionCost cost1= null;
|
FunctionCost cost1= null;
|
||||||
Cost cost2= null;
|
Cost cost2= null;
|
||||||
for (final ICPPMethod op : ops) {
|
for (final ICPPFunction f : ops) {
|
||||||
if (op != null && !(op instanceof IProblemBinding)) {
|
if (f instanceof ICPPMethod && !(f instanceof IProblemBinding)) {
|
||||||
|
ICPPMethod op= (ICPPMethod) f;
|
||||||
final boolean isExplicitConversion= op.isExplicit();
|
final boolean isExplicitConversion= op.isExplicit();
|
||||||
if (isExplicitConversion /** && !direct **/)
|
if (isExplicitConversion /** && !direct **/)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromReturnType;
|
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getSimplifiedType;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getSimplifiedType;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -53,7 +52,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||||
|
@ -69,7 +67,6 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPCompositeBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPCompositeBinding;
|
||||||
|
@ -103,7 +100,6 @@ public class LookupData {
|
||||||
/** In list-initialization **/
|
/** In list-initialization **/
|
||||||
public boolean fNoNarrowing= false;
|
public boolean fNoNarrowing= false;
|
||||||
|
|
||||||
private ICPPASTParameterDeclaration[] functionParameters;
|
|
||||||
private IASTInitializerClause[] functionArgs;
|
private IASTInitializerClause[] functionArgs;
|
||||||
private IType[] functionArgTypes;
|
private IType[] functionArgTypes;
|
||||||
private ValueCategory[] functionArgValueCategories;
|
private ValueCategory[] functionArgValueCategories;
|
||||||
|
@ -171,81 +167,58 @@ public class LookupData {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean forFunctionDeclaration() {
|
/**
|
||||||
if (astName == null) return false;
|
* Returns whether the name belongs to a simple declaration or function definition.
|
||||||
if (astName.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY) return false;
|
*/
|
||||||
|
public IASTDeclaration forDeclaration() {
|
||||||
|
IASTNode node = getDeclarator();
|
||||||
|
|
||||||
|
while (node instanceof IASTDeclarator)
|
||||||
|
node= node.getParent();
|
||||||
|
|
||||||
|
if (node instanceof IASTSimpleDeclaration || node instanceof IASTFunctionDefinition)
|
||||||
|
return (IASTDeclaration) node;
|
||||||
|
|
||||||
IASTName n = astName;
|
return null;
|
||||||
if (n.getParent() instanceof ICPPASTTemplateId)
|
}
|
||||||
n = (IASTName) n.getParent();
|
|
||||||
IASTNode p1 = n.getParent();
|
public IASTDeclarator getDeclarator() {
|
||||||
if (p1 instanceof ICPPASTQualifiedName) {
|
IASTName name= astName;
|
||||||
if (((ICPPASTQualifiedName) p1).getLastName() != n)
|
if (name == null || name.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY)
|
||||||
return false;
|
return null;
|
||||||
p1 = p1.getParent();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p1 instanceof IASTDeclarator) {
|
if (name.getParent() instanceof ICPPASTTemplateId)
|
||||||
IASTNode p2= ASTQueries.findOutermostDeclarator((IASTDeclarator) p1).getParent();
|
name= (IASTName) name.getParent();
|
||||||
if (p2 instanceof IASTSimpleDeclaration) {
|
|
||||||
if (p2.getParent() instanceof ICPPASTExplicitTemplateInstantiation)
|
IASTNode node= name.getParent();
|
||||||
return false;
|
if (node instanceof ICPPASTQualifiedName) {
|
||||||
if (astName instanceof ICPPASTTemplateId &&
|
if (((ICPPASTQualifiedName) node).getLastName() != name)
|
||||||
((ICPPASTDeclSpecifier)((IASTSimpleDeclaration) p2).getDeclSpecifier()).isFriend())
|
return null;
|
||||||
return false;
|
node = node.getParent();
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return p2 instanceof IASTFunctionDefinition;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
if (node instanceof IASTDeclarator)
|
||||||
|
return (IASTDeclarator) node;
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean forExplicitFunctionSpecialization() {
|
public boolean forExplicitFunctionSpecialization() {
|
||||||
if (astName == null) return false;
|
IASTDeclaration decl= forDeclaration();
|
||||||
if (astName.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY) return false;
|
if (decl != null) {
|
||||||
|
IASTName n = astName;
|
||||||
IASTName n = astName;
|
if (n.getParent() instanceof ICPPASTTemplateId)
|
||||||
if (n.getParent() instanceof ICPPASTTemplateId)
|
n = (IASTName) n.getParent();
|
||||||
n = (IASTName) n.getParent();
|
|
||||||
IASTNode p1 = n.getParent();
|
ICPPASTTemplateDeclaration tmplDecl = CPPTemplates.getTemplateDeclaration(n);
|
||||||
if (p1 instanceof ICPPASTQualifiedName) {
|
return tmplDecl instanceof ICPPASTTemplateSpecialization;
|
||||||
if (((ICPPASTQualifiedName) p1).getLastName() != n)
|
|
||||||
return false;
|
|
||||||
p1 = p1.getParent();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p1 instanceof IASTDeclarator) {
|
|
||||||
IASTNode p2= ASTQueries.findOutermostDeclarator((IASTDeclarator) p1).getParent();
|
|
||||||
if (p2 instanceof IASTSimpleDeclaration || p2 instanceof IASTFunctionDefinition) {
|
|
||||||
ICPPASTTemplateDeclaration tmplDecl = CPPTemplates.getTemplateDeclaration(n);
|
|
||||||
return tmplDecl instanceof ICPPASTTemplateSpecialization;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean forExplicitFunctionInstantiation() {
|
public boolean forExplicitFunctionInstantiation() {
|
||||||
if (astName == null) return false;
|
IASTDeclaration decl= forDeclaration();
|
||||||
if (astName.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY) return false;
|
return decl != null && decl.getParent() instanceof ICPPASTExplicitTemplateInstantiation;
|
||||||
|
|
||||||
IASTName n = astName;
|
|
||||||
if (n.getParent() instanceof ICPPASTTemplateId)
|
|
||||||
n = (IASTName) n.getParent();
|
|
||||||
IASTNode p1 = n.getParent();
|
|
||||||
if (p1 instanceof ICPPASTQualifiedName) {
|
|
||||||
if (((ICPPASTQualifiedName) p1).getLastName() != n)
|
|
||||||
return false;
|
|
||||||
p1 = p1.getParent();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p1 instanceof IASTDeclarator) {
|
|
||||||
IASTNode p2= ASTQueries.findOutermostDeclarator((IASTDeclarator) p1).getParent();
|
|
||||||
if (p2 instanceof IASTDeclaration) {
|
|
||||||
return p2.getParent() instanceof ICPPASTExplicitTemplateInstantiation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean qualified() {
|
public boolean qualified() {
|
||||||
|
@ -414,14 +387,6 @@ public class LookupData {
|
||||||
}
|
}
|
||||||
return CPPVisitor.getImpliedObjectType(scope);
|
return CPPVisitor.getImpliedObjectType(scope);
|
||||||
}
|
}
|
||||||
if (prop == IASTDeclarator.DECLARATOR_NAME) {
|
|
||||||
if (forExplicitFunctionInstantiation()) {
|
|
||||||
IScope scope = CPPVisitor.getContainingScope(astName);
|
|
||||||
if (scope instanceof ICPPClassScope) {
|
|
||||||
return ((ICPPClassScope) scope).getClassType();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,13 +456,7 @@ public class LookupData {
|
||||||
return false;
|
return false;
|
||||||
if (p instanceof IASTDeclaration) {
|
if (p instanceof IASTDeclaration) {
|
||||||
if (prop == IASTCompositeTypeSpecifier.MEMBER_DECLARATION) {
|
if (prop == IASTCompositeTypeSpecifier.MEMBER_DECLARATION) {
|
||||||
if (p instanceof IASTSimpleDeclaration) {
|
return CPPVisitor.isFriendDeclaration(p);
|
||||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration) p).getDeclSpecifier();
|
|
||||||
return declSpec.isFriend();
|
|
||||||
} else if (p instanceof IASTFunctionDefinition) {
|
|
||||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition) p).getDeclSpecifier();
|
|
||||||
return declSpec.isFriend();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -547,14 +506,7 @@ public class LookupData {
|
||||||
functionArgTypes[i]= new InitializerListType((ICPPASTInitializerList) e);
|
functionArgTypes[i]= new InitializerListType((ICPPASTInitializerList) e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (functionParameters != null) {
|
}
|
||||||
ICPPASTParameterDeclaration[] pdecls= functionParameters;
|
|
||||||
functionArgTypes= new IType[pdecls.length];
|
|
||||||
for (int i = 0; i < pdecls.length; i++) {
|
|
||||||
functionArgTypes[i] = SemanticUtil.getSimplifiedType(CPPVisitor.createType(
|
|
||||||
pdecls[i], true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return functionArgTypes;
|
return functionArgTypes;
|
||||||
}
|
}
|
||||||
|
@ -570,36 +522,19 @@ public class LookupData {
|
||||||
functionArgValueCategories[i] = ExpressionTypes.valueCat((IASTExpression) arg);
|
functionArgValueCategories[i] = ExpressionTypes.valueCat((IASTExpression) arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
IType[] argTypes= getFunctionArgumentTypes();
|
|
||||||
if (argTypes != null) {
|
|
||||||
functionArgValueCategories= new ValueCategory[argTypes.length];
|
|
||||||
for (int i = 0; i < argTypes.length; i++) {
|
|
||||||
IType t= argTypes[i];
|
|
||||||
functionArgValueCategories[i]= valueCategoryFromReturnType(t);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
functionArgValueCategories= new ValueCategory[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return functionArgValueCategories;
|
return functionArgValueCategories;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFunctionParameters(ICPPASTParameterDeclaration[] parameters) {
|
|
||||||
functionParameters= parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFunctionArgumentCount() {
|
public int getFunctionArgumentCount() {
|
||||||
if (functionArgs != null)
|
if (functionArgs != null)
|
||||||
return functionArgs.length;
|
return functionArgs.length;
|
||||||
if (functionParameters != null)
|
|
||||||
return functionParameters.length;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasFunctionArguments() {
|
public boolean hasFunctionArguments() {
|
||||||
return functionArgs != null || functionParameters != null;
|
return functionArgs != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding[] getFoundBindings() {
|
public IBinding[] getFoundBindings() {
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||||
|
@ -67,181 +68,16 @@ public class TemplateArgumentDeduction {
|
||||||
static ICPPTemplateArgument[] deduceForFunctionCall(ICPPFunctionTemplate template,
|
static ICPPTemplateArgument[] deduceForFunctionCall(ICPPFunctionTemplate template,
|
||||||
ICPPTemplateArgument[] tmplArgs, List<IType> fnArgs, List<ValueCategory> argIsLValue, CPPTemplateParameterMap map)
|
ICPPTemplateArgument[] tmplArgs, List<IType> fnArgs, List<ValueCategory> argIsLValue, CPPTemplateParameterMap map)
|
||||||
throws DOMException {
|
throws DOMException {
|
||||||
|
|
||||||
final ICPPTemplateParameter[] tmplParams = template.getTemplateParameters();
|
final ICPPTemplateParameter[] tmplParams = template.getTemplateParameters();
|
||||||
final int numTmplParams = tmplParams.length;
|
|
||||||
final int numTmplArgs = tmplArgs.length;
|
|
||||||
|
|
||||||
tmplArgs= SemanticUtil.getSimplifiedArguments(tmplArgs);
|
if (!addExplicitArguments(tmplParams, tmplArgs, map))
|
||||||
ICPPTemplateParameter tmplParam= null;
|
return null;
|
||||||
int packOffset= -1;
|
|
||||||
for (int i = 0; i < numTmplArgs; i++) {
|
|
||||||
if (packOffset < 0 || tmplParam == null) {
|
|
||||||
if (i >= numTmplParams)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
tmplParam= tmplParams[i];
|
|
||||||
if (tmplParam.isParameterPack()) {
|
|
||||||
packOffset= i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ICPPTemplateArgument tmplArg= tmplArgs[i];
|
|
||||||
tmplArg= CPPTemplates.matchTemplateParameterAndArgument(tmplParam, tmplArg, map);
|
|
||||||
if (tmplArg == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (packOffset < 0) {
|
|
||||||
map.put(tmplParam, tmplArg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (packOffset >= 0) {
|
|
||||||
final int packSize= tmplArgs.length- packOffset;
|
|
||||||
ICPPTemplateArgument[] pack= new ICPPTemplateArgument[packSize];
|
|
||||||
System.arraycopy(tmplArgs, packOffset, pack, 0, packSize);
|
|
||||||
map.put(tmplParam, pack);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!deduceFromFunctionArgs(template, fnArgs, argIsLValue, map))
|
if (!deduceFromFunctionArgs(template, fnArgs, argIsLValue, map))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
List<ICPPTemplateArgument> result= new ArrayList<ICPPTemplateArgument>(numTmplParams);
|
return createArguments(map, tmplParams);
|
||||||
for (ICPPTemplateParameter tpar : tmplParams) {
|
|
||||||
if (tpar.isParameterPack()) {
|
|
||||||
ICPPTemplateArgument[] deducedArgs= map.getPackExpansion(tpar);
|
|
||||||
if (deducedArgs == null)
|
|
||||||
return null;
|
|
||||||
result.addAll(Arrays.asList(deducedArgs));
|
|
||||||
} else {
|
|
||||||
ICPPTemplateArgument deducedArg= map.getArgument(tpar);
|
|
||||||
if (deducedArg == null) {
|
|
||||||
deducedArg= tpar.getDefaultValue();
|
|
||||||
if (deducedArg == null)
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
result.add(deducedArg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result.toArray(new ICPPTemplateArgument[result.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 14.8.2.2 [temp.deduct.funcaddr]
|
|
||||||
* Deducing template arguments taking the address of a function template
|
|
||||||
* @throws DOMException
|
|
||||||
*/
|
|
||||||
static ICPPTemplateArgument[] deduceForAddressOf(ICPPFunctionTemplate template,
|
|
||||||
ICPPTemplateArgument[] tmplArgs, IFunctionType arg, CPPTemplateParameterMap map) throws DOMException {
|
|
||||||
final ICPPTemplateParameter[] tmplParams = template.getTemplateParameters();
|
|
||||||
final int numTmplParams = tmplParams.length;
|
|
||||||
final int numTmplArgs = tmplArgs.length;
|
|
||||||
|
|
||||||
tmplArgs= SemanticUtil.getSimplifiedArguments(tmplArgs);
|
|
||||||
ICPPTemplateParameter tmplParam= null;
|
|
||||||
int packOffset= -1;
|
|
||||||
for (int i = 0; i < numTmplArgs; i++) {
|
|
||||||
if (packOffset < 0 || tmplParam == null) {
|
|
||||||
if (i >= numTmplParams)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
tmplParam= tmplParams[i];
|
|
||||||
if (tmplParam.isParameterPack()) {
|
|
||||||
packOffset= i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ICPPTemplateArgument tmplArg= tmplArgs[i];
|
|
||||||
tmplArg= CPPTemplates.matchTemplateParameterAndArgument(tmplParam, tmplArg, map);
|
|
||||||
if (tmplArg == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (packOffset < 0) {
|
|
||||||
map.put(tmplParam, tmplArg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (packOffset >= 0) {
|
|
||||||
final int packSize= tmplArgs.length- packOffset;
|
|
||||||
ICPPTemplateArgument[] pack= new ICPPTemplateArgument[packSize];
|
|
||||||
System.arraycopy(tmplArgs, packOffset, pack, 0, packSize);
|
|
||||||
map.put(tmplParam, pack);
|
|
||||||
}
|
|
||||||
|
|
||||||
IType par= template.getType();
|
|
||||||
par= CPPTemplates.instantiateType(par, map, -1, null);
|
|
||||||
if (!CPPTemplates.isValidType(par))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
boolean isDependentPar= CPPTemplates.isDependentType(par);
|
|
||||||
if (isDependentPar) {
|
|
||||||
TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(tmplParams, map, new CPPTemplateParameterMap(tmplParams.length), 0);
|
|
||||||
par= SemanticUtil.getNestedType(par, SemanticUtil.TDEF);
|
|
||||||
if (arg != null && !deduct.fromType(par, arg, false))
|
|
||||||
return null;
|
|
||||||
if (!map.mergeToExplicit(deduct.fDeducedArgs))
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!verifyDeduction(tmplParams, map, true))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (isDependentPar)
|
|
||||||
par= CPPTemplates.instantiateType(par, map, -1, null);
|
|
||||||
|
|
||||||
if (arg == null || arg.isSameType(par)) {
|
|
||||||
List<ICPPTemplateArgument> result= new ArrayList<ICPPTemplateArgument>(numTmplParams);
|
|
||||||
for (ICPPTemplateParameter tpar : tmplParams) {
|
|
||||||
if (tpar.isParameterPack()) {
|
|
||||||
ICPPTemplateArgument[] deducedArgs= map.getPackExpansion(tpar);
|
|
||||||
if (deducedArgs == null)
|
|
||||||
return null;
|
|
||||||
result.addAll(Arrays.asList(deducedArgs));
|
|
||||||
} else {
|
|
||||||
ICPPTemplateArgument deducedArg= map.getArgument(tpar);
|
|
||||||
if (deducedArg == null) {
|
|
||||||
deducedArg= tpar.getDefaultValue();
|
|
||||||
if (deducedArg == null)
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
result.add(deducedArg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result.toArray(new ICPPTemplateArgument[result.size()]);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deduce arguments for a user defined conversion template
|
|
||||||
* 14.8.2.3
|
|
||||||
*/
|
|
||||||
static ICPPTemplateArgument[] deduceForConversion(ICPPFunctionTemplate template,
|
|
||||||
IType conversionType, CPPTemplateParameterMap map) throws DOMException {
|
|
||||||
final ICPPTemplateParameter[] tmplParams = template.getTemplateParameters();
|
|
||||||
final int length = tmplParams.length;
|
|
||||||
|
|
||||||
ICPPTemplateArgument[] result = new ICPPTemplateArgument[length];
|
|
||||||
IType a= SemanticUtil.getSimplifiedType(conversionType);
|
|
||||||
IType p= template.getType().getReturnType();
|
|
||||||
p= getArgumentTypeForDeduction(p, a instanceof ICPPReferenceType);
|
|
||||||
a= SemanticUtil.getNestedType(a, SemanticUtil.REF | SemanticUtil.TDEF);
|
|
||||||
TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(tmplParams, null, map, 0);
|
|
||||||
if (!deduct.fromType(p, a, false)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
|
||||||
if (result[i] == null) {
|
|
||||||
final ICPPTemplateParameter tpar = tmplParams[i];
|
|
||||||
ICPPTemplateArgument deducedArg= map.getArgument(tpar);
|
|
||||||
if (deducedArg == null) {
|
|
||||||
deducedArg= tpar.getDefaultValue();
|
|
||||||
if (deducedArg == null)
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
result[i]= deducedArg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -253,9 +89,6 @@ public class TemplateArgumentDeduction {
|
||||||
try {
|
try {
|
||||||
IType[] fnPars = template.getType().getParameterTypes();
|
IType[] fnPars = template.getType().getParameterTypes();
|
||||||
final int fnParCount = fnPars.length;
|
final int fnParCount = fnPars.length;
|
||||||
if (fnParCount == 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
final ICPPTemplateParameter[] tmplPars = template.getTemplateParameters();
|
final ICPPTemplateParameter[] tmplPars = template.getTemplateParameters();
|
||||||
TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(tmplPars, map, new CPPTemplateParameterMap(fnParCount), 0);
|
TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(tmplPars, map, new CPPTemplateParameterMap(fnParCount), 0);
|
||||||
IType fnParPack= null;
|
IType fnParPack= null;
|
||||||
|
@ -288,7 +121,7 @@ public class TemplateArgumentDeduction {
|
||||||
// C++0x: 14.9.2.1-1
|
// C++0x: 14.9.2.1-1
|
||||||
if (arg instanceof InitializerListType) {
|
if (arg instanceof InitializerListType) {
|
||||||
par= SemanticUtil.getNestedType(par, TDEF | REF | CVTYPE);
|
par= SemanticUtil.getNestedType(par, TDEF | REF | CVTYPE);
|
||||||
|
|
||||||
// Check if this is a deduced context
|
// Check if this is a deduced context
|
||||||
IType inner= Conversions.getInitListType(par);
|
IType inner= Conversions.getInitListType(par);
|
||||||
if (inner != null) {
|
if (inner != null) {
|
||||||
|
@ -338,7 +171,7 @@ public class TemplateArgumentDeduction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!deduct.fExplicitArgs.mergeToExplicit(deduct.fDeducedArgs))
|
if (!map.addDeducedArgs(deduct.fDeducedArgs))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return verifyDeduction(tmplPars, map, true);
|
return verifyDeduction(tmplPars, map, true);
|
||||||
|
@ -346,7 +179,7 @@ public class TemplateArgumentDeduction {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean deduceFromFunctionArg(IType par, IType arg, ValueCategory valueCat, TemplateArgumentDeduction deduct) throws DOMException {
|
private static boolean deduceFromFunctionArg(IType par, IType arg, ValueCategory valueCat, TemplateArgumentDeduction deduct) throws DOMException {
|
||||||
boolean isReferenceTypeParameter= false;
|
boolean isReferenceTypeParameter= false;
|
||||||
if (par instanceof ICPPReferenceType) {
|
if (par instanceof ICPPReferenceType) {
|
||||||
|
@ -407,6 +240,112 @@ public class TemplateArgumentDeduction {
|
||||||
return deduct.fromType(par, arg, true);
|
return deduct.fromType(par, arg, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 14.8.2.2 [temp.deduct.funcaddr]
|
||||||
|
* Deducing template arguments taking the address of a function template
|
||||||
|
* @throws DOMException
|
||||||
|
*/
|
||||||
|
static ICPPTemplateArgument[] deduceForAddressOf(ICPPFunctionTemplate template,
|
||||||
|
ICPPTemplateArgument[] tmplArgs, IFunctionType arg, CPPTemplateParameterMap map) throws DOMException {
|
||||||
|
final ICPPTemplateParameter[] tmplParams = template.getTemplateParameters();
|
||||||
|
if (!addExplicitArguments(tmplParams, tmplArgs, map))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
IType par= template.getType();
|
||||||
|
par= CPPTemplates.instantiateType(par, map, -1, null);
|
||||||
|
if (!CPPTemplates.isValidType(par))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
boolean isDependentPar= CPPTemplates.isDependentType(par);
|
||||||
|
if (isDependentPar) {
|
||||||
|
TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(tmplParams, map, new CPPTemplateParameterMap(tmplParams.length), 0);
|
||||||
|
par= SemanticUtil.getNestedType(par, SemanticUtil.TDEF);
|
||||||
|
if (arg != null && !deduct.fromType(par, arg, false))
|
||||||
|
return null;
|
||||||
|
if (!map.addDeducedArgs(deduct.fDeducedArgs))
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!verifyDeduction(tmplParams, map, true))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (isDependentPar)
|
||||||
|
par= CPPTemplates.instantiateType(par, map, -1, null);
|
||||||
|
|
||||||
|
if (arg == null || arg.isSameType(par)) {
|
||||||
|
return createArguments(map, tmplParams);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deduce arguments for a user defined conversion template
|
||||||
|
* 14.8.2.3
|
||||||
|
*/
|
||||||
|
static ICPPTemplateArgument[] deduceForConversion(ICPPFunctionTemplate template,
|
||||||
|
IType conversionType, CPPTemplateParameterMap map) throws DOMException {
|
||||||
|
final ICPPTemplateParameter[] tmplParams = template.getTemplateParameters();
|
||||||
|
final int length = tmplParams.length;
|
||||||
|
|
||||||
|
ICPPTemplateArgument[] result = new ICPPTemplateArgument[length];
|
||||||
|
IType a= SemanticUtil.getSimplifiedType(conversionType);
|
||||||
|
IType p= template.getType().getReturnType();
|
||||||
|
p= getArgumentTypeForDeduction(p, a instanceof ICPPReferenceType);
|
||||||
|
a= SemanticUtil.getNestedType(a, SemanticUtil.REF | SemanticUtil.TDEF);
|
||||||
|
TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(tmplParams, null, map, 0);
|
||||||
|
if (!deduct.fromType(p, a, false)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
if (result[i] == null) {
|
||||||
|
final ICPPTemplateParameter tpar = tmplParams[i];
|
||||||
|
ICPPTemplateArgument deducedArg= map.getArgument(tpar);
|
||||||
|
if (deducedArg == null) {
|
||||||
|
deducedArg= tpar.getDefaultValue();
|
||||||
|
if (deducedArg == null)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
result[i]= deducedArg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deduce arguments for a function declaration
|
||||||
|
* 14.8.2.6
|
||||||
|
*/
|
||||||
|
static ICPPTemplateArgument[] deduceForDeclaration(ICPPFunctionTemplate template,
|
||||||
|
ICPPTemplateArgument[] args, ICPPFunctionType ftype, CPPTemplateParameterMap map) throws DOMException {
|
||||||
|
final ICPPTemplateParameter[] tmplParams = template.getTemplateParameters();
|
||||||
|
|
||||||
|
if (!addExplicitArguments(tmplParams, args, map))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
IType a= SemanticUtil.getSimplifiedType(ftype);
|
||||||
|
IType p= CPPTemplates.instantiateType(template.getType(), map, -1, null);
|
||||||
|
if (!CPPTemplates.isValidType(p))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(tmplParams, map, new CPPTemplateParameterMap(tmplParams.length), 0);
|
||||||
|
if (!deduct.fromType(p, a, false)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!map.addDeducedArgs(deduct.fDeducedArgs))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (!verifyDeduction(tmplParams, map, true))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
IType type= CPPTemplates.instantiateType(p, map, -1, null);
|
||||||
|
if (!ftype.isSameType(type))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return createArguments(map, tmplParams);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deduces the mapping for the template parameters from the function parameters,
|
* Deduces the mapping for the template parameters from the function parameters,
|
||||||
* returns <code>false</code> if there is no mapping.
|
* returns <code>false</code> if there is no mapping.
|
||||||
|
@ -470,6 +409,64 @@ public class TemplateArgumentDeduction {
|
||||||
return isMoreCVQualified ? 1 : 0;
|
return isMoreCVQualified ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the explicit arguments to the map.
|
||||||
|
*/
|
||||||
|
private static boolean addExplicitArguments(final ICPPTemplateParameter[] tmplParams,
|
||||||
|
ICPPTemplateArgument[] tmplArgs, CPPTemplateParameterMap map) {
|
||||||
|
tmplArgs= SemanticUtil.getSimplifiedArguments(tmplArgs);
|
||||||
|
ICPPTemplateParameter tmplParam= null;
|
||||||
|
int packOffset= -1;
|
||||||
|
for (int i = 0; i < tmplArgs.length; i++) {
|
||||||
|
if (packOffset < 0 || tmplParam == null) {
|
||||||
|
if (i >= tmplParams.length)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
tmplParam= tmplParams[i];
|
||||||
|
if (tmplParam.isParameterPack()) {
|
||||||
|
packOffset= i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ICPPTemplateArgument tmplArg= tmplArgs[i];
|
||||||
|
tmplArg= CPPTemplates.matchTemplateParameterAndArgument(tmplParam, tmplArg, map);
|
||||||
|
if (tmplArg == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (packOffset < 0) {
|
||||||
|
map.put(tmplParam, tmplArg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (packOffset >= 0) {
|
||||||
|
final int packSize= tmplArgs.length- packOffset;
|
||||||
|
ICPPTemplateArgument[] pack= new ICPPTemplateArgument[packSize];
|
||||||
|
System.arraycopy(tmplArgs, packOffset, pack, 0, packSize);
|
||||||
|
map.put(tmplParam, pack);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ICPPTemplateArgument[] createArguments(CPPTemplateParameterMap map,
|
||||||
|
final ICPPTemplateParameter[] tmplParams) {
|
||||||
|
List<ICPPTemplateArgument> result= new ArrayList<ICPPTemplateArgument>(tmplParams.length);
|
||||||
|
for (ICPPTemplateParameter tpar : tmplParams) {
|
||||||
|
if (tpar.isParameterPack()) {
|
||||||
|
ICPPTemplateArgument[] deducedArgs= map.getPackExpansion(tpar);
|
||||||
|
if (deducedArgs == null)
|
||||||
|
return null;
|
||||||
|
result.addAll(Arrays.asList(deducedArgs));
|
||||||
|
} else {
|
||||||
|
ICPPTemplateArgument deducedArg= map.getArgument(tpar);
|
||||||
|
if (deducedArg == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.add(deducedArg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.toArray(new ICPPTemplateArgument[result.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 14.8.2.1.3 If P is a class and has the form template-id, then A can be a derived class of the deduced A.
|
* 14.8.2.1.3 If P is a class and has the form template-id, then A can be a derived class of the deduced A.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
|
@ -254,7 +255,8 @@ abstract public class PDOMWriter {
|
||||||
try {
|
try {
|
||||||
final IBinding binding = name.resolveBinding();
|
final IBinding binding = name.resolveBinding();
|
||||||
if (name.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_NAME &&
|
if (name.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_NAME &&
|
||||||
((IASTName) name.getParent()).getBinding() == binding) {
|
(((IASTName) name.getParent()).getBinding() == binding ||
|
||||||
|
binding instanceof ICPPFunctionTemplate)) {
|
||||||
na[0]= null;
|
na[0]= null;
|
||||||
} else if (binding instanceof IProblemBinding) {
|
} else if (binding instanceof IProblemBinding) {
|
||||||
fStatistics.fProblemBindingCount++;
|
fStatistics.fProblemBindingCount++;
|
||||||
|
|
|
@ -838,3 +838,22 @@ void TestClass::foo()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//!Bug 355006 - NPE implementing template function
|
||||||
|
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
|
||||||
|
//@.config
|
||||||
|
filename=A.h
|
||||||
|
infos=1
|
||||||
|
//@A.h
|
||||||
|
|
||||||
|
/*$*/template<typename T> void func(T&);/*$$*/
|
||||||
|
|
||||||
|
//=
|
||||||
|
|
||||||
|
template<typename T> void func(T&);
|
||||||
|
|
||||||
|
template<typename T> inline void func(T& )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -94,11 +94,19 @@ ActionDefinition.opendecl.description= Open an editor on the selected element's
|
||||||
ActionDefinition.opencview.name= Show in C/C++ Project view
|
ActionDefinition.opencview.name= Show in C/C++ Project view
|
||||||
ActionDefinition.opencview.description= Show the selected resource in the C/C++ Project view
|
ActionDefinition.opencview.description= Show the selected resource in the C/C++ Project view
|
||||||
|
|
||||||
ActionDefinition.finddecl.name= Find Declaration
|
ActionDefinition.finddecl.name= Declaration
|
||||||
ActionDefinition.finddecl.description= Find Declaration
|
ActionDefinition.finddecl.description= Search for declarations of the selected element in the workspace
|
||||||
|
ActionDefinition.finddecl.project.name= Declaration in Project
|
||||||
|
ActionDefinition.finddecl.project.description= Search for declarations of the selected element in the enclosing project
|
||||||
|
ActionDefinition.finddecl.workingset.name= Declaration in Working Set
|
||||||
|
ActionDefinition.finddecl.workingset.description= Search for declarations of the selected element in a working set
|
||||||
|
|
||||||
ActionDefinition.findrefs.name= Find References
|
ActionDefinition.findrefs.name= References
|
||||||
ActionDefinition.findrefs.description= Find References
|
ActionDefinition.findrefs.description= Search for references to the selected element in the workspace
|
||||||
|
ActionDefinition.findrefs.project.name= References in Project
|
||||||
|
ActionDefinition.findrefs.project.description= Search for references to the selected element in the enclosing project
|
||||||
|
ActionDefinition.findrefs.workingset.name= References in Working Set
|
||||||
|
ActionDefinition.findrefs.workingset.description= Search for references to the selected element in a working set
|
||||||
|
|
||||||
ActionDefinition.openCallHierarchy.name= Open Call Hierarchy
|
ActionDefinition.openCallHierarchy.name= Open Call Hierarchy
|
||||||
ActionDefinition.openCallHierarchy.description= Open the call hierarchy for the selected element
|
ActionDefinition.openCallHierarchy.description= Open the call hierarchy for the selected element
|
||||||
|
@ -611,4 +619,4 @@ transfer.EditorBehavior.description = Preference related to how the editor proce
|
||||||
# Refresh Exclusion Contributors
|
# Refresh Exclusion Contributors
|
||||||
RefreshExclusionContributor.name = Resources
|
RefreshExclusionContributor.name = Resources
|
||||||
|
|
||||||
extension-point.name = Refresh Exclusion Contributor
|
extension-point.name = Refresh Exclusion Contributor
|
||||||
|
|
|
@ -2379,11 +2379,31 @@
|
||||||
categoryId="org.eclipse.cdt.ui.category.source"
|
categoryId="org.eclipse.cdt.ui.category.source"
|
||||||
name="%ActionDefinition.finddecl.name"
|
name="%ActionDefinition.finddecl.name"
|
||||||
id="org.eclipse.cdt.ui.search.finddecl"/>
|
id="org.eclipse.cdt.ui.search.finddecl"/>
|
||||||
|
<command
|
||||||
|
description="%ActionDefinition.finddecl.project.description"
|
||||||
|
categoryId="org.eclipse.cdt.ui.category.source"
|
||||||
|
name="%ActionDefinition.finddecl.project.name"
|
||||||
|
id="org.eclipse.cdt.ui.search.finddecl.project"/>
|
||||||
|
<command
|
||||||
|
description="%ActionDefinition.finddecl.workingset.description"
|
||||||
|
categoryId="org.eclipse.cdt.ui.category.source"
|
||||||
|
name="%ActionDefinition.finddecl.workingset.name"
|
||||||
|
id="org.eclipse.cdt.ui.search.finddecl.workingset"/>
|
||||||
<command
|
<command
|
||||||
categoryId="org.eclipse.cdt.ui.category.source"
|
categoryId="org.eclipse.cdt.ui.category.source"
|
||||||
description="%ActionDefinition.findrefs.description"
|
description="%ActionDefinition.findrefs.description"
|
||||||
name="%ActionDefinition.findrefs.name"
|
name="%ActionDefinition.findrefs.name"
|
||||||
id="org.eclipse.cdt.ui.search.findrefs"/>
|
id="org.eclipse.cdt.ui.search.findrefs"/>
|
||||||
|
<command
|
||||||
|
categoryId="org.eclipse.cdt.ui.category.source"
|
||||||
|
description="%ActionDefinition.findrefs.project.description"
|
||||||
|
name="%ActionDefinition.findrefs.project.name"
|
||||||
|
id="org.eclipse.cdt.ui.search.findrefs.project"/>
|
||||||
|
<command
|
||||||
|
categoryId="org.eclipse.cdt.ui.category.source"
|
||||||
|
description="%ActionDefinition.findrefs.workingset.description"
|
||||||
|
name="%ActionDefinition.findrefs.workingset.name"
|
||||||
|
id="org.eclipse.cdt.ui.search.findrefs.workingset"/>
|
||||||
<command
|
<command
|
||||||
categoryId="org.eclipse.ui.category.navigate"
|
categoryId="org.eclipse.ui.category.navigate"
|
||||||
description="%ActionDefinition.openCallHierarchy.description"
|
description="%ActionDefinition.openCallHierarchy.description"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -510,7 +510,8 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
|
||||||
|
|
||||||
// Do this before setting input but after the initializations of the fields filtering
|
// Do this before setting input but after the initializations of the fields filtering
|
||||||
registerActionBars(bars);
|
registerActionBars(bars);
|
||||||
|
bars.updateActionBars();
|
||||||
|
|
||||||
fTreeViewer.setInput(fInput);
|
fTreeViewer.setInput(fInput);
|
||||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(control, ICHelpContextIds.COUTLINE_VIEW);
|
PlatformUI.getWorkbench().getHelpSystem().setHelp(control, ICHelpContextIds.COUTLINE_VIEW);
|
||||||
}
|
}
|
||||||
|
@ -591,7 +592,9 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
|
||||||
if (fRefactoringActionGroup != null) {
|
if (fRefactoringActionGroup != null) {
|
||||||
fRefactoringActionGroup.fillActionBars(actionBars);
|
fRefactoringActionGroup.fillActionBars(actionBars);
|
||||||
}
|
}
|
||||||
|
if (fSelectionSearchGroup != null) {
|
||||||
|
fSelectionSearchGroup.fillActionBars(actionBars);
|
||||||
|
}
|
||||||
IMenuManager menu= actionBars.getMenuManager();
|
IMenuManager menu= actionBars.getMenuManager();
|
||||||
menu.add(new Separator("EndFilterGroup")); //$NON-NLS-1$
|
menu.add(new Separator("EndFilterGroup")); //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2010 QNX Software Systems and others.
|
* Copyright (c) 2000, 2011 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -34,7 +34,7 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
public static final String TOGGLE_COMMENT= "org.eclipse.cdt.ui.edit.text.c.toggle.comment"; //$NON-NLS-1$
|
public static final String TOGGLE_COMMENT= "org.eclipse.cdt.ui.edit.text.c.toggle.comment"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID of the source -> add block comment action
|
* Action definition ID of the source -> add block comment action
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.text.c.add.block.comment"</code>).
|
* (value <code>"org.eclipse.cdt.ui.edit.text.c.add.block.comment"</code>).
|
||||||
|
@ -48,20 +48,20 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public static final String REMOVE_BLOCK_COMMENT= "org.eclipse.cdt.ui.edit.text.c.remove.block.comment"; //$NON-NLS-1$
|
public static final String REMOVE_BLOCK_COMMENT= "org.eclipse.cdt.ui.edit.text.c.remove.block.comment"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID of the source -> join lines action
|
* Action definition ID of the source -> join lines action
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.text.c.join.lines"</code>).
|
* (value <code>"org.eclipse.cdt.ui.edit.text.c.join.lines"</code>).
|
||||||
* @since 3.0.2
|
* @since 3.0.2
|
||||||
*/
|
*/
|
||||||
public static final String JOIN_LINES= "org.eclipse.cdt.ui.edit.text.c.join.lines"; //$NON-NLS-1$
|
public static final String JOIN_LINES= "org.eclipse.cdt.ui.edit.text.c.join.lines"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID of the source -> indent action
|
* Action definition ID of the source -> indent action
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.text.c.indent"</code>).
|
* (value <code>"org.eclipse.cdt.ui.edit.text.c.indent"</code>).
|
||||||
*/
|
*/
|
||||||
public static final String INDENT = "org.eclipse.cdt.ui.edit.text.c.indent"; //$NON-NLS-1$
|
public static final String INDENT = "org.eclipse.cdt.ui.edit.text.c.indent"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID of the source -> format action
|
* Action definition ID of the source -> format action
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.text.c.format"</code>).
|
* (value <code>"org.eclipse.cdt.ui.edit.text.c.format"</code>).
|
||||||
|
@ -72,20 +72,20 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
|
||||||
* Action definition ID of the source -> add include action
|
* Action definition ID of the source -> add include action
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.text.c.add.include"</code>).
|
* (value <code>"org.eclipse.cdt.ui.edit.text.c.add.include"</code>).
|
||||||
*/
|
*/
|
||||||
public static final String ADD_INCLUDE= "org.eclipse.cdt.ui.edit.text.c.add.include"; //$NON-NLS-1$
|
public static final String ADD_INCLUDE= "org.eclipse.cdt.ui.edit.text.c.add.include"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID of the open declaration action
|
* Action definition ID of the open declaration action
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.opendecl"</code>).
|
* (value <code>"org.eclipse.cdt.ui.edit.opendecl"</code>).
|
||||||
*/
|
*/
|
||||||
public static final String OPEN_DECL= "org.eclipse.cdt.ui.edit.opendecl"; //$NON-NLS-1$
|
public static final String OPEN_DECL= "org.eclipse.cdt.ui.edit.opendecl"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID of the show in C/C++ Projects View action
|
* Action definition ID of the show in C/C++ Projects View action
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.opencview"</code>).
|
* (value <code>"org.eclipse.cdt.ui.edit.opencview"</code>).
|
||||||
*/
|
*/
|
||||||
public static final String OPEN_CVIEW= "org.eclipse.cdt.ui.edit.opencview"; //$NON-NLS-1$
|
public static final String OPEN_CVIEW= "org.eclipse.cdt.ui.edit.opencview"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID of the refactor -> rename element action
|
* Action definition ID of the refactor -> rename element action
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.text.rename.element"</code>).
|
* (value <code>"org.eclipse.cdt.ui.edit.text.rename.element"</code>).
|
||||||
|
@ -103,7 +103,7 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
|
||||||
* (value <code>"org.eclipse.cdt.ui.refactor.extract.local.variable"</code>).
|
* (value <code>"org.eclipse.cdt.ui.refactor.extract.local.variable"</code>).
|
||||||
*/
|
*/
|
||||||
public static final String EXTRACT_LOCAL_VARIABLE= "org.eclipse.cdt.ui.refactor.extract.local.variable"; //$NON-NLS-1$
|
public static final String EXTRACT_LOCAL_VARIABLE= "org.eclipse.cdt.ui.refactor.extract.local.variable"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID of the refactor -> extract function action (value
|
* Action definition ID of the refactor -> extract function action (value
|
||||||
* <code>"org.eclipse.cdt.ui.refactor.extract.function"</code>).
|
* <code>"org.eclipse.cdt.ui.refactor.extract.function"</code>).
|
||||||
|
@ -121,7 +121,7 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
|
||||||
* (value <code>"org.eclipse.cdt.ui.refactor.hide.method"</code>).
|
* (value <code>"org.eclipse.cdt.ui.refactor.hide.method"</code>).
|
||||||
*/
|
*/
|
||||||
public static final String HIDE_METHOD= "org.eclipse.cdt.ui.refactor.hide.method"; //$NON-NLS-1$
|
public static final String HIDE_METHOD= "org.eclipse.cdt.ui.refactor.hide.method"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID of the refactor -> implement method action
|
* Action definition ID of the refactor -> implement method action
|
||||||
* (value <code>"org.eclipse.cdt.ui.refactor.implement.method"</code>).
|
* (value <code>"org.eclipse.cdt.ui.refactor.implement.method"</code>).
|
||||||
|
@ -139,24 +139,48 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.text.undo.action"</code>).
|
* (value <code>"org.eclipse.cdt.ui.edit.text.undo.action"</code>).
|
||||||
*/
|
*/
|
||||||
public static final String UNDO_ACTION= "org.eclipse.cdt.ui.edit.text.undo.action"; //$NON-NLS-1$
|
public static final String UNDO_ACTION= "org.eclipse.cdt.ui.edit.text.undo.action"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID of the refactor -> redo action
|
* Action definition ID of the refactor -> redo action
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.text.redo.action"</code>).
|
* (value <code>"org.eclipse.cdt.ui.edit.text.redo.action"</code>).
|
||||||
*/
|
*/
|
||||||
public static final String REDO_ACTION= "org.eclipse.cdt.ui.edit.text.redo.action"; //$NON-NLS-1$
|
public static final String REDO_ACTION= "org.eclipse.cdt.ui.edit.text.redo.action"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID of the find references in workspace action
|
* Action definition ID of the find references in workspace action
|
||||||
* (value <code>"org.eclipse.cdt.ui.search.findrefs"</code>).
|
* (value <code>"org.eclipse.cdt.ui.search.findrefs"</code>).
|
||||||
*/
|
*/
|
||||||
public static final String FIND_REFS= "org.eclipse.cdt.ui.search.findrefs"; //$NON-NLS-1$
|
public static final String FIND_REFS= "org.eclipse.cdt.ui.search.findrefs"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action definition ID of the find references in project action
|
||||||
|
* (value <code>"org.eclipse.cdt.ui.search.findrefs.project"</code>).
|
||||||
|
*/
|
||||||
|
public static final String FIND_REFS_PROJECT= "org.eclipse.cdt.ui.search.findrefs.project"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action definition ID of the find references in working set action
|
||||||
|
* (value <code>"org.eclipse.cdt.ui.search.findrefs.workingset"</code>).
|
||||||
|
*/
|
||||||
|
public static final String FIND_REFS_WORKING_SET= "org.eclipse.cdt.ui.search.findrefs.workingset"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID of the find declarations in workspace action
|
* Action definition ID of the find declarations in workspace action
|
||||||
* (value <code>"org.eclipse.cdt.ui.search.finddecl"</code>).
|
* (value <code>"org.eclipse.cdt.ui.search.finddecl"</code>).
|
||||||
*/
|
*/
|
||||||
public static final String FIND_DECL= "org.eclipse.cdt.ui.search.finddecl"; //$NON-NLS-1$
|
public static final String FIND_DECL= "org.eclipse.cdt.ui.search.finddecl"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action definition ID of the find declarations in project action
|
||||||
|
* (value <code>"org.eclipse.cdt.ui.search.finddecl.project"</code>).
|
||||||
|
*/
|
||||||
|
public static final String FIND_DECL_PROJECT= "org.eclipse.cdt.ui.search.finddecl.project"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action definition ID of the find declarations in working set action
|
||||||
|
* (value <code>"org.eclipse.cdt.ui.search.finddecl.workingset"</code>).
|
||||||
|
*/
|
||||||
|
public static final String FIND_DECL_WORKING_SET= "org.eclipse.cdt.ui.search.finddecl.workingset"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID of the navigate -> open type hierarchy action
|
* Action definition ID of the navigate -> open type hierarchy action
|
||||||
|
@ -218,18 +242,18 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
|
||||||
* Action definition ID for goto next bookmark action
|
* Action definition ID for goto next bookmark action
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.text.c.goto.next.bookmark"</code>).
|
* (value <code>"org.eclipse.cdt.ui.edit.text.c.goto.next.bookmark"</code>).
|
||||||
*/
|
*/
|
||||||
public static final String GOTO_NEXT_BOOKMARK = "org.eclipse.cdt.ui.edit.text.c.goto.next.bookmark"; //$NON-NLS-1$
|
public static final String GOTO_NEXT_BOOKMARK = "org.eclipse.cdt.ui.edit.text.c.goto.next.bookmark"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID for find word action
|
* Action definition ID for find word action
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.text.c.find.word"</code>).
|
* (value <code>"org.eclipse.cdt.ui.edit.text.c.find.word"</code>).
|
||||||
*/
|
*/
|
||||||
public static final String FIND_WORD = "org.eclipse.cdt.ui.edit.text.c.find.word"; //$NON-NLS-1$
|
public static final String FIND_WORD = "org.eclipse.cdt.ui.edit.text.c.find.word"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID for toggle source/header action.
|
* Action definition ID for toggle source/header action.
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.text.c.toggle.source.header"</code>)
|
* (value <code>"org.eclipse.cdt.ui.edit.text.c.toggle.source.header"</code>)
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static final String TOGGLE_SOURCE_HEADER = "org.eclipse.cdt.ui.edit.text.c.toggle.source.header"; //$NON-NLS-1$
|
public static final String TOGGLE_SOURCE_HEADER = "org.eclipse.cdt.ui.edit.text.c.toggle.source.header"; //$NON-NLS-1$
|
||||||
|
@ -260,19 +284,19 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.text.c.select.enclosing"</code>).
|
* (value <code>"org.eclipse.cdt.ui.edit.text.c.select.enclosing"</code>).
|
||||||
*/
|
*/
|
||||||
public static final String SELECT_ENCLOSING = "org.eclipse.cdt.ui.edit.text.c.select.enclosing"; //$NON-NLS-1$
|
public static final String SELECT_ENCLOSING = "org.eclipse.cdt.ui.edit.text.c.select.enclosing"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID of the edit -> select next action
|
* Action definition ID of the edit -> select next action
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.text.c.select.next"</code>).
|
* (value <code>"org.eclipse.cdt.ui.edit.text.c.select.next"</code>).
|
||||||
*/
|
*/
|
||||||
public static final String SELECT_NEXT = "org.eclipse.cdt.ui.edit.text.c.select.next"; //$NON-NLS-1$
|
public static final String SELECT_NEXT = "org.eclipse.cdt.ui.edit.text.c.select.next"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID of the edit -> select previous action
|
* Action definition ID of the edit -> select previous action
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.text.c.select.previous"</code>).
|
* (value <code>"org.eclipse.cdt.ui.edit.text.c.select.previous"</code>).
|
||||||
*/
|
*/
|
||||||
public static final String SELECT_PREVIOUS = "org.eclipse.cdt.ui.edit.text.c.select.previous"; //$NON-NLS-1$
|
public static final String SELECT_PREVIOUS = "org.eclipse.cdt.ui.edit.text.c.select.previous"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID of the edit -> select restore last action
|
* Action definition ID of the edit -> select restore last action
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.text.c.select.last"</code>).
|
* (value <code>"org.eclipse.cdt.ui.edit.text.c.select.last"</code>).
|
||||||
|
|
|
@ -260,15 +260,16 @@ public class ImplementMethodRefactoring extends CRefactoring2 {
|
||||||
IASTFunctionDefinition functionDefinition = nodeFactory.newFunctionDefinition(declSpecifier, createdMethodDeclarator, nodeFactory.newCompoundStatement());
|
IASTFunctionDefinition functionDefinition = nodeFactory.newFunctionDefinition(declSpecifier, createdMethodDeclarator, nodeFactory.newCompoundStatement());
|
||||||
functionDefinition.setParent(unit);
|
functionDefinition.setParent(unit);
|
||||||
|
|
||||||
if (NodeHelper.isContainedInTemplateDeclaration(declarationParent)) {
|
ICPPASTTemplateDeclaration templateDeclaration = NodeHelper.findContainedTemplateDecalaration(declarationParent);
|
||||||
ICPPASTTemplateDeclaration templateDeclaration = nodeFactory.newTemplateDeclaration(functionDefinition);
|
if (templateDeclaration != null) {
|
||||||
templateDeclaration.setParent(unit);
|
ICPPASTTemplateDeclaration newTemplateDeclaration = nodeFactory.newTemplateDeclaration(functionDefinition);
|
||||||
|
newTemplateDeclaration.setParent(unit);
|
||||||
|
|
||||||
for (ICPPASTTemplateParameter templateParameter : ((ICPPASTTemplateDeclaration) declarationParent.getParent().getParent() ).getTemplateParameters()) {
|
for (ICPPASTTemplateParameter templateParameter : templateDeclaration.getTemplateParameters()) {
|
||||||
templateDeclaration.addTemplateParameter(templateParameter.copy(CopyStyle.withLocations));
|
newTemplateDeclaration.addTemplateParameter(templateParameter.copy(CopyStyle.withLocations));
|
||||||
}
|
}
|
||||||
|
|
||||||
return templateDeclaration;
|
return newTemplateDeclaration;
|
||||||
}
|
}
|
||||||
return functionDefinition;
|
return functionDefinition;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik
|
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
|
||||||
* Rapperswil, University of applied sciences and others
|
* Rapperswil, University of applied sciences and others
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
@ -212,11 +212,16 @@ public class NodeHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isContainedInTemplateDeclaration(IASTNode node) {
|
public static boolean isContainedInTemplateDeclaration(IASTNode node) {
|
||||||
if (node == null) {
|
return findContainedTemplateDecalaration(node) != null;
|
||||||
return false;
|
}
|
||||||
} else if (node instanceof ICPPASTTemplateDeclaration) {
|
|
||||||
return true;
|
public static ICPPASTTemplateDeclaration findContainedTemplateDecalaration(IASTNode node) {
|
||||||
|
while (node != null) {
|
||||||
|
if (node instanceof ICPPASTTemplateDeclaration) {
|
||||||
|
return (ICPPASTTemplateDeclaration) node;
|
||||||
|
}
|
||||||
|
node = node.getParent();
|
||||||
}
|
}
|
||||||
return isContainedInTemplateDeclaration(node.getParent());
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -21,6 +21,7 @@ import org.eclipse.jface.text.ITextSelection;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.search.ui.IContextMenuConstants;
|
import org.eclipse.search.ui.IContextMenuConstants;
|
||||||
|
import org.eclipse.ui.IActionBars;
|
||||||
import org.eclipse.ui.IWorkbenchSite;
|
import org.eclipse.ui.IWorkbenchSite;
|
||||||
import org.eclipse.ui.IWorkingSet;
|
import org.eclipse.ui.IWorkingSet;
|
||||||
import org.eclipse.ui.actions.ActionGroup;
|
import org.eclipse.ui.actions.ActionGroup;
|
||||||
|
@ -35,18 +36,21 @@ import org.eclipse.cdt.internal.ui.search.CSearchUtil;
|
||||||
|
|
||||||
|
|
||||||
public class DeclarationsSearchGroup extends ActionGroup {
|
public class DeclarationsSearchGroup extends ActionGroup {
|
||||||
|
|
||||||
private CEditor fEditor;
|
private CEditor fEditor;
|
||||||
private IWorkbenchSite fSite;
|
private IWorkbenchSite fSite;
|
||||||
|
|
||||||
private FindDeclarationsAction fFindDeclarationsAction;
|
private FindDeclarationsAction fFindDeclarationsAction;
|
||||||
private FindDeclarationsProjectAction fFindDeclarationsProjectAction;
|
private FindDeclarationsProjectAction fFindDeclarationsProjectAction;
|
||||||
private FindDeclarationsInWorkingSetAction fFindDeclarationsInWorkingSetAction;
|
private FindDeclarationsInWorkingSetAction fFindDeclarationsInWorkingSetAction;
|
||||||
|
|
||||||
public DeclarationsSearchGroup(IWorkbenchSite site) {
|
public DeclarationsSearchGroup(IWorkbenchSite site) {
|
||||||
fFindDeclarationsAction= new FindDeclarationsAction(site);
|
fFindDeclarationsAction= new FindDeclarationsAction(site);
|
||||||
|
fFindDeclarationsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL);
|
||||||
fFindDeclarationsProjectAction = new FindDeclarationsProjectAction(site);
|
fFindDeclarationsProjectAction = new FindDeclarationsProjectAction(site);
|
||||||
|
fFindDeclarationsProjectAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_PROJECT);
|
||||||
fFindDeclarationsInWorkingSetAction = new FindDeclarationsInWorkingSetAction(site,null);
|
fFindDeclarationsInWorkingSetAction = new FindDeclarationsInWorkingSetAction(site,null);
|
||||||
|
fFindDeclarationsInWorkingSetAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_WORKING_SET);
|
||||||
fSite = site;
|
fSite = site;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -57,45 +61,53 @@ public class DeclarationsSearchGroup extends ActionGroup {
|
||||||
|
|
||||||
fFindDeclarationsAction= new FindDeclarationsAction(editor);
|
fFindDeclarationsAction= new FindDeclarationsAction(editor);
|
||||||
fFindDeclarationsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL);
|
fFindDeclarationsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL);
|
||||||
if (editor != null){
|
editor.setAction(ICEditorActionDefinitionIds.FIND_DECL, fFindDeclarationsAction);
|
||||||
editor.setAction(ICEditorActionDefinitionIds.FIND_DECL, fFindDeclarationsAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
fFindDeclarationsProjectAction = new FindDeclarationsProjectAction(editor);
|
fFindDeclarationsProjectAction = new FindDeclarationsProjectAction(editor);
|
||||||
|
fFindDeclarationsProjectAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_PROJECT);
|
||||||
|
editor.setAction(ICEditorActionDefinitionIds.FIND_DECL_PROJECT, fFindDeclarationsProjectAction);
|
||||||
fFindDeclarationsInWorkingSetAction = new FindDeclarationsInWorkingSetAction(editor,null);
|
fFindDeclarationsInWorkingSetAction = new FindDeclarationsInWorkingSetAction(editor,null);
|
||||||
|
fFindDeclarationsInWorkingSetAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_WORKING_SET);
|
||||||
|
editor.setAction(ICEditorActionDefinitionIds.FIND_DECL_WORKING_SET, fFindDeclarationsInWorkingSetAction);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Method declared on ActionGroup.
|
* Method declared on ActionGroup.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void fillContextMenu(IMenuManager menu) {
|
public void fillContextMenu(IMenuManager menu) {
|
||||||
super.fillContextMenu(menu);
|
super.fillContextMenu(menu);
|
||||||
|
|
||||||
IMenuManager incomingMenu = menu;
|
IMenuManager incomingMenu = menu;
|
||||||
|
|
||||||
IMenuManager declarationsMenu = new MenuManager(CSearchMessages.group_declarations, IContextMenuConstants.GROUP_SEARCH);
|
IMenuManager declarationsMenu = new MenuManager(CSearchMessages.group_declarations, IContextMenuConstants.GROUP_SEARCH);
|
||||||
|
|
||||||
if (fEditor != null){
|
if (fEditor != null){
|
||||||
menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, declarationsMenu);
|
menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, declarationsMenu);
|
||||||
} else {
|
} else {
|
||||||
incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, declarationsMenu);
|
incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, declarationsMenu);
|
||||||
}
|
}
|
||||||
incomingMenu = declarationsMenu;
|
incomingMenu = declarationsMenu;
|
||||||
|
|
||||||
FindAction[] actions = getWorkingSetActions();
|
FindAction[] actions = getWorkingSetActions();
|
||||||
incomingMenu.add(fFindDeclarationsAction);
|
incomingMenu.add(fFindDeclarationsAction);
|
||||||
incomingMenu.add(fFindDeclarationsProjectAction);
|
incomingMenu.add(fFindDeclarationsProjectAction);
|
||||||
incomingMenu.add(fFindDeclarationsInWorkingSetAction);
|
incomingMenu.add(fFindDeclarationsInWorkingSetAction);
|
||||||
|
|
||||||
for (FindAction action : actions) {
|
for (FindAction action : actions) {
|
||||||
incomingMenu.add(action);
|
incomingMenu.add(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fillActionBars(IActionBars actionBars) {
|
||||||
|
actionBars.setGlobalActionHandler(ICEditorActionDefinitionIds.FIND_DECL, fFindDeclarationsAction);
|
||||||
|
actionBars.setGlobalActionHandler(ICEditorActionDefinitionIds.FIND_DECL_PROJECT, fFindDeclarationsProjectAction);
|
||||||
|
actionBars.setGlobalActionHandler(ICEditorActionDefinitionIds.FIND_DECL_WORKING_SET, fFindDeclarationsInWorkingSetAction);
|
||||||
|
}
|
||||||
|
|
||||||
private FindAction[] getWorkingSetActions() {
|
private FindAction[] getWorkingSetActions() {
|
||||||
ArrayList<FindAction> actions= new ArrayList<FindAction>(CSearchUtil.LRU_WORKINGSET_LIST_SIZE);
|
ArrayList<FindAction> actions= new ArrayList<FindAction>(CSearchUtil.LRU_WORKINGSET_LIST_SIZE);
|
||||||
|
|
||||||
Iterator<IWorkingSet[]> iter= CSearchUtil.getLRUWorkingSets().iterator();
|
Iterator<IWorkingSet[]> iter= CSearchUtil.getLRUWorkingSets().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
IWorkingSet[] workingSets= iter.next();
|
IWorkingSet[] workingSets= iter.next();
|
||||||
|
@ -104,10 +116,10 @@ public class DeclarationsSearchGroup extends ActionGroup {
|
||||||
action= new WorkingSetFindAction(fEditor, new FindDeclarationsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets));
|
action= new WorkingSetFindAction(fEditor, new FindDeclarationsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets));
|
||||||
else
|
else
|
||||||
action= new WorkingSetFindAction(fSite, new FindDeclarationsInWorkingSetAction(fSite, workingSets), CSearchUtil.toString(workingSets));
|
action= new WorkingSetFindAction(fSite, new FindDeclarationsInWorkingSetAction(fSite, workingSets), CSearchUtil.toString(workingSets));
|
||||||
|
|
||||||
actions.add(action);
|
actions.add(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
return actions.toArray(new FindAction[actions.size()]);
|
return actions.toArray(new FindAction[actions.size()]);
|
||||||
}
|
}
|
||||||
public static boolean canActionBeAdded(ISelection selection) {
|
public static boolean canActionBeAdded(ISelection selection) {
|
||||||
|
@ -116,7 +128,7 @@ public class DeclarationsSearchGroup extends ActionGroup {
|
||||||
}
|
}
|
||||||
return getElement(selection) != null;
|
return getElement(selection) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ICElement getElement(ISelection sel) {
|
private static ICElement getElement(ISelection sel) {
|
||||||
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
||||||
List<?> list= ((IStructuredSelection)sel).toList();
|
List<?> list= ((IStructuredSelection)sel).toList();
|
||||||
|
@ -129,8 +141,8 @@ public class DeclarationsSearchGroup extends ActionGroup {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Overrides method declared in ActionGroup
|
* Overrides method declared in ActionGroup
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -16,6 +16,7 @@ import java.util.Iterator;
|
||||||
import org.eclipse.jface.action.IMenuManager;
|
import org.eclipse.jface.action.IMenuManager;
|
||||||
import org.eclipse.jface.action.MenuManager;
|
import org.eclipse.jface.action.MenuManager;
|
||||||
import org.eclipse.search.ui.IContextMenuConstants;
|
import org.eclipse.search.ui.IContextMenuConstants;
|
||||||
|
import org.eclipse.ui.IActionBars;
|
||||||
import org.eclipse.ui.IWorkbenchSite;
|
import org.eclipse.ui.IWorkbenchSite;
|
||||||
import org.eclipse.ui.IWorkingSet;
|
import org.eclipse.ui.IWorkingSet;
|
||||||
import org.eclipse.ui.actions.ActionGroup;
|
import org.eclipse.ui.actions.ActionGroup;
|
||||||
|
@ -31,66 +32,78 @@ public class ReferencesSearchGroup extends ActionGroup {
|
||||||
private FindRefsAction fFindRefsAction;
|
private FindRefsAction fFindRefsAction;
|
||||||
private FindRefsProjectAction fFindRefsProjectAction;
|
private FindRefsProjectAction fFindRefsProjectAction;
|
||||||
private FindRefsInWorkingSetAction fFindRefsInWorkingSetAction;
|
private FindRefsInWorkingSetAction fFindRefsInWorkingSetAction;
|
||||||
|
|
||||||
private CEditor fEditor;
|
private CEditor fEditor;
|
||||||
private IWorkbenchSite fSite;
|
private IWorkbenchSite fSite;
|
||||||
|
|
||||||
public ReferencesSearchGroup(IWorkbenchSite site) {
|
public ReferencesSearchGroup(IWorkbenchSite site) {
|
||||||
fFindRefsAction= new FindRefsAction(site);
|
fFindRefsAction= new FindRefsAction(site);
|
||||||
|
fFindRefsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS);
|
||||||
fFindRefsProjectAction = new FindRefsProjectAction(site);
|
fFindRefsProjectAction = new FindRefsProjectAction(site);
|
||||||
|
fFindRefsProjectAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS_PROJECT);
|
||||||
fFindRefsInWorkingSetAction = new FindRefsInWorkingSetAction(site, null);
|
fFindRefsInWorkingSetAction = new FindRefsInWorkingSetAction(site, null);
|
||||||
|
fFindRefsInWorkingSetAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS_WORKING_SET);
|
||||||
fSite=site;
|
fSite=site;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param editor
|
* @param editor
|
||||||
*/
|
*/
|
||||||
public ReferencesSearchGroup(CEditor editor) {
|
public ReferencesSearchGroup(CEditor editor) {
|
||||||
fEditor = editor;
|
fEditor = editor;
|
||||||
|
|
||||||
fFindRefsAction= new FindRefsAction(editor);
|
fFindRefsAction= new FindRefsAction(editor);
|
||||||
fFindRefsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS);
|
fFindRefsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS);
|
||||||
if (editor != null){
|
editor.setAction(ICEditorActionDefinitionIds.FIND_REFS, fFindRefsAction);
|
||||||
editor.setAction(ICEditorActionDefinitionIds.FIND_REFS, fFindRefsAction);
|
|
||||||
}
|
|
||||||
fFindRefsProjectAction = new FindRefsProjectAction(editor);
|
fFindRefsProjectAction = new FindRefsProjectAction(editor);
|
||||||
|
fFindRefsProjectAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS_PROJECT);
|
||||||
|
editor.setAction(ICEditorActionDefinitionIds.FIND_REFS_PROJECT, fFindRefsProjectAction);
|
||||||
fFindRefsInWorkingSetAction = new FindRefsInWorkingSetAction(editor, null);
|
fFindRefsInWorkingSetAction = new FindRefsInWorkingSetAction(editor, null);
|
||||||
|
fFindRefsInWorkingSetAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS_WORKING_SET);
|
||||||
|
editor.setAction(ICEditorActionDefinitionIds.FIND_REFS_WORKING_SET, fFindRefsInWorkingSetAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Method declared on ActionGroup.
|
* Method declared on ActionGroup.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void fillContextMenu(IMenuManager menu) {
|
public void fillContextMenu(IMenuManager menu) {
|
||||||
|
|
||||||
super.fillContextMenu(menu);
|
super.fillContextMenu(menu);
|
||||||
|
|
||||||
IMenuManager incomingMenu = menu;
|
IMenuManager incomingMenu = menu;
|
||||||
|
|
||||||
IMenuManager refsMenu = new MenuManager(CSearchMessages.group_references, IContextMenuConstants.GROUP_SEARCH);
|
IMenuManager refsMenu = new MenuManager(CSearchMessages.group_references, IContextMenuConstants.GROUP_SEARCH);
|
||||||
|
|
||||||
if (fEditor != null){
|
if (fEditor != null){
|
||||||
menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, refsMenu);
|
menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, refsMenu);
|
||||||
} else {
|
} else {
|
||||||
incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, refsMenu);
|
incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, refsMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
incomingMenu = refsMenu;
|
incomingMenu = refsMenu;
|
||||||
|
|
||||||
FindAction[] actions = getWorkingSetActions();
|
FindAction[] actions = getWorkingSetActions();
|
||||||
incomingMenu.add(fFindRefsAction);
|
incomingMenu.add(fFindRefsAction);
|
||||||
incomingMenu.add(fFindRefsProjectAction);
|
incomingMenu.add(fFindRefsProjectAction);
|
||||||
incomingMenu.add(fFindRefsInWorkingSetAction);
|
incomingMenu.add(fFindRefsInWorkingSetAction);
|
||||||
|
|
||||||
for (FindAction action : actions) {
|
for (FindAction action : actions) {
|
||||||
incomingMenu.add(action);
|
incomingMenu.add(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fillActionBars(IActionBars actionBars) {
|
||||||
|
actionBars.setGlobalActionHandler(ICEditorActionDefinitionIds.FIND_REFS, fFindRefsAction);
|
||||||
|
actionBars.setGlobalActionHandler(ICEditorActionDefinitionIds.FIND_REFS_PROJECT, fFindRefsProjectAction);
|
||||||
|
actionBars.setGlobalActionHandler(ICEditorActionDefinitionIds.FIND_REFS, fFindRefsAction);
|
||||||
|
}
|
||||||
|
|
||||||
private FindAction[] getWorkingSetActions() {
|
private FindAction[] getWorkingSetActions() {
|
||||||
ArrayList<FindAction> actions= new ArrayList<FindAction>(CSearchUtil.LRU_WORKINGSET_LIST_SIZE);
|
ArrayList<FindAction> actions= new ArrayList<FindAction>(CSearchUtil.LRU_WORKINGSET_LIST_SIZE);
|
||||||
|
|
||||||
Iterator<IWorkingSet[]> iter= CSearchUtil.getLRUWorkingSets().iterator();
|
Iterator<IWorkingSet[]> iter= CSearchUtil.getLRUWorkingSets().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
IWorkingSet[] workingSets= iter.next();
|
IWorkingSet[] workingSets= iter.next();
|
||||||
|
@ -99,14 +112,14 @@ public class ReferencesSearchGroup extends ActionGroup {
|
||||||
action= new WorkingSetFindAction(fEditor, new FindRefsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets));
|
action= new WorkingSetFindAction(fEditor, new FindRefsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets));
|
||||||
else
|
else
|
||||||
action= new WorkingSetFindAction(fSite, new FindRefsInWorkingSetAction(fSite, workingSets), CSearchUtil.toString(workingSets));
|
action= new WorkingSetFindAction(fSite, new FindRefsInWorkingSetAction(fSite, workingSets), CSearchUtil.toString(workingSets));
|
||||||
|
|
||||||
actions.add(action);
|
actions.add(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
return actions.toArray(new FindAction[actions.size()]);
|
return actions.toArray(new FindAction[actions.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Overrides method declared in ActionGroup
|
* Overrides method declared in ActionGroup
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -12,10 +12,12 @@ package org.eclipse.cdt.internal.ui.search.actions;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.Assert;
|
||||||
import org.eclipse.jface.action.IMenuManager;
|
import org.eclipse.jface.action.IMenuManager;
|
||||||
import org.eclipse.jface.text.ITextSelection;
|
import org.eclipse.jface.text.ITextSelection;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.ui.IActionBars;
|
||||||
import org.eclipse.ui.IWorkbenchSite;
|
import org.eclipse.ui.IWorkbenchSite;
|
||||||
import org.eclipse.ui.actions.ActionGroup;
|
import org.eclipse.ui.actions.ActionGroup;
|
||||||
import org.eclipse.ui.part.Page;
|
import org.eclipse.ui.part.Page;
|
||||||
|
@ -25,16 +27,16 @@ import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
|
|
||||||
public class SelectionSearchGroup extends ActionGroup {
|
public class SelectionSearchGroup extends ActionGroup {
|
||||||
|
|
||||||
private CEditor fEditor;
|
private CEditor fEditor;
|
||||||
|
|
||||||
private DeclarationsSearchGroup fDeclarationsSearchGroup;
|
private DeclarationsSearchGroup fDeclarationsSearchGroup;
|
||||||
private ReferencesSearchGroup fRefSearchGroup;
|
private ReferencesSearchGroup fRefSearchGroup;
|
||||||
|
|
||||||
public SelectionSearchGroup(CEditor editor){
|
public SelectionSearchGroup(CEditor editor){
|
||||||
//TODO: Assert editor not null
|
Assert.isNotNull(editor);
|
||||||
fEditor= editor;
|
fEditor= editor;
|
||||||
|
|
||||||
fDeclarationsSearchGroup= new DeclarationsSearchGroup(fEditor);
|
fDeclarationsSearchGroup= new DeclarationsSearchGroup(fEditor);
|
||||||
fRefSearchGroup = new ReferencesSearchGroup(fEditor);
|
fRefSearchGroup = new ReferencesSearchGroup(fEditor);
|
||||||
}
|
}
|
||||||
|
@ -51,24 +53,32 @@ public class SelectionSearchGroup extends ActionGroup {
|
||||||
fDeclarationsSearchGroup= new DeclarationsSearchGroup(site);
|
fDeclarationsSearchGroup= new DeclarationsSearchGroup(site);
|
||||||
fRefSearchGroup = new ReferencesSearchGroup(site);
|
fRefSearchGroup = new ReferencesSearchGroup(site);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Method declared on ActionGroup.
|
* Method declared on ActionGroup.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void fillContextMenu(IMenuManager menu) {
|
public void fillContextMenu(IMenuManager menu) {
|
||||||
super.fillContextMenu(menu);
|
super.fillContextMenu(menu);
|
||||||
|
|
||||||
fDeclarationsSearchGroup.fillContextMenu(menu);
|
fDeclarationsSearchGroup.fillContextMenu(menu);
|
||||||
fRefSearchGroup.fillContextMenu(menu);
|
fRefSearchGroup.fillContextMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fillActionBars(IActionBars actionBars) {
|
||||||
|
if (fEditor == null) {
|
||||||
|
fDeclarationsSearchGroup.fillActionBars(actionBars);
|
||||||
|
fRefSearchGroup.fillActionBars(actionBars);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean canActionBeAdded(ISelection selection) {
|
public static boolean canActionBeAdded(ISelection selection) {
|
||||||
if(selection instanceof ITextSelection) {
|
if(selection instanceof ITextSelection) {
|
||||||
return (((ITextSelection)selection).getLength() > 0);
|
return (((ITextSelection)selection).getLength() > 0);
|
||||||
}
|
}
|
||||||
return getElement(selection) != null;
|
return getElement(selection) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ICElement getElement(ISelection sel) {
|
private static ICElement getElement(ISelection sel) {
|
||||||
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
||||||
List<?> list= ((IStructuredSelection)sel).toList();
|
List<?> list= ((IStructuredSelection)sel).toList();
|
||||||
|
@ -81,7 +91,7 @@ public class SelectionSearchGroup extends ActionGroup {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.ui.actions.ActionGroup#dispose()
|
* @see org.eclipse.ui.actions.ActionGroup#dispose()
|
||||||
*/
|
*/
|
||||||
|
@ -91,14 +101,14 @@ public class SelectionSearchGroup extends ActionGroup {
|
||||||
fDeclarationsSearchGroup.dispose();
|
fDeclarationsSearchGroup.dispose();
|
||||||
fDeclarationsSearchGroup= null;
|
fDeclarationsSearchGroup= null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fRefSearchGroup != null) {
|
if (fRefSearchGroup != null) {
|
||||||
fRefSearchGroup.dispose();
|
fRefSearchGroup.dispose();
|
||||||
fRefSearchGroup= null;
|
fRefSearchGroup= null;
|
||||||
}
|
}
|
||||||
|
|
||||||
fEditor= null;
|
fEditor= null;
|
||||||
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<groupId>org.eclipse.cdt.features</groupId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdt.build.crossgcc-feature</artifactId>
|
<artifactId>org.eclipse.cdt.build.crossgcc</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>org.eclipse.cdt.gdb-feature</artifactId>
|
<groupId>org.eclipse.cdt.features</groupId>
|
||||||
|
<artifactId>org.eclipse.cdt.gdb</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
<version>7.0.0-SNAPSHOT</version>
|
<version>7.0.0-SNAPSHOT</version>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>org.eclipse.cdt.gdb.source-feature</artifactId>
|
<groupId>org.eclipse.cdt.features</groupId>
|
||||||
|
<artifactId>org.eclipse.cdt.gdb.source</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
<version>7.0.0-SNAPSHOT</version>
|
<version>7.0.0-SNAPSHOT</version>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>org.eclipse.cdt.gnu.debug-feature</artifactId>
|
<groupId>org.eclipse.cdt.feature</groupId>
|
||||||
|
<artifactId>org.eclipse.cdt.gnu.debug</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
<version>7.1.0-SNAPSHOT</version>
|
<version>7.1.0-SNAPSHOT</version>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>org.eclipse.cdt.gnu.debug.source-feature</artifactId>
|
<groupId>org.eclipse.cdt.features</groupId>
|
||||||
|
<artifactId>org.eclipse.cdt.gnu.debug.source</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
<version>7.1.0-SNAPSHOT</version>
|
<version>7.1.0-SNAPSHOT</version>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb.ui;singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb.ui;singleton:=true
|
||||||
Bundle-Version: 2.2.0.qualifier
|
Bundle-Version: 2.3.0.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin
|
Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
Require-Bundle: org.eclipse.ui,
|
Require-Bundle: org.eclipse.ui,
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<version>2.2.0-SNAPSHOT</version>
|
<version>2.3.0-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdt.dsf.gdb.ui</artifactId>
|
<artifactId>org.eclipse.cdt.dsf.gdb.ui</artifactId>
|
||||||
<packaging>eclipse-plugin</packaging>
|
<packaging>eclipse-plugin</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2009 QNX Software Systems and others.
|
* Copyright (c) 2004, 2011 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,10 +7,12 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Marc Khouzam (Ericsson) - Use IDsfBreakpointExtension directly (Bug 355833)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints;
|
package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
|
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IDsfBreakpointExtension;
|
||||||
import org.eclipse.cdt.dsf.gdb.breakpoints.CBreakpointGdbThreadsFilterExtension;
|
import org.eclipse.cdt.dsf.gdb.breakpoints.CBreakpointGdbThreadsFilterExtension;
|
||||||
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate;
|
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -44,12 +46,12 @@ public class CBreakpointGdbThreadFilterPage extends PropertyPage {
|
||||||
return (ICBreakpoint)getElement().getAdapter(ICBreakpoint.class);
|
return (ICBreakpoint)getElement().getAdapter(ICBreakpoint.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CBreakpointGdbThreadsFilterExtension getFilterExtension() {
|
public IDsfBreakpointExtension getFilterExtension() {
|
||||||
ICBreakpoint bp = getBreakpoint();
|
ICBreakpoint bp = getBreakpoint();
|
||||||
if (bp != null) {
|
if (bp != null) {
|
||||||
try {
|
try {
|
||||||
CBreakpointGdbThreadsFilterExtension filter =
|
IDsfBreakpointExtension filter =
|
||||||
(CBreakpointGdbThreadsFilterExtension) bp.getExtension(
|
(IDsfBreakpointExtension) bp.getExtension(
|
||||||
GdbLaunchDelegate.GDB_DEBUG_MODEL_ID, CBreakpointGdbThreadsFilterExtension.class);
|
GdbLaunchDelegate.GDB_DEBUG_MODEL_ID, CBreakpointGdbThreadsFilterExtension.class);
|
||||||
filter.initialize(bp);
|
filter.initialize(bp);
|
||||||
return filter;
|
return filter;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2009 QNX Software Systems and others.
|
* Copyright (c) 2004, 2011 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Marc Khouzam (Ericsson) - Check for a null threadId (Bug 356463)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints;
|
package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints;
|
||||||
|
|
||||||
|
@ -23,17 +24,17 @@ import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
|
||||||
import org.eclipse.cdt.dsf.concurrent.Query;
|
import org.eclipse.cdt.dsf.concurrent.Query;
|
||||||
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||||
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IDsfBreakpointExtension;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IProcesses;
|
import org.eclipse.cdt.dsf.debug.service.IProcesses;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl;
|
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData;
|
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IRunControl;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
|
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
|
||||||
import org.eclipse.cdt.dsf.gdb.breakpoints.CBreakpointGdbThreadsFilterExtension;
|
|
||||||
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
|
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
|
||||||
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
|
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
|
||||||
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
|
|
||||||
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
|
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
|
||||||
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
|
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
|
||||||
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
||||||
|
@ -256,7 +257,7 @@ public class GdbThreadFilterEditor {
|
||||||
|
|
||||||
private void createThreadViewer(Composite parent) {
|
private void createThreadViewer(Composite parent) {
|
||||||
Label label = new Label(parent, SWT.NONE);
|
Label label = new Label(parent, SWT.NONE);
|
||||||
label.setText("&Restrict to Selected Targets and Threads:"); //$NON-NLS-1$
|
label.setText(Messages.GdbThreadFilterEditor_RestrictToSelected);
|
||||||
label.setFont(parent.getFont());
|
label.setFont(parent.getFont());
|
||||||
label.setLayoutData(new GridData());
|
label.setLayoutData(new GridData());
|
||||||
GridData data = new GridData(GridData.FILL_BOTH);
|
GridData data = new GridData(GridData.FILL_BOTH);
|
||||||
|
@ -301,27 +302,19 @@ public class GdbThreadFilterEditor {
|
||||||
* a thread filter in a given thread, that thread should be checked.
|
* a thread filter in a given thread, that thread should be checked.
|
||||||
*/
|
*/
|
||||||
protected void setInitialCheckedState() {
|
protected void setInitialCheckedState() {
|
||||||
CBreakpointGdbThreadsFilterExtension filterExtension = fPage.getFilterExtension();
|
IDsfBreakpointExtension filterExtension = fPage.getFilterExtension();
|
||||||
try {
|
try {
|
||||||
IContainerDMContext[] targets = filterExtension.getTargetFilters();
|
IContainerDMContext[] targets = filterExtension.getTargetFilters();
|
||||||
|
|
||||||
// TODO: Hack to properly initialize the target/thread list
|
|
||||||
// Should be done in filterExtension.initialize() but we don't know
|
|
||||||
// how to get the target list from an ICBreakpoint...
|
|
||||||
if (targets.length == 0) {
|
|
||||||
targets = getDebugTargets();
|
|
||||||
for (IContainerDMContext target : targets) {
|
|
||||||
filterExtension.setTargetFilter(target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO: End of hack
|
|
||||||
|
|
||||||
for (int i = 0; i < targets.length; i++) {
|
for (int i = 0; i < targets.length; i++) {
|
||||||
IExecutionDMContext[] filteredThreads = filterExtension.getThreadFilters(targets[i]);
|
IExecutionDMContext[] filteredThreads = filterExtension.getThreadFilters(targets[i]);
|
||||||
if (filteredThreads != null) {
|
if (filteredThreads != null) {
|
||||||
for (int j = 0; j < filteredThreads.length; ++j)
|
for (int j = 0; j < filteredThreads.length; ++j) {
|
||||||
|
// Mark this thread as selected
|
||||||
fCheckHandler.checkThread(filteredThreads[j], true);
|
fCheckHandler.checkThread(filteredThreads[j], true);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Mark the entire process as selected
|
||||||
fCheckHandler.checkTarget(targets[i], true);
|
fCheckHandler.checkTarget(targets[i], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,7 +324,7 @@ public class GdbThreadFilterEditor {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doStore() {
|
protected void doStore() {
|
||||||
CBreakpointGdbThreadsFilterExtension filterExtension = fPage.getFilterExtension();
|
IDsfBreakpointExtension filterExtension = fPage.getFilterExtension();
|
||||||
IContainerDMContext[] targets = getDebugTargets();
|
IContainerDMContext[] targets = getDebugTargets();
|
||||||
for (int i = 0; i < targets.length; ++i) {
|
for (int i = 0; i < targets.length; ++i) {
|
||||||
try {
|
try {
|
||||||
|
@ -388,7 +381,7 @@ public class GdbThreadFilterEditor {
|
||||||
IContainerDMContext[] containerDmcs = (IContainerDMContext[])getData();
|
IContainerDMContext[] containerDmcs = (IContainerDMContext[])getData();
|
||||||
rm.setData(containerDmcs);
|
rm.setData(containerDmcs);
|
||||||
} else {
|
} else {
|
||||||
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Wront type of container contexts.")); //$NON-NLS-1$
|
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Wrong type of container contexts.")); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
|
@ -409,7 +402,7 @@ public class GdbThreadFilterEditor {
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
}
|
}
|
||||||
return null;
|
return new IContainerDMContext[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
private IExecutionDMContext[] syncGetThreads(final IContainerDMContext container) {
|
private IExecutionDMContext[] syncGetThreads(final IContainerDMContext container) {
|
||||||
|
@ -458,7 +451,7 @@ public class GdbThreadFilterEditor {
|
||||||
|
|
||||||
class ContainerLabelQuery extends Query<String> {
|
class ContainerLabelQuery extends Query<String> {
|
||||||
@Override
|
@Override
|
||||||
protected void execute(DataRequestMonitor<String> rm) {
|
protected void execute(final DataRequestMonitor<String> rm) {
|
||||||
if (!session.isActive()) {
|
if (!session.isActive()) {
|
||||||
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Container's session not active.")); //$NON-NLS-1$
|
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Container's session not active.")); //$NON-NLS-1$
|
||||||
rm.done();
|
rm.done();
|
||||||
|
@ -466,13 +459,30 @@ public class GdbThreadFilterEditor {
|
||||||
}
|
}
|
||||||
|
|
||||||
DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId());
|
DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId());
|
||||||
IGDBBackend backend = tracker.getService(IGDBBackend.class);
|
IProcesses processService = tracker.getService(IProcesses.class);
|
||||||
if (backend != null) {
|
IProcessDMContext procDmc = DMContexts.getAncestorOfType(container, IProcessDMContext.class);
|
||||||
rm.setData(backend.getProgramPath().toOSString());
|
if (processService != null && procDmc != null) {
|
||||||
|
processService.getExecutionData(
|
||||||
|
procDmc,
|
||||||
|
new DataRequestMonitor<IThreadDMData>(ImmediateExecutor.getInstance(), rm) {
|
||||||
|
@Override
|
||||||
|
public void handleSuccess() {
|
||||||
|
final StringBuilder builder = new StringBuilder(getData().getName());
|
||||||
|
String containerId = getData().getId();
|
||||||
|
if (containerId != null) {
|
||||||
|
builder.append(" ["); //$NON-NLS-1$
|
||||||
|
builder.append(containerId);
|
||||||
|
builder.append("]"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
rm.setData(builder.toString());
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "GDB Backend not accessible.")); //$NON-NLS-1$
|
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Processes service not accessible.")); //$NON-NLS-1$
|
||||||
|
rm.done();
|
||||||
}
|
}
|
||||||
rm.done();
|
|
||||||
tracker.dispose();
|
tracker.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -511,11 +521,18 @@ public class GdbThreadFilterEditor {
|
||||||
ImmediateExecutor.getInstance(), rm) {
|
ImmediateExecutor.getInstance(), rm) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleSuccess() {
|
protected void handleSuccess() {
|
||||||
final StringBuilder builder = new StringBuilder("Thread["); //$NON-NLS-1$
|
final StringBuilder builder = new StringBuilder(Messages.GdbThreadFilterEditor_Thread);
|
||||||
|
builder.append("["); //$NON-NLS-1$
|
||||||
builder.append(((IMIExecutionDMContext)thread).getThreadId());
|
builder.append(((IMIExecutionDMContext)thread).getThreadId());
|
||||||
builder.append("] "); //$NON-NLS-1$
|
builder.append("] "); //$NON-NLS-1$
|
||||||
builder.append(getData().getId());
|
String threadId = getData().getId();
|
||||||
builder.append(getData().getName());
|
if (threadId != null) {
|
||||||
|
builder.append(threadId);
|
||||||
|
}
|
||||||
|
String threadName = getData().getName();
|
||||||
|
if (threadName != null) {
|
||||||
|
builder.append(threadName);
|
||||||
|
}
|
||||||
|
|
||||||
rm.setData(builder.toString());
|
rm.setData(builder.toString());
|
||||||
rm.done();
|
rm.done();
|
||||||
|
|
|
@ -31,7 +31,10 @@ public class Messages extends NLS {
|
||||||
public static String TracepointPropertyPage_PassCount;
|
public static String TracepointPropertyPage_PassCount;
|
||||||
public static String TracepointPropertyPage_Class;
|
public static String TracepointPropertyPage_Class;
|
||||||
public static String TracepointPropertyPage_Enabled;
|
public static String TracepointPropertyPage_Enabled;
|
||||||
|
|
||||||
|
public static String GdbThreadFilterEditor_Thread;
|
||||||
|
public static String GdbThreadFilterEditor_RestrictToSelected;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// initialize resource bundle
|
// initialize resource bundle
|
||||||
NLS.initializeMessages(Messages.class.getName(), Messages.class);
|
NLS.initializeMessages(Messages.class.getName(), Messages.class);
|
||||||
|
|
|
@ -29,3 +29,6 @@ TracepointPropertyPage_IgnoreCount=&Ignore count:
|
||||||
TracepointPropertyPage_PassCount=&Pass count:
|
TracepointPropertyPage_PassCount=&Pass count:
|
||||||
TracepointPropertyPage_Class=Class:
|
TracepointPropertyPage_Class=Class:
|
||||||
TracepointPropertyPage_Enabled=Enabled
|
TracepointPropertyPage_Enabled=Enabled
|
||||||
|
|
||||||
|
GdbThreadFilterEditor_Thread=Thread
|
||||||
|
GdbThreadFilterEditor_RestrictToSelected=&Restrict to Selected Processes and Threads:
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2009 Wind River Systems and others.
|
* Copyright (c) 2007, 2011 Wind River Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -35,8 +35,6 @@ public class CBreakpointGdbThreadsFilterExtension implements IDsfBreakpointExten
|
||||||
* @see org.eclipse.cdt.debug.core.model.ICBreakpointExtension#initialize(org.eclipse.cdt.debug.core.model.ICBreakpoint)
|
* @see org.eclipse.cdt.debug.core.model.ICBreakpointExtension#initialize(org.eclipse.cdt.debug.core.model.ICBreakpoint)
|
||||||
*/
|
*/
|
||||||
public void initialize(ICBreakpoint breakpoint) {
|
public void initialize(ICBreakpoint breakpoint) {
|
||||||
// TODO: Initialize fFilteredThreadsByTarget with current IContainerDMContext[]
|
|
||||||
// TODO: IRunControl?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2010 Wind River and others.
|
* Copyright (c) 2007, 2011 Wind River and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -11,6 +11,7 @@
|
||||||
* Ericsson - Added breakpoint filter support
|
* Ericsson - Added breakpoint filter support
|
||||||
* Ericsson - Re-factored the service and put a few comments
|
* Ericsson - Re-factored the service and put a few comments
|
||||||
* Ericsson - Added Action support
|
* Ericsson - Added Action support
|
||||||
|
* Marc Khouzam (Ericsson) - Fix support for thread filter (Bug 355833)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.dsf.mi.service;
|
package org.eclipse.cdt.dsf.mi.service;
|
||||||
|
@ -422,7 +423,24 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
|
||||||
// Upon determining the debuggerPath, the breakpoint is installed
|
// Upon determining the debuggerPath, the breakpoint is installed
|
||||||
determineDebuggerPath(dmc, attributes, new RequestMonitor(getExecutor(), countingRm) {
|
determineDebuggerPath(dmc, attributes, new RequestMonitor(getExecutor(), countingRm) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleSuccess() {
|
protected void handleSuccess() {
|
||||||
|
// Before installing a breakpoint, set the target filter for that target.
|
||||||
|
// Even if the breakpoint is disabled when we start, the target filter
|
||||||
|
// can be accessed by the user through the breakpoint properties UI, so
|
||||||
|
// we must set it right now.
|
||||||
|
// This is the reason we don't do this in 'installBreakpoint', which is not
|
||||||
|
// called right away if the breakpoint is disabled.
|
||||||
|
try {
|
||||||
|
IContainerDMContext containerDmc = DMContexts.getAncestorOfType(dmc, IContainerDMContext.class);
|
||||||
|
IDsfBreakpointExtension filterExt = getFilterExtension(breakpoint);
|
||||||
|
if (filterExt.getThreadFilters(containerDmc) == null) {
|
||||||
|
// Do this only if there wasn't already an entry, or else we would
|
||||||
|
// erase the content of that previous entry.
|
||||||
|
filterExt.setTargetFilter(containerDmc);
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
|
|
||||||
// Install only if the breakpoint is enabled at startup (Bug261082)
|
// Install only if the breakpoint is enabled at startup (Bug261082)
|
||||||
// Note that Tracepoints are not affected by "skip-all"
|
// Note that Tracepoints are not affected by "skip-all"
|
||||||
boolean bpEnabled = attributes.get(ICBreakpoint.ENABLED).equals(true) &&
|
boolean bpEnabled = attributes.get(ICBreakpoint.ENABLED).equals(true) &&
|
||||||
|
@ -718,6 +736,14 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
|
||||||
final Map<ICBreakpoint, Set<String>> threadsIDs = fBreakpointThreads.get(dmc);
|
final Map<ICBreakpoint, Set<String>> threadsIDs = fBreakpointThreads.get(dmc);
|
||||||
assert threadsIDs != null;
|
assert threadsIDs != null;
|
||||||
|
|
||||||
|
// Remove any target filter (if any)
|
||||||
|
try {
|
||||||
|
IContainerDMContext containerDmc = DMContexts.getAncestorOfType(dmc, IContainerDMContext.class);
|
||||||
|
getFilterExtension(breakpoint).removeTargetFilter(containerDmc);
|
||||||
|
}
|
||||||
|
catch( CoreException e ) {
|
||||||
|
}
|
||||||
|
|
||||||
// Remove breakpoint problem marker (if any)
|
// Remove breakpoint problem marker (if any)
|
||||||
removeBreakpointProblemMarker(breakpoint);
|
removeBreakpointProblemMarker(breakpoint);
|
||||||
|
|
||||||
|
@ -1127,6 +1153,18 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
|
||||||
new RequestMonitor(getExecutor(), countingRm) {
|
new RequestMonitor(getExecutor(), countingRm) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleSuccess() {
|
protected void handleSuccess() {
|
||||||
|
// For a new breakpoint, set the target filter.
|
||||||
|
try {
|
||||||
|
IContainerDMContext containerDmc = DMContexts.getAncestorOfType(dmc, IContainerDMContext.class);
|
||||||
|
IDsfBreakpointExtension filterExt = getFilterExtension((ICBreakpoint)breakpoint);
|
||||||
|
if (filterExt.getThreadFilters(containerDmc) == null) {
|
||||||
|
// Do this only if there wasn't already an entry, or else we would
|
||||||
|
// erase the content of that previous entry.
|
||||||
|
filterExt.setTargetFilter(containerDmc);
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
|
|
||||||
installBreakpoint(dmc, (ICBreakpoint) breakpoint,
|
installBreakpoint(dmc, (ICBreakpoint) breakpoint,
|
||||||
attrs, countingRm);
|
attrs, countingRm);
|
||||||
}
|
}
|
||||||
|
@ -1372,15 +1410,28 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
|
||||||
for (IBreakpointsTargetDMContext ctx : fPlatformBPs.keySet()) {
|
for (IBreakpointsTargetDMContext ctx : fPlatformBPs.keySet()) {
|
||||||
Map<ICBreakpoint, Map<String, Object>> breakpoints = fPlatformBPs.get(ctx);
|
Map<ICBreakpoint, Map<String, Object>> breakpoints = fPlatformBPs.get(ctx);
|
||||||
clearBreakpointStatus(breakpoints.keySet().toArray(new ICBreakpoint[breakpoints.size()]), ctx);
|
clearBreakpointStatus(breakpoints.keySet().toArray(new ICBreakpoint[breakpoints.size()]), ctx);
|
||||||
|
|
||||||
|
// Also clear any target filter since we will not be calling uninstallBreakpoint() which
|
||||||
|
// usually does that work.
|
||||||
|
IContainerDMContext dmc = DMContexts.getAncestorOfType(ctx, IContainerDMContext.class);
|
||||||
|
clearTargetFilter(dmc, breakpoints.keySet());
|
||||||
}
|
}
|
||||||
// This will prevent Shutdown() from trying to remove bps from a
|
// This will prevent Shutdown() from trying to remove bps from a
|
||||||
// backend that has already shutdown
|
// backend that has already shutdown
|
||||||
fPlatformBPs.clear();
|
fPlatformBPs.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
private void clearTargetFilter(IContainerDMContext containerDmc, Set<ICBreakpoint> breakpoints) {
|
||||||
// Breakpoint status handling functions
|
// Remove any target filter (if any)
|
||||||
///////////////////////////////////////////////////////////////////////////
|
try {
|
||||||
|
for (ICBreakpoint bp : breakpoints) {
|
||||||
|
getFilterExtension(bp).removeTargetFilter(containerDmc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( CoreException e ) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bps
|
* @param bps
|
||||||
|
@ -1651,41 +1702,28 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Set<String> extractThreads(IBreakpointsTargetDMContext context, ICBreakpoint breakpoint) {
|
private Set<String> extractThreads(IBreakpointsTargetDMContext context, ICBreakpoint breakpoint) {
|
||||||
Set<String> results = new HashSet<String>();
|
Set<String> results = new HashSet<String>();
|
||||||
|
|
||||||
|
IExecutionDMContext[] threads = null;
|
||||||
|
try {
|
||||||
|
IContainerDMContext containerDmc = DMContexts.getAncestorOfType(context, IContainerDMContext.class);
|
||||||
|
threads = getFilterExtension(breakpoint).getThreadFilters(containerDmc);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
|
|
||||||
// Find the ancestor
|
if (threads == null || threads.length == 0) {
|
||||||
List<IExecutionDMContext[]> threads = new ArrayList<IExecutionDMContext[]>(1);
|
results.add("0"); //$NON-NLS-1$
|
||||||
|
return results;
|
||||||
try {
|
|
||||||
// Retrieve the targets
|
|
||||||
IDsfBreakpointExtension filterExtension = getFilterExtension(breakpoint);
|
|
||||||
IContainerDMContext[] targets = filterExtension.getTargetFilters();
|
|
||||||
|
|
||||||
// If no target is present, breakpoint applies to all.
|
|
||||||
if (targets.length == 0) {
|
|
||||||
results.add("0"); //$NON-NLS-1$
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract the thread IDs (if there is none, we are covered)
|
|
||||||
for (IContainerDMContext ctxt : targets) {
|
|
||||||
if (DMContexts.isAncestorOf(ctxt, context)) {
|
|
||||||
threads.add(filterExtension.getThreadFilters(ctxt));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (CoreException e1) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supportsThreads(breakpoint)) {
|
if (supportsThreads(breakpoint)) {
|
||||||
for (IExecutionDMContext[] targetThreads : threads) {
|
for (IExecutionDMContext thread : threads) {
|
||||||
if (targetThreads != null) {
|
if (thread instanceof IMIExecutionDMContext) {
|
||||||
for (IExecutionDMContext thread : targetThreads) {
|
results.add(Integer.toString(((IMIExecutionDMContext)thread).getThreadId()));
|
||||||
if (thread instanceof IMIExecutionDMContext) {
|
|
||||||
IMIExecutionDMContext dmc = (IMIExecutionDMContext) thread;
|
|
||||||
results.add(((Integer) dmc.getThreadId()).toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
// If any of the threads is not an IMIExecutionDMContext,
|
||||||
|
// we don't support thread filters at all.
|
||||||
|
results.clear();
|
||||||
results.add("0"); //$NON-NLS-1$
|
results.add("0"); //$NON-NLS-1$
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<groupId>org.eclipse.cdt.feature</groupId>
|
||||||
<version>4.0.0-SNAPSHOT</version>
|
<version>4.0.0-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdt.gdb.dsf-feature</artifactId>
|
<artifactId>org.eclipse.cdt.gnu.dsf</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<groupId>org.eclipse.cdt.features</groupId>
|
||||||
<version>4.0.0-SNAPSHOT</version>
|
<version>4.0.0-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdt.gdb.dsf.source-feature</artifactId>
|
<artifactId>org.eclipse.cdt.gnu.dsf.source</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -566,11 +566,10 @@ public class SyncUtil {
|
||||||
Assert.assertEquals("unexpected number of processes", 1, contexts.length);
|
Assert.assertEquals("unexpected number of processes", 1, contexts.length);
|
||||||
IDMContext context = contexts[0];
|
IDMContext context = contexts[0];
|
||||||
Assert.assertNotNull("unexpected process context type ", context);
|
Assert.assertNotNull("unexpected process context type ", context);
|
||||||
rm.setData((IContainerDMContext)context);
|
rm.done((IContainerDMContext)context);
|
||||||
} else {
|
} else {
|
||||||
rm.setStatus(getStatus());
|
rm.done(getStatus());
|
||||||
}
|
}
|
||||||
rm.done();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.dsf.ui;singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.dsf.ui;singleton:=true
|
||||||
Bundle-Version: 2.2.0.qualifier
|
Bundle-Version: 2.2.1.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin
|
Bundle-Activator: org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
Require-Bundle: org.eclipse.ui;bundle-version="3.5.0",
|
Require-Bundle: org.eclipse.ui;bundle-version="3.5.0",
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<version>2.2.0-SNAPSHOT</version>
|
<version>2.2.1-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdt.dsf.ui</artifactId>
|
<artifactId>org.eclipse.cdt.dsf.ui</artifactId>
|
||||||
<packaging>eclipse-plugin</packaging>
|
<packaging>eclipse-plugin</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -364,4 +364,8 @@ public class VMDelta extends ModelDelta {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIndex(final int index) {
|
||||||
|
fIndex = index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.dsf;singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.dsf;singleton:=true
|
||||||
Bundle-Version: 2.2.0.qualifier
|
Bundle-Version: 2.3.0.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.dsf.internal.DsfPlugin
|
Bundle-Activator: org.eclipse.cdt.dsf.internal.DsfPlugin
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
Require-Bundle: org.eclipse.core.runtime,
|
Require-Bundle: org.eclipse.core.runtime,
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<version>2.2.0-SNAPSHOT</version>
|
<version>2.3.0-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdt.dsf</artifactId>
|
<artifactId>org.eclipse.cdt.dsf</artifactId>
|
||||||
<packaging>eclipse-plugin</packaging>
|
<packaging>eclipse-plugin</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
|
* Eugene Ostroukhov (NVIDIA) - new done(V) method
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.concurrent;
|
package org.eclipse.cdt.dsf.concurrent;
|
||||||
|
|
||||||
|
@ -33,6 +34,8 @@ public class DataRequestMonitor<V> extends RequestMonitor {
|
||||||
* Sets the data object to specified value. To be called by the
|
* Sets the data object to specified value. To be called by the
|
||||||
* asynchronous method implementor.
|
* asynchronous method implementor.
|
||||||
* @param data Data value to set.
|
* @param data Data value to set.
|
||||||
|
*
|
||||||
|
* @see #done(Object)
|
||||||
*/
|
*/
|
||||||
public synchronized void setData(V data) { fData = data; }
|
public synchronized void setData(V data) { fData = data; }
|
||||||
|
|
||||||
|
@ -41,6 +44,26 @@ public class DataRequestMonitor<V> extends RequestMonitor {
|
||||||
*/
|
*/
|
||||||
public synchronized V getData() { return fData; }
|
public synchronized V getData() { return fData; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Completes the monitor setting data object to specified value. To be
|
||||||
|
* called by asynchronous method implementor.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Note: Only one <code>done</code> method should be called and only once,
|
||||||
|
* for every request issued. Even if the request was canceled.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param data Data value to set
|
||||||
|
* @see #setData(Object)
|
||||||
|
* @see #done()
|
||||||
|
* @see #done(org.eclipse.core.runtime.IStatus)
|
||||||
|
* @since 2.3
|
||||||
|
*/
|
||||||
|
public synchronized void done(V data) {
|
||||||
|
setData(data);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (getData() != null) {
|
if (getData() != null) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2010 Wind River Systems and others.
|
* Copyright (c) 2006, 2011 Wind River Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
|
* Eugene Ostroukhov (NVIDIA) - new done(IStatus) method
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.concurrent;
|
package org.eclipse.cdt.dsf.concurrent;
|
||||||
|
|
||||||
|
@ -165,7 +166,9 @@ public class RequestMonitor extends DsfExecutable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the status of the result of the request. If status is OK, this
|
* Sets the status of the result of the request. If status is OK, this
|
||||||
* method does not need to be called.
|
* method does not need to be called.
|
||||||
|
*
|
||||||
|
* @see #done(IStatus)
|
||||||
*/
|
*/
|
||||||
public synchronized void setStatus(IStatus status) {
|
public synchronized void setStatus(IStatus status) {
|
||||||
assert isCanceled() || status.getSeverity() != IStatus.CANCEL;
|
assert isCanceled() || status.getSeverity() != IStatus.CANCEL;
|
||||||
|
@ -270,8 +273,8 @@ public class RequestMonitor extends DsfExecutable {
|
||||||
* monitor submits a runnable to the DSF Executor to call the
|
* monitor submits a runnable to the DSF Executor to call the
|
||||||
* <code>handle...</code> methods.
|
* <code>handle...</code> methods.
|
||||||
* <p>
|
* <p>
|
||||||
* Note: This method should be called once and only once, for every request
|
* Note: Only one <code>done</code> method should be called and only once,
|
||||||
* issued. Even if the request was canceled.
|
* for every request issued. Even if the request was canceled.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public synchronized void done() {
|
public synchronized void done() {
|
||||||
|
@ -306,6 +309,24 @@ public class RequestMonitor extends DsfExecutable {
|
||||||
handleRejectedExecutionException();
|
handleRejectedExecutionException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets status and marks request monitor as completed.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Note: Only one <code>done</code> method should be called and only once,
|
||||||
|
* for every request issued. Even if the request was canceled.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param status Request processing status
|
||||||
|
* @see #done()
|
||||||
|
* @see #setStatus(IStatus)
|
||||||
|
* @since 2.3
|
||||||
|
*/
|
||||||
|
public synchronized void done(IStatus status) {
|
||||||
|
setStatus(status);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2009 Wind River Systems and others.
|
* Copyright (c) 2007, 2011 Wind River Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
|
* Marc Khouzam (Ericsson) - Adding javadoc (Bug 355833)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.debug.service;
|
package org.eclipse.cdt.dsf.debug.service;
|
||||||
|
|
||||||
|
@ -35,12 +36,60 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
*/
|
*/
|
||||||
public interface IDsfBreakpointExtension extends ICBreakpointExtension {
|
public interface IDsfBreakpointExtension extends ICBreakpointExtension {
|
||||||
|
|
||||||
public void setTargetFilter( IContainerDMContext target ) throws CoreException;
|
/**
|
||||||
public void removeTargetFilter( IContainerDMContext target ) throws CoreException;
|
* Add the given target to the list of this breakpoint's targets.
|
||||||
|
* Target filters are not persisted across workbench invocations.
|
||||||
|
*
|
||||||
|
* @param target the container to add to the list of this breakpoint's targets.
|
||||||
|
* @throws CoreException if unable to set the target filter
|
||||||
|
*/
|
||||||
|
public void setTargetFilter(IContainerDMContext target) throws CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the given target from the breakpoint's target list.
|
||||||
|
* The breakpoint has no effect in the given target.
|
||||||
|
*
|
||||||
|
* @param target the container filter to be removed
|
||||||
|
* @exception CoreException if unable to remove the target filter
|
||||||
|
*/
|
||||||
|
public void removeTargetFilter(IContainerDMContext target) throws CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all target filters set on this breakpoint.
|
||||||
|
*
|
||||||
|
* @return the targets that this breakpoint is restricted to
|
||||||
|
* @exception CoreException if unable to determine this breakpoint's target filters
|
||||||
|
*/
|
||||||
public IContainerDMContext[] getTargetFilters() throws CoreException;
|
public IContainerDMContext[] getTargetFilters() throws CoreException;
|
||||||
|
|
||||||
public void setThreadFilters( IExecutionDMContext[] threads ) throws CoreException;
|
/**
|
||||||
public void removeThreadFilters( IExecutionDMContext[] threads ) throws CoreException;
|
* Restricts this breakpoint to suspend only in the given threads
|
||||||
public IExecutionDMContext[] getThreadFilters( IContainerDMContext target ) throws CoreException;
|
* when encountered in the given threads' target.
|
||||||
|
* All threads must be from the same target.
|
||||||
|
* Thread filters are not persisted across workbench invocations.
|
||||||
|
*
|
||||||
|
* @param threads the thread filters to be set
|
||||||
|
* @exception CoreException if unable to set the thread filters
|
||||||
|
*/
|
||||||
|
public void setThreadFilters(IExecutionDMContext[] threads) throws CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes this breakpoint's thread filters in the given target, if any.
|
||||||
|
* Has no effect if this breakpoint does not have filters in the given target.
|
||||||
|
* All threads must be from the same target.
|
||||||
|
*
|
||||||
|
* @param threads the thread filters to be removed
|
||||||
|
* @exception CoreException if unable to remove the thread filter
|
||||||
|
*/
|
||||||
|
public void removeThreadFilters(IExecutionDMContext[] threads) throws CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the threads in the given target in which this breakpoint
|
||||||
|
* is enabled or <code>null</code> if this breakpoint is enabled in
|
||||||
|
* all threads in the given target.
|
||||||
|
*
|
||||||
|
* @return the threads in the given target that this breakpoint is enabled for
|
||||||
|
* @exception CoreException if unable to determine this breakpoint's thread filters
|
||||||
|
*/
|
||||||
|
public IExecutionDMContext[] getThreadFilters(IContainerDMContext target) throws CoreException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<groupId>org.eclipse.cdt.features</groupId>
|
||||||
<version>2.1.0-SNAPSHOT</version>
|
<version>2.1.0-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdt.examples.dsf-feature</artifactId>
|
<artifactId>org.eclipse.cdt.examples.dsf</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<groupId>org.eclipse.cdt.features</groupId>
|
||||||
<version>7.0.0-SNAPSHOT</version>
|
<version>7.0.0-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdtdebug.gdbjtag-feature</artifactId>
|
<artifactId>org.eclipse.cdt.debug.gdbjtag</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.debug.gdbjtag.core;singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.debug.gdbjtag.core;singleton:=true
|
||||||
Bundle-Version: 8.0.0.qualifier
|
Bundle-Version: 8.0.1.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.debug.gdbjtag.core.Activator
|
Bundle-Activator: org.eclipse.cdt.debug.gdbjtag.core.Activator
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
Require-Bundle: org.eclipse.core.runtime,
|
Require-Bundle: org.eclipse.core.runtime,
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<version>8.0.0-SNAPSHOT</version>
|
<version>8.0.1-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdt.debug.gdbjtag.core</artifactId>
|
<artifactId>org.eclipse.cdt.debug.gdbjtag.core</artifactId>
|
||||||
<packaging>eclipse-plugin</packaging>
|
<packaging>eclipse-plugin</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 - 2010 QNX Software Systems and others.
|
* Copyright (c) 2007 - 2011 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -11,6 +11,7 @@
|
||||||
* Sage Electronic Engineering, LLC - bug 305943
|
* Sage Electronic Engineering, LLC - bug 305943
|
||||||
* - API generalization to become transport-independent (allow
|
* - API generalization to become transport-independent (allow
|
||||||
* connections via serial ports and pipes).
|
* connections via serial ports and pipes).
|
||||||
|
* John Dallaway - Wrong groupId during initialization (Bug 349736)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.gdbjtag.core;
|
package org.eclipse.cdt.debug.gdbjtag.core;
|
||||||
|
|
||||||
|
@ -615,7 +616,7 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
|
||||||
public void execute(final RequestMonitor requestMonitor) {
|
public void execute(final RequestMonitor requestMonitor) {
|
||||||
if (fSessionType != SessionType.CORE) {
|
if (fSessionType != SessionType.CORE) {
|
||||||
MIBreakpointsManager bpmService = fTracker.getService(MIBreakpointsManager.class);
|
MIBreakpointsManager bpmService = fTracker.getService(MIBreakpointsManager.class);
|
||||||
IMIContainerDMContext containerDmc = fProcService.createContainerContextFromGroupId(fCommandControl.getContext(), null);
|
IMIContainerDMContext containerDmc = fProcService.createContainerContextFromGroupId(fCommandControl.getContext(), MIProcesses.UNIQUE_GROUP_ID);
|
||||||
IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(containerDmc, IBreakpointsTargetDMContext.class);
|
IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(containerDmc, IBreakpointsTargetDMContext.class);
|
||||||
|
|
||||||
bpmService.startTrackingBreakpoints(bpTargetDmc, requestMonitor);
|
bpmService.startTrackingBreakpoints(bpTargetDmc, requestMonitor);
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<groupId>org.eclipse.cdt.features</groupId>
|
||||||
<version>5.2.0-SNAPSHOT</version>
|
<version>5.2.0-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdt.core.lrparser.sdk.feature</artifactId>
|
<artifactId>org.eclipse.cdt.core.lrparser.sdk</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<groupId>org.eclipse.cdt.features</groupId>
|
||||||
<version>5.2.0-SNAPSHOT</version>
|
<version>5.2.0-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdt.core.lrparser.source.feature</artifactId>
|
<artifactId>org.eclipse.cdt.core.lrparser.source</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<groupId>org.eclipse.cdt.features</groupId>
|
||||||
<version>2.1.100-SNAPSHOT</version>
|
<version>2.1.100-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdt.debug.ui.memory-feature</artifactId>
|
<artifactId>org.eclipse.cdt.debug.ui.memory</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class GoToAddressBarWidget {
|
||||||
private Button fOKButton;
|
private Button fOKButton;
|
||||||
private Button fOKNewTabButton;
|
private Button fOKNewTabButton;
|
||||||
private Composite fComposite;
|
private Composite fComposite;
|
||||||
|
private Object fCurrentDebugContext;
|
||||||
|
|
||||||
protected static int ID_GO_NEW_TAB = 2000;
|
protected static int ID_GO_NEW_TAB = 2000;
|
||||||
|
|
||||||
|
@ -267,20 +268,22 @@ public class GoToAddressBarWidget {
|
||||||
*/
|
*/
|
||||||
public void loadSavedExpressions(Object context, String memorySpace)
|
public void loadSavedExpressions(Object context, String memorySpace)
|
||||||
{
|
{
|
||||||
|
if ( context != null && ! context.equals( fCurrentDebugContext ) ) {
|
||||||
try {
|
try {
|
||||||
String[] expressions = getSavedExpressions(context, memorySpace);
|
String[] expressions = getSavedExpressions(context, memorySpace);
|
||||||
String currentExpression = fExpression.getText();
|
String currentExpression = fExpression.getText();
|
||||||
fExpression.removeAll();
|
fExpression.removeAll();
|
||||||
for (String expression : expressions) {
|
for (String expression : expressions) {
|
||||||
fExpression.add(expression);
|
fExpression.add(expression);
|
||||||
|
}
|
||||||
|
if (currentExpression != null) {
|
||||||
|
fExpression.setText(currentExpression);
|
||||||
|
}
|
||||||
|
fCurrentDebugContext = context;
|
||||||
|
} catch (CoreException e) {
|
||||||
|
// Unexpected snag dealing with launch configuration
|
||||||
|
MemoryBrowserPlugin.log(e);
|
||||||
}
|
}
|
||||||
if (currentExpression != null) {
|
|
||||||
fExpression.setText(currentExpression);
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
// Unexpected snag dealing with launch configuration
|
|
||||||
MemoryBrowserPlugin.log(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -11,7 +11,8 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<groupId>org.eclipse.cdt.features</groupId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdt.p2-feature</artifactId>
|
<artifactId>org.eclipse.cdt.p2</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>org.eclipse.cdt-feature</artifactId>
|
<groupId>org.eclipse.cdt.features</groupId>
|
||||||
|
<artifactId>org.eclipse.cdt</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>org.eclipse.cdt.platform-feature</artifactId>
|
<groupId>org.eclipse.cdt.features</groupId>
|
||||||
|
<artifactId>org.eclipse.cdt.platform</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>org.eclipse.cdt.platform.source-feature</artifactId>
|
<groupId>org.eclipse.cdt.features</groupId>
|
||||||
|
<artifactId>org.eclipse.cdt.platform.source</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>org.eclipse.cdt.sdk-feature</artifactId>
|
<groupId>org.eclipse.cdt.features</groupId>
|
||||||
|
<artifactId>org.eclipse.cdt.sdk</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<groupId>org.eclipse.cdt.features</groupId>
|
||||||
<version>1.0.3-SNAPSHOT</version>
|
<version>1.0.3-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdt.bupc-feature</artifactId>
|
<artifactId>org.eclipse.cdt.bupc</artifactId>
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue