mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 16:56:04 +02:00
Tentative fix for PR 59098.
This commit is contained in:
parent
27ceac6cb6
commit
9b578a9f0c
11 changed files with 213 additions and 68 deletions
|
@ -1,3 +1,13 @@
|
|||
2004-04-23 Alain Magloire
|
||||
|
||||
Tentative fix for PR 59098.
|
||||
* model/org/eclipse/cdt/internal/core/model/CContainerInfo.java
|
||||
* model/org/eclipse/cdt/internal/core/model/CElement.java
|
||||
* model/org/eclipse/cdt/internal/core/model/CModelManager.java
|
||||
* model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
|
||||
* model/org/eclipse/cdt/internal/core/model/IncludeReference.java
|
||||
|
||||
|
||||
2004-04-23 Alain Magloire
|
||||
|
||||
Moving the work from Sam Robb part of PR 52864, this
|
||||
|
|
|
@ -12,9 +12,12 @@ package org.eclipse.cdt.internal.core.model;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
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.ISourceRoot;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -42,8 +45,19 @@ public class CContainerInfo extends OpenableInfo {
|
|||
return nonCResources;
|
||||
|
||||
ArrayList notChildren = new ArrayList();
|
||||
ICElement parent = getElement();
|
||||
ICProject cproject = parent.getCProject();
|
||||
ICElement celement = getElement();
|
||||
ICProject cproject = celement.getCProject();
|
||||
// move back to the sourceroot.
|
||||
while (! (celement instanceof ISourceRoot) && celement != null) {
|
||||
celement = celement.getParent();
|
||||
}
|
||||
ISourceRoot root = null;
|
||||
if (celement instanceof ISourceRoot) {
|
||||
root = (ISourceRoot)celement;
|
||||
} else {
|
||||
return new Object[0]; // should not be. assert
|
||||
}
|
||||
|
||||
try {
|
||||
IResource[] resources = null;
|
||||
if (res instanceof IContainer) {
|
||||
|
@ -55,34 +69,31 @@ public class CContainerInfo extends OpenableInfo {
|
|||
if (resources != null) {
|
||||
ICElement[] children = getChildren();
|
||||
for (int i = 0; i < resources.length; i++) {
|
||||
boolean found = false;
|
||||
// Check if the folder is not itself a sourceEntry.
|
||||
if (resources[i].getType() == IResource.FOLDER) {
|
||||
IPath fullPath = resources[i].getFullPath();
|
||||
for (int k = 0; k < entries.length; k++) {
|
||||
IPathEntry entry = entries[k];
|
||||
if (entry.getEntryKind() == IPathEntry.CDT_SOURCE) {
|
||||
IPath sourcePath = entry.getPath();
|
||||
if (fullPath.equals(sourcePath)) {
|
||||
found = true;
|
||||
break;
|
||||
IResource member = resources[i];
|
||||
switch(member.getType()) {
|
||||
case IResource.FOLDER: {
|
||||
// Check if the folder is not itself a sourceEntry.
|
||||
IPath resourcePath = member.getFullPath();
|
||||
if (cproject.isOnSourceRoot(member) || isSourceEntry(resourcePath, entries)) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IResource.FILE: {
|
||||
String filename = member.getName();
|
||||
if (CoreModel.isValidTranslationUnitName(filename) && root.isOnSourceEntry(member)) {
|
||||
continue;
|
||||
} else {
|
||||
if (root.isOnSourceEntry(member)) {
|
||||
if (CModelManager.getDefault().createBinaryFile((IFile)member) != null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Check the children for a match
|
||||
if (!found) {
|
||||
for (int j = 0; j < children.length; j++) {
|
||||
IResource r = children[j].getResource();
|
||||
if (r != null && r.equals(resources[i])){
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
notChildren.add(resources[i]);
|
||||
}
|
||||
notChildren.add(member);
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
|
@ -101,4 +112,17 @@ public class CContainerInfo extends OpenableInfo {
|
|||
public void setNonCResources(Object[] resources) {
|
||||
nonCResources = resources;
|
||||
}
|
||||
|
||||
private static boolean isSourceEntry(IPath resourcePath, IPathEntry[] entries) {
|
||||
for (int k = 0; k < entries.length; k++) {
|
||||
IPathEntry entry = entries[k];
|
||||
if (entry.getEntryKind() == IPathEntry.CDT_SOURCE) {
|
||||
IPath sourcePath = entry.getPath();
|
||||
if (resourcePath.equals(sourcePath)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ package org.eclipse.cdt.internal.core.model;
|
|||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICElementVisitor;
|
||||
|
@ -82,7 +81,8 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
try {
|
||||
return getElementInfo() != null;
|
||||
} catch (CModelException e) {
|
||||
CCorePlugin.log(e);
|
||||
// Do not log it, it will fil the .log alarming the user.
|
||||
//CCorePlugin.log(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -372,18 +372,32 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
if (path == null || cproject == null) {
|
||||
return null;
|
||||
}
|
||||
File file = path.toFile();
|
||||
if (file == null || !file.isFile()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
IIncludeReference[] includeReferences = cproject.getIncludeReferences();
|
||||
for (int i = 0; i < includeReferences.length; i++) {
|
||||
if (includeReferences[i].isOnIncludeEntry(path)) {
|
||||
return new ExternalTranslationUnit(includeReferences[i], path);
|
||||
}
|
||||
if (path.isAbsolute()) {
|
||||
File file = path.toFile();
|
||||
if (file == null || !file.isFile()) {
|
||||
return null;
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
try {
|
||||
IIncludeReference[] includeReferences = cproject.getIncludeReferences();
|
||||
for (int i = 0; i < includeReferences.length; i++) {
|
||||
if (includeReferences[i].isOnIncludeEntry(path)) {
|
||||
return new ExternalTranslationUnit(includeReferences[i], path);
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
IIncludeReference[] includeReferences = cproject.getIncludeReferences();
|
||||
for (int i = 0; i < includeReferences.length; i++) {
|
||||
IPath includePath = includeReferences[i].getPath().append(path);
|
||||
File file = path.toFile();
|
||||
if (file != null && file.isFile()) {
|
||||
return new ExternalTranslationUnit(includeReferences[i], path);
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -8,16 +8,22 @@ package org.eclipse.cdt.internal.core.model;
|
|||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.CoreModelUtil;
|
||||
import org.eclipse.cdt.core.model.IArchiveContainer;
|
||||
import org.eclipse.cdt.core.model.IBinaryContainer;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IIncludeReference;
|
||||
import org.eclipse.cdt.core.model.ILibraryReference;
|
||||
import org.eclipse.cdt.core.model.IOutputEntry;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.cdt.core.model.ISourceEntry;
|
||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
/**
|
||||
* Info for ICProject.
|
||||
|
@ -65,15 +71,25 @@ class CProjectInfo extends OpenableInfo {
|
|||
|
||||
// determine if src == project
|
||||
ISourceRoot root = null;
|
||||
ICElement[] elements = getChildren();
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
if (elements[i] instanceof ISourceRoot) {
|
||||
ISourceRoot source = (ISourceRoot)elements[i];
|
||||
if (getElement().getPath().equals(source.getPath())) {
|
||||
root = source;
|
||||
break;
|
||||
boolean srcIsProject = false;
|
||||
IPathEntry[] entries = null;
|
||||
ICProject cproject = getElement().getCProject();
|
||||
IPath projectPath = cproject.getProject().getFullPath();
|
||||
char[][] exclusionPatterns = null;
|
||||
try {
|
||||
entries = cproject.getResolvedPathEntries();
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
if (entries[i].getEntryKind() == IPathEntry.CDT_SOURCE) {
|
||||
ISourceEntry entry = (ISourceEntry)entries[i];
|
||||
if (projectPath.equals(entry.getPath())) {
|
||||
srcIsProject = true;
|
||||
exclusionPatterns = entry.fullExclusionPatternChars();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
ArrayList notChildren = new ArrayList();
|
||||
|
@ -85,24 +101,31 @@ class CProjectInfo extends OpenableInfo {
|
|||
}
|
||||
|
||||
if (resources != null) {
|
||||
ICElement[] children;
|
||||
if (root == null) {
|
||||
children = getChildren();
|
||||
} else {
|
||||
children = root.getChildren();
|
||||
}
|
||||
for (int i = 0; i < resources.length; i++) {
|
||||
boolean found = false;
|
||||
for (int j = 0; j < children.length; j++) {
|
||||
IResource r = children[j].getResource();
|
||||
if (r != null && r.equals(resources[i])){
|
||||
found = true;
|
||||
IResource member = resources[i];
|
||||
switch(member.getType()) {
|
||||
case IResource.FILE: {
|
||||
String filename = member.getName();
|
||||
if (srcIsProject) {
|
||||
if (CoreModel.isValidTranslationUnitName(filename)
|
||||
&& !CoreModelUtil.isExcluded(member, exclusionPatterns)) {
|
||||
continue;
|
||||
} else if (!CoreModelUtil.isExcluded(member, exclusionPatterns)) {
|
||||
Object o = CModelManager.getDefault().createBinaryFile((IFile)member);
|
||||
if (o != null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IResource.FOLDER: {
|
||||
if (srcIsProject && !CoreModelUtil.isExcluded(member, exclusionPatterns)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
notChildren.add(resources[i]);
|
||||
}
|
||||
notChildren.add(member);
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
|
|
|
@ -146,7 +146,10 @@ public class DeltaProcessor {
|
|||
Openable parent = (Openable) child.getParent();
|
||||
if (parent != null && parent.isOpen()) {
|
||||
CElementInfo info = parent.getElementInfo();
|
||||
info.addChild(child);
|
||||
// Check if the element exits
|
||||
if (!info.includesChild(child)) {
|
||||
info.addChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public class IncludeReference extends Openable implements IIncludeReference {
|
|||
}
|
||||
|
||||
public IncludeReference(ICElement celement, IIncludeEntry entry, IPath path) {
|
||||
super(celement, null, path.toString(), ICElement.C_VCONTAINER);
|
||||
super(celement, null, path.lastSegment(), ICElement.C_VCONTAINER);
|
||||
fIncludeEntry = entry;
|
||||
fPath = path;
|
||||
}
|
||||
|
@ -130,4 +130,10 @@ public class IncludeReference extends Openable implements IIncludeReference {
|
|||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICElement#getPath()
|
||||
*/
|
||||
public IPath getPath() {
|
||||
return fPath;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
2004-04-23 Alain Magloire
|
||||
|
||||
Tentative fix for PR 59098.
|
||||
* src/org/eclipse/cdt/internal/ui/cview/CView.java
|
||||
* src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java
|
||||
|
||||
|
||||
2004-04-23 Hoda Amer
|
||||
Fix for bug#Bug 59618 : [Refactoring] Be able to append refactor action group after my own group
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.eclipse.cdt.core.model.ICProject;
|
|||
import org.eclipse.cdt.core.model.IParent;
|
||||
import org.eclipse.cdt.core.model.ISourceReference;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
|
||||
import org.eclipse.cdt.internal.ui.drag.DelegatingDragAdapter;
|
||||
import org.eclipse.cdt.internal.ui.drag.FileTransferDragAdapter;
|
||||
import org.eclipse.cdt.internal.ui.drag.LocalSelectionTransferDragAdapter;
|
||||
|
@ -28,6 +27,7 @@ import org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage;
|
|||
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
||||
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
|
||||
import org.eclipse.cdt.ui.CElementContentProvider;
|
||||
import org.eclipse.cdt.ui.CElementLabelProvider;
|
||||
import org.eclipse.cdt.ui.CElementSorter;
|
||||
import org.eclipse.cdt.ui.CLocalSelectionTransfer;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
@ -554,8 +554,8 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
|
|||
return new CViewContentProvider(showCUChildren, true);
|
||||
}
|
||||
|
||||
protected StandardCElementLabelProvider createLabelProvider() {
|
||||
return new StandardCElementLabelProvider();
|
||||
protected CElementLabelProvider createLabelProvider() {
|
||||
return new CViewLabelProvider();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003,2004 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.cview;
|
||||
|
||||
import org.eclipse.cdt.core.model.IIncludeReference;
|
||||
import org.eclipse.cdt.internal.ui.IAdornmentProvider;
|
||||
import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
|
||||
|
||||
/*
|
||||
* CViewLabelProvider
|
||||
*/
|
||||
public class CViewLabelProvider extends StandardCElementLabelProvider {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public CViewLabelProvider() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param flags
|
||||
* @param adormentProviders
|
||||
*/
|
||||
public CViewLabelProvider(int flags, IAdornmentProvider[] adormentProviders) {
|
||||
super(flags, adormentProviders);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
|
||||
*/
|
||||
public String getText(Object element) {
|
||||
if (element instanceof IIncludeReference) {
|
||||
IIncludeReference ref = (IIncludeReference)element;
|
||||
Object parent = ref.getParent();
|
||||
if (!(parent instanceof IIncludeReference)) {
|
||||
return ref.getPath().toString();
|
||||
}
|
||||
}
|
||||
return super.getText(element);
|
||||
}
|
||||
}
|
|
@ -113,7 +113,15 @@ public class CPListElement {
|
|||
}
|
||||
|
||||
private IPathEntry newPathEntry() {
|
||||
IPath[] exclusionPattern = (IPath[]) getAttribute(EXCLUSION);
|
||||
IPath[] exclusionPattern;
|
||||
//IPath[] exclusionPattern = (IPath[]) getAttribute(EXCLUSION);
|
||||
Object o = getAttribute(EXCLUSION);
|
||||
Class clazz = o.getClass();
|
||||
if (clazz.isArray()) {
|
||||
exclusionPattern = (IPath[]) o;
|
||||
} else {
|
||||
exclusionPattern = new IPath[0];
|
||||
}
|
||||
IPath base = (IPath) getAttribute(BASE);
|
||||
IPath baseRef = (IPath) getAttribute(BASE_REF);
|
||||
switch (fEntryKind) {
|
||||
|
@ -255,7 +263,7 @@ public class CPListElement {
|
|||
if (attrib != null) {
|
||||
return attrib.getValue();
|
||||
}
|
||||
return null;
|
||||
return new Path("");
|
||||
}
|
||||
|
||||
private void createAttributeElement(String key, Object value) {
|
||||
|
|
Loading…
Add table
Reference in a new issue