List of usage examples for org.eclipse.jdt.internal.core.builder State getReferences
public SimpleLookupTable getReferences()
From source file:com.codenvy.ide.ext.java.server.internal.core.search.IndexSelector.java
License:Open Source License
private static boolean canSeeFocus(IJavaElement focus, JavaProject javaProject, char[][][] focusQualifiedNames) { try {//from ww w .j a va 2 s. c om if (focus == null) return false; if (focus.equals(javaProject)) return true; if (focus instanceof JarPackageFragmentRoot) { // focus is part of a jar IPath focusPath = focus.getPath(); IClasspathEntry[] entries = javaProject.getExpandedClasspath(); for (int i = 0, length = entries.length; i < length; i++) { IClasspathEntry entry = entries[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY && entry.getPath().equals(focusPath)) return true; } return false; } // look for dependent projects IPath focusPath = ((JavaProject) focus).getProject().getFullPath(); IClasspathEntry[] entries = javaProject.getExpandedClasspath(); for (int i = 0, length = entries.length; i < length; i++) { IClasspathEntry entry = entries[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT && entry.getPath().equals(focusPath)) { if (focusQualifiedNames != null) { // builder state is usable, hence use it to try to reduce project which can see the focus... State projectState = (State) JavaModelManager.getJavaModelManager() .getLastBuiltState(javaProject.getProject(), null); if (projectState != null) { Object[] values = projectState.getReferences().valueTable; int vLength = values.length; for (int j = 0; j < vLength; j++) { if (values[j] == null) continue; ReferenceCollection references = (ReferenceCollection) values[j]; if (references.includes(focusQualifiedNames, null, null)) { return true; } } return false; } } return true; } } return false; } catch (JavaModelException e) { return false; } }
From source file:org.eclipse.che.jdt.internal.core.search.IndexSelector.java
License:Open Source License
private static int canSeeFocus(IJavaElement focus, JavaProject javaProject, char[][][] focusQualifiedNames) { try {/*ww w . ja v a 2 s . c om*/ if (focus == null) return PROJECT_CAN_NOT_SEE_FOCUS; if (focus.equals(javaProject)) return PROJECT_CAN_SEE_FOCUS; if (focus instanceof JarPackageFragmentRoot) { // focus is part of a jar IPath focusPath = focus.getPath(); IClasspathEntry[] entries = javaProject.getExpandedClasspath(); for (int i = 0, length = entries.length; i < length; i++) { IClasspathEntry entry = entries[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY && entry.getPath().equals(focusPath)) return PROJECT_CAN_SEE_FOCUS; } return PROJECT_CAN_NOT_SEE_FOCUS; } // look for dependent projects IPath focusPath = ((JavaProject) focus).getProject().getFullPath(); IClasspathEntry[] entries = javaProject.getExpandedClasspath(); for (int i = 0, length = entries.length; i < length; i++) { IClasspathEntry entry = entries[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT && entry.getPath().equals(focusPath)) { if (focusQualifiedNames != null) { // builder state is usable, hence use it to try to reduce project which can see the focus... State projectState = (State) JavaModelManager.getJavaModelManager() .getLastBuiltState(javaProject.getProject(), null); if (projectState != null) { Object[] values = projectState.getReferences().valueTable; int vLength = values.length; for (int j = 0; j < vLength; j++) { if (values[j] == null) continue; ReferenceCollection references = (ReferenceCollection) values[j]; if (references.includes(focusQualifiedNames, null, null)) { return PROJECT_CAN_SEE_FOCUS; } } return PROJECT_SOURCE_CAN_NOT_SEE_FOCUS; } } return PROJECT_CAN_SEE_FOCUS; } } return PROJECT_CAN_NOT_SEE_FOCUS; } catch (JavaModelException e) { return PROJECT_CAN_NOT_SEE_FOCUS; } }
From source file:org.eclipse.pde.api.tools.internal.builder.IncrementalApiBuilder.java
License:Open Source License
/** * Adds the dependent files from the current build context based on the * current JDT build state to either the structural or description * dependents./*w ww .j a v a2s .c o m*/ * * @param project the current project being built * @param state the current JDT build state * @param types dot and $ qualified names of base types that changed * @param kind mask of STRUCTURAL or DESCRIPTION */ private void addDependents(final IProject project, State state, String[] types, int kind) { StringSet packages = new StringSet(16); StringSet typenames = new StringSet(16); for (int i = 0; i < types.length; i++) { if (types[i] != null) { splitName(types[i], packages, typenames); } } // the qualifiedStrings are of the form 'p1/p2' & the simpleStrings are // just 'X' char[][][] internedQualifiedNames = ReferenceCollection.internQualifiedNames(packages); // if a well known qualified name was found then we can skip over these if (internedQualifiedNames.length < packages.elementSize) { internedQualifiedNames = null; } char[][] internedSimpleNames = ReferenceCollection.internSimpleNames(typenames, true); // if a well known name was found then we can skip over these if (internedSimpleNames.length < typenames.elementSize) { internedSimpleNames = null; } Object[] keyTable = state.getReferences().keyTable; Object[] valueTable = state.getReferences().valueTable; IFile file = null; String typeLocator = null; for (int i = 0; i < valueTable.length; i++) { typeLocator = (String) keyTable[i]; if (typeLocator != null) { ReferenceCollection refs = (ReferenceCollection) valueTable[i]; if (refs.includes(internedQualifiedNames, internedSimpleNames, null)) { file = project.getFile(typeLocator); if (file == null) { continue; } if (ApiPlugin.DEBUG_BUILDER) { System.out.println("ApiAnalysisBuilder: adding affected source file " + file.getName()); //$NON-NLS-1$ } addDependentTypeToContext(file, kind); } } } }