mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 08:46:02 +02:00
- did a major refactoring with API breakage to get rid of bad dependency from codan.ui to cdt (should be in codan.ui.cxx)
This commit is contained in:
parent
c630261d21
commit
c2074dec42
11 changed files with 103 additions and 62 deletions
|
@ -8,10 +8,10 @@ Require-Bundle: org.eclipse.ui,
|
||||||
org.eclipse.core.runtime,
|
org.eclipse.core.runtime,
|
||||||
org.eclipse.jface.text,
|
org.eclipse.jface.text,
|
||||||
org.eclipse.core.resources,
|
org.eclipse.core.resources,
|
||||||
org.eclipse.cdt.codan.ui,
|
|
||||||
org.eclipse.ui.ide,
|
org.eclipse.ui.ide,
|
||||||
org.eclipse.cdt.core,
|
org.eclipse.cdt.core,
|
||||||
org.eclipse.cdt.codan.core.cxx
|
org.eclipse.cdt.codan.core.cxx,
|
||||||
|
org.eclipse.cdt.codan.ui.cxx
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||||
Bundle-Vendor: %Bundle-Vendor
|
Bundle-Vendor: %Bundle-Vendor
|
||||||
|
|
|
@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.core.runtime,
|
||||||
org.junit,
|
org.junit,
|
||||||
org.eclipse.cdt.codan.checkers.ui;bundle-version="1.0.0",
|
org.eclipse.cdt.codan.checkers.ui;bundle-version="1.0.0",
|
||||||
org.eclipse.cdt.codan.ui;bundle-version="1.1.0",
|
org.eclipse.cdt.codan.ui;bundle-version="1.1.0",
|
||||||
org.eclipse.ui.ide;bundle-version="3.6.0"
|
org.eclipse.ui.ide;bundle-version="3.6.0",
|
||||||
|
org.eclipse.cdt.codan.ui.cxx;bundle-version="2.0.0"
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||||
Bundle-Vendor: %Bundle-Vendor
|
Bundle-Vendor: %Bundle-Vendor
|
||||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %Bundle-Name
|
Bundle-Name: %Bundle-Name
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.codan.ui.cxx;singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.codan.ui.cxx;singleton:=true
|
||||||
Bundle-Version: 1.0.0.qualifier
|
Bundle-Version: 2.0.0.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.codan.internal.ui.cxx.Activator
|
Bundle-Activator: org.eclipse.cdt.codan.internal.ui.cxx.Activator
|
||||||
Bundle-Vendor: %Bundle-Vendor
|
Bundle-Vendor: %Bundle-Vendor
|
||||||
Require-Bundle: org.eclipse.ui,
|
Require-Bundle: org.eclipse.ui,
|
||||||
|
@ -14,7 +14,9 @@ Require-Bundle: org.eclipse.ui,
|
||||||
org.eclipse.cdt.ui,
|
org.eclipse.cdt.ui,
|
||||||
org.eclipse.core.resources,
|
org.eclipse.core.resources,
|
||||||
org.eclipse.cdt.codan.ui,
|
org.eclipse.cdt.codan.ui,
|
||||||
org.eclipse.jface.text
|
org.eclipse.jface.text,
|
||||||
|
org.eclipse.ui.ide
|
||||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Export-Package: org.eclipse.cdt.codan.internal.ui.cxx;x-internal:=true
|
Export-Package: org.eclipse.cdt.codan.internal.ui.cxx;x-internal:=true,
|
||||||
|
org.eclipse.cdt.codan.ui
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.IMarkerResolution;
|
|
||||||
import org.eclipse.ui.IMarkerResolution2;
|
import org.eclipse.ui.IMarkerResolution2;
|
||||||
import org.eclipse.ui.PartInitException;
|
import org.eclipse.ui.PartInitException;
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
@ -43,7 +42,7 @@ import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
*
|
*
|
||||||
* @since 1.1
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractCodanCMarkerResolution implements IMarkerResolution {
|
public abstract class AbstractCodanCMarkerResolution implements ICodanMarkerResolution {
|
||||||
private boolean codanProblem;
|
private boolean codanProblem;
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -2,19 +2,18 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %Bundle-Name
|
Bundle-Name: %Bundle-Name
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.codan.ui; singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.codan.ui; singleton:=true
|
||||||
Bundle-Version: 1.1.0.qualifier
|
Bundle-Version: 2.0.0.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.codan.internal.ui.CodanUIActivator
|
Bundle-Activator: org.eclipse.cdt.codan.internal.ui.CodanUIActivator
|
||||||
Bundle-Vendor: %Bundle-Vendor
|
Bundle-Vendor: %Bundle-Vendor
|
||||||
Require-Bundle: org.eclipse.ui,
|
Require-Bundle: org.eclipse.ui,
|
||||||
org.eclipse.core.runtime,
|
org.eclipse.core.runtime,
|
||||||
org.eclipse.core.resources,
|
org.eclipse.core.resources,
|
||||||
org.eclipse.ui.workbench.texteditor,
|
org.eclipse.ui.workbench.texteditor,
|
||||||
org.eclipse.ui.editors,
|
|
||||||
org.eclipse.cdt.codan.core,
|
org.eclipse.cdt.codan.core,
|
||||||
org.eclipse.jface.text,
|
org.eclipse.jface.text,
|
||||||
org.eclipse.ui.ide,
|
org.eclipse.ui.ide,
|
||||||
org.eclipse.cdt.ui,
|
org.eclipse.cdt.ui,
|
||||||
org.eclipse.cdt.core
|
org.eclipse.core.filesystem
|
||||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Export-Package: org.eclipse.cdt.codan.internal.ui;x-friends:="org.eclipse.cdt.codan.ui.cxx",
|
Export-Package: org.eclipse.cdt.codan.internal.ui;x-friends:="org.eclipse.cdt.codan.ui.cxx",
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.eclipse.cdt.codan.core.model.ICodanProblemMarker;
|
import org.eclipse.cdt.codan.core.model.ICodanProblemMarker;
|
||||||
import org.eclipse.cdt.codan.internal.core.model.CodanProblemMarker;
|
import org.eclipse.cdt.codan.internal.core.model.CodanProblemMarker;
|
||||||
import org.eclipse.cdt.codan.ui.AbstractCodanCMarkerResolution;
|
import org.eclipse.cdt.codan.ui.ICodanMarkerResolution;
|
||||||
import org.eclipse.core.resources.IMarker;
|
import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
|
@ -72,8 +72,8 @@ public class CodanProblemMarkerResolutionGenerator implements IMarkerResolutionG
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (res.res instanceof AbstractCodanCMarkerResolution) {
|
if (res.res instanceof ICodanMarkerResolution) {
|
||||||
if (!((AbstractCodanCMarkerResolution) res.res).isApplicable(marker))
|
if (!((ICodanMarkerResolution) res.res).isApplicable(marker))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
list.add(res.res);
|
list.add(res.res);
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2009, 2010 Alena Laskavaia
|
|
||||||
* 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
|
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* Alena Laskavaia - initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.codan.ui;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated class name was misspelled, use
|
|
||||||
* {@link AbstractCodanCMarkerResolution}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public abstract class AbstarctCodanCMarkerResolution extends AbstractCodanCMarkerResolution {
|
|
||||||
}
|
|
|
@ -81,7 +81,7 @@ public abstract class AbstractCodanProblemDetailsProvider {
|
||||||
* Returns problem arguments by index (set by checker when reporting
|
* Returns problem arguments by index (set by checker when reporting
|
||||||
* problem)
|
* problem)
|
||||||
*
|
*
|
||||||
* @since 1.1
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public String getProblemArgument(int index) {
|
public String getProblemArgument(int index) {
|
||||||
return CodanProblemMarker.getProblemArgument(marker, index);
|
return CodanProblemMarker.getProblemArgument(marker, index);
|
||||||
|
@ -93,7 +93,7 @@ public abstract class AbstractCodanProblemDetailsProvider {
|
||||||
*
|
*
|
||||||
* @param marker - problem marker
|
* @param marker - problem marker
|
||||||
* @return problem arguments, can not be null. Can be 0 sized array.
|
* @return problem arguments, can not be null. Can be 0 sized array.
|
||||||
* @since 1.1
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public String[] getProblemArguments() {
|
public String[] getProblemArguments() {
|
||||||
return CodanProblemMarker.getProblemArguments(marker);
|
return CodanProblemMarker.getProblemArguments(marker);
|
||||||
|
@ -120,7 +120,7 @@ public abstract class AbstractCodanProblemDetailsProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 1.1
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
protected String getLocation() {
|
protected String getLocation() {
|
||||||
return CodanEditorUtility.getLocation(marker);
|
return CodanEditorUtility.getLocation(marker);
|
||||||
|
|
|
@ -10,21 +10,24 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.ui;
|
package org.eclipse.cdt.codan.ui;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import java.io.File;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
|
||||||
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
import org.eclipse.core.filesystem.EFS;
|
||||||
|
import org.eclipse.core.filesystem.IFileStore;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IMarker;
|
import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
|
import org.eclipse.ui.IEditorDescriptor;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
import org.eclipse.ui.IWorkbenchWindow;
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
import org.eclipse.ui.PartInitException;
|
import org.eclipse.ui.PartInitException;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
import org.eclipse.ui.ide.IDE;
|
||||||
import org.eclipse.ui.ide.ResourceUtil;
|
import org.eclipse.ui.ide.ResourceUtil;
|
||||||
|
import org.eclipse.ui.part.FileEditorInput;
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,14 +78,30 @@ public class CodanEditorUtility {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("restriction")
|
|
||||||
public static IEditorPart openInEditor(String file, IResource markerResource) throws PartInitException {
|
public static IEditorPart openInEditor(String file, IResource markerResource) throws PartInitException {
|
||||||
IPath pfile = new Path(file);
|
// ICElement element = null;
|
||||||
ICElement element = null;
|
// if (markerResource != null)
|
||||||
if (markerResource != null)
|
// element = CoreModel.getDefault().create(markerResource);
|
||||||
element = CoreModel.getDefault().create(markerResource);
|
IFile efile = null;
|
||||||
IEditorPart part = EditorUtility.openInEditor(pfile, element);
|
if (markerResource instanceof IFile)
|
||||||
return part;
|
efile = (IFile) markerResource;
|
||||||
|
if (efile != null) {
|
||||||
|
IWorkbenchPage page = getActivePage();
|
||||||
|
IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file);
|
||||||
|
IEditorPart part = page.openEditor(new FileEditorInput(efile), desc.getId());
|
||||||
|
return part;
|
||||||
|
}
|
||||||
|
File fileToOpen = new File(file);
|
||||||
|
if (fileToOpen.exists() && fileToOpen.isFile()) {
|
||||||
|
IFileStore fileStore = EFS.getLocalFileSystem().getStore(fileToOpen.toURI());
|
||||||
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
|
try {
|
||||||
|
return IDE.openEditorOnFileStore(page, fileStore);
|
||||||
|
} catch (PartInitException e) {
|
||||||
|
//Put your exception handler here if you wish to
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEditorPart openInEditor(IMarker marker) throws PartInitException {
|
public static IEditorPart openInEditor(IMarker marker) throws PartInitException {
|
||||||
|
@ -105,7 +124,7 @@ public class CodanEditorUtility {
|
||||||
/**
|
/**
|
||||||
* @param marker
|
* @param marker
|
||||||
* @return
|
* @return
|
||||||
* @since 1.1
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public static String getLocation(IMarker marker) {
|
public static String getLocation(IMarker marker) {
|
||||||
String loc = marker.getResource().getFullPath().toPortableString();
|
String loc = marker.getResource().getFullPath().toPortableString();
|
||||||
|
@ -118,24 +137,34 @@ public class CodanEditorUtility {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 1.1
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public static boolean isResourceOpenInEditor(IResource resource,
|
public static boolean isResourceOpenInEditor(IResource resource, IEditorPart editor) {
|
||||||
IEditorPart editor) {
|
if (editor == null)
|
||||||
if (editor == null) return false;
|
return false;
|
||||||
IResource realResource = ResourceUtil.getResource(editor.getEditorInput());
|
IResource realResource = ResourceUtil.getResource(editor.getEditorInput());
|
||||||
return resource.equals(realResource);
|
return resource.equals(realResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 1.1
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public static IEditorPart getActiveEditor() {
|
public static IEditorPart getActiveEditor() {
|
||||||
IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
|
IWorkbenchPage activePage = getActivePage();
|
||||||
if (activeWorkbenchWindow==null) return null;
|
if (activePage == null)
|
||||||
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
|
return null;
|
||||||
if (activePage==null) return null;
|
|
||||||
IEditorPart e = activePage.getActiveEditor();
|
IEditorPart e = activePage.getActiveEditor();
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static IWorkbenchPage getActivePage() {
|
||||||
|
IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
|
||||||
|
if (activeWorkbenchWindow == null)
|
||||||
|
return null;
|
||||||
|
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
|
||||||
|
return activePage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2009, 2011 Alena Laskavaia
|
||||||
|
* 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
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Alena Laskavaia - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.codan.ui;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IMarker;
|
||||||
|
import org.eclipse.ui.IMarkerResolution;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for codan marker resolution
|
||||||
|
*
|
||||||
|
* @since 2.0
|
||||||
|
*/
|
||||||
|
public interface ICodanMarkerResolution extends IMarkerResolution {
|
||||||
|
/**
|
||||||
|
* Override is extra checks is required to determine applicability of marker
|
||||||
|
* resolution
|
||||||
|
*
|
||||||
|
* @param marker
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isApplicable(IMarker marker);
|
||||||
|
}
|
|
@ -25,8 +25,8 @@ import org.eclipse.swt.widgets.Label;
|
||||||
* A field editor for displaying labels not associated with other widgets.
|
* A field editor for displaying labels not associated with other widgets.
|
||||||
*
|
*
|
||||||
* @author fgiust
|
* @author fgiust
|
||||||
* @version $Revision: 1.3 $ ($Author: fgiust $)
|
* @version $Revision: 1.1 $ ($Author: elaskavaia $)
|
||||||
* @since 1.1
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public class LabelFieldEditor extends FieldEditor {
|
public class LabelFieldEditor extends FieldEditor {
|
||||||
/***
|
/***
|
||||||
|
|
Loading…
Add table
Reference in a new issue