mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-03 21:53:39 +02:00
Cosmetics.
This commit is contained in:
parent
3374ec550e
commit
b84541a5e7
1 changed files with 53 additions and 56 deletions
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -50,7 +49,6 @@ import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
public class PathEntryUtil {
|
public class PathEntryUtil {
|
||||||
|
|
||||||
static PathEntryManager manager = PathEntryManager.getDefault();
|
static PathEntryManager manager = PathEntryManager.getDefault();
|
||||||
static final IMarker[] NO_MARKERS = new IMarker[0];
|
static final IMarker[] NO_MARKERS = new IMarker[0];
|
||||||
|
|
||||||
|
@ -60,8 +58,8 @@ public class PathEntryUtil {
|
||||||
|
|
||||||
public static IPathEntry getExpandedPathEntry(IPathEntry entry, ICProject cproject) throws CModelException {
|
public static IPathEntry getExpandedPathEntry(IPathEntry entry, ICProject cproject) throws CModelException {
|
||||||
switch (entry.getEntryKind()) {
|
switch (entry.getEntryKind()) {
|
||||||
case IPathEntry.CDT_INCLUDE : {
|
case IPathEntry.CDT_INCLUDE: {
|
||||||
IIncludeEntry includeEntry = (IIncludeEntry)entry;
|
IIncludeEntry includeEntry = (IIncludeEntry) entry;
|
||||||
IPath refPath = includeEntry.getBaseReference();
|
IPath refPath = includeEntry.getBaseReference();
|
||||||
if (refPath != null && !refPath.isEmpty()) {
|
if (refPath != null && !refPath.isEmpty()) {
|
||||||
IPath includePath = includeEntry.getIncludePath();
|
IPath includePath = includeEntry.getIncludePath();
|
||||||
|
@ -73,9 +71,9 @@ public class PathEntryUtil {
|
||||||
ICProject refCProject = CoreModel.getDefault().create(project);
|
ICProject refCProject = CoreModel.getDefault().create(project);
|
||||||
if (refCProject != null) {
|
if (refCProject != null) {
|
||||||
IPathEntry[] entries = manager.getResolvedPathEntries(refCProject);
|
IPathEntry[] entries = manager.getResolvedPathEntries(refCProject);
|
||||||
for (IPathEntry entrie : entries) {
|
for (IPathEntry pathEntry : entries) {
|
||||||
if (entrie.getEntryKind() == IPathEntry.CDT_INCLUDE) {
|
if (pathEntry.getEntryKind() == IPathEntry.CDT_INCLUDE) {
|
||||||
IIncludeEntry refEntry = (IIncludeEntry)entrie;
|
IIncludeEntry refEntry = (IIncludeEntry) pathEntry;
|
||||||
if (refEntry.getIncludePath().equals(includePath)) {
|
if (refEntry.getIncludePath().equals(includePath)) {
|
||||||
IPath newBasePath = refEntry.getBasePath();
|
IPath newBasePath = refEntry.getBasePath();
|
||||||
// If the includePath is
|
// If the includePath is
|
||||||
|
@ -109,9 +107,9 @@ public class PathEntryUtil {
|
||||||
IPathEntryContainer container = manager.getPathEntryContainer(refPath, cproject);
|
IPathEntryContainer container = manager.getPathEntryContainer(refPath, cproject);
|
||||||
if (container != null) {
|
if (container != null) {
|
||||||
IPathEntry[] entries = container.getPathEntries();
|
IPathEntry[] entries = container.getPathEntries();
|
||||||
for (IPathEntry entrie : entries) {
|
for (IPathEntry pathEntry : entries) {
|
||||||
if (entrie.getEntryKind() == IPathEntry.CDT_INCLUDE) {
|
if (pathEntry.getEntryKind() == IPathEntry.CDT_INCLUDE) {
|
||||||
IIncludeEntry refEntry = (IIncludeEntry)entrie;
|
IIncludeEntry refEntry = (IIncludeEntry) pathEntry;
|
||||||
if (refEntry.getIncludePath().equals(includePath)) {
|
if (refEntry.getIncludePath().equals(includePath)) {
|
||||||
IPath newBasePath = refEntry.getBasePath();
|
IPath newBasePath = refEntry.getBasePath();
|
||||||
return CoreModel.newIncludeEntry(includeEntry.getPath(), newBasePath, includePath);
|
return CoreModel.newIncludeEntry(includeEntry.getPath(), newBasePath, includePath);
|
||||||
|
@ -124,8 +122,8 @@ public class PathEntryUtil {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IPathEntry.CDT_MACRO : {
|
case IPathEntry.CDT_MACRO: {
|
||||||
IMacroEntry macroEntry = (IMacroEntry)entry;
|
IMacroEntry macroEntry = (IMacroEntry) entry;
|
||||||
IPath refPath = macroEntry.getBaseReference();
|
IPath refPath = macroEntry.getBaseReference();
|
||||||
if (refPath != null && !refPath.isEmpty()) {
|
if (refPath != null && !refPath.isEmpty()) {
|
||||||
String name = macroEntry.getMacroName();
|
String name = macroEntry.getMacroName();
|
||||||
|
@ -137,9 +135,9 @@ public class PathEntryUtil {
|
||||||
ICProject refCProject = CoreModel.getDefault().create(project);
|
ICProject refCProject = CoreModel.getDefault().create(project);
|
||||||
if (refCProject != null) {
|
if (refCProject != null) {
|
||||||
IPathEntry[] entries = manager.getResolvedPathEntries(refCProject);
|
IPathEntry[] entries = manager.getResolvedPathEntries(refCProject);
|
||||||
for (IPathEntry entrie : entries) {
|
for (IPathEntry pathEntry : entries) {
|
||||||
if (entrie.getEntryKind() == IPathEntry.CDT_MACRO) {
|
if (pathEntry.getEntryKind() == IPathEntry.CDT_MACRO) {
|
||||||
IMacroEntry refEntry = (IMacroEntry)entrie;
|
IMacroEntry refEntry = (IMacroEntry) pathEntry;
|
||||||
if (refEntry.getMacroName().equals(name)) {
|
if (refEntry.getMacroName().equals(name)) {
|
||||||
String value = refEntry.getMacroValue();
|
String value = refEntry.getMacroValue();
|
||||||
return CoreModel.newMacroEntry(macroEntry.getPath(), name, value);
|
return CoreModel.newMacroEntry(macroEntry.getPath(), name, value);
|
||||||
|
@ -153,9 +151,9 @@ public class PathEntryUtil {
|
||||||
IPathEntryContainer container = manager.getPathEntryContainer(refPath, cproject);
|
IPathEntryContainer container = manager.getPathEntryContainer(refPath, cproject);
|
||||||
if (container != null) {
|
if (container != null) {
|
||||||
IPathEntry[] entries = container.getPathEntries();
|
IPathEntry[] entries = container.getPathEntries();
|
||||||
for (IPathEntry entrie : entries) {
|
for (IPathEntry pathEntry : entries) {
|
||||||
if (entrie.getEntryKind() == IPathEntry.CDT_MACRO) {
|
if (pathEntry.getEntryKind() == IPathEntry.CDT_MACRO) {
|
||||||
IMacroEntry refEntry = (IMacroEntry)entrie;
|
IMacroEntry refEntry = (IMacroEntry) pathEntry;
|
||||||
if (refEntry.getMacroName().equals(name)) {
|
if (refEntry.getMacroName().equals(name)) {
|
||||||
String value = refEntry.getMacroValue();
|
String value = refEntry.getMacroValue();
|
||||||
return CoreModel.newMacroEntry(macroEntry.getPath(), name, value);
|
return CoreModel.newMacroEntry(macroEntry.getPath(), name, value);
|
||||||
|
@ -168,8 +166,8 @@ public class PathEntryUtil {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IPathEntry.CDT_LIBRARY : {
|
case IPathEntry.CDT_LIBRARY: {
|
||||||
ILibraryEntry libEntry = (ILibraryEntry)entry;
|
ILibraryEntry libEntry = (ILibraryEntry) entry;
|
||||||
IPath refPath = libEntry.getBaseReference();
|
IPath refPath = libEntry.getBaseReference();
|
||||||
if (refPath != null && !refPath.isEmpty()) {
|
if (refPath != null && !refPath.isEmpty()) {
|
||||||
IPath libraryPath = libEntry.getLibraryPath();
|
IPath libraryPath = libEntry.getLibraryPath();
|
||||||
|
@ -181,9 +179,9 @@ public class PathEntryUtil {
|
||||||
ICProject refCProject = CoreModel.getDefault().create(project);
|
ICProject refCProject = CoreModel.getDefault().create(project);
|
||||||
if (refCProject != null) {
|
if (refCProject != null) {
|
||||||
IPathEntry[] entries = manager.getResolvedPathEntries(refCProject);
|
IPathEntry[] entries = manager.getResolvedPathEntries(refCProject);
|
||||||
for (IPathEntry entrie : entries) {
|
for (IPathEntry pathEntry : entries) {
|
||||||
if (entrie.getEntryKind() == IPathEntry.CDT_LIBRARY) {
|
if (pathEntry.getEntryKind() == IPathEntry.CDT_LIBRARY) {
|
||||||
ILibraryEntry refEntry = (ILibraryEntry)entrie;
|
ILibraryEntry refEntry = (ILibraryEntry) pathEntry;
|
||||||
if (refEntry.getLibraryPath().equals(libraryPath)) {
|
if (refEntry.getLibraryPath().equals(libraryPath)) {
|
||||||
IPath newBasePath = refEntry.getBasePath();
|
IPath newBasePath = refEntry.getBasePath();
|
||||||
// If the libraryPath is
|
// If the libraryPath is
|
||||||
|
@ -221,9 +219,9 @@ public class PathEntryUtil {
|
||||||
IPathEntryContainer container = manager.getPathEntryContainer(refPath, cproject);
|
IPathEntryContainer container = manager.getPathEntryContainer(refPath, cproject);
|
||||||
if (container != null) {
|
if (container != null) {
|
||||||
IPathEntry[] entries = container.getPathEntries();
|
IPathEntry[] entries = container.getPathEntries();
|
||||||
for (IPathEntry entrie : entries) {
|
for (IPathEntry pathEntry : entries) {
|
||||||
if (entrie.getEntryKind() == IPathEntry.CDT_LIBRARY) {
|
if (pathEntry.getEntryKind() == IPathEntry.CDT_LIBRARY) {
|
||||||
ILibraryEntry refEntry = (ILibraryEntry)entrie;
|
ILibraryEntry refEntry = (ILibraryEntry) pathEntry;
|
||||||
if (refEntry.getPath().equals(libraryPath)) {
|
if (refEntry.getPath().equals(libraryPath)) {
|
||||||
return CoreModel.newLibraryEntry(entry.getPath(), refEntry.getBasePath(),
|
return CoreModel.newLibraryEntry(entry.getPath(), refEntry.getBasePath(),
|
||||||
refEntry.getLibraryPath(), refEntry.getSourceAttachmentPath(),
|
refEntry.getLibraryPath(), refEntry.getSourceAttachmentPath(),
|
||||||
|
@ -253,8 +251,8 @@ public class PathEntryUtil {
|
||||||
|
|
||||||
IPathEntryVariableManager varManager = CCorePlugin.getDefault().getPathEntryVariableManager();
|
IPathEntryVariableManager varManager = CCorePlugin.getDefault().getPathEntryVariableManager();
|
||||||
switch (entry.getEntryKind()) {
|
switch (entry.getEntryKind()) {
|
||||||
case IPathEntry.CDT_INCLUDE : {
|
case IPathEntry.CDT_INCLUDE: {
|
||||||
IIncludeEntry include = (IIncludeEntry)entry;
|
IIncludeEntry include = (IIncludeEntry) entry;
|
||||||
|
|
||||||
IPath basePath = include.getBasePath();
|
IPath basePath = include.getBasePath();
|
||||||
basePath = varManager.resolvePath(basePath);
|
basePath = varManager.resolvePath(basePath);
|
||||||
|
@ -265,8 +263,8 @@ public class PathEntryUtil {
|
||||||
return CoreModel.newIncludeEntry(resourcePath, basePath, includePath,
|
return CoreModel.newIncludeEntry(resourcePath, basePath, includePath,
|
||||||
include.isSystemInclude(), include.getExclusionPatterns(), include.isExported());
|
include.isSystemInclude(), include.getExclusionPatterns(), include.isExported());
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_INCLUDE_FILE : {
|
case IPathEntry.CDT_INCLUDE_FILE: {
|
||||||
IIncludeFileEntry includeFile = (IIncludeFileEntry)entry;
|
IIncludeFileEntry includeFile = (IIncludeFileEntry) entry;
|
||||||
|
|
||||||
IPath basePath = includeFile.getBasePath();
|
IPath basePath = includeFile.getBasePath();
|
||||||
basePath = varManager.resolvePath(basePath);
|
basePath = varManager.resolvePath(basePath);
|
||||||
|
@ -277,8 +275,8 @@ public class PathEntryUtil {
|
||||||
return CoreModel.newIncludeFileEntry(resourcePath, basePath, Path.EMPTY, includeFilePath,
|
return CoreModel.newIncludeFileEntry(resourcePath, basePath, Path.EMPTY, includeFilePath,
|
||||||
includeFile.getExclusionPatterns(), includeFile.isExported());
|
includeFile.getExclusionPatterns(), includeFile.isExported());
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_LIBRARY : {
|
case IPathEntry.CDT_LIBRARY: {
|
||||||
ILibraryEntry library = (ILibraryEntry)entry;
|
ILibraryEntry library = (ILibraryEntry) entry;
|
||||||
|
|
||||||
IPath basePath = library.getBasePath();
|
IPath basePath = library.getBasePath();
|
||||||
basePath = varManager.resolvePath(basePath);
|
basePath = varManager.resolvePath(basePath);
|
||||||
|
@ -299,13 +297,13 @@ public class PathEntryUtil {
|
||||||
sourceAttachmentPath, sourceAttachmentRootPath,
|
sourceAttachmentPath, sourceAttachmentRootPath,
|
||||||
sourceAttachmentPrefixMapping, library.isExported());
|
sourceAttachmentPrefixMapping, library.isExported());
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_MACRO : {
|
case IPathEntry.CDT_MACRO: {
|
||||||
IMacroEntry macro = (IMacroEntry)entry;
|
IMacroEntry macro = (IMacroEntry) entry;
|
||||||
return CoreModel.newMacroEntry(resourcePath, macro.getMacroName(), macro.getMacroValue(),
|
return CoreModel.newMacroEntry(resourcePath, macro.getMacroName(), macro.getMacroValue(),
|
||||||
macro.getExclusionPatterns(), macro.isExported());
|
macro.getExclusionPatterns(), macro.isExported());
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_MACRO_FILE : {
|
case IPathEntry.CDT_MACRO_FILE: {
|
||||||
IMacroFileEntry macroFile = (IMacroFileEntry)entry;
|
IMacroFileEntry macroFile = (IMacroFileEntry) entry;
|
||||||
|
|
||||||
IPath basePath = macroFile.getBasePath();
|
IPath basePath = macroFile.getBasePath();
|
||||||
basePath = varManager.resolvePath(basePath);
|
basePath = varManager.resolvePath(basePath);
|
||||||
|
@ -316,19 +314,19 @@ public class PathEntryUtil {
|
||||||
return CoreModel.newMacroFileEntry(resourcePath, basePath, Path.EMPTY, macroFilePath,
|
return CoreModel.newMacroFileEntry(resourcePath, basePath, Path.EMPTY, macroFilePath,
|
||||||
macroFile.getExclusionPatterns(), macroFile.isExported());
|
macroFile.getExclusionPatterns(), macroFile.isExported());
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_OUTPUT : {
|
case IPathEntry.CDT_OUTPUT: {
|
||||||
IOutputEntry out = (IOutputEntry)entry;
|
IOutputEntry out = (IOutputEntry) entry;
|
||||||
return CoreModel.newOutputEntry(resourcePath, out.getExclusionPatterns());
|
return CoreModel.newOutputEntry(resourcePath, out.getExclusionPatterns());
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_PROJECT : {
|
case IPathEntry.CDT_PROJECT: {
|
||||||
IProjectEntry projEntry = (IProjectEntry)entry;
|
IProjectEntry projEntry = (IProjectEntry) entry;
|
||||||
return CoreModel.newProjectEntry(projEntry.getPath(), projEntry.isExported());
|
return CoreModel.newProjectEntry(projEntry.getPath(), projEntry.isExported());
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_SOURCE : {
|
case IPathEntry.CDT_SOURCE: {
|
||||||
ISourceEntry source = (ISourceEntry)entry;
|
ISourceEntry source = (ISourceEntry) entry;
|
||||||
return CoreModel.newSourceEntry(resourcePath, source.getExclusionPatterns());
|
return CoreModel.newSourceEntry(resourcePath, source.getExclusionPatterns());
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_CONTAINER : {
|
case IPathEntry.CDT_CONTAINER: {
|
||||||
return CoreModel.newContainerEntry(entry.getPath(), entry.isExported());
|
return CoreModel.newContainerEntry(entry.getPath(), entry.isExported());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -425,13 +423,13 @@ public class PathEntryUtil {
|
||||||
if (!isValidWorkspacePath(project, path)) {
|
if (!isValidWorkspacePath(project, path)) {
|
||||||
return new CModelStatus(
|
return new CModelStatus(
|
||||||
ICModelStatusConstants.INVALID_PATHENTRY,
|
ICModelStatusConstants.INVALID_PATHENTRY,
|
||||||
CoreModelMessages.getFormattedString("PathEntryManager.0", new Object[]{ path.toOSString(), ((PathEntry)entry).getKindString()})); //$NON-NLS-1$
|
CoreModelMessages.getFormattedString("PathEntryManager.0", new Object[]{ path.toOSString(), ((PathEntry) entry).getKindString()})); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (entry.getEntryKind()) {
|
switch (entry.getEntryKind()) {
|
||||||
case IPathEntry.CDT_INCLUDE : {
|
case IPathEntry.CDT_INCLUDE: {
|
||||||
IIncludeEntry include = (IIncludeEntry)entry;
|
IIncludeEntry include = (IIncludeEntry) entry;
|
||||||
IPath includePath = include.getFullIncludePath();
|
IPath includePath = include.getFullIncludePath();
|
||||||
if (!isValidExternalPath(includePath)) {
|
if (!isValidExternalPath(includePath)) {
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY,
|
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY,
|
||||||
|
@ -443,8 +441,8 @@ public class PathEntryUtil {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_LIBRARY : {
|
case IPathEntry.CDT_LIBRARY: {
|
||||||
ILibraryEntry library = (ILibraryEntry)entry;
|
ILibraryEntry library = (ILibraryEntry) entry;
|
||||||
if (checkSourceAttachment) {
|
if (checkSourceAttachment) {
|
||||||
IPath sourceAttach = library.getSourceAttachmentPath();
|
IPath sourceAttach = library.getSourceAttachmentPath();
|
||||||
if (sourceAttach != null) {
|
if (sourceAttach != null) {
|
||||||
|
@ -467,8 +465,8 @@ public class PathEntryUtil {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_PROJECT : {
|
case IPathEntry.CDT_PROJECT: {
|
||||||
IProjectEntry projEntry = (IProjectEntry)entry;
|
IProjectEntry projEntry = (IProjectEntry) entry;
|
||||||
path = projEntry.getPath();
|
path = projEntry.getPath();
|
||||||
IProject reqProject = project.getWorkspace().getRoot().getProject(path.segment(0));
|
IProject reqProject = project.getWorkspace().getRoot().getProject(path.segment(0));
|
||||||
if (!reqProject.isAccessible()) {
|
if (!reqProject.isAccessible()) {
|
||||||
|
@ -481,10 +479,10 @@ public class PathEntryUtil {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_CONTAINER :
|
case IPathEntry.CDT_CONTAINER:
|
||||||
if (recurseInContainers) {
|
if (recurseInContainers) {
|
||||||
try {
|
try {
|
||||||
IPathEntryContainer cont = manager.getPathEntryContainer((IContainerEntry)entry, cProject);
|
IPathEntryContainer cont = manager.getPathEntryContainer((IContainerEntry) entry, cProject);
|
||||||
IPathEntry[] contEntries = cont.getPathEntries();
|
IPathEntry[] contEntries = cont.getPathEntries();
|
||||||
for (IPathEntry contEntrie : contEntries) {
|
for (IPathEntry contEntrie : contEntries) {
|
||||||
ICModelStatus status = validatePathEntry(cProject, contEntrie, checkSourceAttachment, false);
|
ICModelStatus status = validatePathEntry(cProject, contEntrie, checkSourceAttachment, false);
|
||||||
|
@ -633,20 +631,19 @@ public class PathEntryUtil {
|
||||||
public static int code2Severity(ICModelStatus status) {
|
public static int code2Severity(ICModelStatus status) {
|
||||||
int severity;
|
int severity;
|
||||||
switch (status.getCode()) {
|
switch (status.getCode()) {
|
||||||
case ICModelStatusConstants.INVALID_PATHENTRY :
|
case ICModelStatusConstants.INVALID_PATHENTRY:
|
||||||
severity = IMarker.SEVERITY_WARNING;
|
severity = IMarker.SEVERITY_WARNING;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ICModelStatusConstants.INVALID_PATH :
|
case ICModelStatusConstants.INVALID_PATH:
|
||||||
severity = IMarker.SEVERITY_WARNING;
|
severity = IMarker.SEVERITY_WARNING;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
default:
|
||||||
severity = IMarker.SEVERITY_ERROR;
|
severity = IMarker.SEVERITY_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return severity;
|
return severity;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue