/** * Populate properties with everything required for the SonarLint analysis in issues mode. * * @param monitor * @param properties * @return */ public Properties configureAnalysis( final IProgressMonitor monitor, List<SonarLintProperty> extraProps) { Properties properties = new Properties(); IProject project = request.getProject(); final File baseDir = project.getLocation().toFile(); IPath projectSpecificWorkDir = project.getWorkingLocation(SonarLintCorePlugin.PLUGIN_ID); // Preview mode by default properties.setProperty( SonarLintProperties.ANALYSIS_MODE, SonarLintProperties.ANALYSIS_MODE_ISSUES); // Configuration by configurators (common and language specific) configure(project, this.request.getOnlyOnFiles(), properties, monitor); // Append workspace and project properties for (SonarLintProperty sonarProperty : extraProps) { properties.put(sonarProperty.getName(), sonarProperty.getValue()); } if (this.request.getOnlyOnFiles() != null) { Collection<String> paths = new ArrayList<>(this.request.getOnlyOnFiles().size()); for (IFile file : this.request.getOnlyOnFiles()) { MarkerUtils.deleteIssuesMarkers(file); paths.add(file.getProjectRelativePath().toString()); } ProjectConfigurator.setPropertyList(properties, "sonar.tests", paths); ProjectConfigurator.setPropertyList(properties, "sonar.sources", paths); } else { MarkerUtils.deleteIssuesMarkers(project); } properties.setProperty(SonarLintProperties.PROJECT_BASEDIR, baseDir.toString()); properties.setProperty(SonarLintProperties.WORK_DIR, projectSpecificWorkDir.toString()); return properties; }
private void edit(SonarLintProperty data) { SonarLintProperty oldProp = data; SonarLintProperty newProp = editSonarProperty(new SonarLintProperty(oldProp), true, false); if (newProp != null) { data.setValue(newProp.getValue()); fTableViewer.refresh(data); updateButtons(); fTableViewer.setSelection(new StructuredSelection(data)); } }
@Override public String getColumnText(Object element, int columnIndex) { SonarLintProperty data = (SonarLintProperty) element; switch (columnIndex) { case 0: return data.getName(); case 1: return data.getValue(); default: return ""; //$NON-NLS-1$ } }
@Override public boolean performOk() { List<String> keyValuePairs = new ArrayList<String>(sonarProperties.size()); for (SonarLintProperty prop : sonarProperties) { keyValuePairs.add(prop.getName() + "=" + prop.getValue()); } String props = StringUtils.join(keyValuePairs, "\r\n"); if (isGlobal()) { getPreferenceStore().setValue(PreferencesUtils.PREF_EXTRA_ARGS, props); } else { SonarLintProject sonarProject = getSonarProject(); sonarProject.setExtraProperties(sonarProperties); sonarProject.save(); } return true; }