1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 06:32:10 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2013-11-25 20:12:01 -08:00
parent 1a4e509e0d
commit ecf7d25dd9
4 changed files with 21 additions and 49 deletions

View file

@ -1,22 +1,17 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2010 Alena Laskavaia * Copyright (c) 2009, 2010 Alena Laskavaia
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alena Laskavaia - initial API and implementation * Alena Laskavaia - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core; package org.eclipse.cdt.codan.core;
/** /**
* Constant definitions for plug-in preferences * Constant definitions for plug-in preferences
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part
* of a work in progress. There is no guarantee that this API will work or that
* it will remain the same.
* </p>
*/ */
public class PreferenceConstants { public class PreferenceConstants {
public static final String P_RUN_ON_BUILD = "onBuild"; //$NON-NLS-1$ public static final String P_RUN_ON_BUILD = "onBuild"; //$NON-NLS-1$

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alena Laskavaia - initial API and implementation * Alena Laskavaia - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.internal.ui.actions; package org.eclipse.cdt.codan.internal.ui.actions;
@ -27,15 +27,10 @@ import org.eclipse.ui.IWorkbenchPart;
public class ToggleNatureAction implements IObjectActionDelegate { public class ToggleNatureAction implements IObjectActionDelegate {
private ISelection selection; private ISelection selection;
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override @Override
public void run(IAction action) { public void run(IAction action) {
if (selection instanceof IStructuredSelection) { if (selection instanceof IStructuredSelection) {
for (Iterator it = ((IStructuredSelection) selection).iterator(); it.hasNext();) { for (Iterator<?> it = ((IStructuredSelection) selection).iterator(); it.hasNext();) {
Object element = it.next(); Object element = it.next();
IProject project = null; IProject project = null;
if (element instanceof IProject) { if (element instanceof IProject) {
@ -50,25 +45,11 @@ public class ToggleNatureAction implements IObjectActionDelegate {
} }
} }
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action
* .IAction, org.eclipse.jface.viewers.ISelection)
*/
@Override @Override
public void selectionChanged(IAction action, ISelection selection) { public void selectionChanged(IAction action, ISelection selection) {
this.selection = selection; this.selection = selection;
} }
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.
* action.IAction, org.eclipse.ui.IWorkbenchPart)
*/
@Override @Override
public void setActivePart(IAction action, IWorkbenchPart targetPart) { public void setActivePart(IAction action, IWorkbenchPart targetPart) {
} }
@ -90,10 +71,9 @@ public class ToggleNatureAction implements IObjectActionDelegate {
} }
/** /**
* Toggles codan nature on a project * Toggles Codan nature on a project
* *
* @param project * @param project the project to have Codan nature added or removed
* to have codan nature added or removed
*/ */
public void toggleNature(IProject project, boolean add) { public void toggleNature(IProject project, boolean add) {
try { try {
@ -102,7 +82,7 @@ public class ToggleNatureAction implements IObjectActionDelegate {
for (int i = 0; i < natures.length; ++i) { for (int i = 0; i < natures.length; ++i) {
if (CodanCorePlugin.NATURE_ID.equals(natures[i])) { if (CodanCorePlugin.NATURE_ID.equals(natures[i])) {
if (add == false) { if (add == false) {
// Remove the nature // Remove the nature.
String[] newNatures = new String[natures.length - 1]; String[] newNatures = new String[natures.length - 1];
System.arraycopy(natures, 0, newNatures, 0, i); System.arraycopy(natures, 0, newNatures, 0, i);
System.arraycopy(natures, i + 1, newNatures, i, natures.length - i - 1); System.arraycopy(natures, i + 1, newNatures, i, natures.length - i - 1);
@ -110,13 +90,13 @@ public class ToggleNatureAction implements IObjectActionDelegate {
project.setDescription(description, null); project.setDescription(description, null);
return; return;
} }
// already there no need to add // Already there, no need to add.
add = false; add = false;
break; break;
} }
} }
if (add) { if (add) {
// Add the nature // Add the nature.
String[] newNatures = new String[natures.length + 1]; String[] newNatures = new String[natures.length + 1];
System.arraycopy(natures, 0, newNatures, 0, natures.length); System.arraycopy(natures, 0, newNatures, 0, natures.length);
newNatures[natures.length] = CodanCorePlugin.NATURE_ID; newNatures[natures.length] = CodanCorePlugin.NATURE_ID;

View file

@ -22,17 +22,16 @@ import org.eclipse.core.runtime.Status;
* @noinstantiate This class is not intended to be instantiated by clients. * @noinstantiate This class is not intended to be instantiated by clients.
*/ */
public class CCProjectNature extends CProjectNature { public class CCProjectNature extends CProjectNature {
public static final String CC_NATURE_ID= CCorePlugin.PLUGIN_ID + ".ccnature"; //$NON-NLS-1$ public static final String CC_NATURE_ID= CCorePlugin.PLUGIN_ID + ".ccnature"; //$NON-NLS-1$
public static void addCCNature(IProject project, IProgressMonitor mon) throws CoreException { public static void addCCNature(IProject project, IProgressMonitor mon) throws CoreException {
addNature(project, CC_NATURE_ID, mon); addNature(project, CC_NATURE_ID, mon);
} }
public static void removeCCNature(IProject project, IProgressMonitor mon) throws CoreException { public static void removeCCNature(IProject project, IProgressMonitor mon) throws CoreException {
removeNature(project, CC_NATURE_ID, mon); removeNature(project, CC_NATURE_ID, mon);
} }
/** /**
* Checks to ensure that a cnature already exists, * Checks to ensure that a cnature already exists,
* if not throw a CoreException. Does NOT add a default builder * if not throw a CoreException. Does NOT add a default builder
@ -41,12 +40,11 @@ public class CCProjectNature extends CProjectNature {
@Override @Override
public void configure() throws CoreException { public void configure() throws CoreException {
if (!getProject().hasNature(CProjectNature.C_NATURE_ID)){ if (!getProject().hasNature(CProjectNature.C_NATURE_ID)){
IStatus status = new Status(IStatus.ERROR, IStatus status = new Status(IStatus.ERROR,
CCorePlugin.PLUGIN_ID, CCorePlugin.PLUGIN_ID,
CCorePlugin.CDT_PROJECT_NATURE_ID_MISMATCH, CCorePlugin.CDT_PROJECT_NATURE_ID_MISMATCH,
CCorePlugin.getResourceString("CCProjectNature.exception.noNature"), null); // $NON_NLS //$NON-NLS-1$ CCorePlugin.getResourceString("CCProjectNature.exception.noNature"), null); // $NON_NLS //$NON-NLS-1$
throw new CoreException(status); throw new CoreException(status);
} }
} }
} }

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy; package org.eclipse.cdt.internal.ui.callhierarchy;
import java.util.ArrayList; import java.util.ArrayList;
@ -40,7 +40,7 @@ import org.eclipse.cdt.internal.ui.viewsupport.AsyncTreeContentProvider;
import org.eclipse.cdt.internal.ui.viewsupport.IndexUI; import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI; import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
/** /**
* This is the content provider for the call hierarchy. * This is the content provider for the call hierarchy.
*/ */
public class CHContentProvider extends AsyncTreeContentProvider { public class CHContentProvider extends AsyncTreeContentProvider {
@ -80,10 +80,9 @@ public class CHContentProvider extends AsyncTreeContentProvider {
if (node.isInitializer()) { if (node.isInitializer()) {
return NO_CHILDREN; return NO_CHILDREN;
} }
} else if (node.isVariableOrEnumerator() || node.isMacro()) { } else if (node.isVariableOrEnumerator() || node.isMacro()) {
return NO_CHILDREN; return NO_CHILDREN;
} }
} }
// Allow for async computation // Allow for async computation
return null; return null;
@ -110,7 +109,7 @@ public class CHContentProvider extends AsyncTreeContentProvider {
} }
return NO_CHILDREN; return NO_CHILDREN;
} }
private Object[] asyncComputeRoot(final ICElement input) throws CoreException, InterruptedException { private Object[] asyncComputeRoot(final ICElement input) throws CoreException, InterruptedException {
IIndex index= CCorePlugin.getIndexManager().getIndex(input.getCProject(), CallHierarchyUI.INDEX_SEARCH_OPTION); IIndex index= CCorePlugin.getIndexManager().getIndex(input.getCProject(), CallHierarchyUI.INDEX_SEARCH_OPTION);
index.acquireReadLock(); index.acquireReadLock();
@ -203,7 +202,7 @@ public class CHContentProvider extends AsyncTreeContentProvider {
} }
return nodes.toArray(new CHNode[nodes.size()]); return nodes.toArray(new CHNode[nodes.size()]);
} }
private CHNode createRefbyNode(CHNode parent, ICElement element, IIndexName[] refs) throws CoreException { private CHNode createRefbyNode(CHNode parent, ICElement element, IIndexName[] refs) throws CoreException {
ITranslationUnit tu= CModelUtil.getTranslationUnit(element); ITranslationUnit tu= CModelUtil.getTranslationUnit(element);
final IIndexFile file = refs[0].getFile(); final IIndexFile file = refs[0].getFile();
@ -247,14 +246,14 @@ public class CHContentProvider extends AsyncTreeContentProvider {
final IIndexFile file = references[0].getFile(); final IIndexFile file = references[0].getFile();
final long timestamp= file.getTimestamp(); final long timestamp= file.getTimestamp();
final int linkageID= file.getLinkageID(); final int linkageID= file.getLinkageID();
CHNode node; CHNode node;
if (elements.length == 1) { if (elements.length == 1) {
node= new CHNode(parent, tu, timestamp, elements[0], linkageID); node= new CHNode(parent, tu, timestamp, elements[0], linkageID);
} else { } else {
node= new CHMultiDefNode(parent, tu, timestamp, elements, linkageID); node= new CHMultiDefNode(parent, tu, timestamp, elements, linkageID);
} }
boolean readAccess= false; boolean readAccess= false;
boolean writeAccess= false; boolean writeAccess= false;
for (IIndexName reference : references) { for (IIndexName reference : references) {