private ISourceTagProvider createSourceTagProvider(IStorage storage) { ITranslationUnit tUnit = null; if (storage instanceof IFile) { tUnit = (ITranslationUnit) CoreModel.getDefault().create((IFile) storage); } else if (storage instanceof IFileState) { ICModel cModel = CoreModel.getDefault().getCModel(); ICProject[] cProjects; try { cProjects = cModel.getCProjects(); if (cProjects.length > 0) { tUnit = CoreModel.getDefault().createTranslationUnitFrom(cProjects[0], storage.getFullPath()); } } catch (CModelException e) { } } else { IEditorInput input = CDTUITools.getEditorInputForLocation(storage.getFullPath(), null); if (input != null) { tUnit = (ITranslationUnit) input.getAdapter(ITranslationUnit.class); } } if (tUnit != null) { return new CSourceTagProvider(tUnit); } return null; }
public void testCPathEntriesForOldStyle() throws Exception { p2 = CProjectHelper.createCCProject(PROJ_NAME_PREFIX + "b", null, IPDOMManager.ID_NO_INDEXER); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); IProject project = p2.getProject(); ICProjectDescription des = mngr.getProjectDescription(project, false); assertNotNull(des); assertEquals(1, des.getConfigurations().length); assertFalse(mngr.isNewStyleProject(des)); assertFalse(mngr.isNewStyleProject(project)); IPathEntry[] entries = CoreModel.getRawPathEntries(p2); entries = concatEntries( entries, new IPathEntry[] { CoreModel.newSourceEntry(project.getFullPath().append("test_src")), CoreModel.newOutputEntry(project.getFullPath().append("test_out")), }); CoreModel.setRawPathEntries(p2, entries, null); ICSourceEntry[] expectedSourceEntries = new ICSourceEntry[] { new CSourceEntry( project.getFullPath(), new IPath[] {new Path("test_src")}, ICSettingEntry.RESOLVED), new CSourceEntry(project.getFullPath().append("test_src"), null, ICSettingEntry.RESOLVED), }; ICOutputEntry[] expectedOutputEntries = new ICOutputEntry[] { new COutputEntry( project.getFullPath(), null, ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH), new COutputEntry( project.getFullPath().append("test_out"), null, ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH), }; des = mngr.getProjectDescription(project, false); ICConfigurationDescription cfg = des.getDefaultSettingConfiguration(); ICSourceEntry[] sEntries = cfg.getSourceEntries(); ICOutputEntry[] oEntries = cfg.getBuildSetting().getOutputDirectories(); checkCEntriesMatch(expectedSourceEntries, sEntries); checkCEntriesMatch(expectedOutputEntries, oEntries); des = mngr.getProjectDescription(project, true); cfg = des.getDefaultSettingConfiguration(); sEntries = cfg.getSourceEntries(); oEntries = cfg.getBuildSetting().getOutputDirectories(); checkCEntriesMatch(expectedSourceEntries, sEntries); checkCEntriesMatch(expectedOutputEntries, oEntries); }
/* * @see org.eclipse.cdt.internal.ui.BaseCElementContentProvider#getChildren(java.lang.Object) */ @Override public Object[] getChildren(Object element) { if (element instanceof IWorkspaceRoot) { IWorkspaceRoot root = (IWorkspaceRoot) element; IProject[] projects = root.getProjects(); List<ICProject> list = new ArrayList<ICProject>(projects.length); for (int i = 0; i < projects.length; i++) { if (CoreModel.hasCNature(projects[i])) { list.add(CoreModel.getDefault().create(projects[i])); } } return list.toArray(); } return super.getChildren(element); }
private ITranslationUnit getTranslationUnit(IFile file) { Object element = CoreModel.getDefault().create(file); if (element instanceof ITranslationUnit) { return (ITranslationUnit) element; } return null; }
/** * Clone a configuration and put it on the tmp list if it is not already a saved configuration and * not already on the tmp list. * * @param p project * @param oldId the id of the old configuration to clone * @param cfgd the configuration descriptor for the clone * @return true if the configuration is already saved, false otherwise */ public synchronized boolean cloneCfg(IProject p, String oldId, ICConfigurationDescription cfgd) { if (isConfigurationAlreadySaved(p, cfgd)) return true; Map<String, IAConfiguration> tmpList = getTmpConfigs(p); String newId = cfgd.getId(); // Don't bother if the new configuration is already on the tmp list IAConfiguration cfg = tmpList.get(newId); if (cfg != null) return false; // Otherwise, try and find the old id to copy the configuration from // or punt if not found IAConfiguration oldCfg = null; Map<String, IAConfiguration> savedList = getSavedConfigs(p); if (savedList != null) oldCfg = savedList.get(oldId); if (oldCfg != null) { IAConfiguration newCfg = oldCfg.copy(cfgd.getId()); tmpList.put(cfgd.getId(), newCfg); // Check to see if the new configuration is already stored as part of the project description. // If yes, it should already be saved. This can occur if the configuration was added as part // of // another CDT Property page and the Autotools Property page was never opened. if (CoreModel.getDefault().getProjectDescription(p).getConfigurationById(newId) != null) { addConfiguration(p, newCfg); return true; } } return false; }
public synchronized void saveConfigs(IProject project) { synchronized (project) { ICConfigurationDescription[] cfgds = CoreModel.getDefault().getProjectDescription(project).getConfigurations(); saveConfigs(project, cfgds); } }
/* (non-Javadoc) * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { if (this.viewer == null) { MakeCorePlugin.getDefault().getTargetManager().addListener(this); } this.viewer = (StructuredViewer) viewer; IWorkspace oldWorkspace = null; IWorkspace newWorkspace = null; if (oldInput instanceof IWorkspace) { oldWorkspace = (IWorkspace) oldInput; } else if (oldInput instanceof IContainer) { oldWorkspace = ((IContainer) oldInput).getWorkspace(); } else if (oldInput instanceof TargetSourceContainer) { oldWorkspace = ((TargetSourceContainer) oldInput).getContainer().getWorkspace(); } if (newInput instanceof IWorkspace) { newWorkspace = (IWorkspace) newInput; } else if (newInput instanceof IContainer) { newWorkspace = ((IContainer) newInput).getWorkspace(); } else if (newInput instanceof TargetSourceContainer) { newWorkspace = ((TargetSourceContainer) newInput).getContainer().getWorkspace(); } if (oldWorkspace != newWorkspace) { ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); if (oldWorkspace != null) { InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).removePreferenceChangeListener(this); mngr.removeCProjectDescriptionListener(this); oldWorkspace.removeResourceChangeListener(this); } if (newWorkspace != null) { newWorkspace.addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE); mngr.addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED); InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).addPreferenceChangeListener(this); } } }
protected CPElement[] openWorkspacePathEntryDialog(CPElement existing) { Class<?>[] acceptedClasses = new Class[] {ICProject.class, IProject.class, IContainer.class, ICContainer.class}; TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, existing == null); ViewerFilter filter = new TypedViewerFilter(acceptedClasses); String title = (existing == null) ? CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_new_title : CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_edit_title; String message = (existing == null) ? CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_new_description : CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_edit_description; ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog( getShell(), new WorkbenchLabelProvider(), new CElementContentProvider()); dialog.setValidator(validator); dialog.setTitle(title); dialog.setMessage(message); dialog.addFilter(filter); dialog.setInput(CoreModel.getDefault().getCModel()); if (existing == null) { dialog.setInitialSelection(fCurrCProject); } else { dialog.setInitialSelection(existing.getCProject()); } if (dialog.open() == Window.OK) { Object[] elements = dialog.getResult(); CPElement[] res = new CPElement[elements.length]; for (int i = 0; i < res.length; i++) { IProject project; IPath includePath; if (elements[i] instanceof IResource) { project = ((IResource) elements[i]).getProject(); includePath = ((IResource) elements[i]).getProjectRelativePath(); } else { project = ((ICElement) elements[i]).getCProject().getProject(); includePath = ((ICElement) elements[i]).getResource().getProjectRelativePath(); } CPElementGroup group = getSelectedGroup(); res[i] = new CPElement( fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(), group.getResource()); res[i].setAttribute(CPElement.BASE, project.getFullPath().makeRelative()); res[i].setAttribute(CPElement.INCLUDE, includePath); } return res; } return null; }
/** @see IncrementalProjectBuilder#build */ @Override protected IProject[] build( int kind, @SuppressWarnings("rawtypes") Map args, IProgressMonitor monitor) throws CoreException { if (DEBUG_EVENTS) { @SuppressWarnings("unchecked") Map<String, String> argsMap = args; printEvent(kind, argsMap); } // If auto discovery is disabled, do nothing // boolean autodiscoveryEnabled; // boolean autodiscoveryEnabled2; // IScannerConfigBuilderInfo2 buildInfo2 = null; // IConfiguration cfg = ScannerConfigUtil.getActiveConfiguration(getProject()); IManagedBuildInfo bInfo = ManagedBuildManager.getBuildInfo(getProject()); if (bInfo != null) { IConfiguration cfgs[] = bInfo.getManagedProject().getConfigurations(); if (cfgs.length != 0) { if (!needAllConfigBuild()) { ICProjectDescription des = CoreModel.getDefault().getProjectDescription(getProject(), false); IConfiguration cfg = null; if (des != null) { ICConfigurationDescription settingCfgDes = des.getDefaultSettingConfiguration(); if (settingCfgDes != null) { for (int i = 0; i < cfgs.length; i++) { if (settingCfgDes.getId().equals(cfgs[i].getId())) { cfg = cfgs[i]; break; } } } } if (cfg != null) { cfgs = new IConfiguration[] {cfg}; } else { cfgs = new IConfiguration[0]; } } int numWork = cfgs.length; if (numWork > 0) { monitor.beginTask( MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder"), numWork); //$NON-NLS-1$ for (int i = 0; i < cfgs.length; i++) { build(cfgs[i], 0, new SubProgressMonitor(monitor, 1)); } } } CfgDiscoveredPathManager.getInstance().updateCoreSettings(getProject(), cfgs); } return getProject().getReferencedProjects(); }
private ICConfigurationDescription[] getCfgs(IProject prj) { ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(prj, false); if (prjd != null) { ICConfigurationDescription[] cfgs = prjd.getConfigurations(); if (cfgs != null) { return cfgs; } } return new ICConfigurationDescription[0]; }
/** * Gets the CDT environment from the CDT project's configuration referenced by the launch * * @since 3.0 */ public static String[] getLaunchEnvironment(ILaunchConfiguration config) throws CoreException { // Get the project String projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null); if (projectName == null) { return null; } projectName = projectName.trim(); if (projectName.length() == 0) { return null; } IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); if (project == null || !project.isAccessible()) return null; ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project, false); // Not a CDT project? if (projDesc == null) return null; String buildConfigID = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, ""); // $NON-NLS-1$ ICConfigurationDescription cfg = null; if (buildConfigID.length() != 0) cfg = projDesc.getConfigurationById(buildConfigID); // if configuration is null fall-back to active if (cfg == null) cfg = projDesc.getActiveConfiguration(); // Environment variables and inherited vars HashMap<String, String> envMap = new HashMap<String, String>(); IEnvironmentVariable[] vars = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(cfg, true); for (IEnvironmentVariable var : vars) envMap.put(var.getName(), var.getValue()); // Add variables from build info ICdtVariable[] build_vars = CCorePlugin.getDefault().getCdtVariableManager().getVariables(cfg); for (ICdtVariable var : build_vars) { try { envMap.put(var.getName(), var.getStringValue()); } catch (CdtVariableException e) { // Some Eclipse dynamic variables can't be resolved dynamically... we don't care. } } // Turn it into an envp format List<String> strings = new ArrayList<String>(envMap.size()); for (Entry<String, String> entry : envMap.entrySet()) { StringBuffer buffer = new StringBuffer(entry.getKey()); buffer.append('=').append(entry.getValue()); strings.add(buffer.toString()); } return strings.toArray(new String[strings.size()]); }
@Override public void launch(ISelection selection, String mode) { if (!(selection instanceof IStructuredSelection)) { return; } Object s = ((IStructuredSelection) selection).getFirstElement(); if (!(s instanceof IAdaptable)) { return; } IResource r = (IResource) ((IAdaptable) s).getAdapter(IResource.class); if (r == null) { return; } IProject project = r.getProject(); if (project == null) { return; } // verify that this is a non library Android project ProjectState state = Sdk.getProjectState(project); if (state == null || state.isLibrary()) { return; } // verify that this project has C/C++ nature if (!CoreModel.hasCCNature(project) && !CoreModel.hasCNature(project)) { AndmoreAndroidPlugin.printErrorToConsole( project, String.format( "Selected project (%s) does not have C/C++ nature. " + "To add native support, right click on the project, " + "Android Tools -> Add Native Support", project.getName())); return; } debugProject(project, mode); }
/** @see org.eclipse.jface.viewers.IContentProvider#dispose() */ @Override public void dispose() { super.dispose(); if (fListener != null) { CoreModel.getDefault().removeElementChangedListener(fListener); fListener = null; } if (fPropertyListener != null) { PreferenceConstants.getPreferenceStore().removePropertyChangeListener(fPropertyListener); fPropertyListener = null; } }
/* * @see org.eclipse.cdt.internal.ui.BaseCElementContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { boolean isTU = newInput instanceof ITranslationUnit; if (isTU) { root = (ITranslationUnit) newInput; if (fListener == null) { fListener = new ElementChangedListener(); CoreModel.getDefault().addElementChangedListener(fListener); fPropertyListener = new PropertyListener(); PreferenceConstants.getPreferenceStore().addPropertyChangeListener(fPropertyListener); } } else { if (fListener != null) { CoreModel.getDefault().removeElementChangedListener(fListener); PreferenceConstants.getPreferenceStore().removePropertyChangeListener(fPropertyListener); fListener = null; fPropertyListener = null; } root = null; } }
@Override public ICConfigurationDescription resolveSelectedConfiguration() { ICConfigurationDescription result = null; IProject project = resolveProject(); if (project != null) { ICProjectDescription desc = CoreModel.getDefault().getProjectDescription(project); if (desc != null) { result = desc.getConfigurationById(getSelectedConfigurationID()); } } return result; }
private void initProjects() { ArrayList<ICProject> input = new ArrayList<ICProject>(); ICProject[] projects; try { projects = CoreModel.getDefault().getCModel().getCProjects(); for (ICProject project : projects) { if (project.getProject().isOpen()) { input.add(project); } } } catch (CModelException e) { CUIPlugin.log(e); } fProjectViewer.setInput(input); }
/** * Synchronize the current set of configurations for the project with the Autotools saved * configuration data. This is required when configuration management occurs outside of the * Autotools Configure Settings page in the Property menu. * * @param project to synchronize configurations for */ public synchronized void syncConfigurations(IProject project) { setSyncing(true); clearTmpConfigurations(project); ICProjectDescription pd = CoreModel.getDefault().getProjectDescription(project); ICConfigurationDescription[] cfgs = pd.getConfigurations(); Map<String, IAConfiguration> newCfgList = new HashMap<>(); for (int i = 0; i < cfgs.length; ++i) { cfgs[i].getConfigurationData(); IAConfiguration acfg = getTmpConfiguration(project, cfgs[i]); newCfgList.put(cfgs[i].getId(), acfg); } setSyncing(false); clearTmpConfigurations(project); replaceProjectConfigurations(project, newCfgList); }
public DiscoveredScannerInfo getDiscoveredScannerInfo(IProject project, boolean cacheInfo) throws CoreException { DiscoveredScannerInfo scannerInfo = null; // See if there's already one associated with the resource for this // session scannerInfo = (DiscoveredScannerInfo) project.getSessionProperty(scannerInfoProperty); if (scannerInfo == null) { scannerInfo = new DiscoveredScannerInfo(project); // this will convert user info org.eclipse.cdt.make.core.MakeScannerInfo makeScannerInfo = org.eclipse.cdt.make.core.MakeScannerProvider.getDefault() .getMakeScannerInfo(project, cacheInfo); scannerInfo.setUserScannerInfo(makeScannerInfo); // migrate to new C Path Entries IContainerEntry container = CoreModel.newContainerEntry(DiscoveredPathContainer.CONTAINER_ID); ICProject cProject = CoreModel.getDefault().create(project); if (cProject != null) { IPathEntry[] entries = cProject.getRawPathEntries(); List<IPathEntry> newEntries = new ArrayList<IPathEntry>(Arrays.asList(entries)); if (!newEntries.contains(container)) { newEntries.add(container); cProject.setRawPathEntries(newEntries.toArray(new IPathEntry[newEntries.size()]), null); } } ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project); descriptor.remove( CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID); // remove scanner provider which will fallback to // default // cpath provider. // place holder to that we don't convert again. project.setSessionProperty(scannerInfoProperty, scannerInfo); } return scannerInfo; }
public void resourceChanged(IResourceChangeEvent event) { IResourceDelta rootDelta = event.getDelta(); for (IResourceDelta projectDelta : rootDelta.getAffectedChildren()) { for (IResourceDelta fileDelta : projectDelta.getAffectedChildren()) { if (fileDelta.getResource().getName().endsWith(".spd.xml")) { // Refresh the dynamic C++ include paths in case there has been change to a shared // library in // the SDR. CoreModel.getDefault() .getProjectDescriptionManager() .updateExternalSettingsProviders( new String[] {ExternalSettingProvider.ID}, new NullProgressMonitor()); } } } }
@Override public Collection<ICConfigurationDescription> resolveConfigurations() { ICConfigurationDescription[] result = null; IProject project = resolveProject(); if (project != null) { ICProjectDescription desc = CoreModel.getDefault().getProjectDescription(project); if (desc != null) { result = desc.getConfigurations(); } } return (result == null) ? Collections.<ICConfigurationDescription>emptyList() : Arrays.asList(result); }
private boolean isIndexerAffected() { ICProjectDescription desc = CoreModel.getDefault().getProjectDescription(getProject(), false); if (desc == null || desc.isCdtProjectCreating()) return false; Iterator<InternalTab> it = itabs.iterator(); while (it.hasNext()) { InternalTab tab = it.next(); if (tab != null) { ICPropertyTab tabtab = tab.tab; if (tabtab instanceof AbstractCPropertyTab && ((AbstractCPropertyTab) tabtab).isIndexerAffected()) { return true; } } } return false; }
/** * @param cpentry * @param str */ private void addParentInfo(CPElement cpentry, StringBuffer str) { if (bShowParentInfo) { CPElement parent = cpentry.getParentContainer(); if (parent != null) { str.append(" ["); // $NON-NLS-1$ try { IPathEntryContainer container = CoreModel.getPathEntryContainer(cpentry.getPath(), cpentry.getCProject()); if (container != null) { str.append(container.getDescription()); } } catch (CModelException e) { str.append(parent.getPath()); } str.append(']'); } } }
@Override public void activate() { ICConfigurationDescription config = resolveSelectedConfiguration(); if (config != null) { ICProjectDescription desc = config.getProjectDescription(); if (desc.getActiveConfiguration() != config) { try { IProject project = desc.getProject(); desc.setActiveConfiguration(config); CoreModel.getDefault().setProjectDescription(project, desc); } catch (CoreException e) { CUIPlugin.log(e); } } } }
private boolean hasCProjects(IWorkingSet workingSet) { boolean result = false; if (workingSet != null) { IAdaptable[] members = workingSet.getElements(); for (IAdaptable next : members) { IProject project = next.getAdapter(IProject.class); if ((project != null) && CoreModel.hasCNature(project)) { result = true; break; } } } return result; }
private IFile getFileForPathImpl(IPath path, IProject project) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); if (path.isAbsolute()) { IFile c = root.getFileForLocation(path); return c; } if (project != null && project.exists()) { ICProject cproject = CoreModel.getDefault().create(project); if (cproject != null) { try { ISourceRoot[] roots = cproject.getAllSourceRoots(); for (ISourceRoot sourceRoot : roots) { IResource r = sourceRoot.getResource(); if (r instanceof IContainer) { IContainer parent = (IContainer) r; IResource res = parent.findMember(path); if (res != null && res.exists() && res instanceof IFile) { IFile file = (IFile) res; return file; } } } IOutputEntry entries[] = cproject.getOutputEntries(); for (IOutputEntry pathEntry : entries) { IPath p = pathEntry.getPath(); IResource r = root.findMember(p); if (r instanceof IContainer) { IContainer parent = (IContainer) r; IResource res = parent.findMember(path); if (res != null && res.exists() && res instanceof IFile) { IFile file = (IFile) res; return file; } } } } catch (CModelException _) { Activator.getDefault().getLog().log(_.getStatus()); } } } return null; }
/** @since 1.2 */ public synchronized Map<String, IAutotoolsOption> getAutotoolsCfgOptions( IProject project, String cfgId) throws CoreException { // Verify project is valid Autotools project if (project == null || !project.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)) { throw new CoreException( new Status( IStatus.ERROR, AutotoolsPlugin.PLUGIN_ID, ConfigureMessages.getString(INVALID_AUTOTOOLS_PROJECT))); } // Verify configuration id is valid ICConfigurationDescription cfgd = CoreModel.getDefault().getProjectDescription(project).getConfigurationById(cfgId); IConfiguration icfg = ManagedBuildManager.getConfigurationForDescription(cfgd); if (icfg == null) { throw new CoreException( new Status( IStatus.ERROR, AutotoolsPlugin.PLUGIN_ID, ConfigureMessages.getString(INVALID_AUTOTOOLS_CONFIG_ID))); } IAConfiguration cfg = getConfiguration(project, cfgId); HashMap<String, IAutotoolsOption> options = new HashMap<>(); // Get set of configuration options and convert to set of IAutotoolOptions Map<String, IConfigureOption> cfgOptions = cfg.getOptions(); IAConfiguration dummyCfg = createDefaultConfiguration(createDummyId()); for (Iterator<Entry<String, IConfigureOption>> i = cfgOptions.entrySet().iterator(); i.hasNext(); ) { Map.Entry<String, IConfigureOption> entry = i.next(); String name = entry.getKey(); IAutotoolsOption configOption = new AutotoolsOption(entry.getValue().copy((AutotoolsConfiguration) dummyCfg)); options.put(name, configOption); } return options; }
/** @deprecated Not intended to be public - do not use */ @Deprecated public String getDefaultDebugger(final ILaunchConfiguration config) throws CoreException { // Mostly from CDebbuggerTab String defaultDebugger = null; String projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); if (projectName.length() > 0) { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project); if (projDesc != null) { ICConfigurationDescription configDesc = projDesc.getActiveConfiguration(); String configId = configDesc.getId(); ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault().getActiveDebugConfigurations(); outer: for (int i = 0; i < debugConfigs.length; ++i) { ICDebugConfiguration debugConfig = debugConfigs[i]; String[] patterns = debugConfig.getSupportedBuildConfigPatterns(); if (patterns != null) { for (int j = 0; j < patterns.length; ++j) { if (configId.matches(patterns[j])) { defaultDebugger = debugConfig.getID(); break outer; } } } } } } if (defaultDebugger == null) { ICDebugConfiguration dc = CDebugCorePlugin.getDefault().getDefaultDebugConfiguration(); if (dc != null) { defaultDebugger = dc.getID(); } } return defaultDebugger; }
private void initLanguageSettings(IProject project) throws CoreException { ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(project); if (prjDesc == null) throw new IllegalArgumentException("No valid CDT project given!"); ICConfigurationDescription activeConfig = prjDesc.getActiveConfiguration(); if (activeConfig == null) throw new IllegalArgumentException("No valid active configuration found!"); String[] extensionsToInclude = getExtensionsToInclude(project); ICFolderDescription folderDesc = activeConfig.getRootFolderDescription(); for (ICLanguageSetting ls : folderDesc.getLanguageSettings()) { String[] extensions = ls.getSourceExtensions(); Arrays.sort(extensions); if (Arrays.equals(extensionsToInclude, extensions)) { languageSettings.add(ls); } } }
private void addBaseString(IPath endPath, CPElement cpentry, StringBuffer str) { IPath baseRef = (IPath) cpentry.getAttribute(CPElement.BASE_REF); if (!baseRef.isEmpty()) { if (baseRef.isAbsolute()) { // str.append("From project "); IPath path = baseRef; if (endPath != null) { path = path.append(endPath); } str.append(path.makeRelative().toPortableString()); } else { // str.append("From contribution "); IPathEntryContainer container; if (endPath != null) { str.append(endPath.toPortableString()); } str.append(" - ("); // $NON-NLS-1$ try { container = CoreModel.getPathEntryContainer(baseRef, cpentry.getCProject()); if (container != null) { str.append(container.getDescription()); } } catch (CModelException e1) { } str.append(')'); } } else { IPath path = (IPath) cpentry.getAttribute(CPElement.BASE); if (!path.isEmpty()) { if (endPath != null) { path = path.append(endPath); } str.insert(0, path.toPortableString()); } else if (endPath != null) { str.insert(0, endPath.toPortableString()); } } }
private void rebuildIndex() { final Shell shell = getShell(); final String title = getTitle(); final String msg = Messages.AbstractPage_rebuildIndex_question; int result = OptionalMessageDialog.open( PREF_ASK_REINDEX, shell, title, null /* default image */, msg, MessageDialog.QUESTION, new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, 0); if (result == OptionalMessageDialog.NOT_SHOWN) { result = OptionalMessageDialog.getDialogDetail(PREF_ASK_REINDEX); } else if (result != SWT.DEFAULT) { OptionalMessageDialog.setDialogDetail(PREF_ASK_REINDEX, result); } if (result == 0) { // first button final IProject project = getProject(); CCorePlugin.getIndexManager().reindex(CoreModel.getDefault().create(project)); } }