blob: 375d8040abcf65ac84ab0a8275e9efb24ee6e747 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/*******************************************************************************
* Copyright (c) 2006, 2012 Nokia and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Nokia - Initial implementation (159833)
* Broadcom - http://bugs.eclipse.org/247853
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.debug.core.sourcelookup;
import java.io.File;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.internal.core.sourcelookup.SourceUtils;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainer;
public class AbsolutePathSourceContainer extends AbstractSourceContainer {
/**
* Unique identifier for the absolute source container type
* (value <code>org.eclipse.cdt.debug.core.containerType.absolutePath</code>).
*/
public static final String TYPE_ID = CDebugCorePlugin.getUniqueIdentifier() + ".containerType.absolutePath"; //$NON-NLS-1$
public boolean isValidAbsoluteFilePath(String name) {
return isValidAbsoluteFilePath(new File(name));
}
public boolean isValidAbsoluteFilePath(File file) {
return file.isAbsolute() && file.exists() && file.isFile();
}
@Override
public Object[] findSourceElements(String name) throws CoreException {
if (name != null) {
File file = new File(name);
if (isValidAbsoluteFilePath(file)) {
return SourceUtils.findSourceElements(file, getDirector());
}
}
return new Object[0];
}
@Override
public String getName() {
return SourceLookupMessages.AbsolutePathSourceContainer_0;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getType()
*/
@Override
public ISourceContainerType getType() {
return getSourceContainerType(TYPE_ID);
}
@Override
public int hashCode() {
return TYPE_ID.hashCode();
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof AbsolutePathSourceContainer))
return false;
return true;
}
}
|