blob: a4200163b93961fa4436779510627c686de0b9d1 (
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
77
78
79
80
|
/*******************************************************************************
* Copyright (c) 2011 Google, Inc 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:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.index;
import org.eclipse.cdt.core.index.IIndexFileLocation;
import org.eclipse.cdt.core.parser.ISignificantMacros;
/**
* A key that uniquely determines the preprocessed contents of a file.
*/
public class FileContentKey {
private final int linkageID;
private final IIndexFileLocation location;
private final ISignificantMacros significantMacros;
/**
* Creates a file content key.
* @param location the file location.
*/
public FileContentKey(int linkageID, IIndexFileLocation location, ISignificantMacros sigMacros) {
this.linkageID= linkageID;
this.location = location;
this.significantMacros = sigMacros;
}
public int getLinkageID() {
return linkageID;
}
public IIndexFileLocation getLocation() {
return location;
}
public ISignificantMacros getSignificantMacros() {
return significantMacros;
}
@Override
public int hashCode() {
return (linkageID + location.hashCode() * 31) * 31 + significantMacros.hashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
FileContentKey other = (FileContentKey) obj;
if (linkageID != other.linkageID)
return false;
if (!location.equals(other.location))
return false;
if (!significantMacros.equals(other.significantMacros))
return false;
return true;
}
@SuppressWarnings("nls")
@Override
public String toString() {
return linkageID + ": " + location.getURI().toString() + "[" + significantMacros.hashCode() + "]";
}
}
|