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>
|
||||
</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>
|
||||
</project>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</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>
|
||||
</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.internal.core.MakeMessages;
|
||||
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.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -220,7 +221,7 @@ public class ScannerInfoConsoleParserUtility extends AbstractGCCBOPConsoleParser
|
|||
// appending fileName to cwd should yield file path
|
||||
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
|
||||
// check if file name starts with ".."
|
||||
if (fileName.startsWith("..")) { //$NON-NLS-1$
|
||||
|
@ -237,7 +238,7 @@ public class ScannerInfoConsoleParserUtility extends AbstractGCCBOPConsoleParser
|
|||
tPath = tPath.removeFirstSegments(1);
|
||||
}
|
||||
// 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());
|
||||
if (lastFileSegment.matchingFirstSegments(tPath) == tPath.segmentCount()) {
|
||||
cwd = filePath.removeLastSegments(tPath.segmentCount());
|
||||
|
|
|
@ -12,7 +12,8 @@ Require-Bundle: org.eclipse.ui,
|
|||
org.eclipse.cdt.core,
|
||||
org.eclipse.cdt.codan.core.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-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Bundle-Vendor: %Bundle-Vendor
|
||||
|
|
|
@ -37,6 +37,15 @@
|
|||
class="org.eclipse.cdt.codan.internal.checkers.ui.quickfix.QuickFixCreateParameter"
|
||||
problemId="org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem">
|
||||
</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>
|
||||
|
||||
</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 {
|
||||
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 QuickFixCreateLocalVariable_0;
|
||||
public static String QuickFixCreateParameter_0;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
CaseBreakQuickFixBreak_Label=Add break statement
|
||||
CaseBreakQuickFixComment_Label=Add supressing comment
|
||||
QuickFixCreateField_0=Create field
|
||||
QuickFixCreateLocalVariable_0=Create local variable
|
||||
QuickFixCreateParameter_0=Create parameter
|
|
@ -52,7 +52,7 @@ problem.name.FormatString = Format String Vulnerability
|
|||
checker.name.AssignmentToItself = Assignment to itself
|
||||
problem.messagePattern.AssignmentToItself = Assignment to itself ''{0}''
|
||||
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
|
||||
problem.name.ReturnStyle = Return with 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
|
||||
problem.name.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
|
||||
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
|
||||
problem.description.G = Name resolution problem found by the indexer
|
||||
problem.messagePattern.G = Symbol ''{0}'' could not be resolved
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Anton Gorenkov - initial implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
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.IASTTranslationUnit;
|
||||
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.cpp.ICPPASTFunctionCallExpression;
|
||||
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.
|
||||
* If it is - reports violations on each pure virtual method
|
||||
* Checks whether specified type (class or typedef to the class) is an abstract class.
|
||||
* If it is, reports violations on each pure virtual method
|
||||
*/
|
||||
private void reportProblemsIfAbstract(IType typeToCheck, IASTNode problemNode ) {
|
||||
IType unwindedType = CxxAstUtils.getInstance().unwindTypedef(typeToCheck);
|
||||
if (unwindedType instanceof ICPPClassType) {
|
||||
ICPPClassType classType = (ICPPClassType) unwindedType;
|
||||
ICPPMethod[] pureVirtualMethods = pureVirtualMethodsCache.get(classType);
|
||||
if (pureVirtualMethods == null) {
|
||||
pureVirtualMethods = ClassTypeHelper.getPureVirtualMethods(classType);
|
||||
pureVirtualMethodsCache.put(classType, pureVirtualMethods);
|
||||
}
|
||||
|
||||
for (ICPPMethod method : pureVirtualMethods) {
|
||||
reportProblem(ER_ID, problemNode, resolveName(classType), resolveName(method));
|
||||
}
|
||||
if (!(unwindedType instanceof ICPPClassType) || unwindedType instanceof IProblemBinding) {
|
||||
return;
|
||||
}
|
||||
ICPPClassType classType = (ICPPClassType) unwindedType;
|
||||
ICPPMethod[] pureVirtualMethods = pureVirtualMethodsCache.get(classType);
|
||||
if (pureVirtualMethods == null) {
|
||||
pureVirtualMethods = ClassTypeHelper.getPureVirtualMethods(classType);
|
||||
pureVirtualMethodsCache.put(classType, pureVirtualMethods);
|
||||
}
|
||||
|
||||
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
|
||||
* 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
|
||||
* Elena laskavaia - Rewrote checker to reduce false positives in complex cases
|
||||
* Gil Barash - Initial implementation
|
||||
* Elena laskavaia - Rewrote checker to reduce false positives in complex cases
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.internal.checkers;
|
||||
|
||||
import org.eclipse.cdt.codan.core.cxx.CxxAstUtils;
|
||||
import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker;
|
||||
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.core.dom.ast.ASTVisitor;
|
||||
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.IASTDefaultStatement;
|
||||
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.IASTIfStatement;
|
||||
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.IASTReturnStatement;
|
||||
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$
|
||||
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 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
|
||||
* them.
|
||||
* This visitor looks for "switch" statements and invokes "SwitchVisitor" on them.
|
||||
*/
|
||||
class SwitchFindingVisitor extends ASTVisitor {
|
||||
SwitchFindingVisitor() {
|
||||
|
@ -60,7 +67,7 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
|
|||
* - "continue"
|
||||
* - "goto" (does not check that the goto actually exists the
|
||||
* switch)
|
||||
* - "thorw"
|
||||
* - "throw"
|
||||
* - "exit"
|
||||
*/
|
||||
protected boolean isBreakOrExitStatement(IASTStatement statement) {
|
||||
|
@ -72,11 +79,11 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
|
|||
|
||||
@Override
|
||||
public int visit(IASTStatement statement) {
|
||||
if (statement instanceof IASTSwitchStatement && !isProducedMyMacroExpansion(statement)) {
|
||||
if (statement instanceof IASTSwitchStatement && !isProducedByMacroExpansion(statement)) {
|
||||
IASTSwitchStatement switchStmt = (IASTSwitchStatement) statement;
|
||||
IASTStatement body = switchStmt.getBody();
|
||||
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 prevCase = null;
|
||||
for (int i = 0; i < statements.length; i++) {
|
||||
|
@ -90,16 +97,16 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
|
|||
if (isCaseStatement(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)) {
|
||||
// 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) {
|
||||
continue; // empty case & we don't care
|
||||
continue; // Empty case and we don't care
|
||||
}
|
||||
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;
|
||||
if (next != null) {
|
||||
comment = getLeadingComment(next);
|
||||
|
@ -110,10 +117,10 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
|
|||
}
|
||||
if (comment != null) {
|
||||
String str = getTrimmedComment(comment);
|
||||
if (str.equalsIgnoreCase(_noBreakComment))
|
||||
if (str.toLowerCase().contains(_noBreakComment.toLowerCase()))
|
||||
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
|
||||
*/
|
||||
public boolean isFallThroughStamement(IASTStatement body) {
|
||||
if (body == null) return true;
|
||||
if (body == null)
|
||||
return true;
|
||||
if (body instanceof IASTCompoundStatement) {
|
||||
IASTStatement[] statements = ((IASTCompoundStatement) body).getStatements();
|
||||
if (statements.length > 0) {
|
||||
return isFallThroughStamement(statements[statements.length - 1]);
|
||||
return isFallThroughStamement(statements[statements.length - 1]);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (isBreakOrExitStatement(body)) {
|
||||
return false;
|
||||
|
@ -150,26 +157,34 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
|
|||
return true;
|
||||
} else if (body instanceof IASTIfStatement) {
|
||||
IASTIfStatement ifs = (IASTIfStatement) body;
|
||||
return isFallThroughStamement(ifs.getThenClause()) || isFallThroughStamement(ifs.getElseClause()) ;
|
||||
return isFallThroughStamement(ifs.getThenClause()) || isFallThroughStamement(ifs.getElseClause());
|
||||
}
|
||||
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:
|
||||
# Alena Laskavaia - initial API and implementation
|
||||
###############################################################################
|
||||
CaseBreakChecker_DefaultNoBreakCommentDescription=Comment text to suppress the problem (regular expression):
|
||||
CaseBreakChecker_EmptyCaseDescription=Check also empty case statement (except if last)
|
||||
CaseBreakChecker_LastCaseDescription=Check also the last case statement
|
||||
CaseBreakChecker_DefaultNoBreakCommentDescription=Comment text to suppress the problem:
|
||||
CaseBreakChecker_EmptyCaseDescription=Check also empty 'case' statement (except if last)
|
||||
CaseBreakChecker_LastCaseDescription=Check also the last 'case' statement
|
||||
ClassMembersInitializationChecker_SkipConstructorsWithFCalls=Skip constructors with initialization function calls
|
||||
CatchByReference_ReportForUnknownType=Report a problem if type cannot be resolved
|
||||
NamingConventionFunctionChecker_LabelNamePattern=Name Pattern
|
||||
|
@ -18,9 +18,9 @@ NamingConventionFunctionChecker_ParameterMethods=Also check C++ method names
|
|||
ReturnChecker_Param0=Also check functions with implicit return value
|
||||
GenericParameter_ParameterExceptions=Exceptions (value of the problem argument)
|
||||
GenericParameter_ParameterExceptionsItem=Value of the argument
|
||||
StatementHasNoEffectChecker_ParameterMacro=Report problem in statements that comes from macro expansion
|
||||
SuggestedParenthesisChecker_SuggestParanthesesAroundNot=Suggest parenthesis around not operator
|
||||
SuspiciousSemicolonChecker_ParamAfterElse=Report an error if semicolon is right after else statement
|
||||
StatementHasNoEffectChecker_ParameterMacro=Report problem in statements that come from macro expansion
|
||||
SuggestedParenthesisChecker_SuggestParanthesesAroundNot=Suggest parenthesis around 'not' operator
|
||||
SuspiciousSemicolonChecker_ParamAfterElse=Report an error if semicolon is right after 'else' statement
|
||||
SuspiciousSemicolonChecker_ParamElse=Do not report an error after 'if' when 'else' exists
|
||||
|
||||
ProblemBindingChecker_Candidates=Candidates are:
|
||||
|
|
|
@ -57,9 +57,7 @@ public class StatementHasNoEffectChecker extends AbstractIndexAstChecker {
|
|||
if (stmt instanceof IASTExpressionStatement) {
|
||||
IASTExpression expression = ((IASTExpressionStatement) stmt).getExpression();
|
||||
if (hasNoEffect(expression)) {
|
||||
boolean inMacro = CxxAstUtils.getInstance().isInMacro(expression);
|
||||
boolean shouldReportInMacro = shouldReportInMacro();
|
||||
if (inMacro && !shouldReportInMacro)
|
||||
if (!shouldReportInMacro() && CxxAstUtils.isInMacro(expression))
|
||||
return PROCESS_SKIP;
|
||||
String arg = expression.getRawSignature();
|
||||
if (!isFilteredArg(arg))
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Gvozdev - initial API and implementation
|
||||
* Andrew Gvozdev - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.internal.checkers;
|
||||
|
||||
|
@ -18,6 +19,7 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
|
||||
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.model.IProblem;
|
||||
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_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 PARAM_MACRO_ID = "macro"; //$NON-NLS-1$
|
||||
public static final String PARAM_EXCEPT_ARG_LIST = "exceptions"; //$NON-NLS-1$
|
||||
|
||||
private Map<IBinding, IASTDeclarator> externFunctionDeclarations = new HashMap<IBinding, IASTDeclarator>();
|
||||
|
@ -71,6 +74,7 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
|
|||
@Override
|
||||
public void initPreferences(IProblemWorkingCopy problem) {
|
||||
super.initPreferences(problem);
|
||||
addPreference(problem, PARAM_MACRO_ID, CheckersMessages.StatementHasNoEffectChecker_ParameterMacro, Boolean.TRUE);
|
||||
if (problem.getId().equals(ER_UNUSED_VARIABLE_DECLARATION_ID)) {
|
||||
unusedVariableProblem = problem;
|
||||
ListProblemPreference pref = addListPreference(problem, PARAM_EXCEPT_ARG_LIST,
|
||||
|
@ -90,11 +94,11 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
|
|||
}
|
||||
|
||||
private boolean isAnyCandidate() {
|
||||
return externFunctionDeclarations.size() > 0 ||
|
||||
staticFunctionDeclarations.size() > 0 ||
|
||||
staticFunctionDefinitions.size() > 0 ||
|
||||
externVariableDeclarations.size() > 0 ||
|
||||
staticVariableDeclarations.size() > 0;
|
||||
return !externFunctionDeclarations.isEmpty() ||
|
||||
!staticFunctionDeclarations.isEmpty() ||
|
||||
!staticFunctionDefinitions.isEmpty() ||
|
||||
!externVariableDeclarations.isEmpty() ||
|
||||
!staticVariableDeclarations.isEmpty();
|
||||
}
|
||||
|
||||
public void processAst(IASTTranslationUnit ast) {
|
||||
|
@ -131,42 +135,51 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
|
|||
int storageClass = simpleDeclaration.getDeclSpecifier().getStorageClass();
|
||||
|
||||
if (binding instanceof IFunction) {
|
||||
if (storageClass == IASTDeclSpecifier.sc_extern || storageClass == IASTDeclSpecifier.sc_unspecified) {
|
||||
externFunctionDeclarations.put(binding, decl);
|
||||
} else if (storageClass == IASTDeclSpecifier.sc_static) {
|
||||
staticFunctionDeclarations.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);
|
||||
if (storageClass == IASTDeclSpecifier.sc_extern ||
|
||||
storageClass == IASTDeclSpecifier.sc_unspecified) {
|
||||
if (shouldReportInMacro(ER_UNUSED_FUNCTION_DECLARATION_ID) ||
|
||||
!CxxAstUtils.isInMacro(astName)) {
|
||||
externFunctionDeclarations.put(binding, decl);
|
||||
}
|
||||
} else if (storageClass == IASTDeclSpecifier.sc_static) {
|
||||
IType type = ((IVariable) binding).getType();
|
||||
// account for class constructor and avoid possible false positive
|
||||
if (!(type instanceof ICPPClassType) && !(type instanceof IProblemType)) {
|
||||
// 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 (shouldReportInMacro(ER_UNUSED_STATIC_FUNCTION_ID) ||
|
||||
!CxxAstUtils.isInMacro(astName)) {
|
||||
staticFunctionDeclarations.put(binding, decl);
|
||||
}
|
||||
}
|
||||
} else if (binding instanceof IVariable) {
|
||||
if (shouldReportInMacro(ER_UNUSED_VARIABLE_DECLARATION_ID) ||
|
||||
!CxxAstUtils.isInMacro(astName)) {
|
||||
if (storageClass == IASTDeclSpecifier.sc_extern) {
|
||||
// Initializer makes "extern" declaration to become definition do not count these
|
||||
if (decl.getInitializer() == null) {
|
||||
externVariableDeclarations.put(binding, decl);
|
||||
}
|
||||
if (clause instanceof IASTLiteralExpression) {
|
||||
IASTLiteralExpression literalExpression = (IASTLiteralExpression) clause;
|
||||
String literal = literalExpression.toString();
|
||||
if (isFilteredOut(literal, unusedVariableProblem, PARAM_EXCEPT_ARG_LIST))
|
||||
continue;
|
||||
} else if (storageClass == IASTDeclSpecifier.sc_static) {
|
||||
IType type = ((IVariable) binding).getType();
|
||||
// Account for class constructor and avoid possible false positive
|
||||
if (!(type instanceof ICPPClassType) && !(type instanceof IProblemType)) {
|
||||
// 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);
|
||||
}
|
||||
|
||||
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);
|
||||
staticVariableDeclarations.remove(binding);
|
||||
}
|
||||
|
@ -310,7 +328,7 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
|
|||
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);
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
String str = (String) arr[i];
|
||||
|
@ -320,4 +338,7 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
|
|||
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;
|
||||
}
|
||||
|
||||
public boolean isInMacro(IASTNode node) {
|
||||
public static boolean isInMacro(IASTNode node) {
|
||||
IASTNodeSelector nodeSelector = node.getTranslationUnit().getNodeSelector(node.getTranslationUnit().getFilePath());
|
||||
IASTFileLocation fileLocation = node.getFileLocation();
|
||||
IASTPreprocessorMacroExpansion macro = nodeSelector.findEnclosingMacroExpansion(fileLocation.getNodeOffset(),
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
</parent>
|
||||
|
||||
<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>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Gil Barash - Initial implementation
|
||||
* Gil Barash - Initial implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.internal.checkers;
|
||||
|
||||
|
@ -62,7 +63,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
// }
|
||||
public void testLastCaseBad() {
|
||||
loadCodeAndRun(getAboveComment());
|
||||
checkErrorLines(4);
|
||||
checkErrorLines(5);
|
||||
}
|
||||
|
||||
// void foo(void) {
|
||||
|
@ -181,7 +182,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
// }
|
||||
public void testEmptyLastCaseTwoSwitches() {
|
||||
loadCodeAndRun(getAboveComment());
|
||||
checkErrorLines(3);
|
||||
checkErrorLines(7);
|
||||
}
|
||||
|
||||
// void foo(void) {
|
||||
|
@ -222,7 +223,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
// }
|
||||
public void testLastCaseBadCommentNotLast() {
|
||||
loadCodeAndRun(getAboveComment());
|
||||
checkErrorLines(4);
|
||||
checkErrorLines(7);
|
||||
}
|
||||
|
||||
// void foo(void) {
|
||||
|
@ -246,70 +247,74 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
// case 6:
|
||||
// b = 2;
|
||||
// /* no break1 */
|
||||
// case 7:
|
||||
// b = 2;
|
||||
// /* fallthrough */
|
||||
// }
|
||||
// }
|
||||
public void testDifferentComments() {
|
||||
loadCodeAndRun(getAboveComment());
|
||||
checkErrorLines(16, 19);
|
||||
checkErrorLines(17,23);
|
||||
}
|
||||
|
||||
// void foo(void) {
|
||||
// int a, b;
|
||||
// switch( a ) {
|
||||
// case 1:
|
||||
// case 1: //err
|
||||
// // lolo
|
||||
// case 2:
|
||||
// case 3:
|
||||
// case 2: //err
|
||||
// case 3://err
|
||||
// }
|
||||
//
|
||||
// switch( a ) {
|
||||
// case 1:
|
||||
// b = 2;
|
||||
// b = 2; // err
|
||||
// // lolo
|
||||
// case 2:
|
||||
// b = 2;
|
||||
// case 3:
|
||||
// b = 2; // err
|
||||
// case 3: // err
|
||||
// case 4:
|
||||
// break;
|
||||
// case 5:
|
||||
// case 6:
|
||||
// case 5: // err
|
||||
// case 6: // err
|
||||
// }
|
||||
//
|
||||
// switch( a ) {
|
||||
// case 1:
|
||||
// b = 2;
|
||||
// b = 2; // err
|
||||
// // lolo
|
||||
// case 2:
|
||||
// b = 2;
|
||||
// b = 2; //err
|
||||
// case 3:
|
||||
// b = 2;
|
||||
// /* no break */
|
||||
// case 4:
|
||||
// b = 2;
|
||||
// b = 2; // err
|
||||
// case 5:
|
||||
// b = 2;
|
||||
// break;
|
||||
// case 6:
|
||||
// b = 2;
|
||||
// /* no break */
|
||||
// b = 2;
|
||||
// b = 2; //err
|
||||
// case 7:
|
||||
// b = 2;
|
||||
// b = 2;//err
|
||||
// }
|
||||
//
|
||||
// switch( a ) {
|
||||
// case 1:
|
||||
// b = 2;
|
||||
// b = 2; // err
|
||||
// // lolo
|
||||
// case 2:
|
||||
// b = 2;
|
||||
// default:
|
||||
// b = 2; // err
|
||||
// default: //err
|
||||
// }
|
||||
// }
|
||||
public void testGeneral1() {
|
||||
setEmpty(true);
|
||||
setLast(true);
|
||||
loadCodeAndRun(getAboveComment());
|
||||
checkErrorLines(4, 6, 7, 11, 14, 16, 19, 20, 24, 27, 32, 37, 41, 46, 49, 51);
|
||||
checkErrorComments();
|
||||
}
|
||||
|
||||
// void foo(void) {
|
||||
|
@ -339,7 +344,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
// }
|
||||
public void testGeneralComments1() {
|
||||
loadCodeAndRun(getAboveComment());
|
||||
checkErrorLines(8, 12);
|
||||
checkErrorLines(9, 14);
|
||||
}
|
||||
|
||||
// void foo(void) {
|
||||
|
@ -347,14 +352,14 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
// switch( a ) {
|
||||
// case 0:
|
||||
// switch( b ) {
|
||||
// case 2:
|
||||
// }
|
||||
// case 2: // err
|
||||
// } // err
|
||||
//
|
||||
// case 1:
|
||||
// switch( b ) {
|
||||
// case 2:
|
||||
// break;
|
||||
// }
|
||||
// } // err
|
||||
// case 3:
|
||||
// switch( b ) {
|
||||
// case 2:
|
||||
|
@ -365,25 +370,25 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
// switch( b ) {
|
||||
// case 2:
|
||||
// /* no break */
|
||||
// }
|
||||
// } // err
|
||||
// case 5:
|
||||
// switch( b ) {
|
||||
// case 2:
|
||||
// case 2: // err
|
||||
// }
|
||||
// /* no break */
|
||||
// }
|
||||
// }
|
||||
public void testNestedSwitches() {
|
||||
loadCodeAndRun(getAboveComment());
|
||||
checkErrorLines(4, 20, 6, 9, 27);
|
||||
checkErrorComments();
|
||||
}
|
||||
|
||||
// void foo(void) {
|
||||
// int a, b;
|
||||
// switch( a ) {
|
||||
// case 1:
|
||||
// b = 2;
|
||||
// }
|
||||
// int a, b;
|
||||
// switch( a ) {
|
||||
// case 1:
|
||||
// b = 2;
|
||||
// }
|
||||
// }
|
||||
public void testLastCaseIgnore() {
|
||||
setLast(false);
|
||||
|
@ -441,16 +446,16 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
// switch( a ) {
|
||||
// case 1:
|
||||
// while (a--)
|
||||
// break;
|
||||
// break; // err
|
||||
// case 2:
|
||||
// while (a--) {
|
||||
// break;
|
||||
// }
|
||||
// } // err
|
||||
// }
|
||||
// }
|
||||
public void testEmptyCaseWithLoopBreak() {
|
||||
loadCodeAndRun(getAboveComment());
|
||||
checkErrorLines(3, 6);
|
||||
checkErrorComments();
|
||||
}
|
||||
|
||||
// void foo(int a) {
|
||||
|
@ -470,12 +475,12 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
}
|
||||
|
||||
// void foo(void) {
|
||||
// int a;
|
||||
// switch( a ) {
|
||||
// case 2:
|
||||
// int a;
|
||||
// switch( a ) {
|
||||
// case 2:
|
||||
// break;
|
||||
// case 1:
|
||||
// }
|
||||
// case 1:
|
||||
// }
|
||||
// }
|
||||
public void testEmptyLastCaseError() {
|
||||
String code = getAboveComment();
|
||||
|
@ -489,85 +494,76 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
}
|
||||
|
||||
// void foo(int a) {
|
||||
// switch( a ) {
|
||||
// case 2:
|
||||
// switch( a ) {
|
||||
// case 2:
|
||||
// if (a*2<10)
|
||||
// return;
|
||||
// return;
|
||||
// else
|
||||
// break;
|
||||
// case 1:
|
||||
// break;
|
||||
// }
|
||||
// break;
|
||||
// case 1:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
public void testIf() {
|
||||
String code = getAboveComment();
|
||||
loadCodeAndRun(code);
|
||||
checkNoErrors();
|
||||
}
|
||||
|
||||
// void foo(int a) {
|
||||
// switch( a ) {
|
||||
// case 2:
|
||||
// switch(a) {
|
||||
// case 2:
|
||||
// if (a*2<10)
|
||||
// return;
|
||||
// return;
|
||||
// else
|
||||
// a++;
|
||||
// case 1:
|
||||
// break;
|
||||
// }
|
||||
// a++;
|
||||
// case 1:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
public void testIfErr() {
|
||||
String code = getAboveComment();
|
||||
loadCodeAndRun(code);
|
||||
checkErrorLine(3);
|
||||
checkErrorLine(7);
|
||||
}
|
||||
|
||||
// #define DEFINE_BREAK {break;}
|
||||
// void foo ( int a )
|
||||
// {
|
||||
// switch ( a )
|
||||
// {
|
||||
// case 1:
|
||||
// DEFINE_BREAK // <-- Warning: No break at the end of this case
|
||||
// }
|
||||
// }
|
||||
// #define DEFINE_BREAK {break;}
|
||||
// void foo(int a) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// DEFINE_BREAK // No warning here
|
||||
// }
|
||||
// }
|
||||
public void testBreakInBraces() {
|
||||
String code = getAboveComment();
|
||||
loadCodeAndRun(code);
|
||||
checkNoErrors();
|
||||
}
|
||||
|
||||
|
||||
// #define MY_MACRO(i) \
|
||||
// case i: \
|
||||
// { \
|
||||
// break; \
|
||||
// }
|
||||
//
|
||||
// void f()
|
||||
// {
|
||||
// int x;
|
||||
// switch (x)
|
||||
// {
|
||||
// MY_MACRO(1) // WARNING HERE
|
||||
// }
|
||||
// }
|
||||
|
||||
// #define MY_MACRO(i) \
|
||||
// case i: { \
|
||||
// }
|
||||
//
|
||||
// void f() {
|
||||
// int x;
|
||||
// switch (x) {
|
||||
// MY_MACRO(1) // No warning here
|
||||
// }
|
||||
// }
|
||||
public void testInMacro() {
|
||||
String code = getAboveComment();
|
||||
loadCodeAndRun(code);
|
||||
checkNoErrors();
|
||||
}
|
||||
|
||||
//void foo()
|
||||
//{
|
||||
//switch(0)
|
||||
//default:
|
||||
//{
|
||||
//}
|
||||
//}
|
||||
public void testEmptyCompoundStatement() {
|
||||
String code = getAboveComment();
|
||||
loadCodeAndRun(code);
|
||||
checkErrorLine(4);
|
||||
}
|
||||
// void foo() {
|
||||
// switch (0)
|
||||
// default: {
|
||||
// }
|
||||
// }
|
||||
public void testEmptyCompoundStatement() {
|
||||
String code = getAboveComment();
|
||||
loadCodeAndRun(code);
|
||||
checkErrorLine(4);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Gvozdev - initial API and implementation
|
||||
* Andrew Gvozdev - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
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
|
||||
*
|
||||
*/
|
||||
public class UnusedSymbolInFileScopeCheckerTest extends CheckerTestCase {
|
||||
@Override
|
||||
|
@ -222,8 +222,15 @@ public class UnusedSymbolInFileScopeCheckerTest extends CheckerTestCase {
|
|||
checkNoErrors();
|
||||
}
|
||||
|
||||
// extern int test_var=0; // not quite legal but some compilers allow that
|
||||
public void testExternVariable_Definition() throws IOException {
|
||||
// extern const int test_var=0; // not quite legal but some compilers allow that
|
||||
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());
|
||||
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.SuspiciousSemicolonCheckerTest;
|
||||
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.CreateLocalVariableQuickFixTest;
|
||||
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(SuggestedParenthesisQuickFixTest.class);
|
||||
suite.addTestSuite(CatchByReferenceQuickFixTest.class);
|
||||
suite.addTestSuite(CaseBreakQuickFixTest.class);
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
|||
* method to get source directory for the tests,
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("nls")
|
||||
public class CheckerTestCase extends CodanTestCase {
|
||||
|
@ -50,6 +50,13 @@ public class CheckerTestCase extends CodanTestCase {
|
|||
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) {
|
||||
return checkErrorLine(currentFile, i, problemId);
|
||||
}
|
||||
|
@ -82,7 +89,7 @@ public class CheckerTestCase extends CodanTestCase {
|
|||
break;
|
||||
}
|
||||
}
|
||||
assertEquals(Integer.valueOf(expectedLine), line);
|
||||
assertEquals("Error on line "+expectedLine+" is not found",Integer.valueOf(expectedLine), line);
|
||||
if (file != null)
|
||||
assertEquals(file.getName(), mfile);
|
||||
assertTrue(found);
|
||||
|
|
|
@ -10,6 +10,12 @@
|
|||
*******************************************************************************/
|
||||
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.dom.IPDOMManager;
|
||||
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.Plugin;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* TODO: add description
|
||||
*/
|
||||
|
@ -47,6 +47,7 @@ public class CodanTestCase extends BaseTestCase {
|
|||
protected File currentFile;
|
||||
protected ICElement currentCElem;
|
||||
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) {
|
||||
try {
|
||||
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;
|
||||
try {
|
||||
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) {
|
||||
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:
|
||||
# IBM Corporation - initial API and implementation
|
||||
###############################################################################
|
||||
source.cdtaix.jar = src/
|
||||
source.. = src/
|
||||
bin.includes = fragment.xml,\
|
||||
cdtaix.jar,\
|
||||
.,\
|
||||
about.html,\
|
||||
META-INF/,\
|
||||
os/
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
###############################################################################
|
||||
bin.includes = fragment.xml,\
|
||||
about.html,\
|
||||
cdt_linux.jar,\
|
||||
.,\
|
||||
META-INF/
|
||||
src.includes = about.html,\
|
||||
library/
|
||||
source.cdt_linux.jar = src/
|
||||
source.. = src/
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
###############################################################################
|
||||
bin.includes = fragment.xml,\
|
||||
about.html,\
|
||||
cdt_macosx.jar,\
|
||||
.,\
|
||||
os/,\
|
||||
META-INF/
|
||||
src.includes = about.html,\
|
||||
library/
|
||||
source.cdt_macosx.jar = src/
|
||||
source.. = src/
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
bin.includes = fragment.xml,\
|
||||
about.html,\
|
||||
os/,\
|
||||
cdt_solaris.jar,\
|
||||
.,\
|
||||
META-INF/
|
||||
src.includes = about.html,\
|
||||
library/
|
||||
source.cdt_solaris.jar = src/
|
||||
source.. = src/
|
||||
|
|
|
@ -36,8 +36,8 @@ import org.eclipse.core.runtime.Path;
|
|||
/**
|
||||
* Tests for CModel identifier API.
|
||||
*
|
||||
* @see ICElement#getHandleIdentier()
|
||||
* @see CoreModel.create(String)
|
||||
* @see ICElement#getHandleIdentifier()
|
||||
* @see CoreModel#create(String)
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
|
@ -105,7 +105,7 @@ public class CModelIdentifierTests extends BaseTestCase {
|
|||
String identifier= (String) identifiers.get(i);
|
||||
assertNotNull("Could not create identifier for element: "+ expected, 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.getElementType(), actual.getElementType());
|
||||
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 {
|
||||
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[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
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
@ -116,28 +116,28 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
protected class BindingAssertionHelper {
|
||||
protected IASTTranslationUnit tu;
|
||||
protected String contents;
|
||||
|
||||
|
||||
public BindingAssertionHelper(IFile file, String contents, IIndex index) throws CModelException, CoreException {
|
||||
this.contents= contents;
|
||||
this.tu= TestSourceReader.createIndexBasedAST(index, fCProject, file);
|
||||
}
|
||||
|
||||
|
||||
public IASTTranslationUnit getTranslationUnit() {
|
||||
return tu;
|
||||
}
|
||||
|
||||
|
||||
public IBinding assertProblem(String section, int len) {
|
||||
IBinding binding= binding(section, len);
|
||||
assertTrue("Non-ProblemBinding for name: " + section.substring(0, len),
|
||||
binding instanceof IProblemBinding);
|
||||
return binding;
|
||||
}
|
||||
|
||||
|
||||
public <T extends IBinding> T assertNonProblem(String section, int len) {
|
||||
IBinding binding= binding(section, len);
|
||||
if (binding instanceof IProblemBinding) {
|
||||
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) {
|
||||
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) {
|
||||
IASTName name= findName(section,len,false);
|
||||
IASTName name= findName(section, len, false);
|
||||
if (name != null) {
|
||||
String selection = section.substring(0, len);
|
||||
fail("Found unexpected \"" + selection + "\": " + name.resolveBinding());
|
||||
|
@ -158,15 +158,15 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
* it resolves to the given type of binding.
|
||||
*/
|
||||
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);
|
||||
assertNotNull("did not find \""+selection+"\"", name);
|
||||
|
||||
|
||||
assertInstance(name, IASTImplicitName.class);
|
||||
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
||||
IASTImplicitName[] implicits = owner.getImplicitNames();
|
||||
assertNotNull(implicits);
|
||||
|
||||
|
||||
if (implicits.length > 1) {
|
||||
boolean found = false;
|
||||
for (IASTImplicitName n : implicits) {
|
||||
|
@ -177,27 +177,27 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
}
|
||||
assertTrue(found);
|
||||
}
|
||||
|
||||
|
||||
assertEquals(selection, name.getRawSignature());
|
||||
IBinding binding = name.resolveBinding();
|
||||
assertNotNull(binding);
|
||||
assertInstance(binding, bindingClass);
|
||||
return (IASTImplicitName) name;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
assertNull("found name \""+selection+"\"", name);
|
||||
}
|
||||
|
||||
|
||||
public IASTImplicitName[] getImplicitNames(String section, int len) {
|
||||
IASTName name = findName(section,len,true);
|
||||
IASTName name = findName(section, len, true);
|
||||
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
||||
IASTImplicitName[] implicits = owner.getImplicitNames();
|
||||
return implicits;
|
||||
}
|
||||
|
||||
|
||||
private IASTName findName(String section, int len, boolean implicit) {
|
||||
final int offset = contents.indexOf(section);
|
||||
assertTrue(offset >= 0);
|
||||
|
@ -222,7 +222,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
}
|
||||
return "Unknown problem ID";
|
||||
}
|
||||
|
||||
|
||||
public <T extends IBinding> T assertNonProblem(String section, int len, Class<T> type, Class... cs) {
|
||||
IBinding binding= binding(section, len);
|
||||
assertTrue("ProblemBinding for name: " + section.substring(0, len),
|
||||
|
@ -233,16 +233,16 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
}
|
||||
return type.cast(binding);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
assertNotNull("Did not find \"" + selection + "\"", name);
|
||||
assertEquals(selection, name.getRawSignature());
|
||||
|
||||
|
||||
IBinding binding = name.resolveBinding();
|
||||
assertNotNull("No binding for " + name.getRawSignature(), binding);
|
||||
|
||||
|
||||
return name.resolveBinding();
|
||||
}
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
waitForIndexer();
|
||||
fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
if (fCProject != null) {
|
||||
|
@ -269,11 +269,11 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
}
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
|
||||
protected IProject getProject() {
|
||||
return fCProject.getProject();
|
||||
}
|
||||
|
||||
|
||||
protected String[] getContentsForTest(int blocks) throws IOException {
|
||||
CharSequence[] help= TestSourceReader.getContentsForTest(
|
||||
CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), blocks);
|
||||
|
@ -284,7 +284,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
protected IFile createFile(IContainer container, String fileName, String contents) throws Exception {
|
||||
return TestSourceReader.createFile(container, new Path(fileName), contents);
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
String[] parts= qname.split("::");
|
||||
Pattern[] result= new Pattern[parts.length];
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i]= Pattern.compile(parts[i]);
|
||||
result[i]= Pattern.compile(parts[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
IASTName name= ast.getNodeSelector(null).findName(source.indexOf(section), len);
|
||||
assertNotNull("Name not found for \"" + section + "\"", name);
|
||||
assertEquals(section.substring(0, len), name.getRawSignature());
|
||||
|
||||
|
||||
IBinding binding = name.resolveBinding();
|
||||
assertNotNull("No binding for " + section.substring(0, len), binding);
|
||||
assertTrue("ProblemBinding for name: " + section.substring(0, len),
|
||||
|
@ -357,7 +357,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
// public:
|
||||
// void one() {}
|
||||
// void two() {}
|
||||
// };
|
||||
// };
|
||||
|
||||
// class A {
|
||||
// public:
|
||||
|
@ -369,29 +369,29 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
// Because of fix for http://bugs.eclipse.org/193779 this test case passes.
|
||||
// However http://bugs.eclipse.org/154563 remains to be fixed.
|
||||
String[] content= getContentsForTest(2);
|
||||
|
||||
|
||||
IFile file= createFile(getProject(), "header.h", content[0]);
|
||||
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
||||
|
||||
|
||||
IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||
index.acquireReadLock();
|
||||
try {
|
||||
IBinding[] bs= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
||||
assertEquals(1, bs.length);
|
||||
assertEquals(1, bs.length);
|
||||
assertTrue(bs[0] instanceof ICPPClassType);
|
||||
assertEquals(2, ((ICPPClassType)bs[0]).getDeclaredMethods().length);
|
||||
} finally {
|
||||
index.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
file= createFile(getProject(), "header.h", content[1]);
|
||||
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
||||
|
||||
|
||||
index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||
index.acquireReadLock();
|
||||
try {
|
||||
IBinding[] bs= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
||||
assertEquals(1, bs.length);
|
||||
assertEquals(1, bs.length);
|
||||
assertTrue(bs[0] instanceof ICPPClassType);
|
||||
assertEquals(3, ((ICPPClassType)bs[0]).getDeclaredMethods().length);
|
||||
} finally {
|
||||
|
@ -419,9 +419,9 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
try {
|
||||
IIndexBinding[] bindings= fIndex.findBindings(getPattern("arrayDataSize"), true, IndexFilter.ALL, npm());
|
||||
assertEquals(1, bindings.length);
|
||||
|
||||
|
||||
IIndexBinding binding= bindings[0];
|
||||
|
||||
|
||||
// check if we have the definition
|
||||
IIndexName[] decls= fIndex.findNames(binding, IIndex.FIND_DEFINITIONS);
|
||||
assertEquals(1, decls.length);
|
||||
|
@ -504,7 +504,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
|
||||
// namespace ns162011 {
|
||||
// class Class162011 {
|
||||
// friend void function162011(Class162011);
|
||||
// friend void function162011(Class162011);
|
||||
// };
|
||||
// void function162011(Class162011 x){};
|
||||
// }
|
||||
|
@ -517,7 +517,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
int indexOfDef = content.indexOf(funcName, indexOfDecl+1);
|
||||
IFile file= createFile(getProject(), fileName, content);
|
||||
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
||||
|
||||
|
||||
// make sure the ast is correct
|
||||
ITranslationUnit tu= (ITranslationUnit) fCProject.findElement(new Path(fileName));
|
||||
IASTTranslationUnit ast= tu.getAST();
|
||||
|
@ -535,9 +535,9 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
try {
|
||||
IIndexBinding[] bindings= fIndex.findBindings(getPattern("ns162011::function162011"), true, IndexFilter.ALL, npm());
|
||||
assertEquals(1, bindings.length);
|
||||
|
||||
|
||||
IIndexBinding binding= bindings[0];
|
||||
|
||||
|
||||
// check if we have the declaration
|
||||
IIndexName[] decls= fIndex.findNames(binding, IIndex.FIND_DECLARATIONS);
|
||||
assertEquals(1, decls.length);
|
||||
|
@ -630,11 +630,11 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
|
||||
// // header.h
|
||||
// class E {};
|
||||
|
||||
|
||||
// #include "header.h"
|
||||
// E var;
|
||||
|
||||
// // header.h
|
||||
|
||||
// // header.h
|
||||
// enum E {A,B,C};
|
||||
public void test171834() throws Exception {
|
||||
CModelListener.sSuppressUpdateOfLastRecentlyUsed= false;
|
||||
|
@ -659,7 +659,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
index.releaseReadLock();
|
||||
}
|
||||
|
||||
InputStream in = new ByteArrayInputStream(testData[2].getBytes());
|
||||
InputStream in = new ByteArrayInputStream(testData[2].getBytes());
|
||||
header.setContents(in, IResource.FORCE, null);
|
||||
TestSourceReader.waitUntilFileIsIndexed(index, header, INDEX_WAIT_TIME);
|
||||
|
||||
|
@ -692,7 +692,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
try {
|
||||
IBinding[] bindings= fIndex.findBindings("S20070201".toCharArray(), IndexFilter.getFilter(ILinkage.C_LINKAGE_ID), npm());
|
||||
assertEquals(2, bindings.length);
|
||||
|
||||
|
||||
IBinding struct, typedef;
|
||||
if (bindings[0] instanceof ICompositeType) {
|
||||
struct= bindings[0];
|
||||
|
@ -701,7 +701,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
struct= bindings[1];
|
||||
typedef= bindings[0];
|
||||
}
|
||||
|
||||
|
||||
assertTrue(struct instanceof ICompositeType);
|
||||
assertTrue(typedef instanceof ITypedef);
|
||||
assertTrue(((ITypedef) typedef).getType() instanceof ICompositeType);
|
||||
|
@ -725,7 +725,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
try {
|
||||
IBinding[] bindings= fIndex.findBindings("S20070201".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
|
||||
assertEquals(2, bindings.length);
|
||||
|
||||
|
||||
IBinding struct, typedef;
|
||||
if (bindings[0] instanceof ICPPClassType) {
|
||||
struct= bindings[0];
|
||||
|
@ -734,7 +734,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
struct= bindings[1];
|
||||
typedef= bindings[0];
|
||||
}
|
||||
|
||||
|
||||
assertTrue(struct instanceof ICPPClassType);
|
||||
assertTrue(((ICPPClassType)struct).getKey()==ICompositeType.k_struct);
|
||||
assertTrue(typedef instanceof ITypedef);
|
||||
|
@ -768,7 +768,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
long timestamp= file.getLocalTimeStamp();
|
||||
content= "int UPDATED20070213;\n" + content.replaceFirst("int", "float");
|
||||
file= TestSourceReader.createFile(fCProject.getProject(), "test173997.cpp", content);
|
||||
|
@ -779,7 +779,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
// double check if file was indexed
|
||||
IBinding[] bindings= fIndex.findBindings("UPDATED20070213".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
|
||||
assertEquals(1, bindings.length);
|
||||
|
||||
|
||||
bindings= fIndex.findBindings("T20070213".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
|
||||
assertEquals(1, bindings.length);
|
||||
assertTrue(bindings[0] instanceof ITypedef);
|
||||
|
@ -797,36 +797,36 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
// class A {};
|
||||
// class B {};
|
||||
// A var;
|
||||
|
||||
|
||||
// class A {};
|
||||
// class B {};
|
||||
// B var;
|
||||
public void test173997_2() throws Exception {
|
||||
String[] content= getContentsForTest(2);
|
||||
|
||||
|
||||
IFile file= createFile(getProject(), "header.h", content[0]);
|
||||
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
||||
|
||||
|
||||
IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||
index.acquireReadLock();
|
||||
try {
|
||||
IBinding[] bs= index.findBindings("var".toCharArray(), IndexFilter.ALL, npm());
|
||||
assertEquals(1, bs.length);
|
||||
assertEquals(1, bs.length);
|
||||
assertTrue(bs[0] instanceof ICPPVariable);
|
||||
assertTrue(((ICPPVariable)bs[0]).getType() instanceof ICPPClassType);
|
||||
assertEquals("A", ((ICPPClassType)(((ICPPVariable)bs[0]).getType())).getName());
|
||||
} finally {
|
||||
index.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
file= createFile(getProject(), "header.h", content[1]);
|
||||
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
||||
|
||||
|
||||
index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||
index.acquireReadLock();
|
||||
try {
|
||||
IBinding[] bs= index.findBindings("var".toCharArray(), IndexFilter.ALL, npm());
|
||||
assertEquals(1, bs.length);
|
||||
assertEquals(1, bs.length);
|
||||
assertTrue(bs[0] instanceof ICPPVariable);
|
||||
assertTrue(((ICPPVariable)bs[0]).getType() instanceof ICPPClassType);
|
||||
assertEquals("B", ((ICPPClassType)(((ICPPVariable)bs[0]).getType())).getName());
|
||||
|
@ -838,7 +838,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
// // header.h
|
||||
// template <class T1> class Test {};
|
||||
// template <class T2> void f() {}
|
||||
|
||||
|
||||
// #include "header.h"
|
||||
// struct 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
|
||||
* appear in the initial index of a newly created project of the same name */
|
||||
|
||||
|
||||
String pname = "deleteTest"+System.currentTimeMillis();
|
||||
ICProject cproject = CProjectHelper.createCCProject(pname, "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
|
||||
|
@ -994,8 +994,8 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
File newLocation = CProjectHelper.freshDir();
|
||||
IProjectDescription description = cproject.getProject().getDescription();
|
||||
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.acquireReadLock();
|
||||
try {
|
||||
|
@ -1031,23 +1031,23 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
return !(binding instanceof IFunction);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
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);
|
||||
assertEquals(6,bindings.length);
|
||||
|
||||
assertEquals(6, bindings.length);
|
||||
|
||||
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);
|
||||
assertEquals(2, bindings.length);
|
||||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// class a { class b { class c { void f(); }; }; };
|
||||
public void testFilterFindBindingsFQCharArray() throws Exception {
|
||||
waitForIndexer();
|
||||
|
@ -1064,27 +1064,27 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
return !(binding instanceof ICPPClassType);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
IBinding[] bindings= fIndex.findBindings(new char[][]{{'a'},{'b'},{'c'},{'f'}}, NON_CLASS, npm());
|
||||
assertEquals(1,bindings.length);
|
||||
assertEquals(1, bindings.length);
|
||||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// typedef struct {
|
||||
// float fNumber;
|
||||
// int iIdx;
|
||||
// } StructA_T;
|
||||
|
||||
|
||||
// #include "../__bugsTest__/common.h"
|
||||
// StructA_T gvar1;
|
||||
|
||||
|
||||
// #include "../__bugsTest__/common.h"
|
||||
// StructA_T gvar2;
|
||||
public void testFileInMultipleFragments_bug192352() throws Exception {
|
||||
String[] contents= getContentsForTest(3);
|
||||
|
||||
|
||||
ICProject p2 = CProjectHelper.createCCProject("__bugsTest_2_", "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||
try {
|
||||
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "common.h", contents[0]);
|
||||
|
@ -1109,22 +1109,22 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
CProjectHelper.delete(p2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// #ifndef _h1
|
||||
// #define _h1
|
||||
// #define M v
|
||||
// #endif
|
||||
|
||||
|
||||
// #ifndef _h1
|
||||
// #include "header1.h"
|
||||
// #endif
|
||||
|
||||
|
||||
// #include "header1.h"
|
||||
// #include "header2.h"
|
||||
|
||||
|
||||
// #include "header2.h"
|
||||
// int M;
|
||||
|
||||
|
||||
// #include "header2.h"
|
||||
// #ifndef _h1
|
||||
// #include "header1.h"
|
||||
|
@ -1140,7 +1140,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
IFile f4= TestSourceReader.createFile(fCProject.getProject(), "src2.cpp", contents[3]);
|
||||
IFile f5= TestSourceReader.createFile(fCProject.getProject(), "src3.cpp", contents[4]);
|
||||
waitForIndexer();
|
||||
|
||||
|
||||
IIndex index= indexManager.getIndex(fCProject);
|
||||
index.acquireReadLock();
|
||||
try {
|
||||
|
@ -1151,7 +1151,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
IIndexName[] names = index.findNames(binding, IIndex.FIND_ALL_OCCURRENCES);
|
||||
assertEquals(1, names.length);
|
||||
assertEquals(f4.getFullPath().toString(), names[0].getFile().getLocation().getFullPath());
|
||||
|
||||
|
||||
IIndexFile idxFile= index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(f5));
|
||||
IIndexInclude[] includes= idxFile.getIncludes();
|
||||
assertEquals(2, includes.length);
|
||||
|
@ -1163,10 +1163,9 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
index.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// #define MAC(...) Bug200239
|
||||
|
||||
|
||||
// #include "header.h"
|
||||
// int MAC(1);
|
||||
// void func() {
|
||||
|
@ -1190,9 +1189,9 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// #define GMAC(x...) Bug200239
|
||||
|
||||
|
||||
// #include "header.h"
|
||||
// int GMAC(1);
|
||||
// void func() {
|
||||
|
@ -1217,7 +1216,6 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// typedef bug200553_A bug200553_B;
|
||||
// typedef bug200553_B bug200553_A;
|
||||
public void testTypedefRecursionCpp_Bug200553() throws Exception {
|
||||
|
@ -1266,7 +1264,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
}
|
||||
assertTrue(maxDepth > 0);
|
||||
}
|
||||
|
||||
|
||||
// typedef bug200553_A bug200553_B;
|
||||
// typedef bug200553_B bug200553_A;
|
||||
public void testTypedefRecursionC_Bug200553() throws Exception {
|
||||
|
@ -1306,7 +1304,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// #ifndef GUARD
|
||||
// #include "source.cpp"
|
||||
// #endif
|
||||
|
@ -1315,7 +1313,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[0]);
|
||||
waitForIndexer();
|
||||
|
||||
|
||||
final ITranslationUnit tu= (ITranslationUnit) fCProject.findElement(new Path("source.cpp"));
|
||||
Thread th= new Thread() {
|
||||
@Override
|
||||
|
@ -1324,7 +1322,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
tu.getAST(fIndex, ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
fIndex.acquireReadLock();
|
||||
|
@ -1357,9 +1355,9 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// static inline void staticInHeader() {};
|
||||
|
||||
|
||||
// #include "header.h"
|
||||
// void f1() {
|
||||
// staticInHeader();
|
||||
|
@ -1384,9 +1382,9 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// static const int staticConstInHeader= 12;
|
||||
|
||||
|
||||
// #include "header.h"
|
||||
// void f1() {
|
||||
// int a= staticConstInHeader;
|
||||
|
@ -1413,7 +1411,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
}
|
||||
|
||||
// static inline void staticInHeader() {};
|
||||
|
||||
|
||||
// #include "header.h"
|
||||
// void f1() {
|
||||
// staticInHeader();
|
||||
|
@ -1438,9 +1436,9 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// static const int staticConstInHeader= 12;
|
||||
|
||||
|
||||
// #include "header.h"
|
||||
// void f1() {
|
||||
// int a= staticConstInHeader;
|
||||
|
@ -1467,7 +1465,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
}
|
||||
|
||||
// int ok;
|
||||
|
||||
|
||||
// #include "header.x"
|
||||
public void testNonStandardSuffix_Bug205778() throws Exception {
|
||||
String[] contents= getContentsForTest(2);
|
||||
|
@ -1484,14 +1482,14 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// inline void MyClass::method() {}
|
||||
|
||||
|
||||
// class MyClass {
|
||||
// void method();
|
||||
// };
|
||||
// #include "MyClass_inline.h"
|
||||
|
||||
|
||||
// #include "MyClass.h"
|
||||
public void testAddingMemberBeforeContainer_Bug203170() throws Exception {
|
||||
String[] contents= getContentsForTest(3);
|
||||
|
@ -1512,14 +1510,13 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// typedef int unrelated;
|
||||
|
||||
|
||||
// class unrelated {
|
||||
// public: int b;
|
||||
// };
|
||||
|
||||
|
||||
// #include "h1.h"
|
||||
// void test() {
|
||||
// unrelated a;
|
||||
|
@ -1546,7 +1543,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
}
|
||||
|
||||
// #undef BBB
|
||||
|
||||
|
||||
// #define BBB
|
||||
// #include "header.h"
|
||||
// #ifdef BBB
|
||||
|
@ -1574,9 +1571,9 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// #define BUG ok
|
||||
|
||||
|
||||
// int BUG;
|
||||
|
||||
// #include "common.h"
|
||||
|
@ -1601,7 +1598,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
}
|
||||
|
||||
// #include "h2.h"
|
||||
|
||||
|
||||
// int BUG;
|
||||
|
||||
// #define BUG ok
|
||||
|
@ -1625,7 +1622,6 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// #include <header.h>
|
||||
// #define _CONCAT(x,y) 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(), "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");
|
||||
|
||||
|
||||
waitForIndexer();
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
|
@ -1652,7 +1648,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testIncludeHeuristicsFlag_Bug213562() throws Exception {
|
||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||
TestSourceReader.createFile(fCProject.getProject(), "f1/header.h", "");
|
||||
|
@ -1673,8 +1669,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// #include "dir"
|
||||
// #include "header.h"
|
||||
public void testInclusionOfFolders_Bug243682() throws Exception {
|
||||
|
@ -1696,9 +1691,8 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// #ifndef B_H
|
||||
// #include "b.h"
|
||||
// #endif
|
||||
|
@ -1760,7 +1754,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// namespace ns {
|
||||
// template<typename T> class X {};
|
||||
// }
|
||||
|
@ -1788,8 +1782,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// #include "B.cpp"
|
||||
|
||||
// static int STATIC;
|
||||
|
@ -1812,9 +1805,9 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// int a;
|
||||
|
||||
|
||||
// #include "a.h"
|
||||
// void test() {a=0;}
|
||||
public void testDeclarationForBinding_Bug254844() throws Exception {
|
||||
|
@ -1857,7 +1850,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
// int i;
|
||||
// };
|
||||
// }
|
||||
|
||||
|
||||
// #include "a.h"
|
||||
// using ns::A;
|
||||
// void test() {
|
||||
|
@ -1870,7 +1863,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
// struct A {
|
||||
// int j;
|
||||
// };
|
||||
|
||||
|
||||
// #include "b.h"
|
||||
// void test() {
|
||||
// A a;
|
||||
|
@ -1908,14 +1901,14 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
// namespace ns {
|
||||
// enum E1 { e = 1 };
|
||||
// }
|
||||
|
||||
|
||||
// #include "a.h"
|
||||
// using namespace ns;
|
||||
// int i = e;
|
||||
|
||||
// // b.h
|
||||
// enum E2 { e = 2 };
|
||||
|
||||
|
||||
// #include "b.h"
|
||||
// int i = e;
|
||||
public void testDisambiguationByReachability_268704_2() throws Exception {
|
||||
|
@ -2016,7 +2009,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
|
||||
// // header.h
|
||||
// namespace ns2 { class A {}; }
|
||||
|
||||
|
||||
// #include "header.h"
|
||||
// namespace ns1 {
|
||||
// class B : public ns2::A {};
|
||||
|
@ -2049,7 +2042,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
|
||||
// // a.h
|
||||
// #undef AAA
|
||||
|
||||
|
||||
// // b.h
|
||||
// #include "a.h"
|
||||
// #define AAA
|
||||
|
@ -2083,7 +2076,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
|
||||
// // a.h
|
||||
// #undef AAA
|
||||
|
||||
|
||||
// // b.h
|
||||
// #define AAA
|
||||
// #include "a.h"
|
||||
|
@ -2153,7 +2146,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
index.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// template<typename T> void f(T t) throw (T) {}
|
||||
public void testFunctionTemplateWithThrowsException_293021() throws Exception {
|
||||
waitForIndexer();
|
||||
|
@ -2176,19 +2169,19 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
index.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// // a.h
|
||||
// class P {};
|
||||
|
||||
|
||||
// // b.h
|
||||
// namespace P {class C {};}
|
||||
|
||||
// // source1.cpp
|
||||
// #include "a.h"
|
||||
// #include "a.h"
|
||||
// P p;
|
||||
|
||||
// // source2.cpp
|
||||
// #include "b.h"
|
||||
// #include "b.h"
|
||||
// P::C c;
|
||||
public void testDisambiguateClassVsNamespace_297686() throws Exception {
|
||||
waitForIndexer();
|
||||
|
@ -2221,12 +2214,12 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
|
||||
// // a.h
|
||||
// struct Error{};
|
||||
|
||||
|
||||
// // b.h
|
||||
// void Error(int errCode) {}
|
||||
|
||||
// // source1.cpp
|
||||
// #include "a.h"
|
||||
// #include "a.h"
|
||||
// Error d;
|
||||
|
||||
// // source2.cpp
|
||||
|
@ -2261,7 +2254,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
|
||||
public void testUpdateNonSrcFolderHeader_283080() throws Exception {
|
||||
IIndexBinding[] r;
|
||||
|
||||
|
||||
final IProject prj = fCProject.getProject();
|
||||
final IFolder src= prj.getFolder("src");
|
||||
final IFolder h= prj.getFolder("h");
|
||||
|
@ -2278,7 +2271,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
CCorePlugin.getDefault().setProjectDescription(prj, desc);
|
||||
TestSourceReader.createFile(h, "a.h", "int version1;");
|
||||
waitForIndexer(fCProject);
|
||||
|
||||
|
||||
final IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||
index.acquireReadLock();
|
||||
try {
|
||||
|
@ -2287,7 +2280,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
} finally {
|
||||
index.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
IFile s= TestSourceReader.createFile(h, "a.h", "int version2;");
|
||||
waitForIndexer(fCProject);
|
||||
index.acquireReadLock();
|
||||
|
@ -2307,7 +2300,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
} finally {
|
||||
index.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
s= TestSourceReader.createFile(h, "a.h", "int version3;");
|
||||
waitUntilFileIsIndexed(s, INDEX_WAIT_TIME);
|
||||
index.acquireReadLock();
|
||||
|
@ -2323,12 +2316,12 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
|
||||
public void testUpdateForContentTypeChange_283080() throws Exception {
|
||||
IIndexBinding[] r;
|
||||
|
||||
|
||||
final IProject prj = fCProject.getProject();
|
||||
IFile file= TestSourceReader.createFile(prj, "a.cpp", "// \u0110 \n int a;");
|
||||
file.setCharset("US-ASCII", new NullProgressMonitor());
|
||||
waitForIndexer(fCProject);
|
||||
|
||||
|
||||
final IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||
int offset1= 0;
|
||||
index.acquireReadLock();
|
||||
|
@ -2341,7 +2334,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
} finally {
|
||||
index.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
file.setCharset("UTF-8", new NullProgressMonitor());
|
||||
waitForIndexer(fCProject);
|
||||
int offset2= 0;
|
||||
|
@ -2355,13 +2348,13 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
} finally {
|
||||
index.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
assertTrue(offset1 != offset2);
|
||||
}
|
||||
|
||||
public void testUpdateOnFolderRemove_343538() throws Exception {
|
||||
IIndexBinding[] r;
|
||||
|
||||
|
||||
final IProject prj = fCProject.getProject();
|
||||
final IFolder root= prj.getFolder("root");
|
||||
root.create(true, false, null);
|
||||
|
@ -2376,7 +2369,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
TestSourceReader.createFile(child1, "a.c", "void bug343538() {}");
|
||||
TestSourceReader.createFile(child2, "b.c", "void bug343538();");
|
||||
waitForIndexer(fCProject);
|
||||
|
||||
|
||||
final IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||
index.acquireReadLock();
|
||||
try {
|
||||
|
@ -2387,7 +2380,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
} finally {
|
||||
index.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
// Collect files and folders
|
||||
final Set<IFile> files = new HashSet<IFile>();
|
||||
final Set<IFolder> folders = new HashSet<IFolder>();
|
||||
|
@ -2430,5 +2423,4 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
index.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -11,18 +11,23 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.pdom.tests;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
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.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.index.IndexFilter;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||
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.pdom.PDOM;
|
||||
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 fooAB= (ICPPFunctionTemplate) bs[b ? 1 : 0];
|
||||
|
||||
assertNameCount(pdom, fooX, IIndexFragment.FIND_REFERENCES, 3);
|
||||
assertNameCount(pdom, fooAB, IIndexFragment.FIND_REFERENCES, 6);
|
||||
List<ICPPTemplateInstance> instances= Arrays.asList(((ICPPInstanceCache) fooX).getAllInstances());
|
||||
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,\
|
||||
about.html,\
|
||||
cdt_win32.jar,\
|
||||
.,\
|
||||
META-INF/
|
||||
src.includes = about.html,\
|
||||
library/
|
||||
source.cdt_win32.jar = src/
|
||||
source.. = src/
|
||||
|
|
|
@ -49,6 +49,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
|||
|
||||
private IRegion fRegion;
|
||||
private long fTimestamp;
|
||||
private int fIndex;
|
||||
|
||||
public CElementHandle(ICElement parent, int type, String name) {
|
||||
fParent= parent;
|
||||
|
@ -57,8 +58,8 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
|||
// undo this here
|
||||
if (name.length() > 0 && name.charAt(0)=='{') {
|
||||
fName= ""; //$NON-NLS-1$
|
||||
}
|
||||
else {
|
||||
fIndex= name.hashCode();
|
||||
} else {
|
||||
fName= name;
|
||||
}
|
||||
fRegion= new Region(0,0);
|
||||
|
@ -313,6 +314,6 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
|||
}
|
||||
|
||||
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) {
|
||||
if (source == null || source.length == 0)
|
||||
|
@ -246,8 +253,12 @@ public abstract class ArrayUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Concatenates two arrays skipping <code>null</code> elements.
|
||||
* Assumes that both arrays contain <code>null</code>s at the end, only.
|
||||
* Takes contents of the two arrays up to the first <code>null</code> element and concatenates
|
||||
* 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
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -264,7 +275,8 @@ public abstract class ArrayUtil {
|
|||
}
|
||||
|
||||
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);
|
||||
System.arraycopy(source, 0, dest, 0, numToAdd);
|
||||
return dest;
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||
*******************************************************************************/
|
||||
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.
|
||||
*/
|
||||
public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclaration, IASTAmbiguityParent {
|
||||
|
||||
private IASTDeclarator[] declarators;
|
||||
private int declaratorsPos = -1;
|
||||
private IASTDeclSpecifier declSpecifier;
|
||||
|
||||
public CASTSimpleDeclaration() {
|
||||
}
|
||||
|
@ -42,7 +44,7 @@ public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclarat
|
|||
CASTSimpleDeclaration copy = new CASTSimpleDeclaration();
|
||||
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.setOffsetAndLength(this);
|
||||
|
@ -57,26 +59,21 @@ public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclarat
|
|||
}
|
||||
|
||||
public IASTDeclarator[] getDeclarators() {
|
||||
if( declarators == null ) return IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
||||
declarators = (IASTDeclarator[]) ArrayUtil.removeNullsAfter( IASTDeclarator.class, declarators, declaratorsPos );
|
||||
if (declarators == null)
|
||||
return IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
||||
declarators = (IASTDeclarator[]) ArrayUtil.removeNullsAfter(IASTDeclarator.class, declarators, declaratorsPos);
|
||||
return declarators;
|
||||
}
|
||||
|
||||
public void addDeclarator( IASTDeclarator d ) {
|
||||
public void addDeclarator(IASTDeclarator d) {
|
||||
assertNotFrozen();
|
||||
if (d != null) {
|
||||
d.setParent(this);
|
||||
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) {
|
||||
assertNotFrozen();
|
||||
this.declSpecifier = declSpecifier;
|
||||
|
@ -87,25 +84,28 @@ public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclarat
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean accept( ASTVisitor action ){
|
||||
if( action.shouldVisitDeclarations ){
|
||||
switch( action.visit( this ) ){
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
default : break;
|
||||
public boolean accept(ASTVisitor action) {
|
||||
if (action.shouldVisitDeclarations) {
|
||||
switch (action.visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT: return false;
|
||||
case ASTVisitor.PROCESS_SKIP: return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
if( declSpecifier != null ) if( !declSpecifier.accept( action ) ) return false;
|
||||
IASTDeclarator [] dtors = getDeclarators();
|
||||
for( int i = 0; i < dtors.length; i++ )
|
||||
if( !dtors[i].accept( action ) ) return false;
|
||||
if (declSpecifier != null && !declSpecifier.accept(action))
|
||||
return false;
|
||||
IASTDeclarator[] dtors = getDeclarators();
|
||||
for (int i = 0; i < dtors.length; i++) {
|
||||
if (!dtors[i].accept(action))
|
||||
return false;
|
||||
}
|
||||
|
||||
if( action.shouldVisitDeclarations ){
|
||||
switch( action.leave( this ) ){
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
default : break;
|
||||
if (action.shouldVisitDeclarations) {
|
||||
switch (action.leave(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT: return false;
|
||||
case ASTVisitor.PROCESS_SKIP: return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -118,8 +118,8 @@ public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclarat
|
|||
declSpecifier= (IASTDeclSpecifier) other;
|
||||
} else {
|
||||
IASTDeclarator[] declarators = getDeclarators();
|
||||
for(int i = 0; i < declarators.length; i++) {
|
||||
if(declarators[i] == child) {
|
||||
for (int i = 0; i < declarators.length; i++) {
|
||||
if (declarators[i] == child) {
|
||||
declarators[i] = (IASTDeclarator)other;
|
||||
other.setParent(child.getParent());
|
||||
other.setPropertyInParent(child.getPropertyInParent());
|
||||
|
|
|
@ -94,7 +94,7 @@ public class CASTTypeIdExpression extends ASTNode implements IASTTypeIdExpressio
|
|||
|
||||
public IType getExpressionType() {
|
||||
if (getOperator() == op_sizeof) {
|
||||
return CVisitor.getSize_T(this);
|
||||
return CVisitor.get_SIZE_T(this);
|
||||
}
|
||||
return CVisitor.createType(typeId.getAbstractDeclarator());
|
||||
}
|
||||
|
|
|
@ -107,9 +107,12 @@ public class CASTUnaryExpression extends ASTNode implements IASTUnaryExpression,
|
|||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
int op = getOperator();
|
||||
if (op == op_sizeof) {
|
||||
return CVisitor.get_SIZE_T(this);
|
||||
}
|
||||
final IType exprType = getOperand().getExpressionType();
|
||||
IType type = CVisitor.unwrapTypedefs(exprType);
|
||||
int op = getOperator();
|
||||
switch(op) {
|
||||
case op_star:
|
||||
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.
|
||||
*/
|
||||
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 {
|
||||
{
|
||||
shouldVisitDeclarations = true;
|
||||
|
@ -646,19 +651,21 @@ public class CVisitor extends ASTQueries {
|
|||
|
||||
return new CBasicType(Kind.eInt, 0, expr);
|
||||
}
|
||||
|
||||
static IType getSize_T(IASTExpression expr) {
|
||||
IScope scope = getContainingScope(expr);
|
||||
IBinding[] bs = scope.find(SIZE_T);
|
||||
for (IBinding b : bs) {
|
||||
if (b instanceof IType) {
|
||||
if (!(b instanceof ICInternalBinding) ||
|
||||
CVisitor.declaredBefore(((ICInternalBinding) b).getPhysicalNode(), expr)) {
|
||||
return (IType) b;
|
||||
|
||||
static IType get_SIZE_T(IASTExpression expr) {
|
||||
IASTTranslationUnit tu= expr.getTranslationUnit();
|
||||
if (tu != null) {
|
||||
IBinding[] bs = tu.getScope().find(SIZE_T);
|
||||
for (IBinding b : bs) {
|
||||
if (b instanceof IType) {
|
||||
if (!(b instanceof ICInternalBinding) ||
|
||||
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) {
|
||||
|
|
|
@ -163,7 +163,7 @@ public class CPPTemplateParameterMap implements ICPPTemplateParameterMap {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean mergeToExplicit(CPPTemplateParameterMap deducedMap) {
|
||||
public boolean addDeducedArgs(CPPTemplateParameterMap deducedMap) {
|
||||
Integer[] keys= deducedMap.getAllParameterPositions();
|
||||
for (Integer key : keys) {
|
||||
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
|
||||
* include methods declared in base classes.
|
||||
* @param classType
|
||||
* @return
|
||||
*/
|
||||
private static ObjectSet<ICPPMethod> getOwnMethods(ICPPClassType classType) {
|
||||
ObjectSet<ICPPMethod> set= new ObjectSet<ICPPMethod>(4);
|
||||
set.addAll(classType.getDeclaredMethods());
|
||||
if (classType instanceof IProblemBinding) {
|
||||
return set;
|
||||
}
|
||||
ICPPClassScope scope= (ICPPClassScope) classType.getCompositeScope();
|
||||
set.addAll(scope.getImplicitMethods());
|
||||
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.IProblemBinding;
|
||||
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.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
|
@ -56,8 +55,13 @@ class BaseClassLookup {
|
|||
rootInfo.collectResultForContentAssist(data);
|
||||
} else {
|
||||
hideVirtualBases(rootInfo, infoMap);
|
||||
IBinding[] result= rootInfo.collectResult(data, true, null);
|
||||
verifyResult(data, result);
|
||||
IBinding[] result= rootInfo.collectResult(data, true, IBinding.EMPTY_BINDING_ARRAY);
|
||||
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 (fHiddenAsVirtualBase)
|
||||
return result;
|
||||
|
@ -337,41 +341,27 @@ class BaseClassLookup {
|
|||
if (fCollected)
|
||||
return result;
|
||||
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++) {
|
||||
BaseClassLookup child = fChildren.get(i);
|
||||
result= child.collectResult(data, fVirtual.get(i), 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.
|
||||
if (binding instanceof IFunction) {
|
||||
if (data.forFunctionDeclaration()) {
|
||||
IASTNode declaration= data.astName;
|
||||
while (declaration instanceof IASTName)
|
||||
declaration= declaration.getParent();
|
||||
while (declaration instanceof IASTDeclarator)
|
||||
declaration= declaration.getParent();
|
||||
|
||||
final IASTDeclaration declaration = data.forDeclaration();
|
||||
if (declaration != null) {
|
||||
// Functions
|
||||
if (binding instanceof IFunction) {
|
||||
binding= checkDeclSpecifier(binding, data.astName, declaration);
|
||||
if (!(binding instanceof IProblemBinding)) {
|
||||
if (declaration instanceof ICPPASTFunctionDefinition) {
|
||||
|
@ -475,24 +471,17 @@ public class CPPSemantics {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Definitions of static fields are found via name resolution, need to add name to
|
||||
// the binding to get the right type of arrays that may be declared incomplete.
|
||||
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);
|
||||
// Definitions of static fields.
|
||||
if (binding instanceof ICPPField && data.astName.isDefinition()) {
|
||||
if (declaration.getPropertyInParent() != IASTCompositeTypeSpecifier.MEMBER_DECLARATION) {
|
||||
ASTInternal.addDefinition(binding, data.astName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If we're still 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,
|
||||
data.getFoundBindings());
|
||||
} else {
|
||||
|
@ -601,9 +590,7 @@ public class CPPSemantics {
|
|||
data.forceQualified = true;
|
||||
}
|
||||
|
||||
if (parent instanceof ICPPASTFunctionDeclarator) {
|
||||
data.setFunctionParameters(((ICPPASTFunctionDeclarator) parent).getParameters());
|
||||
} else if (parent instanceof IASTIdExpression) {
|
||||
if (parent instanceof IASTIdExpression) {
|
||||
IASTNode grand= parent.getParent();
|
||||
while (grand instanceof IASTUnaryExpression
|
||||
&& ((IASTUnaryExpression) grand).getOperator() == IASTUnaryExpression.op_bracketedPrimary) {
|
||||
|
@ -2276,7 +2263,7 @@ public class CPPSemantics {
|
|||
}
|
||||
|
||||
private static ICPPFunction[] selectByArgumentCount(LookupData data, ICPPFunction[] functions) throws DOMException {
|
||||
assert !data.forFunctionDeclaration();
|
||||
assert data.forDeclaration() == null;
|
||||
|
||||
int argumentCount = data.getFunctionArgumentCount();
|
||||
|
||||
|
@ -2328,16 +2315,6 @@ public class CPPSemantics {
|
|||
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 {
|
||||
fns= (ICPPFunction[]) ArrayUtil.trim(ICPPFunction.class, fns);
|
||||
if (fns == null || fns.length == 0)
|
||||
|
@ -2348,17 +2325,18 @@ public class CPPSemantics {
|
|||
if (data.forUsingDeclaration())
|
||||
return new CPPUsingDeclaration(data.astName, fns);
|
||||
|
||||
// No arguments to resolve function
|
||||
if (!data.hasFunctionArguments()) {
|
||||
return createFunctionSet(data.astName, fns);
|
||||
}
|
||||
|
||||
if (data.astName instanceof ICPPASTConversionName) {
|
||||
return resolveUserDefinedConversion(data, fns);
|
||||
}
|
||||
|
||||
if (data.forFunctionDeclaration())
|
||||
if (data.forDeclaration() != null) {
|
||||
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
|
||||
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 {
|
||||
if (data.forExplicitFunctionSpecialization()) {
|
||||
fns = CPPTemplates.instantiateForFunctionCall(data.astName,
|
||||
fns,
|
||||
Arrays.asList(data.getFunctionArgumentTypes()), Arrays.asList(data.getFunctionArgumentValueCategories()),
|
||||
data.argsContainImpliedObject);
|
||||
final IASTDeclarator dtor= ASTQueries.findTypeRelevantDeclarator(data.getDeclarator());
|
||||
final IType t = CPPVisitor.createType(dtor);
|
||||
if (!(t instanceof ICPPFunctionType))
|
||||
return null;
|
||||
|
||||
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();
|
||||
if (argCount == 1) {
|
||||
// check for parameter of type void
|
||||
final IType[] argTypes = data.getFunctionArgumentTypes();
|
||||
if (argTypes.length == 1 && SemanticUtil.isVoidType(argTypes[0])) {
|
||||
argCount= 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (ICPPFunction fn : fns) {
|
||||
if (fn != null && !(fn instanceof IProblemBinding) && !(fn instanceof ICPPUnknownBinding)) {
|
||||
// The index is optimized to provide the function type, avoid using the parameters
|
||||
// as long as possible.
|
||||
final IType[] parameterTypes = fn.getType().getParameterTypes();
|
||||
int parCount = parameterTypes.length;
|
||||
if (parCount == 1 && SemanticUtil.isVoidType(parameterTypes[0]))
|
||||
parCount= 0;
|
||||
|
||||
if (parCount == argCount && isMatchingFunctionDeclaration(fn, data)) {
|
||||
return fn;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
ICPPFunctionTemplate bestTemplate= null;
|
||||
ICPPFunction bestInst= null;
|
||||
boolean isAmbiguous= false;
|
||||
for (ICPPFunction fn : fns) {
|
||||
if (fn instanceof ICPPFunctionTemplate
|
||||
&& !(fn instanceof IProblemBinding) && !(fn instanceof ICPPUnknownBinding)) {
|
||||
ICPPFunctionTemplate template= (ICPPFunctionTemplate) fn;
|
||||
ICPPFunction inst= CPPTemplates.instantiateForFunctionDeclaration(template, tmplArgs, ft);
|
||||
if (inst != null) {
|
||||
int cmp= CPPTemplates.orderFunctionTemplates(bestTemplate, template, TypeSelection.PARAMETERS_AND_RETURN_TYPE);
|
||||
if (cmp == 0)
|
||||
cmp= compareByRelevance(tu, bestTemplate, template);
|
||||
|
||||
if (cmp == 0)
|
||||
isAmbiguous= true;
|
||||
|
||||
if (cmp < 0) {
|
||||
isAmbiguous= false;
|
||||
bestTemplate= template;
|
||||
bestInst= inst;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isAmbiguous)
|
||||
return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, fns);
|
||||
|
||||
return bestInst;
|
||||
}
|
||||
|
||||
public static void sortAstBeforeIndex(IFunction[] fns) {
|
||||
|
@ -2691,14 +2708,15 @@ public class CPPSemantics {
|
|||
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;
|
||||
IType t= CPPVisitor.createType(astName.getTypeId());
|
||||
if (t instanceof ISemanticProblem) {
|
||||
return new ProblemBinding(astName, IProblemBinding.SEMANTIC_INVALID_TYPE, data.getFoundBindings());
|
||||
}
|
||||
if (!data.forFunctionDeclaration() || data.forExplicitFunctionSpecialization()) {
|
||||
CPPTemplates.instantiateConversionTemplates(fns, t);
|
||||
if (data.forDeclaration() == null ||
|
||||
data.forExplicitFunctionSpecialization() || data.forExplicitFunctionInstantiation()) {
|
||||
fns= CPPTemplates.instantiateConversionTemplates(fns, t);
|
||||
}
|
||||
|
||||
IFunction unknown= null;
|
||||
|
@ -2896,12 +2914,10 @@ public class CPPSemantics {
|
|||
final ICPPFunctionTemplate template = (ICPPFunctionTemplate) fn;
|
||||
ICPPFunction inst= CPPTemplates.instantiateForAddressOfFunction(template, (ICPPFunctionType) targetType, name);
|
||||
if (inst != null) {
|
||||
int cmp= -1;
|
||||
if (result != null) {
|
||||
cmp= CPPTemplates.orderFunctionTemplates(resultTemplate, template, TypeSelection.PARAMETERS_AND_RETURN_TYPE);
|
||||
if (cmp == 0)
|
||||
cmp= compareByRelevance(tu, resultTemplate, template);
|
||||
}
|
||||
int cmp= CPPTemplates.orderFunctionTemplates(resultTemplate, template, TypeSelection.PARAMETERS_AND_RETURN_TYPE);
|
||||
if (cmp == 0)
|
||||
cmp= compareByRelevance(tu, resultTemplate, template);
|
||||
|
||||
if (cmp == 0)
|
||||
isAmbiguous= true;
|
||||
|
||||
|
@ -3627,7 +3643,9 @@ public class CPPSemantics {
|
|||
if (templateDecl != null) {
|
||||
|
||||
if (templateDecl instanceof ICPPASTTemplateSpecialization) {
|
||||
if (!(function instanceof ICPPSpecialization))
|
||||
if (!(function instanceof ICPPTemplateInstance))
|
||||
return false;
|
||||
if (!((ICPPTemplateInstance) function).isExplicitSpecialization())
|
||||
return false;
|
||||
} else {
|
||||
if (function instanceof ICPPTemplateDefinition) {
|
||||
|
@ -3641,7 +3659,7 @@ public class CPPSemantics {
|
|||
}
|
||||
} else if (function instanceof ICPPTemplateDefinition) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
declarator= ASTQueries.findTypeRelevantDeclarator(declarator);
|
||||
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.IASTExpression;
|
||||
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.IASTIdExpression;
|
||||
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.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
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.ICPPASTExplicitTemplateInstantiation;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
||||
|
@ -706,10 +708,17 @@ public class CPPTemplates {
|
|||
parentOfName= parentOfName.getParent();
|
||||
}
|
||||
|
||||
return parentOfName instanceof ICPPASTElaboratedTypeSpecifier ||
|
||||
if (parentOfName instanceof ICPPASTElaboratedTypeSpecifier ||
|
||||
parentOfName instanceof ICPPASTCompositeTypeSpecifier ||
|
||||
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
|
||||
int level= missingTemplateDecls;
|
||||
if (!CPPVisitor.isFriendFunctionDeclaration(innerMostTDecl.getDeclaration())) {
|
||||
if (!isFriendFunctionDeclaration(innerMostTDecl.getDeclaration())) {
|
||||
node= outerMostTDecl.getParent();
|
||||
while (node != null) {
|
||||
if (node instanceof ICPPASTInternalTemplateDeclaration) {
|
||||
|
@ -1335,6 +1344,23 @@ public class CPPTemplates {
|
|||
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) {
|
||||
CharArraySet set= new CharArraySet(4);
|
||||
while(true) {
|
||||
|
@ -1628,24 +1654,30 @@ public class CPPTemplates {
|
|||
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;
|
||||
for (int i = 0; i < functions.length; i++) {
|
||||
IFunction func = functions[i];
|
||||
if (func instanceof ICPPFunctionTemplate) {
|
||||
ICPPFunctionTemplate template= (ICPPFunctionTemplate) func;
|
||||
functions[i]= null;
|
||||
ICPPFunction[] result= functions;
|
||||
int i=0;
|
||||
boolean done= false;
|
||||
for (ICPPFunction f : functions) {
|
||||
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) {
|
||||
try {
|
||||
if (isDependentType(conversionType)) {
|
||||
functions[i]= CPPUnknownFunction.createForSample(template);
|
||||
return;
|
||||
inst= CPPUnknownFunction.createForSample(template);
|
||||
done= true;
|
||||
}
|
||||
checkedForDependentType= true;
|
||||
} catch (DOMException e) {
|
||||
return;
|
||||
return functions;
|
||||
}
|
||||
}
|
||||
CPPTemplateParameterMap map= new CPPTemplateParameterMap(1);
|
||||
|
@ -1653,16 +1685,48 @@ public class CPPTemplates {
|
|||
ICPPTemplateArgument[] args= TemplateArgumentDeduction.deduceForConversion(template, conversionType, map);
|
||||
if (args != null) {
|
||||
IBinding instance= instantiateFunctionTemplate(template, args, map);
|
||||
if (instance instanceof IFunction) {
|
||||
functions[i]= (IFunction) instance;
|
||||
if (instance instanceof ICPPFunction) {
|
||||
inst= (ICPPFunction) instance;
|
||||
}
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
// 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]
|
||||
|
@ -1702,6 +1766,13 @@ public class CPPTemplates {
|
|||
// 14.5.6.2 Partial ordering of function templates
|
||||
static int orderFunctionTemplates(ICPPFunctionTemplate f1, ICPPFunctionTemplate f2, TypeSelection mode)
|
||||
throws DOMException {
|
||||
if (f1 == f2)
|
||||
return 0;
|
||||
if (f1 == null)
|
||||
return -1;
|
||||
if (f2 == null)
|
||||
return 1;
|
||||
|
||||
int s1 = compareSpecialization(f1, f2, 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.ICPPMethod;
|
||||
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.ICPPScope;
|
||||
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.
|
||||
*/
|
||||
public class CPPVisitor extends ASTQueries {
|
||||
public static final char[] SIZE_T = "size_t".toCharArray(); //$NON-NLS-1$
|
||||
public static final char[] PTRDIFF_T = "ptrdiff_t".toCharArray(); //$NON-NLS-1$
|
||||
private static final CPPBasicType UNSIGNED_LONG = new CPPBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED);
|
||||
private static final CPPBasicType INT_TYPE = new CPPBasicType(Kind.eInt, 0);
|
||||
|
||||
static final char[] BEGIN = "begin".toCharArray(); //$NON-NLS-1$
|
||||
public static final String STD = "std"; //$NON-NLS-1$
|
||||
public static final String TYPE_INFO= "type_info"; //$NON-NLS-1$
|
||||
private static final String INITIALIZER_LIST = "initializer_list"; //$NON-NLS-1$
|
||||
static final String STD = "std"; //$NON-NLS-1$
|
||||
private static final char[] SIZE_T = "size_t".toCharArray(); //$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.
|
||||
// Used to prevent infinite recursion while processing invalid self-referencing
|
||||
|
@ -633,13 +637,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
boolean isFriendDecl= false;
|
||||
ICPPScope scope = (ICPPScope) getContainingNonTemplateScope(name);
|
||||
if (scope instanceof ICPPClassScope) {
|
||||
if (parent instanceof IASTSimpleDeclaration) {
|
||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration) parent).getDeclSpecifier();
|
||||
isFriendDecl= declSpec.isFriend();
|
||||
} else if (parent instanceof IASTFunctionDefinition) {
|
||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition) parent).getDeclSpecifier();
|
||||
isFriendDecl= declSpec.isFriend();
|
||||
}
|
||||
isFriendDecl = isFriendDeclaration(parent);
|
||||
if (isFriendDecl) {
|
||||
try {
|
||||
while (scope.getKind() == EScopeKind.eClassType) {
|
||||
|
@ -753,6 +751,18 @@ public class CPPVisitor extends ASTQueries {
|
|||
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) {
|
||||
if (containingScope == null || !(containingScope instanceof ICPPClassScope))
|
||||
return false;
|
||||
|
@ -2085,53 +2095,21 @@ public class CPPVisitor extends ASTQueries {
|
|||
}
|
||||
|
||||
public static IType getPointerDiffType(final IASTBinaryExpression binary) {
|
||||
CPPBasicType basicType;
|
||||
IScope scope = getContainingScope(binary);
|
||||
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;
|
||||
IType t= getStdType(binary, PTRDIFF_T);
|
||||
return t != null ? t : INT_TYPE;
|
||||
}
|
||||
|
||||
public static IType get_type_info(IASTExpression expression) {
|
||||
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) {
|
||||
private static IType getStdType(final IASTNode node, char[] name) {
|
||||
IBinding[] std= node.getTranslationUnit().getScope().find(STD);
|
||||
for (IBinding binding : std) {
|
||||
if (binding instanceof ICPPNamespace) {
|
||||
IBinding[] initializer_list= ((ICPPNamespace) binding).getNamespaceScope().find(INITIALIZER_LIST);
|
||||
for (IBinding t : initializer_list) {
|
||||
if (t instanceof ICPPClassTemplate) {
|
||||
return (ICPPClassTemplate) t;
|
||||
final ICPPNamespaceScope scope = ((ICPPNamespace) binding).getNamespaceScope();
|
||||
IBinding[] bs= CPPSemantics.findBindings(scope, name, false, node);
|
||||
if (bs.length > 0) {
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
CollectProblemsAction action = new CollectProblemsAction();
|
||||
tu.accept(action);
|
||||
|
@ -2340,7 +2335,6 @@ public class CPPVisitor extends ASTQueries {
|
|||
*/
|
||||
public static IBinding findDeclarationOwner(IASTNode node, boolean allowFunction) {
|
||||
// Search for declaration
|
||||
boolean isFriend= false;
|
||||
boolean isNonSimpleElabDecl= false;
|
||||
while (!(node instanceof IASTDeclaration)) {
|
||||
if (node == null)
|
||||
|
@ -2360,19 +2354,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
node= node.getParent();
|
||||
}
|
||||
|
||||
if (node instanceof IASTSimpleDeclaration) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
boolean isFriend= isFriendDeclaration(node);
|
||||
|
||||
// Search for enclosing binding
|
||||
IASTName name= null;
|
||||
|
@ -2409,26 +2391,6 @@ public class CPPVisitor extends ASTQueries {
|
|||
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) {
|
||||
if (declspec instanceof ICPPASTSimpleDeclSpecifier) {
|
||||
ICPPASTSimpleDeclSpecifier ds= (ICPPASTSimpleDeclSpecifier) declspec;
|
||||
|
|
|
@ -684,10 +684,11 @@ public class Conversions {
|
|||
|
||||
final IType uqSource= getNestedType(source, TDEF | REF | CVTYPE);
|
||||
if (uqSource instanceof ICPPClassType) {
|
||||
ICPPMethod[] ops = SemanticUtil.getConversionOperators((ICPPClassType) uqSource);
|
||||
CPPTemplates.instantiateConversionTemplates(ops, t);
|
||||
for (final ICPPMethod op : ops) {
|
||||
if (op != null && !(op instanceof IProblemBinding)) {
|
||||
ICPPFunction[] ops = SemanticUtil.getConversionOperators((ICPPClassType) uqSource);
|
||||
ops= CPPTemplates.instantiateConversionTemplates(ops, t);
|
||||
for (final ICPPFunction f : ops) {
|
||||
if (f instanceof ICPPMethod && !(f instanceof IProblemBinding)) {
|
||||
ICPPMethod op= (ICPPMethod) f;
|
||||
if (op.isExplicit())
|
||||
continue;
|
||||
final IType returnType = op.getType().getReturnType();
|
||||
|
@ -733,12 +734,13 @@ public class Conversions {
|
|||
c.setDeferredUDC(DeferredUDC.INIT_BY_CONVERSION);
|
||||
return c;
|
||||
}
|
||||
ICPPMethod[] ops = SemanticUtil.getConversionOperators(uqSource);
|
||||
CPPTemplates.instantiateConversionTemplates(ops, target);
|
||||
ICPPFunction[] ops = SemanticUtil.getConversionOperators(uqSource);
|
||||
ops= CPPTemplates.instantiateConversionTemplates(ops, target);
|
||||
FunctionCost cost1= null;
|
||||
Cost cost2= null;
|
||||
for (final ICPPMethod op : ops) {
|
||||
if (op != null && !(op instanceof IProblemBinding)) {
|
||||
for (final ICPPFunction f : ops) {
|
||||
if (f instanceof ICPPMethod && !(f instanceof IProblemBinding)) {
|
||||
ICPPMethod op= (ICPPMethod) f;
|
||||
final boolean isExplicitConversion= op.isExplicit();
|
||||
if (isExplicitConversion /** && !direct **/)
|
||||
continue;
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
*******************************************************************************/
|
||||
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 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.ICPPASTInitializerList;
|
||||
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.ICPPASTTemplateDeclaration;
|
||||
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.CharArrayUtils;
|
||||
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.cpp.CPPASTTranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPCompositeBinding;
|
||||
|
@ -103,7 +100,6 @@ public class LookupData {
|
|||
/** In list-initialization **/
|
||||
public boolean fNoNarrowing= false;
|
||||
|
||||
private ICPPASTParameterDeclaration[] functionParameters;
|
||||
private IASTInitializerClause[] functionArgs;
|
||||
private IType[] functionArgTypes;
|
||||
private ValueCategory[] functionArgValueCategories;
|
||||
|
@ -171,81 +167,58 @@ public class LookupData {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean forFunctionDeclaration() {
|
||||
if (astName == null) return false;
|
||||
if (astName.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY) return false;
|
||||
/**
|
||||
* Returns whether the name belongs to a simple declaration or function definition.
|
||||
*/
|
||||
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;
|
||||
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();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IASTDeclarator getDeclarator() {
|
||||
IASTName name= astName;
|
||||
if (name == null || name.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY)
|
||||
return null;
|
||||
|
||||
if (p1 instanceof IASTDeclarator) {
|
||||
IASTNode p2= ASTQueries.findOutermostDeclarator((IASTDeclarator) p1).getParent();
|
||||
if (p2 instanceof IASTSimpleDeclaration) {
|
||||
if (p2.getParent() instanceof ICPPASTExplicitTemplateInstantiation)
|
||||
return false;
|
||||
if (astName instanceof ICPPASTTemplateId &&
|
||||
((ICPPASTDeclSpecifier)((IASTSimpleDeclaration) p2).getDeclSpecifier()).isFriend())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
return p2 instanceof IASTFunctionDefinition;
|
||||
if (name.getParent() instanceof ICPPASTTemplateId)
|
||||
name= (IASTName) name.getParent();
|
||||
|
||||
IASTNode node= name.getParent();
|
||||
if (node instanceof ICPPASTQualifiedName) {
|
||||
if (((ICPPASTQualifiedName) node).getLastName() != name)
|
||||
return null;
|
||||
node = node.getParent();
|
||||
}
|
||||
return false;
|
||||
|
||||
if (node instanceof IASTDeclarator)
|
||||
return (IASTDeclarator) node;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean forExplicitFunctionSpecialization() {
|
||||
if (astName == null) return false;
|
||||
if (astName.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY) return false;
|
||||
|
||||
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 IASTSimpleDeclaration || p2 instanceof IASTFunctionDefinition) {
|
||||
ICPPASTTemplateDeclaration tmplDecl = CPPTemplates.getTemplateDeclaration(n);
|
||||
return tmplDecl instanceof ICPPASTTemplateSpecialization;
|
||||
}
|
||||
IASTDeclaration decl= forDeclaration();
|
||||
if (decl != null) {
|
||||
IASTName n = astName;
|
||||
if (n.getParent() instanceof ICPPASTTemplateId)
|
||||
n = (IASTName) n.getParent();
|
||||
|
||||
ICPPASTTemplateDeclaration tmplDecl = CPPTemplates.getTemplateDeclaration(n);
|
||||
return tmplDecl instanceof ICPPASTTemplateSpecialization;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean forExplicitFunctionInstantiation() {
|
||||
if (astName == null) return false;
|
||||
if (astName.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY) return false;
|
||||
|
||||
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;
|
||||
IASTDeclaration decl= forDeclaration();
|
||||
return decl != null && decl.getParent() instanceof ICPPASTExplicitTemplateInstantiation;
|
||||
}
|
||||
|
||||
public boolean qualified() {
|
||||
|
@ -414,14 +387,6 @@ public class LookupData {
|
|||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -491,13 +456,7 @@ public class LookupData {
|
|||
return false;
|
||||
if (p instanceof IASTDeclaration) {
|
||||
if (prop == IASTCompositeTypeSpecifier.MEMBER_DECLARATION) {
|
||||
if (p instanceof IASTSimpleDeclaration) {
|
||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration) p).getDeclSpecifier();
|
||||
return declSpec.isFriend();
|
||||
} else if (p instanceof IASTFunctionDefinition) {
|
||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition) p).getDeclSpecifier();
|
||||
return declSpec.isFriend();
|
||||
}
|
||||
return CPPVisitor.isFriendDeclaration(p);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -547,14 +506,7 @@ public class LookupData {
|
|||
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;
|
||||
}
|
||||
|
@ -570,36 +522,19 @@ public class LookupData {
|
|||
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;
|
||||
}
|
||||
|
||||
public void setFunctionParameters(ICPPASTParameterDeclaration[] parameters) {
|
||||
functionParameters= parameters;
|
||||
}
|
||||
|
||||
public int getFunctionArgumentCount() {
|
||||
if (functionArgs != null)
|
||||
return functionArgs.length;
|
||||
if (functionParameters != null)
|
||||
return functionParameters.length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean hasFunctionArguments() {
|
||||
return functionArgs != null || functionParameters != null;
|
||||
return functionArgs != null;
|
||||
}
|
||||
|
||||
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.ICPPFunction;
|
||||
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.ICPPParameterPackType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||
|
@ -67,181 +68,16 @@ public class TemplateArgumentDeduction {
|
|||
static ICPPTemplateArgument[] deduceForFunctionCall(ICPPFunctionTemplate template,
|
||||
ICPPTemplateArgument[] tmplArgs, List<IType> fnArgs, List<ValueCategory> argIsLValue, 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);
|
||||
}
|
||||
if (!addExplicitArguments(tmplParams, tmplArgs, map))
|
||||
return null;
|
||||
|
||||
if (!deduceFromFunctionArgs(template, fnArgs, argIsLValue, map))
|
||||
return null;
|
||||
|
||||
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()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
return createArguments(map, tmplParams);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -253,9 +89,6 @@ public class TemplateArgumentDeduction {
|
|||
try {
|
||||
IType[] fnPars = template.getType().getParameterTypes();
|
||||
final int fnParCount = fnPars.length;
|
||||
if (fnParCount == 0)
|
||||
return true;
|
||||
|
||||
final ICPPTemplateParameter[] tmplPars = template.getTemplateParameters();
|
||||
TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(tmplPars, map, new CPPTemplateParameterMap(fnParCount), 0);
|
||||
IType fnParPack= null;
|
||||
|
@ -288,7 +121,7 @@ public class TemplateArgumentDeduction {
|
|||
// C++0x: 14.9.2.1-1
|
||||
if (arg instanceof InitializerListType) {
|
||||
par= SemanticUtil.getNestedType(par, TDEF | REF | CVTYPE);
|
||||
|
||||
|
||||
// Check if this is a deduced context
|
||||
IType inner= Conversions.getInitListType(par);
|
||||
if (inner != null) {
|
||||
|
@ -338,7 +171,7 @@ public class TemplateArgumentDeduction {
|
|||
}
|
||||
}
|
||||
|
||||
if (!deduct.fExplicitArgs.mergeToExplicit(deduct.fDeducedArgs))
|
||||
if (!map.addDeducedArgs(deduct.fDeducedArgs))
|
||||
return false;
|
||||
|
||||
return verifyDeduction(tmplPars, map, true);
|
||||
|
@ -346,7 +179,7 @@ public class TemplateArgumentDeduction {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private static boolean deduceFromFunctionArg(IType par, IType arg, ValueCategory valueCat, TemplateArgumentDeduction deduct) throws DOMException {
|
||||
boolean isReferenceTypeParameter= false;
|
||||
if (par instanceof ICPPReferenceType) {
|
||||
|
@ -407,6 +240,112 @@ public class TemplateArgumentDeduction {
|
|||
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,
|
||||
* returns <code>false</code> if there is no mapping.
|
||||
|
@ -470,6 +409,64 @@ public class TemplateArgumentDeduction {
|
|||
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.
|
||||
*/
|
||||
|
|
|
@ -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.ICPPASTUsingDirective;
|
||||
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.ICPPNamespaceAlias;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
|
@ -254,7 +255,8 @@ abstract public class PDOMWriter {
|
|||
try {
|
||||
final IBinding binding = name.resolveBinding();
|
||||
if (name.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_NAME &&
|
||||
((IASTName) name.getParent()).getBinding() == binding) {
|
||||
(((IASTName) name.getParent()).getBinding() == binding ||
|
||||
binding instanceof ICPPFunctionTemplate)) {
|
||||
na[0]= null;
|
||||
} else if (binding instanceof IProblemBinding) {
|
||||
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.description= Show the selected resource in the C/C++ Project view
|
||||
|
||||
ActionDefinition.finddecl.name= Find Declaration
|
||||
ActionDefinition.finddecl.description= Find Declaration
|
||||
ActionDefinition.finddecl.name= 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.description= Find References
|
||||
ActionDefinition.findrefs.name= 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.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
|
||||
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"
|
||||
name="%ActionDefinition.finddecl.name"
|
||||
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
|
||||
categoryId="org.eclipse.cdt.ui.category.source"
|
||||
description="%ActionDefinition.findrefs.description"
|
||||
name="%ActionDefinition.findrefs.name"
|
||||
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
|
||||
categoryId="org.eclipse.ui.category.navigate"
|
||||
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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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
|
||||
registerActionBars(bars);
|
||||
|
||||
bars.updateActionBars();
|
||||
|
||||
fTreeViewer.setInput(fInput);
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(control, ICHelpContextIds.COUTLINE_VIEW);
|
||||
}
|
||||
|
@ -591,7 +592,9 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
|
|||
if (fRefactoringActionGroup != null) {
|
||||
fRefactoringActionGroup.fillActionBars(actionBars);
|
||||
}
|
||||
|
||||
if (fSelectionSearchGroup != null) {
|
||||
fSelectionSearchGroup.fillActionBars(actionBars);
|
||||
}
|
||||
IMenuManager menu= actionBars.getMenuManager();
|
||||
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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -34,7 +34,7 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
|
|||
* @since 4.0.0
|
||||
*/
|
||||
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
|
||||
* (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
|
||||
*/
|
||||
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
|
||||
* (value <code>"org.eclipse.cdt.ui.edit.text.c.join.lines"</code>).
|
||||
* @since 3.0.2
|
||||
*/
|
||||
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
|
||||
* (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$
|
||||
|
||||
|
||||
/**
|
||||
* Action definition ID of the source -> format action
|
||||
* (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
|
||||
* (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
|
||||
* (value <code>"org.eclipse.cdt.ui.edit.opendecl"</code>).
|
||||
*/
|
||||
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
|
||||
* (value <code>"org.eclipse.cdt.ui.edit.opencview"</code>).
|
||||
*/
|
||||
public static final String OPEN_CVIEW= "org.eclipse.cdt.ui.edit.opencview"; //$NON-NLS-1$
|
||||
|
||||
|
||||
/**
|
||||
* Action definition ID of the refactor -> rename element action
|
||||
* (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>).
|
||||
*/
|
||||
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
|
||||
* <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>).
|
||||
*/
|
||||
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
|
||||
* (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>).
|
||||
*/
|
||||
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
|
||||
* (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
|
||||
* (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
|
||||
* (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
|
||||
|
@ -218,18 +242,18 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
|
|||
* Action definition ID for goto next bookmark action
|
||||
* (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
|
||||
* (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.
|
||||
* (value <code>"org.eclipse.cdt.ui.edit.text.c.toggle.source.header"</code>)
|
||||
*
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
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>).
|
||||
*/
|
||||
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
|
||||
* (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$
|
||||
|
||||
|
||||
/**
|
||||
* Action definition ID of the edit -> select previous action
|
||||
* (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$
|
||||
|
||||
|
||||
/**
|
||||
* Action definition ID of the edit -> select restore last action
|
||||
* (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());
|
||||
functionDefinition.setParent(unit);
|
||||
|
||||
if (NodeHelper.isContainedInTemplateDeclaration(declarationParent)) {
|
||||
ICPPASTTemplateDeclaration templateDeclaration = nodeFactory.newTemplateDeclaration(functionDefinition);
|
||||
templateDeclaration.setParent(unit);
|
||||
ICPPASTTemplateDeclaration templateDeclaration = NodeHelper.findContainedTemplateDecalaration(declarationParent);
|
||||
if (templateDeclaration != null) {
|
||||
ICPPASTTemplateDeclaration newTemplateDeclaration = nodeFactory.newTemplateDeclaration(functionDefinition);
|
||||
newTemplateDeclaration.setParent(unit);
|
||||
|
||||
for (ICPPASTTemplateParameter templateParameter : ((ICPPASTTemplateDeclaration) declarationParent.getParent().getParent() ).getTemplateParameters()) {
|
||||
templateDeclaration.addTemplateParameter(templateParameter.copy(CopyStyle.withLocations));
|
||||
for (ICPPASTTemplateParameter templateParameter : templateDeclaration.getTemplateParameters()) {
|
||||
newTemplateDeclaration.addTemplateParameter(templateParameter.copy(CopyStyle.withLocations));
|
||||
}
|
||||
|
||||
return templateDeclaration;
|
||||
return newTemplateDeclaration;
|
||||
}
|
||||
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
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* 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) {
|
||||
if (node == null) {
|
||||
return false;
|
||||
} else if (node instanceof ICPPASTTemplateDeclaration) {
|
||||
return true;
|
||||
return findContainedTemplateDecalaration(node) != null;
|
||||
}
|
||||
|
||||
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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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.IStructuredSelection;
|
||||
import org.eclipse.search.ui.IContextMenuConstants;
|
||||
import org.eclipse.ui.IActionBars;
|
||||
import org.eclipse.ui.IWorkbenchSite;
|
||||
import org.eclipse.ui.IWorkingSet;
|
||||
import org.eclipse.ui.actions.ActionGroup;
|
||||
|
@ -35,18 +36,21 @@ import org.eclipse.cdt.internal.ui.search.CSearchUtil;
|
|||
|
||||
|
||||
public class DeclarationsSearchGroup extends ActionGroup {
|
||||
|
||||
|
||||
private CEditor fEditor;
|
||||
private IWorkbenchSite fSite;
|
||||
|
||||
|
||||
private FindDeclarationsAction fFindDeclarationsAction;
|
||||
private FindDeclarationsProjectAction fFindDeclarationsProjectAction;
|
||||
private FindDeclarationsInWorkingSetAction fFindDeclarationsInWorkingSetAction;
|
||||
|
||||
|
||||
public DeclarationsSearchGroup(IWorkbenchSite site) {
|
||||
fFindDeclarationsAction= new FindDeclarationsAction(site);
|
||||
fFindDeclarationsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL);
|
||||
fFindDeclarationsProjectAction = new FindDeclarationsProjectAction(site);
|
||||
fFindDeclarationsProjectAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_PROJECT);
|
||||
fFindDeclarationsInWorkingSetAction = new FindDeclarationsInWorkingSetAction(site,null);
|
||||
fFindDeclarationsInWorkingSetAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_WORKING_SET);
|
||||
fSite = site;
|
||||
}
|
||||
/**
|
||||
|
@ -57,45 +61,53 @@ public class DeclarationsSearchGroup extends ActionGroup {
|
|||
|
||||
fFindDeclarationsAction= new FindDeclarationsAction(editor);
|
||||
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.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_PROJECT);
|
||||
editor.setAction(ICEditorActionDefinitionIds.FIND_DECL_PROJECT, fFindDeclarationsProjectAction);
|
||||
fFindDeclarationsInWorkingSetAction = new FindDeclarationsInWorkingSetAction(editor,null);
|
||||
fFindDeclarationsInWorkingSetAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_WORKING_SET);
|
||||
editor.setAction(ICEditorActionDefinitionIds.FIND_DECL_WORKING_SET, fFindDeclarationsInWorkingSetAction);
|
||||
}
|
||||
/*
|
||||
/*
|
||||
* Method declared on ActionGroup.
|
||||
*/
|
||||
@Override
|
||||
public void fillContextMenu(IMenuManager menu) {
|
||||
super.fillContextMenu(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){
|
||||
menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, declarationsMenu);
|
||||
menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, declarationsMenu);
|
||||
} else {
|
||||
incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, declarationsMenu);
|
||||
}
|
||||
incomingMenu = declarationsMenu;
|
||||
|
||||
|
||||
FindAction[] actions = getWorkingSetActions();
|
||||
incomingMenu.add(fFindDeclarationsAction);
|
||||
incomingMenu.add(fFindDeclarationsProjectAction);
|
||||
incomingMenu.add(fFindDeclarationsInWorkingSetAction);
|
||||
|
||||
|
||||
for (FindAction action : actions) {
|
||||
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() {
|
||||
ArrayList<FindAction> actions= new ArrayList<FindAction>(CSearchUtil.LRU_WORKINGSET_LIST_SIZE);
|
||||
|
||||
|
||||
Iterator<IWorkingSet[]> iter= CSearchUtil.getLRUWorkingSets().iterator();
|
||||
while (iter.hasNext()) {
|
||||
IWorkingSet[] workingSets= iter.next();
|
||||
|
@ -104,10 +116,10 @@ public class DeclarationsSearchGroup extends ActionGroup {
|
|||
action= new WorkingSetFindAction(fEditor, new FindDeclarationsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets));
|
||||
else
|
||||
action= new WorkingSetFindAction(fSite, new FindDeclarationsInWorkingSetAction(fSite, workingSets), CSearchUtil.toString(workingSets));
|
||||
|
||||
|
||||
actions.add(action);
|
||||
}
|
||||
|
||||
|
||||
return actions.toArray(new FindAction[actions.size()]);
|
||||
}
|
||||
public static boolean canActionBeAdded(ISelection selection) {
|
||||
|
@ -116,7 +128,7 @@ public class DeclarationsSearchGroup extends ActionGroup {
|
|||
}
|
||||
return getElement(selection) != null;
|
||||
}
|
||||
|
||||
|
||||
private static ICElement getElement(ISelection sel) {
|
||||
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
||||
List<?> list= ((IStructuredSelection)sel).toList();
|
||||
|
@ -129,8 +141,8 @@ public class DeclarationsSearchGroup extends ActionGroup {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* Overrides method declared in ActionGroup
|
||||
*/
|
||||
@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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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.MenuManager;
|
||||
import org.eclipse.search.ui.IContextMenuConstants;
|
||||
import org.eclipse.ui.IActionBars;
|
||||
import org.eclipse.ui.IWorkbenchSite;
|
||||
import org.eclipse.ui.IWorkingSet;
|
||||
import org.eclipse.ui.actions.ActionGroup;
|
||||
|
@ -31,66 +32,78 @@ public class ReferencesSearchGroup extends ActionGroup {
|
|||
private FindRefsAction fFindRefsAction;
|
||||
private FindRefsProjectAction fFindRefsProjectAction;
|
||||
private FindRefsInWorkingSetAction fFindRefsInWorkingSetAction;
|
||||
|
||||
|
||||
private CEditor fEditor;
|
||||
private IWorkbenchSite fSite;
|
||||
|
||||
|
||||
public ReferencesSearchGroup(IWorkbenchSite site) {
|
||||
fFindRefsAction= new FindRefsAction(site);
|
||||
fFindRefsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS);
|
||||
fFindRefsProjectAction = new FindRefsProjectAction(site);
|
||||
fFindRefsProjectAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS_PROJECT);
|
||||
fFindRefsInWorkingSetAction = new FindRefsInWorkingSetAction(site, null);
|
||||
fFindRefsInWorkingSetAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS_WORKING_SET);
|
||||
fSite=site;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param editor
|
||||
*/
|
||||
public ReferencesSearchGroup(CEditor editor) {
|
||||
fEditor = editor;
|
||||
|
||||
|
||||
fFindRefsAction= new FindRefsAction(editor);
|
||||
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.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS_PROJECT);
|
||||
editor.setAction(ICEditorActionDefinitionIds.FIND_REFS_PROJECT, fFindRefsProjectAction);
|
||||
fFindRefsInWorkingSetAction = new FindRefsInWorkingSetAction(editor, null);
|
||||
fFindRefsInWorkingSetAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS_WORKING_SET);
|
||||
editor.setAction(ICEditorActionDefinitionIds.FIND_REFS_WORKING_SET, fFindRefsInWorkingSetAction);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* Method declared on ActionGroup.
|
||||
*/
|
||||
@Override
|
||||
public void fillContextMenu(IMenuManager menu) {
|
||||
|
||||
|
||||
super.fillContextMenu(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){
|
||||
menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, refsMenu);
|
||||
menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, refsMenu);
|
||||
} else {
|
||||
incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, refsMenu);
|
||||
}
|
||||
|
||||
|
||||
incomingMenu = refsMenu;
|
||||
|
||||
|
||||
FindAction[] actions = getWorkingSetActions();
|
||||
incomingMenu.add(fFindRefsAction);
|
||||
incomingMenu.add(fFindRefsProjectAction);
|
||||
incomingMenu.add(fFindRefsInWorkingSetAction);
|
||||
|
||||
|
||||
for (FindAction action : actions) {
|
||||
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() {
|
||||
ArrayList<FindAction> actions= new ArrayList<FindAction>(CSearchUtil.LRU_WORKINGSET_LIST_SIZE);
|
||||
|
||||
|
||||
Iterator<IWorkingSet[]> iter= CSearchUtil.getLRUWorkingSets().iterator();
|
||||
while (iter.hasNext()) {
|
||||
IWorkingSet[] workingSets= iter.next();
|
||||
|
@ -99,14 +112,14 @@ public class ReferencesSearchGroup extends ActionGroup {
|
|||
action= new WorkingSetFindAction(fEditor, new FindRefsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets));
|
||||
else
|
||||
action= new WorkingSetFindAction(fSite, new FindRefsInWorkingSetAction(fSite, workingSets), CSearchUtil.toString(workingSets));
|
||||
|
||||
|
||||
actions.add(action);
|
||||
}
|
||||
|
||||
|
||||
return actions.toArray(new FindAction[actions.size()]);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* Overrides method declared in ActionGroup
|
||||
*/
|
||||
@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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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 org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
import org.eclipse.jface.text.ITextSelection;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.ui.IActionBars;
|
||||
import org.eclipse.ui.IWorkbenchSite;
|
||||
import org.eclipse.ui.actions.ActionGroup;
|
||||
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;
|
||||
|
||||
public class SelectionSearchGroup extends ActionGroup {
|
||||
|
||||
|
||||
private CEditor fEditor;
|
||||
|
||||
|
||||
private DeclarationsSearchGroup fDeclarationsSearchGroup;
|
||||
private ReferencesSearchGroup fRefSearchGroup;
|
||||
|
||||
|
||||
public SelectionSearchGroup(CEditor editor){
|
||||
//TODO: Assert editor not null
|
||||
Assert.isNotNull(editor);
|
||||
fEditor= editor;
|
||||
|
||||
|
||||
fDeclarationsSearchGroup= new DeclarationsSearchGroup(fEditor);
|
||||
fRefSearchGroup = new ReferencesSearchGroup(fEditor);
|
||||
}
|
||||
|
@ -51,24 +53,32 @@ public class SelectionSearchGroup extends ActionGroup {
|
|||
fDeclarationsSearchGroup= new DeclarationsSearchGroup(site);
|
||||
fRefSearchGroup = new ReferencesSearchGroup(site);
|
||||
}
|
||||
/*
|
||||
/*
|
||||
* Method declared on ActionGroup.
|
||||
*/
|
||||
@Override
|
||||
public void fillContextMenu(IMenuManager menu) {
|
||||
super.fillContextMenu(menu);
|
||||
|
||||
|
||||
fDeclarationsSearchGroup.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) {
|
||||
if(selection instanceof ITextSelection) {
|
||||
return (((ITextSelection)selection).getLength() > 0);
|
||||
}
|
||||
return getElement(selection) != null;
|
||||
}
|
||||
|
||||
|
||||
private static ICElement getElement(ISelection sel) {
|
||||
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
||||
List<?> list= ((IStructuredSelection)sel).toList();
|
||||
|
@ -81,7 +91,7 @@ public class SelectionSearchGroup extends ActionGroup {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.actions.ActionGroup#dispose()
|
||||
*/
|
||||
|
@ -91,14 +101,14 @@ public class SelectionSearchGroup extends ActionGroup {
|
|||
fDeclarationsSearchGroup.dispose();
|
||||
fDeclarationsSearchGroup= null;
|
||||
}
|
||||
|
||||
|
||||
if (fRefSearchGroup != null) {
|
||||
fRefSearchGroup.dispose();
|
||||
fRefSearchGroup= null;
|
||||
}
|
||||
|
||||
|
||||
fEditor= null;
|
||||
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>org.eclipse.cdt.features</groupId>
|
||||
<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>
|
||||
</project>
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>org.eclipse.cdt.gdb-feature</artifactId>
|
||||
<groupId>org.eclipse.cdt.features</groupId>
|
||||
<artifactId>org.eclipse.cdt.gdb</artifactId>
|
||||
<packaging>eclipse-feature</packaging>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
</project>
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</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>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
</project>
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</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>
|
||||
<version>7.1.0-SNAPSHOT</version>
|
||||
</project>
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</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>
|
||||
<version>7.1.0-SNAPSHOT</version>
|
||||
</project>
|
||||
|
|
|
@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
|
|||
Bundle-Name: %pluginName
|
||||
Bundle-Vendor: %providerName
|
||||
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-Localization: plugin
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<version>2.2.0-SNAPSHOT</version>
|
||||
<version>2.3.0-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.dsf.gdb.ui</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,10 +7,12 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Marc Khouzam (Ericsson) - Use IDsfBreakpointExtension directly (Bug 355833)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints;
|
||||
|
||||
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.launching.GdbLaunchDelegate;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -44,12 +46,12 @@ public class CBreakpointGdbThreadFilterPage extends PropertyPage {
|
|||
return (ICBreakpoint)getElement().getAdapter(ICBreakpoint.class);
|
||||
}
|
||||
|
||||
public CBreakpointGdbThreadsFilterExtension getFilterExtension() {
|
||||
public IDsfBreakpointExtension getFilterExtension() {
|
||||
ICBreakpoint bp = getBreakpoint();
|
||||
if (bp != null) {
|
||||
try {
|
||||
CBreakpointGdbThreadsFilterExtension filter =
|
||||
(CBreakpointGdbThreadsFilterExtension) bp.getExtension(
|
||||
IDsfBreakpointExtension filter =
|
||||
(IDsfBreakpointExtension) bp.getExtension(
|
||||
GdbLaunchDelegate.GDB_DEBUG_MODEL_ID, CBreakpointGdbThreadsFilterExtension.class);
|
||||
filter.initialize(bp);
|
||||
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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* 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;
|
||||
|
||||
|
@ -23,17 +24,17 @@ import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
|
|||
import org.eclipse.cdt.dsf.concurrent.Query;
|
||||
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||
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.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.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.IExecutionDMContext;
|
||||
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.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.IMIProcesses;
|
||||
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
||||
|
@ -256,7 +257,7 @@ public class GdbThreadFilterEditor {
|
|||
|
||||
private void createThreadViewer(Composite parent) {
|
||||
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.setLayoutData(new GridData());
|
||||
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.
|
||||
*/
|
||||
protected void setInitialCheckedState() {
|
||||
CBreakpointGdbThreadsFilterExtension filterExtension = fPage.getFilterExtension();
|
||||
IDsfBreakpointExtension filterExtension = fPage.getFilterExtension();
|
||||
try {
|
||||
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++) {
|
||||
IExecutionDMContext[] filteredThreads = filterExtension.getThreadFilters(targets[i]);
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
// Mark the entire process as selected
|
||||
fCheckHandler.checkTarget(targets[i], true);
|
||||
}
|
||||
}
|
||||
|
@ -331,7 +324,7 @@ public class GdbThreadFilterEditor {
|
|||
}
|
||||
|
||||
protected void doStore() {
|
||||
CBreakpointGdbThreadsFilterExtension filterExtension = fPage.getFilterExtension();
|
||||
IDsfBreakpointExtension filterExtension = fPage.getFilterExtension();
|
||||
IContainerDMContext[] targets = getDebugTargets();
|
||||
for (int i = 0; i < targets.length; ++i) {
|
||||
try {
|
||||
|
@ -388,7 +381,7 @@ public class GdbThreadFilterEditor {
|
|||
IContainerDMContext[] containerDmcs = (IContainerDMContext[])getData();
|
||||
rm.setData(containerDmcs);
|
||||
} 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();
|
||||
}
|
||||
|
@ -409,7 +402,7 @@ public class GdbThreadFilterEditor {
|
|||
} catch (InterruptedException e) {
|
||||
} catch (ExecutionException e) {
|
||||
}
|
||||
return null;
|
||||
return new IContainerDMContext[0];
|
||||
}
|
||||
|
||||
private IExecutionDMContext[] syncGetThreads(final IContainerDMContext container) {
|
||||
|
@ -458,7 +451,7 @@ public class GdbThreadFilterEditor {
|
|||
|
||||
class ContainerLabelQuery extends Query<String> {
|
||||
@Override
|
||||
protected void execute(DataRequestMonitor<String> rm) {
|
||||
protected void execute(final DataRequestMonitor<String> rm) {
|
||||
if (!session.isActive()) {
|
||||
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Container's session not active.")); //$NON-NLS-1$
|
||||
rm.done();
|
||||
|
@ -466,13 +459,30 @@ public class GdbThreadFilterEditor {
|
|||
}
|
||||
|
||||
DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId());
|
||||
IGDBBackend backend = tracker.getService(IGDBBackend.class);
|
||||
if (backend != null) {
|
||||
rm.setData(backend.getProgramPath().toOSString());
|
||||
IProcesses processService = tracker.getService(IProcesses.class);
|
||||
IProcessDMContext procDmc = DMContexts.getAncestorOfType(container, IProcessDMContext.class);
|
||||
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 {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -511,11 +521,18 @@ public class GdbThreadFilterEditor {
|
|||
ImmediateExecutor.getInstance(), rm) {
|
||||
@Override
|
||||
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("] "); //$NON-NLS-1$
|
||||
builder.append(getData().getId());
|
||||
builder.append(getData().getName());
|
||||
String threadId = getData().getId();
|
||||
if (threadId != null) {
|
||||
builder.append(threadId);
|
||||
}
|
||||
String threadName = getData().getName();
|
||||
if (threadName != null) {
|
||||
builder.append(threadName);
|
||||
}
|
||||
|
||||
rm.setData(builder.toString());
|
||||
rm.done();
|
||||
|
|
|
@ -31,7 +31,10 @@ public class Messages extends NLS {
|
|||
public static String TracepointPropertyPage_PassCount;
|
||||
public static String TracepointPropertyPage_Class;
|
||||
public static String TracepointPropertyPage_Enabled;
|
||||
|
||||
|
||||
public static String GdbThreadFilterEditor_Thread;
|
||||
public static String GdbThreadFilterEditor_RestrictToSelected;
|
||||
|
||||
static {
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages(Messages.class.getName(), Messages.class);
|
||||
|
|
|
@ -29,3 +29,6 @@ TracepointPropertyPage_IgnoreCount=&Ignore count:
|
|||
TracepointPropertyPage_PassCount=&Pass count:
|
||||
TracepointPropertyPage_Class=Class:
|
||||
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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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)
|
||||
*/
|
||||
public void initialize(ICBreakpoint breakpoint) {
|
||||
// TODO: Initialize fFilteredThreadsByTarget with current IContainerDMContext[]
|
||||
// TODO: IRunControl?
|
||||
}
|
||||
|
||||
/* (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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -11,6 +11,7 @@
|
|||
* Ericsson - Added breakpoint filter support
|
||||
* Ericsson - Re-factored the service and put a few comments
|
||||
* Ericsson - Added Action support
|
||||
* Marc Khouzam (Ericsson) - Fix support for thread filter (Bug 355833)
|
||||
*******************************************************************************/
|
||||
|
||||
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
|
||||
determineDebuggerPath(dmc, attributes, new RequestMonitor(getExecutor(), countingRm) {
|
||||
@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)
|
||||
// Note that Tracepoints are not affected by "skip-all"
|
||||
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);
|
||||
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)
|
||||
removeBreakpointProblemMarker(breakpoint);
|
||||
|
||||
|
@ -1127,6 +1153,18 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
|
|||
new RequestMonitor(getExecutor(), countingRm) {
|
||||
@Override
|
||||
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,
|
||||
attrs, countingRm);
|
||||
}
|
||||
|
@ -1372,15 +1410,28 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
|
|||
for (IBreakpointsTargetDMContext ctx : fPlatformBPs.keySet()) {
|
||||
Map<ICBreakpoint, Map<String, Object>> breakpoints = fPlatformBPs.get(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
|
||||
// backend that has already shutdown
|
||||
fPlatformBPs.clear();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Breakpoint status handling functions
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
private void clearTargetFilter(IContainerDMContext containerDmc, Set<ICBreakpoint> breakpoints) {
|
||||
// Remove any target filter (if any)
|
||||
try {
|
||||
for (ICBreakpoint bp : breakpoints) {
|
||||
getFilterExtension(bp).removeTargetFilter(containerDmc);
|
||||
}
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param bps
|
||||
|
@ -1651,41 +1702,28 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
|
|||
* @return
|
||||
*/
|
||||
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
|
||||
List<IExecutionDMContext[]> threads = new ArrayList<IExecutionDMContext[]>(1);
|
||||
|
||||
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 (threads == null || threads.length == 0) {
|
||||
results.add("0"); //$NON-NLS-1$
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
if (supportsThreads(breakpoint)) {
|
||||
for (IExecutionDMContext[] targetThreads : threads) {
|
||||
if (targetThreads != null) {
|
||||
for (IExecutionDMContext thread : targetThreads) {
|
||||
if (thread instanceof IMIExecutionDMContext) {
|
||||
IMIExecutionDMContext dmc = (IMIExecutionDMContext) thread;
|
||||
results.add(((Integer) dmc.getThreadId()).toString());
|
||||
}
|
||||
}
|
||||
for (IExecutionDMContext thread : threads) {
|
||||
if (thread instanceof IMIExecutionDMContext) {
|
||||
results.add(Integer.toString(((IMIExecutionDMContext)thread).getThreadId()));
|
||||
} 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$
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>org.eclipse.cdt.feature</groupId>
|
||||
<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>
|
||||
</project>
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>org.eclipse.cdt.features</groupId>
|
||||
<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>
|
||||
</project>
|
||||
|
|
|
@ -566,11 +566,10 @@ public class SyncUtil {
|
|||
Assert.assertEquals("unexpected number of processes", 1, contexts.length);
|
||||
IDMContext context = contexts[0];
|
||||
Assert.assertNotNull("unexpected process context type ", context);
|
||||
rm.setData((IContainerDMContext)context);
|
||||
rm.done((IContainerDMContext)context);
|
||||
} else {
|
||||
rm.setStatus(getStatus());
|
||||
rm.done(getStatus());
|
||||
}
|
||||
rm.done();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
|
|||
Bundle-Name: %pluginName
|
||||
Bundle-Vendor: %providerName
|
||||
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-Localization: plugin
|
||||
Require-Bundle: org.eclipse.ui;bundle-version="3.5.0",
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<version>2.2.0-SNAPSHOT</version>
|
||||
<version>2.2.1-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.dsf.ui</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</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-Vendor: %providerName
|
||||
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-Localization: plugin
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<version>2.2.0-SNAPSHOT</version>
|
||||
<version>2.3.0-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.dsf</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
* Eugene Ostroukhov (NVIDIA) - new done(V) method
|
||||
*******************************************************************************/
|
||||
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
|
||||
* asynchronous method implementor.
|
||||
* @param data Data value to set.
|
||||
*
|
||||
* @see #done(Object)
|
||||
*/
|
||||
public synchronized void setData(V data) { fData = data; }
|
||||
|
||||
|
@ -41,6 +44,26 @@ public class DataRequestMonitor<V> extends RequestMonitor {
|
|||
*/
|
||||
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
|
||||
public String toString() {
|
||||
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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
* Eugene Ostroukhov (NVIDIA) - new done(IStatus) method
|
||||
*******************************************************************************/
|
||||
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
|
||||
* method does not need to be called.
|
||||
* method does not need to be called.
|
||||
*
|
||||
* @see #done(IStatus)
|
||||
*/
|
||||
public synchronized void setStatus(IStatus status) {
|
||||
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
|
||||
* <code>handle...</code> methods.
|
||||
* <p>
|
||||
* Note: This method should be called once and only once, for every request
|
||||
* issued. Even if the request was canceled.
|
||||
* Note: Only one <code>done</code> method should be called and only once,
|
||||
* for every request issued. Even if the request was canceled.
|
||||
* </p>
|
||||
*/
|
||||
public synchronized void done() {
|
||||
|
@ -306,6 +309,24 @@ public class RequestMonitor extends DsfExecutable {
|
|||
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
|
||||
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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
* Marc Khouzam (Ericsson) - Adding javadoc (Bug 355833)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.debug.service;
|
||||
|
||||
|
@ -35,12 +36,60 @@ import org.eclipse.core.runtime.CoreException;
|
|||
*/
|
||||
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 void setThreadFilters( IExecutionDMContext[] threads ) throws CoreException;
|
||||
public void removeThreadFilters( IExecutionDMContext[] threads ) throws CoreException;
|
||||
public IExecutionDMContext[] getThreadFilters( IContainerDMContext target ) throws CoreException;
|
||||
/**
|
||||
* Restricts this breakpoint to suspend only in the given threads
|
||||
* 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>
|
||||
</parent>
|
||||
|
||||
<groupId>org.eclipse.cdt.features</groupId>
|
||||
<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>
|
||||
</project>
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>org.eclipse.cdt.features</groupId>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdtdebug.gdbjtag-feature</artifactId>
|
||||
<artifactId>org.eclipse.cdt.debug.gdbjtag</artifactId>
|
||||
<packaging>eclipse-feature</packaging>
|
||||
</project>
|
||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
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-Localization: plugin
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<version>8.0.0-SNAPSHOT</version>
|
||||
<version>8.0.1-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.debug.gdbjtag.core</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -11,6 +11,7 @@
|
|||
* Sage Electronic Engineering, LLC - bug 305943
|
||||
* - API generalization to become transport-independent (allow
|
||||
* connections via serial ports and pipes).
|
||||
* John Dallaway - Wrong groupId during initialization (Bug 349736)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.gdbjtag.core;
|
||||
|
||||
|
@ -615,7 +616,7 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
|
|||
public void execute(final RequestMonitor requestMonitor) {
|
||||
if (fSessionType != SessionType.CORE) {
|
||||
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);
|
||||
|
||||
bpmService.startTrackingBreakpoints(bpTargetDmc, requestMonitor);
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>org.eclipse.cdt.features</groupId>
|
||||
<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>
|
||||
</project>
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>org.eclipse.cdt.features</groupId>
|
||||
<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>
|
||||
</project>
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>org.eclipse.cdt.features</groupId>
|
||||
<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>
|
||||
</project>
|
||||
|
|
|
@ -62,6 +62,7 @@ public class GoToAddressBarWidget {
|
|||
private Button fOKButton;
|
||||
private Button fOKNewTabButton;
|
||||
private Composite fComposite;
|
||||
private Object fCurrentDebugContext;
|
||||
|
||||
protected static int ID_GO_NEW_TAB = 2000;
|
||||
|
||||
|
@ -267,20 +268,22 @@ public class GoToAddressBarWidget {
|
|||
*/
|
||||
public void loadSavedExpressions(Object context, String memorySpace)
|
||||
{
|
||||
|
||||
try {
|
||||
String[] expressions = getSavedExpressions(context, memorySpace);
|
||||
String currentExpression = fExpression.getText();
|
||||
fExpression.removeAll();
|
||||
for (String expression : expressions) {
|
||||
fExpression.add(expression);
|
||||
if ( context != null && ! context.equals( fCurrentDebugContext ) ) {
|
||||
try {
|
||||
String[] expressions = getSavedExpressions(context, memorySpace);
|
||||
String currentExpression = fExpression.getText();
|
||||
fExpression.removeAll();
|
||||
for (String expression : expressions) {
|
||||
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>
|
||||
</parent>
|
||||
|
||||
<groupId>org.eclipse.cdt.features</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.p2-feature</artifactId>
|
||||
<artifactId>org.eclipse.cdt.p2</artifactId>
|
||||
<packaging>eclipse-feature</packaging>
|
||||
</project>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>org.eclipse.cdt-feature</artifactId>
|
||||
<groupId>org.eclipse.cdt.features</groupId>
|
||||
<artifactId>org.eclipse.cdt</artifactId>
|
||||
<packaging>eclipse-feature</packaging>
|
||||
</project>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>org.eclipse.cdt.platform-feature</artifactId>
|
||||
<groupId>org.eclipse.cdt.features</groupId>
|
||||
<artifactId>org.eclipse.cdt.platform</artifactId>
|
||||
<packaging>eclipse-feature</packaging>
|
||||
</project>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</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>
|
||||
</project>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>org.eclipse.cdt.sdk-feature</artifactId>
|
||||
<groupId>org.eclipse.cdt.features</groupId>
|
||||
<artifactId>org.eclipse.cdt.sdk</artifactId>
|
||||
<packaging>eclipse-feature</packaging>
|
||||
</project>
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>org.eclipse.cdt.features</groupId>
|
||||
<version>1.0.3-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.bupc-feature</artifactId>
|
||||
<artifactId>org.eclipse.cdt.bupc</artifactId>
|
||||
<packaging>eclipse-feature</packaging>
|
||||
</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