1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Merge remote branch 'cdt/master' into sd90

This commit is contained in:
Andrew Gvozdev 2011-09-27 16:45:18 -04:00
commit ddde8b7b3b
10 changed files with 96 additions and 46 deletions

View file

@ -75,17 +75,12 @@ public class FilterEmtpyFoldersAction extends Action {
if(haveTargets[0]) {
return false; //We found what we were looking for
}
if(proxy.getType() != IResource.FOLDER) {
return true; //We only look at folders for content
}
IContainer folder = (IContainer) proxy.requestResource();
if (CCorePlugin.showSourceRootsAtTopOfProject() && !(folder instanceof IProject)) {
boolean isSourceEntry = MakeContentProvider.isSourceEntry(folder);
if (isSourceEntry)
return false;
}
IContainer folder = (IContainer) proxy.requestResource();
IMakeTarget [] targets = MakeCorePlugin.getDefault().getTargetManager().getTargets(folder);
if(targets != null && targets.length > 0) {
haveTargets[0] = true;

View file

@ -70,6 +70,8 @@ import org.eclipse.swt.widgets.ScrollBar;
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPreferencePageContainer {
private static ToolListElement selectedElement;
/*
* Dialog widgets
*/
@ -87,7 +89,6 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
private Map<String, List<AbstractToolSettingUI>> configToPageListMap;
private IPreferenceStore settingsStore;
private AbstractToolSettingUI currentSettingsPage;
private ToolListElement selectedElement;
private ToolListContentProvider listprovider;
private Object propertyObject;
@ -377,7 +378,6 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
@Override
public void setVisible(boolean visible){
if(visible){
selectedElement = null;
updateData(page.getResDesc());
}
super.setVisible(visible);
@ -414,7 +414,7 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
// with an object in the new element list.
// Otherwise, select the first tool in the tree
Object primaryObject = null;
if (selectedElement != null) {
if (selectedElement != null && newElements != null) {
selectedElement = matchSelectionElement(selectedElement, newElements);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2010 QNX Software Systems and others.
* Copyright (c) 2008, 2011 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -30,6 +30,7 @@ import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.CTestPlugin;
import org.eclipse.core.internal.registry.ExtensionRegistry;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceDescription;
@ -305,4 +306,24 @@ public class ErrorParserManagerTest extends TestCase {
assertEquals(" la la 99 ",end);
}
public static class TestParser4 implements IErrorParser {
public boolean processLine(String line, ErrorParserManager eoParser) {
ProblemMarkerInfo problemMarkerInfo = new ProblemMarkerInfo(null, 0, "Workspace level marker", IMarker.SEVERITY_INFO, null);
eoParser.addProblemMarker(problemMarkerInfo);
return true;
}
}
public void testWorkspaceLevelError() throws IOException {
String id = addErrorParserExtension("test4", TestParser4.class);
epManager = new ErrorParserManager(null, markerGenerator, new String[] { id });
StringBuffer buf = new StringBuffer("errorT: ");
output(buf.toString()+"\n");
end();
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
assertEquals("Workspace level marker", problemMarkerInfo.description);
assertTrue(problemMarkerInfo.file instanceof IWorkspaceRoot);
}
}

View file

@ -118,7 +118,7 @@ public class ErrorParserManager extends OutputStream {
* @param parsersIDs - array of error parsers' IDs.
*/
public ErrorParserManager(IProject project, IMarkerGenerator markerGenerator, String[] parsersIDs) {
this(project, project.getLocationURI(), markerGenerator, parsersIDs);
this(project, (URI)null, markerGenerator, parsersIDs);
}
/**
@ -154,8 +154,10 @@ public class ErrorParserManager extends OutputStream {
if (baseDirectoryURI != null)
fBaseDirectoryURI = baseDirectoryURI;
else
else if (project != null)
fBaseDirectoryURI = project.getLocationURI();
else
fBaseDirectoryURI = org.eclipse.core.filesystem.URIUtil.toURI(System.getProperty("user.dir")); // CWD //$NON-NLS-1$
}
private void enableErrorParsers(String[] parsersIDs) {
@ -420,12 +422,15 @@ outer:
// Try to find best match considering known partial path
if (file==null) {
path = path.setDevice(null);
IProject[] prjs = new IProject[] { fProject };
IFile[] files = ResourceLookup.findFilesByName(path, prjs, false);
if (files.length == 0)
files = ResourceLookup.findFilesByName(path, prjs, /* ignoreCase */ true);
if (files.length == 0) {
prjs = ResourcesPlugin.getWorkspace().getRoot().getProjects();
IFile[] files = null;
if (fProject != null) {
IProject[] prjs = new IProject[] { fProject };
files = ResourceLookup.findFilesByName(path, prjs, false);
if (files.length == 0)
files = ResourceLookup.findFilesByName(path, prjs, /* ignoreCase */ true);
}
if (files == null || files.length == 0) {
IProject[] prjs = ResourcesPlugin.getWorkspace().getRoot().getProjects();
files = ResourceLookup.findFilesByName(path, prjs, false);
if (files.length == 0)
files = ResourceLookup.findFilesByName(path, prjs, /* ignoreCase */ true);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2009 QNX Software Systems and others.
* Copyright (c) 2000, 2011 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.core;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
/**
@ -17,9 +18,9 @@ import org.eclipse.core.resources.IResource;
* @noextend This interface is not intended to be extended by clients.
*/
public interface IMarkerGenerator {
int SEVERITY_INFO = 0;
int SEVERITY_WARNING = 1;
int SEVERITY_ERROR_RESOURCE = 2;
int SEVERITY_INFO = IMarker.SEVERITY_INFO; // 0
int SEVERITY_WARNING = IMarker.SEVERITY_WARNING; // 1
int SEVERITY_ERROR_RESOURCE = IMarker.SEVERITY_ERROR; // 2
int SEVERITY_ERROR_BUILD = 3;
/**

View file

@ -19,6 +19,7 @@ import java.util.Map;
import org.eclipse.cdt.core.resources.ACBuilder;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
/**
@ -52,7 +53,7 @@ public class ProblemMarkerInfo {
* @param variableName - the name of the variable involved in the error if any.
*/
public ProblemMarkerInfo(IResource file, int lineNumber, String description, int severity, String variableName) {
this.file = file;
this.file = (file != null) ? file : ResourcesPlugin.getWorkspace().getRoot();
this.lineNumber = lineNumber;
this.description = description;
this.severity = severity;

View file

@ -918,8 +918,10 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
*/
@Override
public int visit(IASTStatement node) {
if (startsWithMacroExpansion(node))
if (scribe.scanner.getCurrentPosition() <= node.getFileLocation().getNodeOffset() &&
startsWithMacroExpansion(node)) {
scribe.printCommentPreservingNewLines();
}
if (!startNode(node)) { return PROCESS_SKIP; }
int indentLevel= scribe.indentationLevel;
try {

View file

@ -2472,8 +2472,10 @@ public class CodeFormatterTest extends BaseUITestCase {
//#define MY_MACRO switch (0) case 0: default: if (bool x = false) ; else GetStream()
//
//void test() {
//MY_MACRO << "Loooooooooooooooooooong string literal" << " another literal.";
//MY_MACRO << "Looooooooooooooooooooong string literal" << " another literal.";
//MY_MACRO
//<< "Loooooooooooooooooooong string literal" << " another literal.";
//MY_MACRO
//<< "Looooooooooooooooooooong string literal" << " another literal.";
//}
//struct Stream {

View file

@ -37,7 +37,6 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@ -124,6 +123,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
};
private static final Comparator<Object> comp = CDTListComparator.getInstance();
private static String selectedLanguageId;
private static final int[] DEFAULT_SASH_WEIGHTS = new int[] { 10, 30 };
@ -312,6 +312,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
ICLanguageSetting langSetting = (ICLanguageSetting) items[0].getData();
if (langSetting != null) {
lang = langSetting;
selectedLanguageId = lang.getLanguageId();
update();
}
}
@ -394,7 +395,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
if (rcDes == null || !canBeVisible()) return;
updateExport();
langTree.removeAll();
TreeItem firstItem = null;
TreeItem selectedItem = null;
ls = getLangSetting(rcDes);
if (ls != null) {
Arrays.sort(ls, CDTListComparator.getInstance());
@ -414,15 +415,15 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
langId = langSetting.getName();
t.setText(0, langId);
t.setData(langSetting);
if (firstItem == null) {
firstItem = t;
if (selectedItem == null || langSetting.getLanguageId().equals(selectedLanguageId)) {
selectedItem = t;
lang = langSetting;
}
}
}
if (firstItem != null && table != null) {
langTree.setSelection(firstItem);
if (selectedItem != null && table != null) {
langTree.setSelection(selectedItem);
}
}
update();

View file

@ -151,6 +151,8 @@ implements
private static final String PREF_ASK_REINDEX = "askReindex"; //$NON-NLS-1$
private Map<URL, Image> loadedIcons = new HashMap<URL, Image>();
private static Map<Class<? extends AbstractPage>, Class<? extends ICPropertyTab>> recentTabs =
new HashMap<Class<? extends AbstractPage>, Class<? extends ICPropertyTab>>();
private final Image IMG_WARN = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_REFACTORING_WARNING);
/*
@ -362,20 +364,40 @@ implements
// Set listener after data load, to avoid firing
// selection event on not-initialized tab items
if (folder != null) {
folder.addSelectionListener(new SelectionAdapter() {
@Override
folder.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) {
if (folder.getSelection().length > 0 ) {
ICPropertyTab newTab = (ICPropertyTab)folder.getSelection()[0].getData();
if (newTab != null && currentTab != newTab) {
if (currentTab != null) currentTab.handleTabEvent(ICPropertyTab.VISIBLE, null);
currentTab = newTab;
currentTab.handleTabEvent(ICPropertyTab.VISIBLE, NOT_NULL);
}
}
}
});
if (folder.getItemCount() > 0) folder.setSelection(0);
if (folder.getSelection().length > 0 ) {
updateSelectedTab();
}
}
});
if (folder.getItemCount() > 0) {
int selectedTab = 0;
Class<? extends ICPropertyTab> recentTab = recentTabs.get(getClass());
if (recentTab != null) {
TabItem[] tabs = folder.getItems();
for (int i = 0; i < tabs.length; i++) {
TabItem control = tabs[i];
if (recentTab.isInstance(control.getData())) {
selectedTab = i;
break;
}
}
}
folder.setSelection(selectedTab);
updateSelectedTab();
}
}
}
private void updateSelectedTab() {
ICPropertyTab newTab = (ICPropertyTab)folder.getSelection()[0].getData();
if (newTab != null && currentTab != newTab) {
recentTabs.put(getClass(), newTab.getClass());
if (currentTab != null) currentTab.handleTabEvent(ICPropertyTab.VISIBLE, null);
currentTab = newTab;
currentTab.handleTabEvent(ICPropertyTab.VISIBLE, NOT_NULL);
}
}
/**