mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 01:45:33 +02:00
Merge branch 'master' into sd90
This commit is contained in:
commit
89c6f3a80c
36 changed files with 825 additions and 596 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2010 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
|
||||
|
@ -68,18 +68,18 @@ import org.w3c.dom.Element;
|
|||
public class PerProjectSICollector implements IScannerInfoCollector3, IScannerInfoCollectorCleaner {
|
||||
public static final String COLLECTOR_ID = MakeCorePlugin.getUniqueIdentifier() + ".PerProjectSICollector"; //$NON-NLS-1$
|
||||
|
||||
private IProject project;
|
||||
private InfoContext context;
|
||||
protected IProject project;
|
||||
protected InfoContext context;
|
||||
private boolean isBuiltinConfig= false;
|
||||
|
||||
private Map<ScannerInfoTypes, List<String>> discoveredSI;
|
||||
protected Map<ScannerInfoTypes, List<String>> discoveredSI;
|
||||
// private List discoveredIncludes;
|
||||
// private List discoveredSymbols;
|
||||
// private List discoveredTSO; // target specific options
|
||||
// cumulative values
|
||||
private List<String> sumDiscoveredIncludes;
|
||||
protected List<String> sumDiscoveredIncludes;
|
||||
private Map<String, SymbolEntry> sumDiscoveredSymbols;
|
||||
private boolean scPersisted = false;
|
||||
protected boolean scPersisted = false;
|
||||
|
||||
public PerProjectSICollector() {
|
||||
discoveredSI = new HashMap<ScannerInfoTypes, List<String>>();
|
||||
|
@ -185,7 +185,7 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn
|
|||
* @param ordered - to preserve order or append at the end
|
||||
* @return boolean - true if added
|
||||
*/
|
||||
private boolean addItemsWithOrder(List<String> sumIncludes, List<String> includes, boolean ordered) {
|
||||
protected boolean addItemsWithOrder(List<String> sumIncludes, List<String> includes, boolean ordered) {
|
||||
if (includes.isEmpty())
|
||||
return false;
|
||||
|
||||
|
@ -321,7 +321,7 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn
|
|||
/**
|
||||
* Compare symbol definitions with already discovered.
|
||||
*/
|
||||
private boolean definedSymbolsNeedUpdate(IPerProjectDiscoveredPathInfo discPathInfo) {
|
||||
protected boolean definedSymbolsNeedUpdate(IPerProjectDiscoveredPathInfo discPathInfo) {
|
||||
boolean addedSymbols = false;
|
||||
List<String> discoveredSymbols = discoveredSI.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
|
||||
if (discoveredSymbols != null) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2008 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
|
||||
|
@ -19,14 +19,14 @@ import org.eclipse.jface.action.Separator;
|
|||
import org.eclipse.ui.IActionBars;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IWorkbenchActionConstants;
|
||||
import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;
|
||||
import org.eclipse.ui.editors.text.TextEditorActionContributor;
|
||||
import org.eclipse.ui.texteditor.ITextEditor;
|
||||
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
|
||||
import org.eclipse.ui.texteditor.RetargetTextEditorAction;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class MakefileEditorActionContributor extends BasicTextEditorActionContributor {
|
||||
public class MakefileEditorActionContributor extends TextEditorActionContributor {
|
||||
|
||||
private MakefileEditorTogglePresentationAction fTogglePresentation;
|
||||
private OpenDeclarationAction fOpenDeclarationAction;
|
||||
|
|
|
@ -1132,25 +1132,6 @@ Overrides language id specified with the languageId attribute.
|
|||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="fieldEditor" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Optional ID of the custom field-editor to represent this build-option in the project Properties dialog UI. If no custom field-editor ID is specified then the option will be represented by one of the built-in field-editors based on the option's <code>valueType</code> attribute.
|
||||
|
||||
A custom field-editor needs to be registered, under the same ID, through the <code>org.eclipse.cdt.managedbuilder.ui.buildDefinitionsUI</code> extension-point's <code>&lt;fieldEditor&gt;</code> element.
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="identifier" basedOn="org.eclipse.cdt.managedbuilder.ui.buildDefinitionsUI/fieldEditor/@id"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="fieldEditorExtraArgument" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
An optional extra text string that is passed into the field-editor. Can be used to parameterize the field-editor instance.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
|
@ -1458,6 +1439,25 @@ Additional special types exist to flag options of special relevance to the build
|
|||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="fieldEditor" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Optional ID of the custom field-editor to represent this build-option in the project Properties dialog UI. If no custom field-editor ID is specified then the option will be represented by one of the built-in field-editors based on the option's <code>valueType</code> attribute.
|
||||
|
||||
A custom field-editor needs to be registered, under the same ID, through the <code>org.eclipse.cdt.managedbuilder.ui.buildDefinitionsUI</code> extension-point's <code>&lt;fieldEditor&gt;</code> element.
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="identifier" basedOn="org.eclipse.cdt.managedbuilder.ui.buildDefinitionsUI/fieldEditor/@id"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="fieldEditorExtraArgument" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
An optional extra text string that is passed into the field-editor. Can be used to parameterize the field-editor instance.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
<artifactId>tycho-surefire-plugin</artifactId>
|
||||
<version>${tycho-version}</version>
|
||||
<configuration>
|
||||
<useUIHarness>false</useUIHarness>
|
||||
<!-- Need UI harness for quick fix tests -->
|
||||
<useUIHarness>true</useUIHarness>
|
||||
<argLine>-Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
|
||||
<includes>
|
||||
<include>**/AutomatedIntegrationSuite.*</include>
|
||||
|
|
|
@ -9,3 +9,4 @@ Fragment-Host: org.eclipse.cdt.core;bundle-version="[5.2.0,6.0.0)"
|
|||
Bundle-Localization: plugin
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.4
|
||||
Eclipse-PlatformFilter: (osgi.os=win32)
|
||||
Eclipse-BundleShape: dir
|
||||
|
|
|
@ -278,6 +278,20 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
|||
|
||||
public void projectClosedRemove(IProject project) {
|
||||
CProjectDescriptionStorageManager.getInstance().projectClosedRemove(project);
|
||||
disposeAssociatedListeners(project);
|
||||
}
|
||||
|
||||
private void disposeAssociatedListeners(IProject project) {
|
||||
List<ScannerInfoProviderProxy> proxyListeners = new ArrayList<ScannerInfoProviderProxy>();
|
||||
for (ListenerDescriptor ldescriptor : fListeners) {
|
||||
if (ldescriptor.fListener instanceof ScannerInfoProviderProxy)
|
||||
proxyListeners.add((ScannerInfoProviderProxy) ldescriptor.fListener);
|
||||
}
|
||||
// avoid calling proxy.close() inside fListeners loop as it modifies the collection
|
||||
for (ScannerInfoProviderProxy proxy : proxyListeners) {
|
||||
if (project.equals(proxy.getProject()))
|
||||
proxy.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -90,11 +90,21 @@ public interface IIndexManager extends IPDOMManager {
|
|||
public final static int UPDATE_CHECK_CONTENTS_HASH= 0x10;
|
||||
|
||||
/**
|
||||
* Include files that are otherwise would be excluded from the index.
|
||||
* Include files that are otherwise would be excluded from the index. This flag is sticky
|
||||
* for the duration of the Eclipse session. If the files are later updated without this flag,
|
||||
* they remain in the index.
|
||||
* @since 5.3
|
||||
*/
|
||||
public final static int FORCE_INDEX_INCLUSION= 0x20;
|
||||
|
||||
/**
|
||||
* Causes files previously included in the index due to FORCE_INDEX_INCLUSION to loose
|
||||
* their index inclusion privilege. The files included only due to FORCE_INDEX_INCLUSION,
|
||||
* will be removed from the index.
|
||||
* @since 5.4
|
||||
*/
|
||||
public final static int RESET_INDEX_INCLUSION= 0x40;
|
||||
|
||||
/**
|
||||
* Returns the index for the given project.
|
||||
* @param project the project to get the index for
|
||||
|
|
|
@ -18,23 +18,18 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.ASTCommenter;
|
|||
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* ASTWriter main class. Generates source code from <code>IASTNode</code>. Uses a
|
||||
* <codeC>hangeGeneratorWriterVisitor</code> to generate the code for the given
|
||||
* nodes.
|
||||
* ASTWriter main class. Generates source code from <code>IASTNode</code>.
|
||||
* Uses a <code>hangeGeneratorWriterVisitor</code> to generate the code for the given nodes.
|
||||
*
|
||||
* @see ChangeGeneratorWriterVisitor
|
||||
*
|
||||
* @author Emanuel Graf
|
||||
*
|
||||
*/
|
||||
public class ASTWriter {
|
||||
|
||||
private ChangeGeneratorWriterVisitor transformationVisitor;
|
||||
private ASTModificationStore modificationStore = new ASTModificationStore();
|
||||
private String givenIndentation = ""; //$NON-NLS-1$
|
||||
|
||||
|
||||
/**
|
||||
* Creates a <code>ASTWriter</code>.
|
||||
*/
|
||||
|
@ -53,8 +48,7 @@ public class ASTWriter {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Genereates the source code representing this node.
|
||||
* Generates the source code representing this node.
|
||||
*
|
||||
* @param rootNode Node to write.
|
||||
* @return A <code>String</code> representing the source code for the node.
|
||||
|
@ -69,19 +63,21 @@ public class ASTWriter {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Generates the source code representing this node including comments.
|
||||
*
|
||||
* @param rootNode Node to write.
|
||||
* @param fileScope
|
||||
* @param commentMap Node Comment Map <code>ASTCommenter</code>
|
||||
* @return A <code>String</code> representing the source code for the node.
|
||||
* @throws ProblemRuntimeException if the node or one of it's children is a <code>IASTProblemNode</code>.
|
||||
* @throws ProblemRuntimeException if the node or one of it's children is
|
||||
* an <code>IASTProblemNode</code>.
|
||||
*
|
||||
* @see ASTCommenter#getCommentedNodeMap(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
|
||||
*/
|
||||
public String write(IASTNode rootNode, String fileScope, NodeCommentMap commentMap) throws ProblemRuntimeException {
|
||||
transformationVisitor = new ChangeGeneratorWriterVisitor(modificationStore, givenIndentation, fileScope, commentMap);
|
||||
public String write(IASTNode rootNode, String fileScope, NodeCommentMap commentMap)
|
||||
throws ProblemRuntimeException {
|
||||
transformationVisitor = new ChangeGeneratorWriterVisitor(modificationStore, givenIndentation,
|
||||
fileScope, commentMap);
|
||||
if (rootNode != null) {
|
||||
rootNode.accept(transformationVisitor);
|
||||
}
|
||||
|
@ -90,9 +86,7 @@ public class ASTWriter {
|
|||
return str;
|
||||
}
|
||||
|
||||
|
||||
public void setModificationStore(ASTModificationStore modificationStore) {
|
||||
this.modificationStore = modificationStore;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -83,7 +83,6 @@ public class ASTWriterVisitor extends ASTVisitor {
|
|||
scribe.setGivenIndentation(givenIndentation);
|
||||
init(commentMap);
|
||||
this.commentMap = commentMap;
|
||||
|
||||
}
|
||||
|
||||
private void init(NodeCommentMap commentMap) {
|
||||
|
@ -120,8 +119,6 @@ public class ASTWriterVisitor extends ASTVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ArrayList<IASTComment> getLeadingComments(IASTNode node) {
|
||||
ArrayList<IASTComment> leadingComments = commentMap.getLeadingCommentsForNode(node);
|
||||
IASTNodeLocation[] locs = node.getNodeLocations();
|
||||
|
@ -157,7 +154,8 @@ public class ASTWriterVisitor extends ASTVisitor {
|
|||
writeLeadingComments(expression);
|
||||
if (!macroHandler.checkisMacroExpansionNode(expression)) {
|
||||
if (expression instanceof IGNUASTCompoundStatementExpression) {
|
||||
IGNUASTCompoundStatementExpression gnuCompStmtExp = (IGNUASTCompoundStatementExpression) expression;
|
||||
IGNUASTCompoundStatementExpression gnuCompStmtExp =
|
||||
(IGNUASTCompoundStatementExpression) expression;
|
||||
gnuCompStmtExp.getCompoundStatement().accept(this);
|
||||
} else {
|
||||
expWriter.writeExpression(expression);
|
||||
|
@ -169,7 +167,8 @@ public class ASTWriterVisitor extends ASTVisitor {
|
|||
@Override
|
||||
public int visit(IASTStatement statement) {
|
||||
writeLeadingComments(statement);
|
||||
if(macroHandler.isStatementWithMixedLocation(statement) && !(statement instanceof IASTCompoundStatement)){
|
||||
if (macroHandler.isStatementWithMixedLocation(statement) &&
|
||||
!(statement instanceof IASTCompoundStatement)) {
|
||||
return statementWriter.writeMixedStatement(statement);
|
||||
}
|
||||
if (macroHandler.checkisMacroExpansionNode(statement)) {
|
||||
|
@ -232,8 +231,7 @@ public class ASTWriterVisitor extends ASTVisitor {
|
|||
return declarator.getName();
|
||||
}
|
||||
|
||||
protected IASTDeclarator getParameterDeclarator(
|
||||
IASTParameterDeclaration parameterDeclaration) {
|
||||
protected IASTDeclarator getParameterDeclarator(IASTParameterDeclaration parameterDeclaration) {
|
||||
return parameterDeclaration.getDeclarator();
|
||||
}
|
||||
|
||||
|
|
|
@ -39,19 +39,15 @@ import org.eclipse.cdt.core.parser.Keywords;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Generates source code of declaration nodes. The actual string operations are delegated
|
||||
* to the <code>Scribe</code> class.
|
||||
*
|
||||
* @see Scribe
|
||||
* @see IASTDeclaration
|
||||
* @author Emanuel Graf IFS
|
||||
*
|
||||
*/
|
||||
public class DeclarationWriter extends NodeWriter{
|
||||
|
||||
private static final String ASM_END = ")"; //$NON-NLS-1$
|
||||
private static final String ASM_START = "asm("; //$NON-NLS-1$
|
||||
private static final String TEMPLATE_DECLARATION = "template<"; //$NON-NLS-1$
|
||||
|
@ -300,8 +296,8 @@ public class DeclarationWriter extends NodeWriter{
|
|||
}
|
||||
}
|
||||
|
||||
protected void writeCtorChainInitializer(
|
||||
ICPPASTFunctionDefinition funcDec, ICPPASTConstructorChainInitializer[] ctorInitChain) {
|
||||
protected void writeCtorChainInitializer(ICPPASTFunctionDefinition funcDec,
|
||||
ICPPASTConstructorChainInitializer[] ctorInitChain) {
|
||||
if (ctorInitChain.length != 0) {
|
||||
scribe.newLine();
|
||||
scribe.print(':');
|
||||
|
@ -337,5 +333,4 @@ public class DeclarationWriter extends NodeWriter{
|
|||
|
||||
printSemicolon();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,14 +35,12 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMMacroReferenceName;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
*
|
||||
* Recognizes nodes that are the result of an macro expansion and replaces them
|
||||
* with a suitable macro call.
|
||||
* @author Emanuel Graf IFS
|
||||
*
|
||||
* @author Emanuel Graf IFS
|
||||
*/
|
||||
public class MacroExpansionHandler {
|
||||
|
||||
private int lastMacroExpOffset;
|
||||
private final Scribe scribe;
|
||||
private IASTTranslationUnit tu;
|
||||
|
@ -176,7 +174,8 @@ public class MacroExpansionHandler {
|
|||
for (IASTPreprocessorMacroDefinition iastPreprocessorMacroDefinition : md) {
|
||||
if (iastPreprocessorMacroDefinition.getExpansion().length() == 0) {
|
||||
try {
|
||||
IIndexMacro[] macroBinding = index.findMacros(iastPreprocessorMacroDefinition.getName().toCharArray(), IndexFilter.ALL, null);
|
||||
IIndexMacro[] macroBinding = index.findMacros(iastPreprocessorMacroDefinition.getName().toCharArray(),
|
||||
IndexFilter.ALL, null);
|
||||
if (macroBinding.length > 0) {
|
||||
IIndexName[] refs = index.findReferences(macroBinding[0]);
|
||||
for (IIndexName iIndexName : refs) {
|
||||
|
@ -205,5 +204,4 @@ public class MacroExpansionHandler {
|
|||
public void reset() {
|
||||
lastMacroExpOffset = -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,8 +55,6 @@ import org.eclipse.text.edits.ReplaceEdit;
|
|||
import org.eclipse.text.edits.TextEditGroup;
|
||||
|
||||
public class ChangeGenerator extends ASTVisitor {
|
||||
|
||||
|
||||
private final LinkedHashMap<String, Integer> sourceOffsets = new LinkedHashMap<String, Integer>();
|
||||
public LinkedHashMap<IASTNode, List<ASTModification>> modificationParent = new LinkedHashMap<IASTNode, List<ASTModification>>();
|
||||
private final LinkedHashMap<IFile, MultiTextEdit> changes = new LinkedHashMap<IFile, MultiTextEdit>();
|
||||
|
@ -67,37 +65,23 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
|
||||
{
|
||||
shouldVisitExpressions = true;
|
||||
|
||||
shouldVisitStatements = true;
|
||||
|
||||
shouldVisitNames = true;
|
||||
|
||||
shouldVisitDeclarations = true;
|
||||
|
||||
shouldVisitDeclSpecifiers = true;
|
||||
|
||||
shouldVisitDeclarators = true;
|
||||
|
||||
shouldVisitArrayModifiers= true;
|
||||
|
||||
shouldVisitInitializers = true;
|
||||
|
||||
shouldVisitBaseSpecifiers = true;
|
||||
|
||||
shouldVisitNamespaces = true;
|
||||
|
||||
shouldVisitTemplateParameters = true;
|
||||
|
||||
shouldVisitParameterDeclarations = true;
|
||||
|
||||
shouldVisitTranslationUnit = true;
|
||||
|
||||
}
|
||||
|
||||
public ChangeGenerator(ASTModificationStore modificationStore, NodeCommentMap commentMap) {
|
||||
this.modificationStore = modificationStore;
|
||||
this.commentMap = commentMap;
|
||||
|
||||
}
|
||||
|
||||
public void generateChange(IASTNode rootNode) throws ProblemRuntimeException {
|
||||
|
@ -110,7 +94,6 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
initParentModList();
|
||||
rootNode.accept(pathProvider);
|
||||
for (IFile currentFile : changes.keySet()) {
|
||||
|
||||
TextFileChange subchange= ASTRewriteAnalyzer.createCTextFileChange(currentFile);
|
||||
subchange.setEdit(changes.get(currentFile));
|
||||
change.add(subchange);
|
||||
|
@ -118,20 +101,19 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
}
|
||||
|
||||
private void initParentModList() {
|
||||
ASTModificationMap rootModifications = modificationStore
|
||||
.getRootModifications();
|
||||
ASTModificationMap rootModifications = modificationStore.getRootModifications();
|
||||
if (rootModifications != null) {
|
||||
for (IASTNode modifiedNode : rootModifications.getModifiedNodes()) {
|
||||
List<ASTModification> modificationsForNode = rootModifications
|
||||
.getModificationsForNode(modifiedNode);
|
||||
List<ASTModification> modificationsForNode = rootModifications.getModificationsForNode(modifiedNode);
|
||||
IASTNode modifiedNodeParent = determineParentToBeRewritten(modifiedNode, modificationsForNode);
|
||||
List<ASTModification> list = modificationParent.get(modifiedNodeParent != null ? modifiedNodeParent : modifiedNode);
|
||||
List<ASTModification> list = modificationParent.get(modifiedNodeParent != null ?
|
||||
modifiedNodeParent : modifiedNode);
|
||||
if (list != null) {
|
||||
list.addAll(modificationsForNode);
|
||||
} else {
|
||||
List<ASTModification> modifiableList = new ArrayList<ASTModification>(modificationsForNode);
|
||||
modificationParent.put(modifiedNodeParent != null ? modifiedNodeParent : modifiedNode,
|
||||
modifiableList);
|
||||
modificationParent.put(modifiedNodeParent != null ?
|
||||
modifiedNodeParent : modifiedNode, modifiableList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -152,21 +134,20 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
@Override
|
||||
public int visit(IASTTranslationUnit translationUnit) {
|
||||
if (hasChangedChild(translationUnit)) {
|
||||
|
||||
synthTreatment(translationUnit);
|
||||
}
|
||||
IASTFileLocation location = getFileLocationOfEmptyTranslationUnit(translationUnit);
|
||||
sourceOffsets.put(location.getFileName(),
|
||||
Integer.valueOf(location.getNodeOffset()));
|
||||
sourceOffsets.put(location.getFileName(), Integer.valueOf(location.getNodeOffset()));
|
||||
return super.visit(translationUnit);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a Workaround for a known but not jet solved Problem in IASTNode. If you get the FileFocation of a translationUnit
|
||||
* that was built on an empty file you will get null because there it explicitly returns null if the index and length is 0.
|
||||
* To get to the Filename and other information, the location is never the less needed.
|
||||
* This is a workaround for a known but not jet solved problem in IASTNode. If you get
|
||||
* the FileFocation of a translation unit that was built on an empty file you will get null
|
||||
* because there it explicitly returns null if the index and length is 0.
|
||||
* To get to the filename and other information, the location is never the less needed.
|
||||
* @param node
|
||||
* @return a hopefully "unnull" FileLocation
|
||||
* @return a hopefully non-{@code null} FileLocation
|
||||
*/
|
||||
public IASTFileLocation getFileLocationOfEmptyTranslationUnit(IASTNode node) {
|
||||
IASTFileLocation fileLocation = node.getFileLocation();
|
||||
|
@ -175,7 +156,7 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
if (lr != null) {
|
||||
fileLocation = lr.getMappedFileLocation(0, 0);
|
||||
} else {
|
||||
// support for old location map
|
||||
// Support for old location map
|
||||
fileLocation = node.getTranslationUnit().flattenLocationsToFile(node.getNodeLocations());
|
||||
}
|
||||
}
|
||||
|
@ -184,14 +165,11 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
|
||||
@Override
|
||||
public int leave(IASTTranslationUnit tu) {
|
||||
|
||||
return super.leave(tu);
|
||||
}
|
||||
|
||||
private int getOffsetForNodeFile(IASTNode rootNode) {
|
||||
|
||||
Integer offset = sourceOffsets.get(rootNode.getFileLocation()
|
||||
.getFileName());
|
||||
Integer offset = sourceOffsets.get(rootNode.getFileLocation().getFileName());
|
||||
return offset == null ? 0 : offset.intValue();
|
||||
}
|
||||
|
||||
|
@ -217,10 +195,8 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
|
||||
createChange(synthNode, synthSource);
|
||||
|
||||
int newOffset = synthNode.getFileLocation().getNodeOffset()
|
||||
+ synthNode.getFileLocation().getNodeLength();
|
||||
int newOffset = synthNode.getFileLocation().getNodeOffset() + synthNode.getFileLocation().getNodeLength();
|
||||
sourceOffsets.put(synthNode.getFileLocation().getFileName(), Integer.valueOf(newOffset));
|
||||
|
||||
}
|
||||
|
||||
private void synthTreatment(IASTTranslationUnit synthTU) {
|
||||
|
@ -228,9 +204,8 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
synthWriter.setModificationStore(modificationStore);
|
||||
|
||||
for (ASTModification modification : modificationParent.get(synthTU)) {
|
||||
IASTFileLocation targetLocation;
|
||||
|
||||
targetLocation = getFileLocationOfEmptyTranslationUnit(modification.getTargetNode());
|
||||
IASTFileLocation targetLocation =
|
||||
getFileLocationOfEmptyTranslationUnit(modification.getTargetNode());
|
||||
String currentFile = targetLocation.getFileName();
|
||||
IPath implPath = new Path(currentFile);
|
||||
IFile relevantFile= ResourceLookup.selectFileForLocation(implPath, null);
|
||||
|
@ -256,14 +231,16 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
newNodeCode));
|
||||
break;
|
||||
case APPEND_CHILD:
|
||||
if(modification.getTargetNode() instanceof IASTTranslationUnit && ((IASTTranslationUnit)modification.getTargetNode()).getDeclarations().length > 0) {
|
||||
if (modification.getTargetNode() instanceof IASTTranslationUnit &&
|
||||
((IASTTranslationUnit)modification.getTargetNode()).getDeclarations().length > 0) {
|
||||
IASTTranslationUnit tu = (IASTTranslationUnit)modification.getTargetNode();
|
||||
IASTDeclaration lastDecl = tu.getDeclarations()[tu.getDeclarations().length -1];
|
||||
targetLocation = lastDecl.getFileLocation();
|
||||
}
|
||||
String lineDelimiter = FileHelper.determineLineDelimiter(FileHelper.getIFilefromIASTNode(modification.getTargetNode()));
|
||||
edit.addChild(new InsertEdit(targetLocation.getNodeOffset()
|
||||
+ targetLocation.getNodeLength(),lineDelimiter + lineDelimiter + newNodeCode));
|
||||
String lineDelimiter = FileHelper.determineLineDelimiter(
|
||||
FileHelper.getIFilefromIASTNode(modification.getTargetNode()));
|
||||
edit.addChild(new InsertEdit(targetLocation.getNodeOffset() + targetLocation.getNodeLength(),
|
||||
lineDelimiter + lineDelimiter + newNodeCode));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -338,16 +315,13 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
|
||||
private String getIndent(IASTNode nextNode) {
|
||||
IASTFileLocation fileLocation = nextNode.getFileLocation();
|
||||
int length = fileLocation.getNodeOffset()
|
||||
- getOffsetForNodeFile(nextNode);
|
||||
int length = fileLocation.getNodeOffset() - getOffsetForNodeFile(nextNode);
|
||||
|
||||
String originalSource = FileContentHelper.getContent(FileHelper
|
||||
.getIFilefromIASTNode(nextNode),
|
||||
String originalSource = FileContentHelper.getContent(FileHelper.getIFilefromIASTNode(nextNode),
|
||||
getOffsetForNodeFile(nextNode), length);
|
||||
StringBuilder indent = new StringBuilder(originalSource);
|
||||
indent.reverse();
|
||||
String lastline = indent
|
||||
.substring(0, Math.max(indent.indexOf("\n"), 0)); //$NON-NLS-1$
|
||||
String lastline = indent.substring(0, Math.max(indent.indexOf("\n"), 0)); //$NON-NLS-1$
|
||||
if (lastline.trim().length() == 0) {
|
||||
return lastline;
|
||||
}
|
||||
|
@ -355,11 +329,9 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
}
|
||||
|
||||
private boolean hasChangedChild(IASTNode parent) {
|
||||
|
||||
return modificationParent.containsKey(parent);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int visit(IASTDeclarator declarator) {
|
||||
if (hasChangedChild(declarator)) {
|
||||
|
@ -378,7 +350,6 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
return super.visit(mod);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int visit(ICPPASTNamespaceDefinition namespaceDefinition) {
|
||||
if (hasChangedChild(namespaceDefinition)) {
|
||||
|
@ -443,7 +414,6 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
}
|
||||
|
||||
class CodeComparer {
|
||||
|
||||
private final StringBuilder originalCode;
|
||||
private final StringBuilder synthCode;
|
||||
private int lastCommonInSynthStart;
|
||||
|
@ -460,34 +430,34 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
private void calculatePositions() {
|
||||
lastCommonInSynthStart = calcLastCommonPositionInSynthCode();
|
||||
lastCommonInOriginalStart = calcLastCommonPositionInOriginalCode();
|
||||
firstCommonInSynthEnd = calcFirstPositionOfCommonEndInSynthCode(lastCommonInSynthStart, lastCommonInOriginalStart);
|
||||
firstCommonInOriginalEnd = calcFirstPositionOfCommonEndInOriginalCode(lastCommonInOriginalStart, lastCommonInSynthStart);
|
||||
firstCommonInSynthEnd =
|
||||
calcFirstPositionOfCommonEndInSynthCode(lastCommonInSynthStart, lastCommonInOriginalStart);
|
||||
firstCommonInOriginalEnd =
|
||||
calcFirstPositionOfCommonEndInOriginalCode(lastCommonInOriginalStart, lastCommonInSynthStart);
|
||||
trimTrailingNewlines();
|
||||
}
|
||||
|
||||
private void trimTrailingNewlines() {
|
||||
int prevOrigEnd = firstCommonInOriginalEnd - 1;
|
||||
while( prevOrigEnd > lastCommonInOriginalStart
|
||||
&& prevOrigEnd > -1
|
||||
&& isUninterresting(originalCode, prevOrigEnd)){
|
||||
|
||||
while (prevOrigEnd > lastCommonInOriginalStart && prevOrigEnd > -1 &&
|
||||
isUninterresting(originalCode, prevOrigEnd)) {
|
||||
firstCommonInOriginalEnd = prevOrigEnd;
|
||||
prevOrigEnd--;
|
||||
}
|
||||
|
||||
while(firstCommonInOriginalEnd > 0 && firstCommonInOriginalEnd +1 < originalCode.length() && (originalCode.charAt(firstCommonInOriginalEnd) == ' ' || originalCode.charAt(firstCommonInOriginalEnd) == '\t')){
|
||||
while (firstCommonInOriginalEnd > 0 && firstCommonInOriginalEnd + 1 < originalCode.length() &&
|
||||
(originalCode.charAt(firstCommonInOriginalEnd) == ' ' || originalCode.charAt(firstCommonInOriginalEnd) == '\t')) {
|
||||
firstCommonInOriginalEnd++;
|
||||
}
|
||||
|
||||
int prevSynthEnd = firstCommonInSynthEnd - 1;
|
||||
while( prevSynthEnd > lastCommonInSynthStart
|
||||
&& prevSynthEnd > -1
|
||||
&& isUninterresting(synthCode, prevSynthEnd)){
|
||||
|
||||
while (prevSynthEnd > lastCommonInSynthStart && prevSynthEnd > -1 &&
|
||||
isUninterresting(synthCode, prevSynthEnd)) {
|
||||
firstCommonInSynthEnd = prevSynthEnd;
|
||||
prevSynthEnd--;
|
||||
}
|
||||
while(firstCommonInSynthEnd > 0 && firstCommonInSynthEnd +1< synthCode.length() && (synthCode.charAt(firstCommonInSynthEnd) == ' ' || synthCode.charAt(firstCommonInSynthEnd) == '\t')){
|
||||
while (firstCommonInSynthEnd > 0 && firstCommonInSynthEnd + 1 < synthCode.length() &&
|
||||
(synthCode.charAt(firstCommonInSynthEnd) == ' ' || synthCode.charAt(firstCommonInSynthEnd) == '\t')) {
|
||||
firstCommonInSynthEnd++;
|
||||
}
|
||||
}
|
||||
|
@ -508,7 +478,6 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
return firstCommonInSynthEnd;
|
||||
}
|
||||
|
||||
|
||||
public int calcLastCommonPositionInSynthCode() {
|
||||
return findLastCommonPosition(synthCode, originalCode);
|
||||
}
|
||||
|
@ -517,18 +486,14 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
return findLastCommonPosition(originalCode, synthCode);
|
||||
}
|
||||
|
||||
|
||||
private int calcFirstPositionOfCommonEndInOriginalCode(int originalLimit, int synthLimit) {
|
||||
|
||||
StringBuilder reverseOriginalCode = new StringBuilder(originalCode)
|
||||
.reverse();
|
||||
StringBuilder reverseSynthCode = new StringBuilder(synthCode)
|
||||
.reverse();
|
||||
StringBuilder reverseOriginalCode = new StringBuilder(originalCode).reverse();
|
||||
StringBuilder reverseSynthCode = new StringBuilder(synthCode).reverse();
|
||||
int lastCommonPosition = findLastCommonPosition(reverseOriginalCode, reverseSynthCode,
|
||||
reverseOriginalCode.length() - originalLimit - 1, reverseSynthCode.length() - synthLimit - 1);
|
||||
reverseOriginalCode.length() - originalLimit - 1,
|
||||
reverseSynthCode.length() - synthLimit - 1);
|
||||
|
||||
if (lastCommonPosition < 0
|
||||
|| lastCommonPosition >= originalCode.length()) {
|
||||
if (lastCommonPosition < 0 || lastCommonPosition >= originalCode.length()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -536,29 +501,26 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
}
|
||||
|
||||
private int calcFirstPositionOfCommonEndInSynthCode(int synthLimit, int originalLimit) {
|
||||
StringBuilder reverseOriginalCode = new StringBuilder(originalCode)
|
||||
.reverse();
|
||||
StringBuilder reverseSynthCode = new StringBuilder(synthCode)
|
||||
.reverse();
|
||||
StringBuilder reverseOriginalCode = new StringBuilder(originalCode).reverse();
|
||||
StringBuilder reverseSynthCode = new StringBuilder(synthCode).reverse();
|
||||
|
||||
int lastCommonPosition = findLastCommonPosition(reverseSynthCode, reverseOriginalCode,
|
||||
reverseSynthCode.length() - synthLimit -1, reverseOriginalCode.length() - originalLimit -1);
|
||||
reverseSynthCode.length() - synthLimit - 1,
|
||||
reverseOriginalCode.length() - originalLimit - 1);
|
||||
|
||||
if (lastCommonPosition < 0
|
||||
|| lastCommonPosition >= synthCode.length()) {
|
||||
if (lastCommonPosition < 0 || lastCommonPosition >= synthCode.length()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return synthCode.length() - lastCommonPosition - 1;
|
||||
}
|
||||
|
||||
|
||||
private int findLastCommonPosition(StringBuilder first, StringBuilder second) {
|
||||
return findLastCommonPosition(first, second, first.length(), second.length());
|
||||
}
|
||||
|
||||
|
||||
private int findLastCommonPosition(StringBuilder first, StringBuilder second, int firstLimit, int secondLimit){
|
||||
private int findLastCommonPosition(StringBuilder first, StringBuilder second, int firstLimit,
|
||||
int secondLimit) {
|
||||
int firstIndex = -1;
|
||||
int secondIndex = -1;
|
||||
int lastCommonIndex = -1;
|
||||
|
@ -567,11 +529,8 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
lastCommonIndex = firstIndex;
|
||||
firstIndex = nextInterrestingPosition(first, firstIndex);
|
||||
secondIndex = nextInterrestingPosition(second, secondIndex);
|
||||
} while (firstIndex > -1
|
||||
&& firstIndex <= firstLimit
|
||||
&& secondIndex > -1
|
||||
&& secondIndex <= secondLimit
|
||||
&& first.charAt(firstIndex) == second.charAt(secondIndex));
|
||||
} while (firstIndex > -1 && firstIndex <= firstLimit && secondIndex > -1 &&
|
||||
secondIndex <= secondLimit && first.charAt(firstIndex) == second.charAt(secondIndex));
|
||||
return lastCommonIndex;
|
||||
}
|
||||
|
||||
|
@ -600,63 +559,52 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
|
||||
protected void createChange(MultiTextEdit edit, IASTNode changedNode) {
|
||||
int changeOffset = getOffsetIncludingComments(changedNode);
|
||||
|
||||
TextEditGroup editGroup = new TextEditGroup(Messages.ChangeGenerator_group);
|
||||
for (ASTModification currentModification : modificationParent
|
||||
.get(changedNode)) {
|
||||
for (ASTModification currentModification : modificationParent.get(changedNode)) {
|
||||
if (currentModification.getAssociatedEditGroup() != null) {
|
||||
editGroup = currentModification.getAssociatedEditGroup();
|
||||
edit.addChildren(editGroup.getTextEdits());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
createChange(edit, changeOffset);
|
||||
}
|
||||
|
||||
private void createChange(MultiTextEdit edit, int changeOffset) {
|
||||
|
||||
int i = (firstCommonInSynthEnd >= 0 ? firstCommonInOriginalEnd
|
||||
: originalCode.length())
|
||||
- lastCommonInOriginalStart;
|
||||
int i = (firstCommonInSynthEnd >= 0 ?
|
||||
firstCommonInOriginalEnd : originalCode.length()) - lastCommonInOriginalStart;
|
||||
if (i <= 0) {
|
||||
String insertCode = synthCode.substring(
|
||||
lastCommonInSynthStart, firstCommonInSynthEnd);
|
||||
InsertEdit iEdit = new InsertEdit(changeOffset
|
||||
+ lastCommonInOriginalStart, insertCode);
|
||||
String insertCode = synthCode.substring(lastCommonInSynthStart,
|
||||
firstCommonInSynthEnd);
|
||||
InsertEdit iEdit = new InsertEdit(changeOffset + lastCommonInOriginalStart,
|
||||
insertCode);
|
||||
edit.addChild(iEdit);
|
||||
} else if ((firstCommonInSynthEnd >= 0 ? firstCommonInSynthEnd
|
||||
: synthCode.length())
|
||||
- lastCommonInSynthStart <= 0) {
|
||||
} else if ((firstCommonInSynthEnd >= 0 ?
|
||||
firstCommonInSynthEnd : synthCode.length()) - lastCommonInSynthStart <= 0) {
|
||||
int correction = 0;
|
||||
if (lastCommonInSynthStart > firstCommonInSynthEnd) {
|
||||
correction = lastCommonInSynthStart
|
||||
- firstCommonInSynthEnd;
|
||||
correction = lastCommonInSynthStart - firstCommonInSynthEnd;
|
||||
}
|
||||
DeleteEdit dEdit = new DeleteEdit(changeOffset
|
||||
+ lastCommonInOriginalStart,
|
||||
firstCommonInOriginalEnd
|
||||
- lastCommonInOriginalStart + correction);
|
||||
DeleteEdit dEdit = new DeleteEdit(changeOffset + lastCommonInOriginalStart,
|
||||
firstCommonInOriginalEnd - lastCommonInOriginalStart + correction);
|
||||
edit.addChild(dEdit);
|
||||
} else {
|
||||
String replacementCode = getReplacementCode(
|
||||
lastCommonInSynthStart, firstCommonInSynthEnd);
|
||||
String replacementCode = getReplacementCode(lastCommonInSynthStart,
|
||||
firstCommonInSynthEnd);
|
||||
ReplaceEdit rEdit = new ReplaceEdit(
|
||||
changeOffset
|
||||
+ Math.max(lastCommonInOriginalStart, 0),
|
||||
(firstCommonInOriginalEnd >= 0 ? firstCommonInOriginalEnd
|
||||
: originalCode.length())
|
||||
- Math.max(lastCommonInOriginalStart, 0),
|
||||
changeOffset + Math.max(lastCommonInOriginalStart, 0),
|
||||
(firstCommonInOriginalEnd >= 0 ?
|
||||
firstCommonInOriginalEnd :
|
||||
originalCode.length()) - Math.max(lastCommonInOriginalStart, 0),
|
||||
replacementCode);
|
||||
edit.addChild(rEdit);
|
||||
}
|
||||
}
|
||||
|
||||
private String getReplacementCode(int lastCommonPositionInSynth,
|
||||
int firstOfCommonEndInSynth) {
|
||||
private String getReplacementCode(int lastCommonPositionInSynth, int firstOfCommonEndInSynth) {
|
||||
int replacementStart = Math.max(lastCommonPositionInSynth, 0);
|
||||
int replacementEnd = (firstOfCommonEndInSynth >= 0 ? firstOfCommonEndInSynth
|
||||
: synthCode.length());
|
||||
int replacementEnd = (firstOfCommonEndInSynth >= 0 ?
|
||||
firstOfCommonEndInSynth : synthCode.length());
|
||||
if (replacementStart < replacementEnd) {
|
||||
return synthCode.substring(replacementStart, replacementEnd);
|
||||
}
|
||||
|
|
|
@ -37,15 +37,12 @@ import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriterVisitor;
|
|||
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* Visits the nodes in consideration of {@link ASTModification}s.
|
||||
*
|
||||
* @since 5.0
|
||||
* @author Emanuel Graf IFS
|
||||
*
|
||||
*/
|
||||
public class ChangeGeneratorWriterVisitor extends ASTWriterVisitor {
|
||||
|
||||
private static final String DEFAULT_INDENTATION = ""; //$NON-NLS-1$
|
||||
private final ASTModificationStore modificationStore;
|
||||
private final String fileScope;
|
||||
|
@ -74,15 +71,14 @@ public class ChangeGeneratorWriterVisitor extends ASTWriterVisitor {
|
|||
shouldVisitProblems = delegateVisitor.shouldVisitProblems;
|
||||
shouldVisitTypeIds = delegateVisitor.shouldVisitTypeIds;
|
||||
shouldVisitArrayModifiers= delegateVisitor.shouldVisitArrayModifiers;
|
||||
|
||||
}
|
||||
|
||||
public ChangeGeneratorWriterVisitor(ASTModificationStore modStore, NodeCommentMap nodeMap) {
|
||||
this(modStore, DEFAULT_INDENTATION, null, nodeMap);
|
||||
}
|
||||
|
||||
public ChangeGeneratorWriterVisitor(ASTModificationStore modStore,
|
||||
String givenIndentation, String fileScope, NodeCommentMap commentMap) {
|
||||
public ChangeGeneratorWriterVisitor(ASTModificationStore modStore, String givenIndentation,
|
||||
String fileScope, NodeCommentMap commentMap) {
|
||||
super(givenIndentation, commentMap);
|
||||
this.modificationStore = modStore;
|
||||
this.fileScope = fileScope;
|
||||
|
@ -98,13 +94,12 @@ public class ChangeGeneratorWriterVisitor extends ASTWriterVisitor {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected IASTDeclarator getParameterDeclarator(
|
||||
IASTParameterDeclaration parameterDeclaration) {
|
||||
|
||||
protected IASTDeclarator getParameterDeclarator(IASTParameterDeclaration parameterDeclaration) {
|
||||
IASTDeclarator newDecl = parameterDeclaration.getDeclarator();
|
||||
if (stack.getModifiedNodes().contains(newDecl)) {
|
||||
for (ASTModification currentModification : stack.getModificationsForNode(newDecl)) {
|
||||
if(currentModification.getKind() == ASTModification.ModificationKind.REPLACE && currentModification.getTargetNode() == parameterDeclaration){
|
||||
if (currentModification.getKind() == ASTModification.ModificationKind.REPLACE &&
|
||||
currentModification.getTargetNode() == parameterDeclaration) {
|
||||
newDecl = (IASTDeclarator) currentModification.getNewNode();
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +112,8 @@ public class ChangeGeneratorWriterVisitor extends ASTWriterVisitor {
|
|||
IASTName newName = declarator.getName();
|
||||
if (stack.getModifiedNodes().contains(newName)) {
|
||||
for (ASTModification currentModification : stack.getModificationsForNode(newName)) {
|
||||
if(currentModification.getKind() == ASTModification.ModificationKind.REPLACE && currentModification.getTargetNode() == newName){
|
||||
if (currentModification.getKind() == ASTModification.ModificationKind.REPLACE &&
|
||||
currentModification.getTargetNode() == newName) {
|
||||
newName = (IASTName) currentModification.getNewNode();
|
||||
}
|
||||
}
|
||||
|
@ -329,14 +325,12 @@ public class ChangeGeneratorWriterVisitor extends ASTWriterVisitor {
|
|||
|
||||
@Override
|
||||
public int visit(IASTTranslationUnit tu) {
|
||||
ASTModificationHelper helper = new ASTModificationHelper(
|
||||
stack);
|
||||
|
||||
IASTDeclaration[] declarations = helper.createModifiedChildArray(tu, tu.getDeclarations(), IASTDeclaration.class, commentMap);
|
||||
ASTModificationHelper helper = new ASTModificationHelper(stack);
|
||||
IASTDeclaration[] declarations = helper.createModifiedChildArray(tu, tu.getDeclarations(),
|
||||
IASTDeclaration.class, commentMap);
|
||||
for (IASTDeclaration currentDeclaration : declarations) {
|
||||
currentDeclaration.accept(this);
|
||||
}
|
||||
|
||||
return PROCESS_SKIP;
|
||||
}
|
||||
|
||||
|
@ -357,7 +351,8 @@ public class ChangeGeneratorWriterVisitor extends ASTWriterVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
//Check all insert before and append modifications for the current node. If necessary put it onto the stack.
|
||||
// Check all insert before and append modifications for the current node.
|
||||
// If necessary put it onto the stack.
|
||||
for (IASTNode currentModifiedNode : stack.getModifiedNodes()) {
|
||||
for (ASTModification currentMod : stack.getModificationsForNode(currentModifiedNode)) {
|
||||
if (currentMod.getNewNode() == node) {
|
||||
|
@ -377,8 +372,7 @@ public class ChangeGeneratorWriterVisitor extends ASTWriterVisitor {
|
|||
currentMod.getNewNode().accept(this);
|
||||
stack.popScope(node);
|
||||
return PROCESS_SKIP;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
return PROCESS_SKIP;
|
||||
}
|
||||
}
|
||||
|
@ -389,7 +383,6 @@ public class ChangeGeneratorWriterVisitor extends ASTWriterVisitor {
|
|||
}
|
||||
|
||||
private String getCorrespondingFile(IASTNode node) {
|
||||
|
||||
if (node.getFileLocation() != null) {
|
||||
return node.getFileLocation().getFileName();
|
||||
}
|
||||
|
@ -398,11 +391,8 @@ public class ChangeGeneratorWriterVisitor extends ASTWriterVisitor {
|
|||
return getCorrespondingFile(node.getParent());
|
||||
}
|
||||
|
||||
for (IASTNode modifiedNode : modificationStore.getRootModifications()
|
||||
.getModifiedNodes()) {
|
||||
for (ASTModification modification : modificationStore
|
||||
.getRootModifications().getModificationsForNode(
|
||||
modifiedNode)) {
|
||||
for (IASTNode modifiedNode : modificationStore.getRootModifications().getModifiedNodes()) {
|
||||
for (ASTModification modification : modificationStore.getRootModifications().getModificationsForNode(modifiedNode)) {
|
||||
if (modification.getNewNode() == node) {
|
||||
return getCorrespondingFile(modification.getTargetNode());
|
||||
}
|
||||
|
|
|
@ -74,6 +74,16 @@ public class StandaloneIndexerInputAdapter extends IndexerInputAdapter {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIndexedUnconditionally(Object tu) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIndexedUnconditionally(IIndexFileLocation ifl) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSource(String filename) {
|
||||
return isValidSourceUnitName(filename);
|
||||
|
|
|
@ -83,10 +83,12 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
fUri= uri;
|
||||
fLinkageID= linkageID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return fUri.hashCode() * 31 + fLinkageID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
FileKey other = (FileKey) obj;
|
||||
|
@ -202,7 +204,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
fIsFastIndexer= fastIndexer;
|
||||
fFilesToUpdate= filesToUpdate;
|
||||
Collections.addAll(fFilesToRemove, filesToRemove);
|
||||
updateRequestedFiles(fFilesToUpdate.length + fFilesToRemove.size());
|
||||
incrementRequestedFilesCount(fFilesToUpdate.length + fFilesToRemove.size());
|
||||
fUrgentTasks = new LinkedList<AbstractIndexerTask>();
|
||||
}
|
||||
|
||||
|
@ -402,7 +404,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
fFilesToUpdate = urgentTask.fFilesToUpdate;
|
||||
fForceNumberFiles = urgentTask.fForceNumberFiles;
|
||||
fFilesToRemove = urgentTask.fFilesToRemove;
|
||||
updateRequestedFiles(fFilesToUpdate.length + fFilesToRemove.size());
|
||||
incrementRequestedFilesCount(fFilesToUpdate.length + fFilesToRemove.size());
|
||||
extractFiles(files, indexFilesToRemove, monitor);
|
||||
removeFilesInIndex(fFilesToRemove, indexFilesToRemove, monitor);
|
||||
}
|
||||
|
@ -465,7 +467,6 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
final boolean checkTimestamps= (fUpdateFlags & IIndexManager.UPDATE_CHECK_TIMESTAMPS) != 0;
|
||||
final boolean checkFileContentsHash = (fUpdateFlags & IIndexManager.UPDATE_CHECK_CONTENTS_HASH) != 0;
|
||||
final boolean checkConfig= (fUpdateFlags & IIndexManager.UPDATE_CHECK_CONFIGURATION) != 0;
|
||||
final boolean forceInclusion= (fUpdateFlags & IIndexManager.FORCE_INDEX_INCLUSION) != 0;
|
||||
|
||||
int count= 0;
|
||||
int forceFirst= fForceNumberFiles;
|
||||
|
@ -484,7 +485,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
final boolean isExcludedSource= isSourceUnit && !fIndexFilesWithoutConfiguration && !fResolver.isFileBuildConfigured(tu);
|
||||
|
||||
if ((isSourceUnit && !isExcludedSource) || fIndexHeadersWithoutContext != UnusedHeaderStrategy.skip ||
|
||||
forceInclusion) {
|
||||
fResolver.isIndexedUnconditionally(tu)) {
|
||||
// Headers or sources required with a specific linkage
|
||||
AbstractLanguage[] langs= fResolver.getLanguages(tu, fIndexHeadersWithoutContext == UnusedHeaderStrategy.useBoth);
|
||||
for (AbstractLanguage lang : langs) {
|
||||
|
@ -515,7 +516,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
for (IIndexFragmentFile ifile : indexFiles) {
|
||||
if (ifile != null) {
|
||||
IIndexInclude ctx= ifile.getParsedInContext();
|
||||
if (ctx == null) {
|
||||
if (ctx == null && !fResolver.isIndexedUnconditionally(ifile.getLocation())) {
|
||||
iFilesToRemove.add(ifile);
|
||||
count++;
|
||||
} else {
|
||||
|
@ -535,7 +536,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
}
|
||||
}
|
||||
synchronized (this) {
|
||||
updateRequestedFiles(count - fFilesToUpdate.length);
|
||||
incrementRequestedFilesCount(count - fFilesToUpdate.length);
|
||||
fFilesToUpdate= null;
|
||||
}
|
||||
}
|
||||
|
@ -644,14 +645,14 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
for (IIndexFragmentFile ifile : ifiles) {
|
||||
fIndex.clearFile(ifile, null);
|
||||
}
|
||||
updateRequestedFiles(-1);
|
||||
incrementRequestedFilesCount(-1);
|
||||
}
|
||||
for (IIndexFragmentFile ifile : indexFilesToRemove) {
|
||||
if (monitor.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
fIndex.clearFile(ifile, null);
|
||||
updateRequestedFiles(-1);
|
||||
incrementRequestedFilesCount(-1);
|
||||
}
|
||||
} finally {
|
||||
fIndex.releaseWriteLock(1);
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2011 Google, Inc 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Thread-safe reference counted set of objects.
|
||||
*
|
||||
* @param <T> Type of the objects contained in the set.
|
||||
*/
|
||||
public class AtomicMultiSet<T> {
|
||||
private final HashMap<T, Integer> map = new HashMap<T, Integer>();
|
||||
|
||||
/**
|
||||
* Adds object to the set if it was not present, or increments its reference count
|
||||
* otherwise.
|
||||
* @param object The object to add to the set.
|
||||
* @return Reference count of the object after the operation.
|
||||
*/
|
||||
public synchronized int add(T object) {
|
||||
Integer count = map.get(object);
|
||||
if (count == null) {
|
||||
count = Integer.valueOf(1);
|
||||
} else {
|
||||
count = Integer.valueOf(count.intValue() + 1);
|
||||
}
|
||||
map.put(object, count);
|
||||
return count.intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrements reference count of the object in the set and removes the object if its
|
||||
* reference count reaches zero.
|
||||
* @param object The object to remove from the set.
|
||||
* @return Reference count of the object after the operation, or -1 if the object was not
|
||||
* present in the set.
|
||||
*/
|
||||
public synchronized int remove(T object) {
|
||||
Integer count = map.remove(object);
|
||||
if (count == null) {
|
||||
return -1;
|
||||
}
|
||||
int n = count.intValue() - 1;
|
||||
if (n <= 0) {
|
||||
return n;
|
||||
}
|
||||
map.put(object, Integer.valueOf(n));
|
||||
return n;
|
||||
}
|
||||
|
||||
public synchronized void clear() {
|
||||
map.clear();
|
||||
}
|
||||
|
||||
public synchronized boolean contains(T object) {
|
||||
return map.containsKey(object);
|
||||
}
|
||||
|
||||
public synchronized int getCount(T object) {
|
||||
Integer count = map.get(object);
|
||||
return count != null ? count.intValue() : 0;
|
||||
}
|
||||
|
||||
public synchronized boolean isEmpty() {
|
||||
return map.isEmpty();
|
||||
}
|
||||
|
||||
public synchronized int size() {
|
||||
return map.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized String toString() {
|
||||
return map.toString();
|
||||
}
|
||||
}
|
|
@ -50,11 +50,25 @@ public abstract class IndexerInputAdapter extends ASTFilePathResolver {
|
|||
public abstract boolean isFileBuildConfigured(Object tu);
|
||||
|
||||
/**
|
||||
* Returns whether the given translation-unit is not indexed unless it gets included.
|
||||
* Returns whether the given translation unit is not indexed unless it gets included.
|
||||
* This applies to files that are outside of a source root.
|
||||
*/
|
||||
public abstract boolean isIndexedOnlyIfIncluded(Object tu);
|
||||
|
||||
/**
|
||||
* Checks whether the given translation unit should be indexed unconditionally.
|
||||
* @param tu An ITranslationUnit or a file location in String form.
|
||||
* @return {@code true} if the translation unit should be indexed unconditionally.
|
||||
*/
|
||||
public abstract boolean isIndexedUnconditionally(Object tu);
|
||||
|
||||
/**
|
||||
* Checks whether the given file should be indexed unconditionally.
|
||||
* @param ifl The Location of the file.
|
||||
* @return {@code true} if the file should be indexed unconditionally.
|
||||
*/
|
||||
public abstract boolean isIndexedUnconditionally(IIndexFileLocation ifl);
|
||||
|
||||
/**
|
||||
* Tests whether the file in the index is allowed to be part of an SDK. If not
|
||||
* it will be indexed.
|
||||
|
|
|
@ -147,6 +147,8 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
private final LinkedList<Runnable> fChangeEvents= new LinkedList<Runnable>();
|
||||
private final Job fNotificationJob;
|
||||
|
||||
private final AtomicMultiSet<IIndexFileLocation> fFilesIndexedUnconditionlly= new AtomicMultiSet<IIndexFileLocation>();
|
||||
|
||||
/**
|
||||
* Stores mapping from pdom to project, used to serialize creation of new pdoms.
|
||||
*/
|
||||
|
@ -1366,6 +1368,24 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
private void update(ICProject project, List<ICElement> filesAndFolders, int options) throws CoreException {
|
||||
assert !Thread.holdsLock(fProjectToPDOM);
|
||||
synchronized (fUpdatePolicies) {
|
||||
if ((options & IIndexManager.FORCE_INDEX_INCLUSION) != 0) {
|
||||
for (ICElement element : filesAndFolders) {
|
||||
if (element instanceof ITranslationUnit) {
|
||||
ITranslationUnit tu = (ITranslationUnit) element;
|
||||
IIndexFileLocation ifl = IndexLocationFactory.getIFL(tu);
|
||||
fFilesIndexedUnconditionlly.add(ifl);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((options & IIndexManager.RESET_INDEX_INCLUSION) != 0) {
|
||||
for (ICElement element : filesAndFolders) {
|
||||
if (element instanceof ITranslationUnit) {
|
||||
ITranslationUnit tu = (ITranslationUnit) element;
|
||||
IIndexFileLocation ifl = IndexLocationFactory.getIFL(tu);
|
||||
fFilesIndexedUnconditionlly.remove(ifl);
|
||||
}
|
||||
}
|
||||
}
|
||||
IPDOMIndexer indexer= getIndexer(project);
|
||||
PDOMUpdateTask task= new PDOMUpdateTask(indexer, options);
|
||||
task.setTranslationUnitSelection(filesAndFolders);
|
||||
|
@ -1541,4 +1561,8 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isFileIndexedUnconditionally(IIndexFileLocation ifl) {
|
||||
return fFilesIndexedUnconditionlly.contains(ifl);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -531,7 +531,7 @@ abstract public class PDOMWriter {
|
|||
/**
|
||||
* Updates current progress information with the provided delta.
|
||||
*/
|
||||
protected final void updateRequestedFiles(int delta) {
|
||||
protected final void incrementRequestedFilesCount(int delta) {
|
||||
synchronized (fInfo) {
|
||||
fInfo.fRequestedFilesCount += delta;
|
||||
}
|
||||
|
|
|
@ -52,8 +52,8 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment {
|
|||
this(dbPath, locationConverter, ChunkCache.getSharedInstance(), linkageFactoryMappings);
|
||||
}
|
||||
|
||||
public WritablePDOM(File dbPath, IIndexLocationConverter locationConverter, ChunkCache cache, Map<String,
|
||||
IPDOMLinkageFactory> linkageFactoryMappings) throws CoreException {
|
||||
public WritablePDOM(File dbPath, IIndexLocationConverter locationConverter, ChunkCache cache,
|
||||
Map<String, IPDOMLinkageFactory> linkageFactoryMappings) throws CoreException {
|
||||
super(dbPath, locationConverter, cache, linkageFactoryMappings);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.eclipse.cdt.core.model.LanguageManager;
|
|||
import org.eclipse.cdt.core.parser.FileContent;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.parser.InternalParserUtil;
|
||||
import org.eclipse.cdt.internal.core.pdom.IndexerInputAdapter;
|
||||
import org.eclipse.cdt.internal.core.resources.PathCanonicalizationStrategy;
|
||||
|
@ -241,6 +242,17 @@ public class ProjectIndexerInputAdapter extends IndexerInputAdapter {
|
|||
return tu instanceof PotentialTranslationUnit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIndexedUnconditionally(Object tuo) {
|
||||
ITranslationUnit tu= (ITranslationUnit) tuo;
|
||||
return isIndexedUnconditionally(IndexLocationFactory.getIFL(tu));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIndexedUnconditionally(IIndexFileLocation ifl) {
|
||||
return CCoreInternals.getPDOMManager().isFileIndexedUnconditionally(ifl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSourceUnit(Object tuo) {
|
||||
ITranslationUnit tu= (ITranslationUnit) tuo;
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings;
|
|||
*/
|
||||
public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||
|
||||
private static final boolean PRINT_POSITIONS= true;
|
||||
private static final boolean PRINT_POSITIONS= false;
|
||||
|
||||
private static final Class<?> THIS= SemanticHighlightingTest.class;
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
|||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.content.IContentType;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.eclipse.help.IContext;
|
||||
import org.eclipse.help.IContextProvider;
|
||||
|
@ -176,13 +178,8 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
|
||||
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.index.IIndexFile;
|
||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||
import org.eclipse.cdt.core.index.IIndexManager;
|
||||
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
|
@ -208,20 +205,20 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
|
|||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
|
||||
import org.eclipse.cdt.internal.ui.actions.AddBlockCommentAction;
|
||||
import org.eclipse.cdt.internal.ui.actions.StructureSelectHistoryAction;
|
||||
import org.eclipse.cdt.internal.ui.actions.StructureSelectEnclosingAction;
|
||||
import org.eclipse.cdt.internal.ui.actions.StructureSelectNextAction;
|
||||
import org.eclipse.cdt.internal.ui.actions.StructureSelectPreviousAction;
|
||||
import org.eclipse.cdt.internal.ui.actions.FindWordAction;
|
||||
import org.eclipse.cdt.internal.ui.actions.FoldingActionGroup;
|
||||
import org.eclipse.cdt.internal.ui.actions.GoToNextPreviousMemberAction;
|
||||
import org.eclipse.cdt.internal.ui.actions.GotoNextBookmarkAction;
|
||||
import org.eclipse.cdt.internal.ui.actions.IndentAction;
|
||||
import org.eclipse.cdt.internal.ui.actions.RemoveBlockCommentAction;
|
||||
import org.eclipse.cdt.internal.ui.actions.StructureSelectEnclosingAction;
|
||||
import org.eclipse.cdt.internal.ui.actions.StructureSelectHistoryAction;
|
||||
import org.eclipse.cdt.internal.ui.actions.StructureSelectNextAction;
|
||||
import org.eclipse.cdt.internal.ui.actions.StructureSelectPreviousAction;
|
||||
import org.eclipse.cdt.internal.ui.actions.StructureSelectionAction;
|
||||
import org.eclipse.cdt.internal.ui.actions.SurroundWithActionGroup;
|
||||
import org.eclipse.cdt.internal.ui.search.IOccurrencesFinder.OccurrenceLocation;
|
||||
import org.eclipse.cdt.internal.ui.search.IOccurrencesFinder;
|
||||
import org.eclipse.cdt.internal.ui.search.IOccurrencesFinder.OccurrenceLocation;
|
||||
import org.eclipse.cdt.internal.ui.search.OccurrencesFinder;
|
||||
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
|
||||
import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
|
||||
|
@ -272,7 +269,6 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
// look up the current range of the marker when the document has been edited
|
||||
IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
|
||||
if (model instanceof AbstractMarkerAnnotationModel) {
|
||||
|
||||
AbstractMarkerAnnotationModel markerModel= (AbstractMarkerAnnotationModel) model;
|
||||
Position pos= markerModel.getMarkerPosition(marker);
|
||||
if (pos != null && !pos.isDeleted()) {
|
||||
|
@ -1226,6 +1222,70 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
}
|
||||
}
|
||||
|
||||
private class IndexerPreferenceListener implements IPreferenceChangeListener {
|
||||
private IProject fProject;
|
||||
|
||||
public void preferenceChange(PreferenceChangeEvent event) {
|
||||
if (IndexerPreferences.KEY_INDEX_ON_OPEN.equals(event.getKey())) {
|
||||
ICElement element= getInputCElement();
|
||||
ITranslationUnit tu = element != null ? (ITranslationUnit) element : null;
|
||||
updateIndexInclusion(tu, false);
|
||||
}
|
||||
}
|
||||
|
||||
void registerFor(IProject project) {
|
||||
if (fProject == project || fProject != null && fProject.equals(project)) {
|
||||
return;
|
||||
}
|
||||
unregister();
|
||||
fProject = project;
|
||||
if (fProject != null) {
|
||||
IndexerPreferences.addChangeListener(fProject, this);
|
||||
}
|
||||
}
|
||||
|
||||
void unregister() {
|
||||
if (fProject != null) {
|
||||
IndexerPreferences.removeChangeListener(fProject, this);
|
||||
fProject = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class IndexUpdateRequestorJob extends Job {
|
||||
private final ITranslationUnit tuToAdd;
|
||||
private final ITranslationUnit tuToReset;
|
||||
|
||||
/**
|
||||
* @param tu The translation unit to add or to remove from the index.
|
||||
* @param add {@code true} to add, {@code false} to reset index inclusion.
|
||||
*/
|
||||
IndexUpdateRequestorJob(ITranslationUnit tuToAdd, ITranslationUnit tuToReset) {
|
||||
super(CEditorMessages.CEditor_index_expander_job_name);
|
||||
this.tuToAdd = tuToAdd;
|
||||
this.tuToReset = tuToReset;
|
||||
setSystem(true);
|
||||
setPriority(Job.DECORATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||
if (tuToReset != null) {
|
||||
indexManager.update(new ICElement[] { tuToReset },
|
||||
IIndexManager.RESET_INDEX_INCLUSION | IIndexManager.UPDATE_CHECK_TIMESTAMPS);
|
||||
}
|
||||
if (tuToAdd != null) {
|
||||
indexManager.update(new ICElement[] { tuToAdd },
|
||||
IIndexManager.FORCE_INDEX_INCLUSION | IIndexManager.UPDATE_CHECK_TIMESTAMPS);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The editor selection changed listener.
|
||||
*
|
||||
|
@ -1335,6 +1395,11 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
|
||||
private SelectionHistory fSelectionHistory;
|
||||
|
||||
/** The translation unit that was added by the editor to index, or <code>null</code>. */
|
||||
private ITranslationUnit fTuAddedToIndex;
|
||||
|
||||
private IndexerPreferenceListener fIndexerPreferenceListener;
|
||||
|
||||
private static final Set<String> angularIntroducers = new HashSet<String>();
|
||||
static {
|
||||
angularIntroducers.add("template"); //$NON-NLS-1$
|
||||
|
@ -1370,6 +1435,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
setOutlinerContextMenuId("#CEditorOutlinerContext"); //$NON-NLS-1$
|
||||
|
||||
fCEditorErrorTickUpdater = new CEditorErrorTickUpdater(this);
|
||||
fIndexerPreferenceListener = new IndexerPreferenceListener();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1422,6 +1488,8 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
if (cSourceViewer != null && isFoldingEnabled() && (store == null || !store.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS)))
|
||||
cSourceViewer.prepareDelayedProjection();
|
||||
|
||||
fIndexerPreferenceListener.unregister();
|
||||
|
||||
super.doSetInput(input);
|
||||
|
||||
setOutlinePageInput(fOutlinePage, input);
|
||||
|
@ -1433,57 +1501,39 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
fCEditorErrorTickUpdater.updateEditorImage(getInputCElement());
|
||||
}
|
||||
ICElement element= getInputCElement();
|
||||
if (element != null) {
|
||||
IProject project = element.getCProject().getProject();
|
||||
fIndexerPreferenceListener.registerFor(project);
|
||||
}
|
||||
|
||||
if (element instanceof ITranslationUnit) {
|
||||
ITranslationUnit tu = (ITranslationUnit) element;
|
||||
addToIndexIfNecessary(tu);
|
||||
updateIndexInclusion(tu, false);
|
||||
fBracketMatcher.configure(tu.getLanguage());
|
||||
} else {
|
||||
updateIndexInclusion(null, false);
|
||||
fBracketMatcher.configure(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void addToIndexIfNecessary(ITranslationUnit tu) {
|
||||
private void updateIndexInclusion(ITranslationUnit tu, boolean synchronous) {
|
||||
if (tu!= null) {
|
||||
IProject project = tu.getCProject().getProject();
|
||||
if (String.valueOf(true).equals(IndexerPreferences.get(project, IndexerPreferences.KEY_INDEX_ON_OPEN, null))) {
|
||||
IndexUpdateRequestorJob job = new IndexUpdateRequestorJob(tu);
|
||||
if (!String.valueOf(true).equals(IndexerPreferences.get(project, IndexerPreferences.KEY_INDEX_ON_OPEN, null))) {
|
||||
tu = null;
|
||||
}
|
||||
}
|
||||
if (tu != null || fTuAddedToIndex != null) {
|
||||
IndexUpdateRequestorJob job = new IndexUpdateRequestorJob(tu, fTuAddedToIndex);
|
||||
fTuAddedToIndex = tu;
|
||||
job.schedule();
|
||||
}
|
||||
}
|
||||
|
||||
private static class IndexUpdateRequestorJob extends Job {
|
||||
private final ITranslationUnit tu;
|
||||
|
||||
IndexUpdateRequestorJob(ITranslationUnit tu) {
|
||||
super(CEditorMessages.CEditor_index_expander_job_name);
|
||||
this.tu = tu;
|
||||
setSystem(true);
|
||||
setPriority(Job.DECORATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
ICProject[] projects;
|
||||
if (synchronous) {
|
||||
try {
|
||||
projects = CoreModel.getDefault().getCModel().getCProjects();
|
||||
IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||
IIndex index = indexManager.getIndex(projects);
|
||||
index.acquireReadLock();
|
||||
try {
|
||||
IIndexFileLocation ifl = IndexLocationFactory.getIFL(tu);
|
||||
IIndexFile file = index.getFile(tu.getLanguage().getLinkageID(), ifl);
|
||||
if (file != null) {
|
||||
return Status.OK_STATUS; // Already indexed.
|
||||
}
|
||||
indexManager.update(new ICElement[] { tu },
|
||||
IIndexManager.FORCE_INDEX_INCLUSION | IIndexManager.UPDATE_CHECK_TIMESTAMPS);
|
||||
} finally {
|
||||
index.releaseReadLock();
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
} catch (CoreException e) {
|
||||
job.join();
|
||||
} catch (InterruptedException e) {
|
||||
// Ignore.
|
||||
}
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2148,6 +2198,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
updateIndexInclusion(null, true);
|
||||
|
||||
ISourceViewer sourceViewer = getSourceViewer();
|
||||
if (sourceViewer instanceof ITextViewerExtension)
|
||||
|
|
|
@ -30,17 +30,13 @@ import org.eclipse.osgi.util.NLS;
|
|||
* A Change for creating a new file with the given name, content and encoding at the specified path.
|
||||
*
|
||||
* @author Emanuel Graf
|
||||
*
|
||||
*/
|
||||
public class CreateFileChange extends Change {
|
||||
|
||||
private String name;
|
||||
private final IPath path;
|
||||
private final String source;
|
||||
private final String encoding;
|
||||
|
||||
|
||||
|
||||
public CreateFileChange(String name, IPath path, String source, String encoding) {
|
||||
super();
|
||||
this.name = name;
|
||||
|
@ -55,8 +51,7 @@ public class CreateFileChange extends Change {
|
|||
|
||||
@Override
|
||||
public Object getModifiedElement() {
|
||||
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
|
||||
return file;
|
||||
return ResourcesPlugin.getWorkspace().getRoot().getFile(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,8 +67,8 @@ public class CreateFileChange extends Change {
|
|||
}
|
||||
|
||||
@Override
|
||||
public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException,
|
||||
OperationCanceledException {
|
||||
public RefactoringStatus isValid(IProgressMonitor pm)
|
||||
throws CoreException, OperationCanceledException {
|
||||
RefactoringStatus result= new RefactoringStatus();
|
||||
IFile file= ResourcesPlugin.getWorkspace().getRoot().getFile(path);
|
||||
|
||||
|
@ -84,8 +79,7 @@ public class CreateFileChange extends Change {
|
|||
}
|
||||
|
||||
if (file.exists()) {
|
||||
result.addFatalError( NLS.bind(Messages.CreateFileChange_FileExists,
|
||||
file.getFullPath().toString()));
|
||||
result.addFatalError(NLS.bind(Messages.CreateFileChange_FileExists, file.getFullPath().toString()));
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
|
@ -102,8 +96,6 @@ public class CreateFileChange extends Change {
|
|||
return new DeleteFileChange(file.getFullPath());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
|
@ -116,5 +108,4 @@ public class CreateFileChange extends Change {
|
|||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import org.eclipse.ltk.core.refactoring.Change;
|
||||
import org.eclipse.ltk.core.refactoring.CompositeChange;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
|
||||
|
@ -38,7 +39,6 @@ public class ModificationCollector {
|
|||
if (!rewriters.containsKey(ast)) {
|
||||
rewriters.put(ast, ASTRewrite.create(ast));
|
||||
}
|
||||
|
||||
return rewriters.get(ast);
|
||||
}
|
||||
|
||||
|
@ -55,13 +55,31 @@ public class ModificationCollector {
|
|||
CCompositeChange result = new CCompositeChange(""); //$NON-NLS-1$
|
||||
result.markAsSynthetic();
|
||||
|
||||
if (changes != null)
|
||||
result.addAll(changes.toArray(new Change[changes.size()]));
|
||||
if (changes != null) {
|
||||
for (Change change : changes) {
|
||||
addFlattened(change, result);
|
||||
}
|
||||
}
|
||||
|
||||
for (ASTRewrite each : rewriters.values()) {
|
||||
result.add(each.rewriteAST());
|
||||
Change change = each.rewriteAST();
|
||||
addFlattened(change, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* If {@code change} is a CompositeChange, merges it into the {@code receiver}, otherwise
|
||||
* adds it to the {@code receiver}.
|
||||
* @param change The change being added.
|
||||
* @param receiver The composite change that receives the addition.
|
||||
*/
|
||||
private void addFlattened(Change change, CompositeChange receiver) {
|
||||
if (change instanceof CompositeChange) {
|
||||
receiver.merge((CompositeChange) change);
|
||||
} else {
|
||||
receiver.add(change);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
||||
|
@ -118,21 +120,26 @@ public class FunctionFactory {
|
|||
CPPASTCompoundStatement compound = new CPPASTCompoundStatement();
|
||||
CPPASTExpressionStatement exprStmt = new CPPASTExpressionStatement();
|
||||
CPPASTBinaryExpression binExpr = new CPPASTBinaryExpression();
|
||||
CPPASTFieldReference fieldRef = new CPPASTFieldReference();
|
||||
CPPASTLiteralExpression litExpr = new CPPASTLiteralExpression();
|
||||
litExpr.setValue(Keywords.cTHIS);
|
||||
fieldRef.setFieldOwner(litExpr);
|
||||
IASTDeclarator innerDeclarator = fieldDeclaration.getDeclarators()[0];
|
||||
while (innerDeclarator.getNestedDeclarator() != null) {
|
||||
innerDeclarator = innerDeclarator.getNestedDeclarator();
|
||||
}
|
||||
IASTName fieldName = innerDeclarator.getName();
|
||||
fieldRef.setFieldName(fieldName.copy(CopyStyle.withLocations));
|
||||
CPPASTName parameterName = getSetterParameterName(fieldName);
|
||||
if (Arrays.equals(fieldName.getSimpleID(), parameterName.getSimpleID())) {
|
||||
CPPASTFieldReference fieldRef = new CPPASTFieldReference();
|
||||
CPPASTLiteralExpression litExpr = new CPPASTLiteralExpression();
|
||||
litExpr.setValue(Keywords.cTHIS);
|
||||
fieldRef.setFieldOwner(litExpr);
|
||||
fieldRef.setIsPointerDereference(true);
|
||||
fieldRef.setFieldName(fieldName.copy(CopyStyle.withLocations));
|
||||
binExpr.setOperand1(fieldRef);
|
||||
} else {
|
||||
CPPASTIdExpression idExpr = new CPPASTIdExpression(fieldName.copy(CopyStyle.withLocations));
|
||||
binExpr.setOperand1(idExpr);
|
||||
}
|
||||
binExpr.setOperator(IASTBinaryExpression.op_assign);
|
||||
CPPASTIdExpression idExpr = new CPPASTIdExpression();
|
||||
idExpr.setName(fieldName.copy(CopyStyle.withLocations));
|
||||
CPPASTIdExpression idExpr = new CPPASTIdExpression(parameterName);
|
||||
binExpr.setOperand2(idExpr);
|
||||
exprStmt.setExpression(binExpr);
|
||||
compound.addStatement(exprStmt);
|
||||
|
@ -151,13 +158,20 @@ public class FunctionFactory {
|
|||
declarator.setName(setterName);
|
||||
}
|
||||
CPPASTParameterDeclaration parameterDeclaration = new CPPASTParameterDeclaration();
|
||||
parameterDeclaration.setDeclarator(fieldDeclaration.getDeclarators()[0].copy(CopyStyle.withLocations));
|
||||
IASTDeclarator parameterDeclarator = fieldDeclaration.getDeclarators()[0].copy(CopyStyle.withLocations);
|
||||
parameterDeclarator.setName(getSetterParameterName(fieldName));
|
||||
parameterDeclaration.setDeclarator(parameterDeclarator);
|
||||
parameterDeclaration.setDeclSpecifier(fieldDeclaration.getDeclSpecifier().copy(
|
||||
CopyStyle.withLocations));
|
||||
declarator.addParameterDeclaration(parameterDeclaration.copy(CopyStyle.withLocations));
|
||||
return declarator;
|
||||
}
|
||||
|
||||
private static CPPASTName getSetterParameterName(IASTName fieldName) {
|
||||
String parameterName = GetterSetterNameGenerator.generateSetterParameterName(fieldName);
|
||||
return new CPPASTName(parameterName.toCharArray());
|
||||
}
|
||||
|
||||
private static CPPASTSimpleDeclSpecifier getVoidDeclSpec() {
|
||||
CPPASTSimpleDeclSpecifier declSpecifier = new CPPASTSimpleDeclSpecifier();
|
||||
declSpecifier.setType(IASTSimpleDeclSpecifier.t_void);
|
||||
|
|
|
@ -79,6 +79,22 @@ public class GetterSetterNameGenerator {
|
|||
return composer.compose(name);
|
||||
}
|
||||
|
||||
public static String generateSetterParameterName(IASTName fieldName) {
|
||||
IPreferencesService preferences = Platform.getPreferencesService();
|
||||
int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
|
||||
PreferenceConstants.NAME_STYLE_VARIABLE_CAPITALIZATION,
|
||||
PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL, null);
|
||||
String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
|
||||
PreferenceConstants.NAME_STYLE_VARIABLE_WORD_DELIMITER, "", null); //$NON-NLS-1$
|
||||
String prefix = preferences.getString(CUIPlugin.PLUGIN_ID,
|
||||
PreferenceConstants.NAME_STYLE_VARIABLE_PREFIX, "", null); //$NON-NLS-1$
|
||||
String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
|
||||
PreferenceConstants.NAME_STYLE_VARIABLE_SUFFIX, "", null); //$NON-NLS-1$
|
||||
NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
|
||||
String name = GetterSetterNameGenerator.trimFieldName(fieldName.toString());
|
||||
return composer.compose(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the trimmed field name. Leading and trailing non-alphanumeric characters are trimmed.
|
||||
* If the first word of the name consists of a single letter and the name contains more than
|
||||
|
|
|
@ -37,6 +37,11 @@ public class ImplementMethodData implements ITreeContentProvider{
|
|||
for (IASTSimpleDeclaration declaration : methodDeclarations) {
|
||||
this.methodDeclarations.add(new MethodToImplementConfig(declaration, new ParameterHandler(declaration)));
|
||||
}
|
||||
|
||||
// Only one declaration available, might as well check it
|
||||
if (this.methodDeclarations.size() == 1) {
|
||||
this.methodDeclarations.get(0).setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
public List<MethodToImplementConfig> getMethodDeclarations() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2010 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
|
||||
|
@ -12,9 +12,6 @@
|
|||
package org.eclipse.cdt.debug.internal.ui;
|
||||
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
public interface IInternalCDebugUIConstants {
|
||||
|
||||
|
@ -36,14 +33,6 @@ public interface IInternalCDebugUIConstants {
|
|||
*/
|
||||
public static final String DISASSEMBLY_FONT = PREFIX + "disassemblyFont"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The color id to highlight the source lines in disassembly view. This color is managed via
|
||||
* the workbench font preference page.
|
||||
*/
|
||||
public static final String DISASSEMBLY_SOURCE_LINE_COLOR = PREFIX + "disassembly.sourceLineColor"; //$NON-NLS-1$
|
||||
|
||||
public static final RGB DEFAULT_DISASSEMBLY_SOURCE_LINE_RGB = Display.getDefault().getSystemColor( SWT.COLOR_DARK_BLUE ).getRGB();
|
||||
|
||||
// Current stack frame instruction pointer
|
||||
public static final String DISASM_INSTRUCTION_POINTER = PREFIX + "disassemblyInstructionPointer"; //$NON-NLS-1$
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2010 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
|
||||
|
@ -22,13 +22,11 @@ import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
|||
import org.eclipse.cdt.debug.core.ICDebugConstants;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIFormat;
|
||||
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
|
||||
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
import org.eclipse.debug.ui.IDebugView;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.preference.PreferenceConverter;
|
||||
import org.eclipse.jface.preference.PreferencePage;
|
||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||
|
@ -106,6 +104,7 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr
|
|||
*
|
||||
* @see org.eclipse.jface.preference.PreferencePage#createContents(Composite)
|
||||
*/
|
||||
@Override
|
||||
protected Control createContents( Composite parent ) {
|
||||
getWorkbench().getHelpSystem().setHelp( getControl(), ICDebugHelpContextIds.C_DEBUG_PREFERENCE_PAGE );
|
||||
//The main composite
|
||||
|
@ -174,12 +173,12 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr
|
|||
*/
|
||||
public static void initDefaults( IPreferenceStore store ) {
|
||||
store.setDefault( ICDebugPreferenceConstants.PREF_SHOW_HEX_VALUES, false );
|
||||
PreferenceConverter.setDefault( store, IInternalCDebugUIConstants.DISASSEMBLY_SOURCE_LINE_COLOR, IInternalCDebugUIConstants.DEFAULT_DISASSEMBLY_SOURCE_LINE_RGB );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.dialogs.IDialogPage#dispose()
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
getPreferenceStore().removePropertyChangeListener( getPropertyChangeListener() );
|
||||
|
@ -246,6 +245,7 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.preference.IPreferencePage#performOk()
|
||||
*/
|
||||
@Override
|
||||
public boolean performOk() {
|
||||
storeValues();
|
||||
if ( getPropertyChangeListener().hasStateChanged() ) {
|
||||
|
@ -310,6 +310,7 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr
|
|||
*
|
||||
* @see PreferencePage#performDefaults()
|
||||
*/
|
||||
@Override
|
||||
protected void performDefaults() {
|
||||
setDefaultValues();
|
||||
super.performDefaults();
|
||||
|
|
|
@ -12,6 +12,8 @@ package org.eclipse.cdt.dsf.debug.ui.viewmodel.update;
|
|||
|
||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.StateChangeReason;
|
||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueRetriever;
|
||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueVMUtil;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.update.IElementUpdateTester;
|
||||
|
||||
/**
|
||||
|
@ -21,6 +23,28 @@ public class BreakpointHitUpdatePolicy extends DebugManualUpdatePolicy {
|
|||
|
||||
public static String BREAKPOINT_HIT_UPDATE_POLICY_ID = "org.eclipse.cdt.dsf.debug.ui.viewmodel.update.breakpointHitUpdatePolicy"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Creates a breakpoint hit update policy for debug views.
|
||||
*/
|
||||
public BreakpointHitUpdatePolicy() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a breakpoint hit update policy for debug views for models that
|
||||
* retrieve multiple formatted values for each view entry. The given
|
||||
* prefixes distinguish the formatted values properties from each other.
|
||||
*
|
||||
* @see FormattedValueRetriever
|
||||
* @see FormattedValueVMUtil#getPropertyForFormatId(String, String)
|
||||
*
|
||||
* @param prefixes Prefixes to use when flushing the active formatted value
|
||||
* from VM cache.
|
||||
*/
|
||||
public BreakpointHitUpdatePolicy(String[] prefixes) {
|
||||
super(prefixes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return BREAKPOINT_HIT_UPDATE_POLICY_ID;
|
||||
|
|
|
@ -731,7 +731,7 @@ public class VariableVMNode extends AbstractExpressionVMNode
|
|||
int count = 0;
|
||||
|
||||
for (final IPropertiesUpdate update : updates) {
|
||||
IExpression expression = (IExpression)DebugPlugin.getAdapter(update.getElement(), IExpression.class);
|
||||
final IExpression expression = (IExpression)DebugPlugin.getAdapter(update.getElement(), IExpression.class);
|
||||
if (expression != null) {
|
||||
update.setProperty(AbstractExpressionVMNode.PROP_ELEMENT_EXPRESSION, expression.getExpressionText());
|
||||
}
|
||||
|
@ -761,10 +761,13 @@ public class VariableVMNode extends AbstractExpressionVMNode
|
|||
if (isSuccess()) {
|
||||
fillExpressionDataProperties(update, getData());
|
||||
} else {
|
||||
// In case of an error fill in the expression next in the name column.
|
||||
// In case of an error fill in the expression text in the name column and expressions columns.
|
||||
IExpressionDMContext dmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IExpressions.IExpressionDMContext.class);
|
||||
if (dmc != null && dmc.getExpression() != null) {
|
||||
update.setProperty(PROP_NAME, dmc.getExpression());
|
||||
if (expression == null) {
|
||||
update.setProperty(PROP_ELEMENT_EXPRESSION, dmc.getExpression());
|
||||
}
|
||||
}
|
||||
update.setStatus(getStatus());
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.ui.viewmodel.properties;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
@ -113,8 +114,11 @@ public class PropertiesUpdateStatus extends DsfMultiStatus {
|
|||
PropertiesUpdateStatus newStatus, Set<String> properties)
|
||||
{
|
||||
PropertiesUpdateStatus mergedStatus = new PropertiesUpdateStatus();
|
||||
// Copy the property status map from the base status.
|
||||
mergedStatus.fPropertiesStatus.putAll(baseStatus.fPropertiesStatus);
|
||||
|
||||
// Add in the property statuses from the new status, but only for the
|
||||
// specified properties.
|
||||
for (String property : properties) {
|
||||
IStatus propertyStatus = newStatus.getStatus(property);
|
||||
if (propertyStatus != null) {
|
||||
|
@ -123,13 +127,30 @@ public class PropertiesUpdateStatus extends DsfMultiStatus {
|
|||
mergedStatus.fPropertiesStatus.remove(property);
|
||||
}
|
||||
}
|
||||
Set<IStatus> children = new HashSet<IStatus>((baseStatus.getChildren().length + newStatus.getChildren().length) * 4/3);
|
||||
|
||||
// Children of merged status should contain all statuses that are found in the fPropertiesStatus map, but
|
||||
// without duplicates.
|
||||
Set<IStatus> children = new HashSet<IStatus>((baseStatus.getChildren().length + newStatus.getChildren().length) * 4/3);
|
||||
children.addAll(mergedStatus.fPropertiesStatus.values());
|
||||
for (IStatus child : children) {
|
||||
mergedStatus.add(child);
|
||||
}
|
||||
|
||||
// Merged status should contain all children statuses that were added without a corresponding property to the
|
||||
// base status and to the new status.
|
||||
Collection<IStatus> baseStatusPropertyChildren = baseStatus.fPropertiesStatus.values();
|
||||
for (IStatus baseStatusChild : baseStatus.getChildren()) {
|
||||
if (!baseStatusPropertyChildren.contains(baseStatusChild)) {
|
||||
mergedStatus.add(baseStatusChild);
|
||||
}
|
||||
}
|
||||
Collection<IStatus> newStatusPropertyChildren = newStatus.fPropertiesStatus.values();
|
||||
for (IStatus newStatusChild : newStatus.getChildren()) {
|
||||
if (!newStatusPropertyChildren.contains(newStatusChild)) {
|
||||
mergedStatus.add(newStatusChild);
|
||||
}
|
||||
}
|
||||
|
||||
return mergedStatus;
|
||||
}
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ Option.noroconst=Do not place constant values in read only storage (-qnoroconst)
|
|||
Option.roptr=Place constant pointers in read only storage (-qroptr)
|
||||
Option.Statsym=Generate symbols for static variables (-qstatsym )
|
||||
Option.xcall=Generate code to treat static functions as external functions (-qxcall )
|
||||
Option.funcset=Place instructions for each function in a separate object file control section or csect (-qfuncset)
|
||||
Option.funcsect=Place instructions for each function in a separate object file control section or csect (-qfuncsect)
|
||||
Option.ppline=Enable generation of #line directive in the preprocessed output (-qppline)
|
||||
Option.upconv=Preserve the unsigned specification when performing integral promotions (-qupconv)
|
||||
Option.namemangling=Name mangling scheme for external symbol names (-qnamemangling=)
|
||||
|
@ -193,6 +193,7 @@ Option.statsym = Add static variables to the symbol table (-qstatsym)
|
|||
Option.threaded = Enable multi-threaded execution (-qthreaded)
|
||||
Option.unique = Generate unique names for static constructor/deconstructor file compilation units (-qunique)
|
||||
Option.unique.v10 = Generate unique names for static constructor/deconstructor file compilation units (-qunique)
|
||||
Option.qconcurrentupdate.v11 = Update the operating system while the kernel is running (-qconcurrentupdate)
|
||||
Option.novftable = Do not generate virtual function table (-qnovftable)
|
||||
Option.vrsave = Maintain the VRSAVE register (-qvrsave)
|
||||
Option.weaksymbol = Generate weak symbols (-qweaksymbol)
|
||||
|
@ -202,7 +203,7 @@ Option.macros.pre=predefined (-qshowmacros=pre)
|
|||
Option.macros.nopre=no macros (-qshowmacros=nopre)
|
||||
Option.qstackprotect = Protect against malicious code or programming errors that overwrite or corrupt the stack (-qstackprotect=)
|
||||
Options.timestamps=Suppress insert of implicit timestamps into an object file (-qnotimestamps)
|
||||
|
||||
Option.qrestrict = Stop pointers from accessing the same memory that has been addressed by function parameter pointers (-qrestrict=)
|
||||
|
||||
# Optimization options
|
||||
Option.OptLevel = Optimization level
|
||||
|
|
|
@ -229,6 +229,25 @@
|
|||
name="%Option.unique.v10"
|
||||
resourceFilter="all"
|
||||
valueType="boolean">
|
||||
</option>
|
||||
<option
|
||||
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
|
||||
category="xlc.c.compiler.category.objcc"
|
||||
command="-qconcurrentupdate"
|
||||
defaultValue="false"
|
||||
id="org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.output.qconcurrentupdate"
|
||||
isAbstract="false"
|
||||
name="%Option.qconcurrentupdate.v11"
|
||||
resourceFilter="all"
|
||||
valueType="boolean">
|
||||
</option>
|
||||
<option
|
||||
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
|
||||
category="xlc.c.compiler.category.optimization"
|
||||
command="-qrestrict"
|
||||
id="xlc.c.compiler.option.optimization.qrestrict"
|
||||
name="%Option.qrestrict"
|
||||
valueType="string">
|
||||
</option>
|
||||
</tool>
|
||||
<tool
|
||||
|
@ -1495,10 +1514,10 @@
|
|||
|
||||
<option
|
||||
category="xlc.c.compiler.category.output"
|
||||
command="-qfuncset"
|
||||
command="-qfuncsect"
|
||||
defaultValue="false"
|
||||
id="xlc.c.compiler.option.output.funcset"
|
||||
name="%Option.funcset"
|
||||
id="xlc.c.compiler.option.output.funcsect"
|
||||
name="%Option.funcsect"
|
||||
valueType="boolean">
|
||||
</option>
|
||||
<option
|
||||
|
@ -3393,34 +3412,12 @@
|
|||
</enumeratedOptionValue>
|
||||
</option>
|
||||
<option
|
||||
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
|
||||
category="xlc.c.compiler.category.lm"
|
||||
command="-qlistfmt"
|
||||
id="xlc.c.compiler.option.lm.qlistfmt"
|
||||
name="%Option.qlistfmt"
|
||||
valueType="string">
|
||||
<enumeratedOptionValue
|
||||
id="xlc.c.lm.attr.none"
|
||||
isDefault="false"
|
||||
name="%Option.none">
|
||||
</enumeratedOptionValue>
|
||||
<enumeratedOptionValue
|
||||
command="-qnoattr"
|
||||
id="xlc.c.lm.attr.noattr"
|
||||
isDefault="false"
|
||||
name="%Option.attr.noattr">
|
||||
</enumeratedOptionValue>
|
||||
<enumeratedOptionValue
|
||||
command="-qattr=full"
|
||||
id="xlc.c.lm.attr.fullattr"
|
||||
isDefault="false"
|
||||
name="%Option.attr.fullattr">
|
||||
</enumeratedOptionValue>
|
||||
<enumeratedOptionValue
|
||||
command="-qattr"
|
||||
id="xlc.c.lm.attr.attr"
|
||||
isDefault="false"
|
||||
name="%Option.attr.attr">
|
||||
</enumeratedOptionValue>
|
||||
</option>
|
||||
<option
|
||||
category="xlc.c.compiler.category.optimization"
|
||||
|
|
|
@ -27,17 +27,20 @@ xlc.c.compiler.option.ecd.optdebug=v9.0+
|
|||
xlc.c.compiler.option.optimization.smp=v8.0,v9.0
|
||||
xlc.c.compiler.option.optimization.smp.v10=v10.1
|
||||
xlc.c.compiler.option.optimization.strict=v8.0,v9.0
|
||||
xlc.c.compiler.option.optimization.strict.v10=v10.1
|
||||
xlc.c.compiler.option.optimization.strict.v10=v10.1+
|
||||
org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.output.unique.v10=v10.1
|
||||
org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.namemangling=v8.0,v9.0
|
||||
org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.namemangling.v10=v10.1
|
||||
org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.output.qconcurrentupdate=v11.1
|
||||
xlc.c.compiler.option.cc.tls=v8.0,v9.0
|
||||
xlc.c.compiler.option.cc.tls.v10=v10.1
|
||||
xlc.c.compiler.option.output.macros=v10.1
|
||||
xlc.c.compiler.option.output.timestamps=v10.1
|
||||
xlc.c.compiler.option.output.qstackprotect=v11.1+
|
||||
xlc.c.compiler.option.output.enablevmx=v8.0,v9.0,v10.1,v11.1
|
||||
xlc.ui.cpp.option.output.qconcurrentupdate
|
||||
xlc.c.compiler.option.qfunctrace=v11.1+
|
||||
|
||||
xlc.c.compiler.option.optimization.qrestrict=v11.1+
|
||||
xlc.c.compiler.option.lm.qlistfmt=v11.1+
|
||||
|
||||
# END NON-TRANSLATABLE
|
||||
|
|
Loading…
Add table
Reference in a new issue