mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics.
This commit is contained in:
parent
4daceaf58c
commit
64d21644a9
1 changed files with 31 additions and 34 deletions
|
@ -74,12 +74,12 @@ public class CIndex implements IIndex {
|
||||||
if (name instanceof IIndexFragmentName) {
|
if (name instanceof IIndexFragmentName) {
|
||||||
return adaptBinding(((IIndexFragmentName) name).getBinding());
|
return adaptBinding(((IIndexFragmentName) name).getBinding());
|
||||||
} else if (name instanceof IASTName) {
|
} else if (name instanceof IASTName) {
|
||||||
if(SPECIALCASE_SINGLES && fFragments.length==1) {
|
if (SPECIALCASE_SINGLES && fFragments.length == 1) {
|
||||||
return fFragments[0].findBinding((IASTName) name);
|
return fFragments[0].findBinding((IASTName) name);
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
||||||
IIndexFragmentBinding binding= fFragments[i].findBinding((IASTName) name);
|
IIndexFragmentBinding binding= fFragments[i].findBinding((IASTName) name);
|
||||||
if(binding!=null) {
|
if (binding!=null) {
|
||||||
return getCompositesFactory(binding.getLinkage().getLinkageID()).getCompositeBinding(binding);
|
return getCompositesFactory(binding.getLinkage().getLinkageID()).getCompositeBinding(binding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,13 +93,13 @@ public class CIndex implements IIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexBinding[] findBindings(Pattern[] patterns, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
|
public IIndexBinding[] findBindings(Pattern[] patterns, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
|
||||||
if(SPECIALCASE_SINGLES && fFragments.length==1) {
|
if (SPECIALCASE_SINGLES && fFragments.length == 1) {
|
||||||
return fFragments[0].findBindings(patterns, isFullyQualified, filter, monitor);
|
return fFragments[0].findBindings(patterns, isFullyQualified, filter, monitor);
|
||||||
} else {
|
} else {
|
||||||
List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
|
List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
|
||||||
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
||||||
for(int j=0; j < linkages.length; j++) {
|
for (int j = 0; j < linkages.length; j++) {
|
||||||
if(filter.acceptLinkage(linkages[j])) {
|
if (filter.acceptLinkage(linkages[j])) {
|
||||||
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
||||||
try {
|
try {
|
||||||
|
@ -120,13 +120,13 @@ public class CIndex implements IIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexBinding[] findMacroContainers(Pattern pattern, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
|
public IIndexBinding[] findMacroContainers(Pattern pattern, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
|
||||||
if(SPECIALCASE_SINGLES && fFragments.length==1) {
|
if (SPECIALCASE_SINGLES && fFragments.length == 1) {
|
||||||
return fFragments[0].findMacroContainers(pattern, filter, monitor);
|
return fFragments[0].findMacroContainers(pattern, filter, monitor);
|
||||||
} else {
|
} else {
|
||||||
List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
|
List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
|
||||||
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
||||||
for(int j=0; j < linkages.length; j++) {
|
for (int j = 0; j < linkages.length; j++) {
|
||||||
if(filter.acceptLinkage(linkages[j])) {
|
if (filter.acceptLinkage(linkages[j])) {
|
||||||
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
||||||
try {
|
try {
|
||||||
|
@ -182,8 +182,7 @@ public class CIndex implements IIndex {
|
||||||
final IIndexFile otherFile= fileMap.get(fileKey);
|
final IIndexFile otherFile= fileMap.get(fileKey);
|
||||||
if (otherFile == null) {
|
if (otherFile == null) {
|
||||||
fileMap.put(fileKey, file);
|
fileMap.put(fileKey, file);
|
||||||
}
|
} else if (!otherFile.equals(file)) { // same file in another fragment
|
||||||
else if (!otherFile.equals(file)) { // same file in another fragment
|
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,9 +262,9 @@ public class CIndex implements IIndex {
|
||||||
List<IIndexFile> nextLevel= depth != 0 ? new LinkedList<IIndexFile>() : null;
|
List<IIndexFile> nextLevel= depth != 0 ? new LinkedList<IIndexFile>() : null;
|
||||||
for (Iterator<IIndexFile> it= in.iterator(); it.hasNext(); ) {
|
for (Iterator<IIndexFile> it= in.iterator(); it.hasNext(); ) {
|
||||||
IIndexFragmentFile file = (IIndexFragmentFile) it.next();
|
IIndexFragmentFile file = (IIndexFragmentFile) it.next();
|
||||||
for (int j= 0; j < fPrimaryFragmentCount; j++) {
|
for (int j = 0; j < fPrimaryFragmentCount; j++) {
|
||||||
IIndexInclude[] includedBy= fFragments[j].findIncludedBy(file);
|
IIndexInclude[] includedBy= fFragments[j].findIncludedBy(file);
|
||||||
for (int k= 0; k < includedBy.length; k++) {
|
for (int k = 0; k < includedBy.length; k++) {
|
||||||
IIndexInclude include = includedBy[k];
|
IIndexInclude include = includedBy[k];
|
||||||
if (handled.add(include.getIncludedByLocation())) {
|
if (handled.add(include.getIncludedByLocation())) {
|
||||||
out.add(include);
|
out.add(include);
|
||||||
|
@ -301,7 +300,7 @@ public class CIndex implements IIndex {
|
||||||
for (Iterator<IIndexFile> it= in.iterator(); it.hasNext(); ) {
|
for (Iterator<IIndexFile> it= in.iterator(); it.hasNext(); ) {
|
||||||
IIndexFragmentFile file = (IIndexFragmentFile) it.next();
|
IIndexFragmentFile file = (IIndexFragmentFile) it.next();
|
||||||
IIndexInclude[] includes= file.getIncludes();
|
IIndexInclude[] includes= file.getIncludes();
|
||||||
for (int k= 0; k < includes.length; k++) {
|
for (int k = 0; k < includes.length; k++) {
|
||||||
IIndexInclude include = includes[k];
|
IIndexInclude include = includes[k];
|
||||||
IIndexFileLocation target= include.getIncludesLocation();
|
IIndexFileLocation target= include.getIncludesLocation();
|
||||||
Object key= target != null ? (Object) target : include.getFullName();
|
Object key= target != null ? (Object) target : include.getFullName();
|
||||||
|
@ -332,8 +331,7 @@ public class CIndex implements IIndex {
|
||||||
for (i = 0; i < fFragments.length; i++) {
|
for (i = 0; i < fFragments.length; i++) {
|
||||||
fFragments[i].acquireReadLock();
|
fFragments[i].acquireReadLock();
|
||||||
}
|
}
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
if (i < fFragments.length) {
|
if (i < fFragments.length) {
|
||||||
// rollback
|
// rollback
|
||||||
fReadLock--;
|
fReadLock--;
|
||||||
|
@ -347,7 +345,7 @@ public class CIndex implements IIndex {
|
||||||
|
|
||||||
public synchronized void releaseReadLock() {
|
public synchronized void releaseReadLock() {
|
||||||
if (--fReadLock == 0) {
|
if (--fReadLock == 0) {
|
||||||
for (int i=0; i < fFragments.length; i++) {
|
for (int i = 0; i < fFragments.length; i++) {
|
||||||
fFragments[i].releaseReadLock();
|
fFragments[i].releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,14 +357,14 @@ public class CIndex implements IIndex {
|
||||||
|
|
||||||
public long getLastWriteAccess() {
|
public long getLastWriteAccess() {
|
||||||
long result= 0;
|
long result= 0;
|
||||||
for (int i=0; i < fFragments.length; i++) {
|
for (int i = 0; i < fFragments.length; i++) {
|
||||||
result= Math.max(result, fFragments[i].getLastWriteAccess());
|
result= Math.max(result, fFragments[i].getLastWriteAccess());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexBinding[] findBindings(char[][] names, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
|
public IIndexBinding[] findBindings(char[][] names, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
|
||||||
if(SPECIALCASE_SINGLES && fFragments.length==1) {
|
if (SPECIALCASE_SINGLES && fFragments.length == 1) {
|
||||||
try {
|
try {
|
||||||
return fFragments[0].findBindings(names, filter, monitor);
|
return fFragments[0].findBindings(names, filter, monitor);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -380,8 +378,8 @@ public class CIndex implements IIndex {
|
||||||
List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
|
List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
|
||||||
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
||||||
monitor.beginTask(Messages.CIndex_FindBindingsTask_label, fFragments.length * linkages.length);
|
monitor.beginTask(Messages.CIndex_FindBindingsTask_label, fFragments.length * linkages.length);
|
||||||
for(int j=0; j < linkages.length; j++) {
|
for (int j = 0; j < linkages.length; j++) {
|
||||||
if(filter.acceptLinkage(linkages[j])) {
|
if (filter.acceptLinkage(linkages[j])) {
|
||||||
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
||||||
try {
|
try {
|
||||||
|
@ -405,7 +403,7 @@ public class CIndex implements IIndex {
|
||||||
|
|
||||||
public IIndexBinding adaptBinding(IBinding binding) {
|
public IIndexBinding adaptBinding(IBinding binding) {
|
||||||
try {
|
try {
|
||||||
if(SPECIALCASE_SINGLES && fFragments.length==1) {
|
if (SPECIALCASE_SINGLES && fFragments.length == 1) {
|
||||||
return fFragments[0].adaptBinding(binding);
|
return fFragments[0].adaptBinding(binding);
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
||||||
|
@ -431,12 +429,12 @@ public class CIndex implements IIndex {
|
||||||
|
|
||||||
private IIndexBinding[] flatten(List<IIndexBinding[]> bindingArrays) {
|
private IIndexBinding[] flatten(List<IIndexBinding[]> bindingArrays) {
|
||||||
int size = 0;
|
int size = 0;
|
||||||
for(int i=0; i<bindingArrays.size(); i++) {
|
for (int i = 0; i<bindingArrays.size(); i++) {
|
||||||
size += bindingArrays.get(i).length;
|
size += bindingArrays.get(i).length;
|
||||||
}
|
}
|
||||||
IIndexBinding[] result = new IIndexBinding[size];
|
IIndexBinding[] result = new IIndexBinding[size];
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
for(int i=0; i<bindingArrays.size(); i++) {
|
for (int i = 0; i<bindingArrays.size(); i++) {
|
||||||
IBinding[] src = bindingArrays.get(i);
|
IBinding[] src = bindingArrays.get(i);
|
||||||
System.arraycopy(src, 0, result, offset, src.length);
|
System.arraycopy(src, 0, result, offset, src.length);
|
||||||
offset += src.length;
|
offset += src.length;
|
||||||
|
@ -464,19 +462,19 @@ public class CIndex implements IIndex {
|
||||||
private ICompositesFactory getCompositesFactory(int linkageID) {
|
private ICompositesFactory getCompositesFactory(int linkageID) {
|
||||||
switch (linkageID) {
|
switch (linkageID) {
|
||||||
case ILinkage.CPP_LINKAGE_ID:
|
case ILinkage.CPP_LINKAGE_ID:
|
||||||
if(cppCF==null) {
|
if (cppCF == null) {
|
||||||
cppCF = new CPPCompositesFactory(new CIndex(fFragments, fFragments.length));
|
cppCF = new CPPCompositesFactory(new CIndex(fFragments, fFragments.length));
|
||||||
}
|
}
|
||||||
return cppCF;
|
return cppCF;
|
||||||
|
|
||||||
case ILinkage.C_LINKAGE_ID:
|
case ILinkage.C_LINKAGE_ID:
|
||||||
if(cCF==null) {
|
if (cCF == null) {
|
||||||
cCF = new CCompositesFactory(new CIndex(fFragments, fFragments.length));
|
cCF = new CCompositesFactory(new CIndex(fFragments, fFragments.length));
|
||||||
}
|
}
|
||||||
return cCF;
|
return cCF;
|
||||||
|
|
||||||
case ILinkage.FORTRAN_LINKAGE_ID:
|
case ILinkage.FORTRAN_LINKAGE_ID:
|
||||||
if(fCF==null) {
|
if (fCF == null) {
|
||||||
fCF = new CCompositesFactory(new CIndex(fFragments, fFragments.length));
|
fCF = new CCompositesFactory(new CIndex(fFragments, fFragments.length));
|
||||||
}
|
}
|
||||||
// This is a placeholder - it will throw CompositingNotImplementedError
|
// This is a placeholder - it will throw CompositingNotImplementedError
|
||||||
|
@ -500,13 +498,13 @@ public class CIndex implements IIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexBinding[] findBindingsForPrefix(char[] prefix, boolean filescope, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
|
public IIndexBinding[] findBindingsForPrefix(char[] prefix, boolean filescope, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
|
||||||
if(SPECIALCASE_SINGLES && fFragments.length==1) {
|
if (SPECIALCASE_SINGLES && fFragments.length == 1) {
|
||||||
return fFragments[0].findBindingsForPrefix(prefix, filescope, filter, monitor);
|
return fFragments[0].findBindingsForPrefix(prefix, filescope, filter, monitor);
|
||||||
} else {
|
} else {
|
||||||
List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
|
List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
|
||||||
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
||||||
for(int j=0; j < linkages.length; j++) {
|
for (int j = 0; j < linkages.length; j++) {
|
||||||
if(filter.acceptLinkage(linkages[j])) {
|
if (filter.acceptLinkage(linkages[j])) {
|
||||||
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
||||||
try {
|
try {
|
||||||
|
@ -527,13 +525,13 @@ public class CIndex implements IIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexBinding[] findBindings(char[] name, boolean filescope, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
|
public IIndexBinding[] findBindings(char[] name, boolean filescope, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
|
||||||
if(SPECIALCASE_SINGLES && fFragments.length==1) {
|
if (SPECIALCASE_SINGLES && fFragments.length == 1) {
|
||||||
return fFragments[0].findBindings(name, filescope, filter, monitor);
|
return fFragments[0].findBindings(name, filescope, filter, monitor);
|
||||||
} else {
|
} else {
|
||||||
List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
|
List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
|
||||||
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
ILinkage[] linkages = Linkage.getIndexerLinkages();
|
||||||
for(int j=0; j < linkages.length; j++) {
|
for (int j = 0; j < linkages.length; j++) {
|
||||||
if(filter.acceptLinkage(linkages[j])) {
|
if (filter.acceptLinkage(linkages[j])) {
|
||||||
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
||||||
try {
|
try {
|
||||||
|
@ -580,8 +578,7 @@ public class CIndex implements IIndex {
|
||||||
if (!allowedFiles.contains(file)) {
|
if (!allowedFiles.contains(file)) {
|
||||||
if (handledIFLs.add(file.getLocation())) {
|
if (handledIFLs.add(file.getLocation())) {
|
||||||
allowedFiles.add(file);
|
allowedFiles.add(file);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue