diff --git tools/pldt/org.eclipse.ptp.pldt.common/src/org/eclipse/ptp/pldt/common/ArtifactAnalysisBase.java tools/pldt/org.eclipse.ptp.pldt.common/src/org/eclipse/ptp/pldt/common/ArtifactAnalysisBase.java
new file mode 100644
index 0000000..888b9d4
--- /dev/null
+++ tools/pldt/org.eclipse.ptp.pldt.common/src/org/eclipse/ptp/pldt/common/ArtifactAnalysisBase.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011, 2012 IBM Corporation, University of Illinois, 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Jeff Overbey (UIUC) - modified to use extension point
+ *******************************************************************************/
+package org.eclipse.ptp.pldt.common;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * Base class for implementations of {@link IArtifactAnalysis} that handle C and
+ * C++.
+ *
+ * This class contains the {@link #getAST(ITranslationUnit)} utility method,
+ * which returns an {@link IASTTranslationUnit} for an {@link ITranslationUnit}.
+ *
+ * @author Beth Tibbitts
+ * @author Jeff Overbey
+ *
+ * @since 6.0
+ */
+public abstract class ArtifactAnalysisBase implements IArtifactAnalysis {
+ /**
+ * Get AST from index, not full tu
+ *
+ * @param tu
+ * translation unit from which to get the AST
+ * @return {@link IASTTranslationUnit} or null
+ */
+ protected IASTTranslationUnit getAST(ITranslationUnit tu) {
+ try {
+ IIndex index = CCorePlugin.getIndexManager().getIndex(tu.getCProject());
+ return tu.getAST(index, ITranslationUnit.AST_SKIP_ALL_HEADERS);
+ } catch (Exception e) {
+ CommonPlugin.log(IStatus.ERROR, "RunAnalyseHandlerBase.getAST(): Error getting AST (from index) for project " + tu.getCProject() + " " + e.getMessage()); //$NON-NLS-1$
+ return null;
+ }
+ }
+}
diff --git tools/pldt/org.eclipse.ptp.pldt.common/src/org/eclipse/ptp/pldt/common/IArtifactAnalysis.java tools/pldt/org.eclipse.ptp.pldt.common/src/org/eclipse/ptp/pldt/common/IArtifactAnalysis.java
new file mode 100644
index 0000000..b2694e7
--- /dev/null
+++ tools/pldt/org.eclipse.ptp.pldt.common/src/org/eclipse/ptp/pldt/common/IArtifactAnalysis.java
@@ -0,0 +1,25 @@
+package org.eclipse.ptp.pldt.common;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+/**
+ * An artifact analysis for MPI, OpenMP, or OpenACC.
+ *
+ * This interface is implemented by contributions to the following extension points:
+ *
+ * - org.eclipse.ptp.pldt.mpi.core.artifactAnalysis
+ *
- org.eclipse.ptp.pldt.openmp.core.artifactAnalysis
+ *
- org.eclipse.ptp.pldt.openacc.artifactAnalysis
+ *
+ *
+ * Implementations targeting C and C++ will typically subclass {@link ArtifactAnalysisBase}.
+ *
+ * @since 6.0
+ *
+ * @see ArtifactAnalysisBase
+ */
+public interface IArtifactAnalysis {
+ ScanReturn runArtifactAnalysis(String languageID, ITranslationUnit tu, List includes, boolean allowPrefixOnlyMatch);
+}
diff --git tools/pldt/org.eclipse.ptp.pldt.common/src/org/eclipse/ptp/pldt/common/actions/RunAnalyseHandlerBase.java tools/pldt/org.eclipse.ptp.pldt.common/src/org/eclipse/ptp/pldt/common/actions/RunAnalyseHandlerBase.java
index aa6e7c0..d0ee672 100644
--- tools/pldt/org.eclipse.ptp.pldt.common/src/org/eclipse/ptp/pldt/common/actions/RunAnalyseHandlerBase.java
+++ tools/pldt/org.eclipse.ptp.pldt.common/src/org/eclipse/ptp/pldt/common/actions/RunAnalyseHandlerBase.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation.
+ * Copyright (c) 2005, 2011, 2012 IBM Corporation, University of Illinois, 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
@@ -7,17 +7,14 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Jeff Overbey (UIUC) - modified to use extension point
*******************************************************************************/
-
package org.eclipse.ptp.pldt.common.actions;
import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
import java.util.List;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.ICContainer;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
@@ -31,8 +28,10 @@ import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -43,6 +42,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ptp.pldt.common.Artifact;
import org.eclipse.ptp.pldt.common.ArtifactMarkingVisitor;
import org.eclipse.ptp.pldt.common.CommonPlugin;
+import org.eclipse.ptp.pldt.common.IArtifactAnalysis;
import org.eclipse.ptp.pldt.common.ScanReturn;
import org.eclipse.ptp.pldt.common.messages.Messages;
import org.eclipse.ptp.pldt.common.util.AnalysisUtil;
@@ -62,6 +62,7 @@ import org.eclipse.ui.actions.WorkspaceModifyOperation;
* The analysis is done in the doArtifactAnalysis() method
*
* @author Beth Tibbitts
+ * @author Jeff Overbey
*
* IObjectActionDelegate enables popup menu selection
* IWindowActionDelegate enables toolbar(or menu) selection
@@ -220,6 +221,41 @@ public abstract class RunAnalyseHandlerBase extends RunAnalyseHandler {
public abstract ScanReturn doArtifactAnalysis(final ITranslationUnit tu, final List includes);
/**
+ * Runs an artifact analysis for the given file by searching the given extension point for an {@link IArtifactAnalysis} that matches its language ID.
+ *
+ * This is a utility method generally invoked from {@link #doArtifactAnalysis(ITranslationUnit, List)}.
+ *
+ * It is assumed that only one extension will be contributed per language ID. If multiple extensions are found, it is unspecified which one will be run.
+ *
+ * @param extensionPointID
+ * @param tu
+ * @param includes
+ * @param allowPrefixOnlyMatch
+ * @return {@link ScanReturn}
+ *
+ * @since 6.0
+ */
+ protected ScanReturn runArtifactAnalysisFromExtensionPoint(String extensionPointID, final ITranslationUnit tu, final List includes, final boolean allowPrefixOnlyMatch) {
+ try {
+ final String languageID = tu.getLanguage().getId();
+ for (IConfigurationElement config : Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointID)) {
+ try {
+ if (languageID.equals(config.getAttribute("languageID"))) {
+ IArtifactAnalysis artifactAnalysis = (IArtifactAnalysis) config.createExecutableExtension("class"); //$NON-NLS-1$
+ return artifactAnalysis.runArtifactAnalysis(languageID, tu, includes, allowPrefixOnlyMatch);
+ }
+ } catch (CoreException e) {
+ CommonPlugin.log(e.getClass().getSimpleName() + ": " + e.getMessage());
+ }
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ CommonPlugin.log(IStatus.ERROR, "RunAnalyseMPICommandHandler: Error setting up analysis for project " + tu.getCProject() + " error=" + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return new ScanReturn();
+ }
+
+ /**
* Implemented for Handler; this replaces run() which is for actions.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
@@ -515,32 +551,6 @@ public abstract class RunAnalyseHandlerBase extends RunAnalyseHandler {
}
/**
- * Get AST from index, not full tu
- *
- * @param tu
- * translation unit from which to get the AST
- * @return
- */
- protected IASTTranslationUnit getAST(ITranslationUnit tu) {
- IIndex index;
- try {
- index = CCorePlugin.getIndexManager().getIndex(tu.getCProject());
- IASTTranslationUnit ast = tu.getAST(index, ITranslationUnit.AST_SKIP_ALL_HEADERS);
- // IASTTranslationUnit ast = tu.getAST(index, 0);
- if (traceOn) {
- System.out.println(" getAST(index,AST_SKIP_ALL_HEADERS)"); //$NON-NLS-1$
- }
-
- return ast;
- } catch (Exception e) {
- String msg = "RunAnalyseHandlerBase.getAST(): Error getting AST (from index) for project " + tu.getCProject() + " " + e.getMessage();//$NON-NLS-1$
- CommonPlugin.log(IStatus.ERROR, msg);
- return null;
- }
-
- }
-
- /**
* Get the include path. Subclass should override this method.
*
* @return
diff --git tools/pldt/org.eclipse.ptp.pldt.mpi.core/build.properties tools/pldt/org.eclipse.ptp.pldt.mpi.core/build.properties
index 0122072..f8cfd95 100644
--- tools/pldt/org.eclipse.ptp.pldt.mpi.core/build.properties
+++ tools/pldt/org.eclipse.ptp.pldt.mpi.core/build.properties
@@ -7,7 +7,8 @@ bin.includes = plugin.xml,\
.,\
templates/,\
plugin.properties,\
- about.html
+ about.html,\
+ schema/
src.includes = html/,\
icons/,\
mpiref.xml,\
diff --git tools/pldt/org.eclipse.ptp.pldt.mpi.core/plugin.xml tools/pldt/org.eclipse.ptp.pldt.mpi.core/plugin.xml
index e6134a7..9f95ce8 100644
--- tools/pldt/org.eclipse.ptp.pldt.mpi.core/plugin.xml
+++ tools/pldt/org.eclipse.ptp.pldt.mpi.core/plugin.xml
@@ -119,10 +119,25 @@
-
+
+
-
+
+
+
+
+
+
+
+
diff --git tools/pldt/org.eclipse.ptp.pldt.mpi.core/schema/artifactAnalysis.exsd tools/pldt/org.eclipse.ptp.pldt.mpi.core/schema/artifactAnalysis.exsd
new file mode 100644
index 0000000..749c1af
--- /dev/null
+++ tools/pldt/org.eclipse.ptp.pldt.mpi.core/schema/artifactAnalysis.exsd
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+ Allows plug-ins to contribute MPI artifact analyses.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 6.0
+
+
+
+
+
+
+
+
diff --git tools/pldt/org.eclipse.ptp.pldt.mpi.core/src/org/eclipse/ptp/pldt/mpi/core/actions/RunAnalyseMPIcommandHandler.java tools/pldt/org.eclipse.ptp.pldt.mpi.core/src/org/eclipse/ptp/pldt/mpi/core/actions/RunAnalyseMPIcommandHandler.java
index 0ba3102..a6aadf7 100644
--- tools/pldt/org.eclipse.ptp.pldt.mpi.core/src/org/eclipse/ptp/pldt/mpi/core/actions/RunAnalyseMPIcommandHandler.java
+++ tools/pldt/org.eclipse.ptp.pldt.mpi.core/src/org/eclipse/ptp/pldt/mpi/core/actions/RunAnalyseMPIcommandHandler.java
@@ -1,5 +1,5 @@
-/**********************************************************************
- * Copyright (c) 2007,2011 IBM Corporation.
+/*******************************************************************************
+ * Copyright (c) 2007, 2011, 2012 IBM Corporation, University of Illinois, 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
@@ -7,36 +7,31 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Jeff Overbey (UIUC) - modified to use extension point
*******************************************************************************/
-
package org.eclipse.ptp.pldt.mpi.core.actions;
-import java.lang.reflect.Method;
import java.util.List;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
-import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
-import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.ptp.pldt.common.CommonPlugin;
import org.eclipse.ptp.pldt.common.ScanReturn;
import org.eclipse.ptp.pldt.common.actions.RunAnalyseHandlerBase;
import org.eclipse.ptp.pldt.common.util.ViewActivator;
import org.eclipse.ptp.pldt.mpi.core.MPIArtifactMarkingVisitor;
import org.eclipse.ptp.pldt.mpi.core.MpiPlugin;
-import org.eclipse.ptp.pldt.mpi.core.analysis.MpiCASTVisitor;
-import org.eclipse.ptp.pldt.mpi.core.analysis.MpiCPPASTVisitor;
import org.eclipse.ptp.pldt.mpi.internal.core.MpiIDs;
/**
- * @author tibbitts
- *
+ * @author Beth Tibbitts
+ * @author Jeff Overbey
*/
public class RunAnalyseMPIcommandHandler extends RunAnalyseHandlerBase {
/**
+ * ID for the extension point which allows plug-ins to contribute MPI artifact analyses based on language IDs.
+ */
+ private static final String EXTENSION_POINT_ID = "org.eclipse.ptp.pldt.mpi.core.artifactAnalysis";
+
+ /**
* Constructor for the "Run Analysis" action
*/
public RunAnalyseMPIcommandHandler() {
@@ -53,50 +48,8 @@ public class RunAnalyseMPIcommandHandler extends RunAnalyseHandlerBase {
*/
@Override
public ScanReturn doArtifactAnalysis(final ITranslationUnit tu, final List includes) {
- final ScanReturn msr = new ScanReturn();
- final String fileName = tu.getElementName();
- ILanguage lang;
- boolean allowPrefixOnlyMatch = MpiPlugin.getDefault().getPreferenceStore()
- .getBoolean(MpiIDs.MPI_RECOGNIZE_APIS_BY_PREFIX_ALONE);
- try {
- lang = tu.getLanguage();
-
- // long startTime = System.currentTimeMillis();
- IASTTranslationUnit atu = getAST(tu); // use index; was tu.getAST();
-
- // long endTime = System.currentTimeMillis();
- // System.out.println("RunAnalyseMPICommandHandler: time to build AST for "+tu+": "+(endTime-startTime)/1000.0+" sec");
- String languageID = lang.getId();
- if (languageID.equals(GCCLanguage.ID) || languageID.equals(GPPLanguage.ID)) {
- // null IASTTranslationUnit when we're doing C/C++ means we should quit.
- // but want to continue to see if this is a fortran file we are analyzing.
- if (atu == null) {// this is null for Fortran file during JUnit testing.
- System.out.println("RunAnalyseMPICommandHandler.doArtifactAnalysis(), atu is null (Fortran testing?)"); //$NON-NLS-1$
- return msr;
- }
- }
- if (languageID.equals(GCCLanguage.ID)) {// C
- atu.accept(new MpiCASTVisitor(includes, fileName, allowPrefixOnlyMatch, msr));
- } else if (languageID.equals(GPPLanguage.ID)) { // C++
- atu.accept(new MpiCPPASTVisitor(includes, fileName, allowPrefixOnlyMatch, msr));
- } else {
- // Attempt to handle Fortran
- // Instantiate using reflection to avoid static Photran dependencies
- try {
- Class> c = Class.forName("org.eclipse.ptp.pldt.mpi.fortran.actions.AnalyseMPIFortranHandler"); //$NON-NLS-1$
- Method method = c.getMethod("run", String.class, ITranslationUnit.class, String.class, ScanReturn.class); //$NON-NLS-1$
- method.invoke(c.newInstance(), languageID, tu, fileName, msr);
- } catch (Exception e) {
- System.err.println("RunAnalyseMPIcommandHandler.doArtifactAnalysis: Photran not installed"); //$NON-NLS-1$
- }
- }
- } catch (CoreException e) {
- e.printStackTrace();
- CommonPlugin
- .log(IStatus.ERROR,
- "RunAnalyseMPICommandHandler.getAST():Error setting up visitor for project " + tu.getCProject() + " error=" + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return msr;
+ final boolean allowPrefixOnlyMatch = MpiPlugin.getDefault().getPreferenceStore().getBoolean(MpiIDs.MPI_RECOGNIZE_APIS_BY_PREFIX_ALONE);
+ return runArtifactAnalysisFromExtensionPoint(EXTENSION_POINT_ID, tu, includes, allowPrefixOnlyMatch);
}
@Override
diff --git tools/pldt/org.eclipse.ptp.pldt.mpi.core/src/org/eclipse/ptp/pldt/mpi/core/analysis/CMPIArtifactAnalysis.java tools/pldt/org.eclipse.ptp.pldt.mpi.core/src/org/eclipse/ptp/pldt/mpi/core/analysis/CMPIArtifactAnalysis.java
new file mode 100644
index 0000000..768014e
--- /dev/null
+++ tools/pldt/org.eclipse.ptp.pldt.mpi.core/src/org/eclipse/ptp/pldt/mpi/core/analysis/CMPIArtifactAnalysis.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011, 2012 IBM Corporation, University of Illinois, 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Jeff Overbey (UIUC) - modified to use extension point
+ *******************************************************************************/
+package org.eclipse.ptp.pldt.mpi.core.analysis;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
+import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.ptp.pldt.common.ArtifactAnalysisBase;
+import org.eclipse.ptp.pldt.common.IArtifactAnalysis;
+import org.eclipse.ptp.pldt.common.ScanReturn;
+
+/**
+ * MPI artifact analysis for C and C++.
+ *
+ * Contributed to the org.eclipse.ptp.pldt.mpi.core.artifactAnalysis
extension point.
+ *
+ * @author Beth Tibbitts
+ * @author Jeff Overbey
+ */
+public class CMPIArtifactAnalysis extends ArtifactAnalysisBase implements IArtifactAnalysis {
+ public ScanReturn runArtifactAnalysis(String languageID, ITranslationUnit tu, List includes, boolean allowPrefixOnlyMatch) {
+ final ScanReturn msr = new ScanReturn();
+ final String fileName = tu.getElementName();
+ final IASTTranslationUnit atu = getAST(tu); // use index; was tu.getAST();
+ if (atu != null) {
+ if (languageID.equals(GCCLanguage.ID)) { // C
+ atu.accept(new MpiCASTVisitor(includes, fileName, allowPrefixOnlyMatch, msr));
+ } else if (languageID.equals(GPPLanguage.ID)) { // C++
+ atu.accept(new MpiCPPASTVisitor(includes, fileName, allowPrefixOnlyMatch, msr));
+ } else {
+ throw new IllegalStateException("Unexpected language ID " + languageID);
+ }
+ }
+ return msr;
+ }
+}
diff --git tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/META-INF/MANIFEST.MF tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/META-INF/MANIFEST.MF
index 3aa32e3..9a9d359 100644
--- tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/META-INF/MANIFEST.MF
+++ tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/META-INF/MANIFEST.MF
@@ -7,13 +7,17 @@ Bundle-ClassPath: .
Bundle-Activator: org.eclipse.ptp.pldt.mpi.fortran.Activator
Bundle-Vendor: %pluginProvider
Bundle-Localization: plugin
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
+Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
+ org.eclipse.help,
+ org.eclipse.ui,
+ org.eclipse.ui.editors,
org.eclipse.cdt.core,
org.eclipse.cdt.ui,
- org.eclipse.ptp.pldt.common,
org.eclipse.photran.cdtinterface;bundle-version="7.0.0",
- org.eclipse.photran.core.vpg;bundle-version="7.0.0"
+ org.eclipse.photran.core.vpg;bundle-version="7.0.0",
+ org.eclipse.photran.ui;bundle-version="8.0.0",
+ org.eclipse.ptp.pldt.common,
+ org.eclipse.ptp.pldt.mpi.core
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/build.properties tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/build.properties
index 41c9fe3..ee9ccb9 100644
--- tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/build.properties
+++ tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/build.properties
@@ -1,7 +1,8 @@
bin.includes = META-INF/,\
.,\
plugin.properties,\
- about.html
+ about.html,\
+ plugin.xml
jars.compile.order = .
source.. = src/
output.. = bin/
diff --git tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/plugin.xml tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/plugin.xml
new file mode 100644
index 0000000..2022dbd
--- /dev/null
+++ tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/plugin.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/Activator.java tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/Activator.java
index 14ac9cc..276035a 100644
--- tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/Activator.java
+++ tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/Activator.java
@@ -13,6 +13,8 @@ package org.eclipse.ptp.pldt.mpi.fortran;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -28,6 +30,38 @@ public class Activator extends AbstractUIPlugin {
private static final String PLUGIN_ID = "org.eclipse.ptp.pldt.mpi.fortran"; //$NON-NLS-1$
/**
+ * Returns the shared instance.
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns the workspace instance.
+ */
+ public static IWorkspace getWorkspace() {
+ return ResourcesPlugin.getWorkspace();
+ }
+
+ /**
+ * Returns the standard display to be used. The method first checks, if the
+ * thread calling this method has an associated display. If so, this display
+ * is returned. Otherwise the method returns the default display.
+ */
+ public static Display getStandardDisplay() {
+ Display display;
+ display = Display.getCurrent();
+ if (display == null) {
+ display = Display.getDefault();
+ }
+ return display;
+ }
+
+ public static String getPluginId() {
+ return PLUGIN_ID;
+ }
+
+ /**
* The constructor.
*/
public Activator() {
@@ -53,34 +87,29 @@ public class Activator extends AbstractUIPlugin {
}
/**
- * Returns the shared instance.
+ * Create log entry from an IStatus
+ *
+ * @param status
*/
- public static Activator getDefault() {
- return plugin;
+ public static void log(IStatus status) {
+ getDefault().getLog().log(status);
}
/**
- * Returns the workspace instance.
+ * Create log entry from a string
+ *
+ * @param msg
*/
- public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
+ public static void log(String msg) {
+ log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, msg, null));
}
/**
- * Returns the standard display to be used. The method first checks, if the
- * thread calling this method has an associated display. If so, this display
- * is returned. Otherwise the method returns the default display.
+ * Create log entry from a Throwable
+ *
+ * @param e
*/
- public static Display getStandardDisplay() {
- Display display;
- display = Display.getCurrent();
- if (display == null) {
- display = Display.getDefault();
- }
- return display;
- }
-
- public static String getPluginId() {
- return PLUGIN_ID;
+ public static void log(Throwable e) {
+ log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, e.getMessage(), e));
}
}
diff --git tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/actions/AnalyseMPIFortranHandler.java tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/actions/AnalyseMPIFortranHandler.java
index 08d02d8..abcedfa 100644
--- tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/actions/AnalyseMPIFortranHandler.java
+++ tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/actions/AnalyseMPIFortranHandler.java
@@ -19,7 +19,7 @@ import org.eclipse.photran.internal.core.lexer.ASTLexerFactory;
import org.eclipse.photran.internal.core.parser.ASTExecutableProgramNode;
import org.eclipse.photran.internal.core.parser.Parser;
import org.eclipse.ptp.pldt.common.ScanReturn;
-import org.eclipse.ptp.pldt.mpi.fortran.analysis.MpiFortranASTVisitor;
+import org.eclipse.ptp.pldt.mpi.fortran.analysis.MPIFortranASTVisitor;
/**
* @since 4.0
@@ -34,7 +34,7 @@ public class AnalyseMPIFortranHandler {
try {
ASTExecutableProgramNode ast = new Parser().parse(new ASTLexerFactory().createLexer(file));
- ast.accept(new MpiFortranASTVisitor(fileName, msr));
+ ast.accept(new MPIFortranASTVisitor(fileName, msr));
} catch (Exception e) {
e.printStackTrace(); // TODO
}
diff --git tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/analysis/MPIFortranASTVisitor.java tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/analysis/MPIFortranASTVisitor.java
new file mode 100644
index 0000000..404b709
--- /dev/null
+++ tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/analysis/MPIFortranASTVisitor.java
@@ -0,0 +1,71 @@
+/**********************************************************************
+ * Copyright (c) 2005, 2010 IBM Corporation.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ptp.pldt.mpi.fortran.analysis;
+
+import org.eclipse.photran.internal.core.lexer.Token;
+import org.eclipse.photran.internal.core.parser.ASTCallStmtNode;
+import org.eclipse.photran.internal.core.parser.ASTNameNode;
+import org.eclipse.photran.internal.core.parser.ASTVarOrFnRefNode;
+import org.eclipse.photran.internal.core.parser.GenericASTVisitor;
+import org.eclipse.ptp.pldt.common.Artifact;
+import org.eclipse.ptp.pldt.common.ScanReturn;
+import org.eclipse.ptp.pldt.common.util.SourceInfo;
+
+/**
+ * This dom-walker collects "artifacts" related to the specific domain
+ * (e.g. MPI, OpenMP, etc.). Currently these artifacts include function calls
+ * and constants. It adds markers to the source file for C code, marking the
+ * position of the artifacts found.
+ *
+ * @author Beth Tibbitts
+ * @since 4.0
+ *
+ */
+public class MPIFortranASTVisitor extends GenericASTVisitor {
+ private static final String PREFIX = "MPI_"; //$NON-NLS-1$
+
+ @SuppressWarnings("unused")
+ private static final boolean traceOn = false;
+ private final ScanReturn scanReturn;
+ private final String fileName;
+
+ @Override
+ public void visitASTCallStmtNode(ASTCallStmtNode node) {
+ Token subroutineName = node.getSubroutineName();
+ addArtifact(subroutineName, Artifact.FUNCTION_CALL);
+ }
+
+ @Override
+ public void visitASTVarOrFnRefNode(ASTVarOrFnRefNode node) {
+ ASTNameNode nameNode = node.getName();
+ if (nameNode != null) {
+ Token varName = nameNode.getName();
+ addArtifact(varName, Artifact.CONSTANT);
+ }
+ }
+
+ private void addArtifact(Token subroutineName, int artifactType) {
+ String callname = subroutineName.getText().toUpperCase();
+ if (callname.startsWith(PREFIX)) {
+ int start = subroutineName.getFileOffset();
+ int end = subroutineName.getFileOffset() + subroutineName.getLength();
+ SourceInfo si = new SourceInfo(subroutineName.getLine(), start, end, artifactType);
+ scanReturn.addArtifact(new Artifact(fileName, subroutineName.getLine(), 1, callname, si));
+ }
+ }
+
+ public MPIFortranASTVisitor(String fileName, ScanReturn scanReturn) {
+ super();
+ this.scanReturn = scanReturn;
+ this.fileName = fileName;
+ }
+
+}
\ No newline at end of file
diff --git tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/analysis/MPIFortranArtifactAnalysis.java tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/analysis/MPIFortranArtifactAnalysis.java
new file mode 100644
index 0000000..24d9552
--- /dev/null
+++ tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/analysis/MPIFortranArtifactAnalysis.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2012 University of Illinois at Urbana-Champaign 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * UIUC - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ptp.pldt.mpi.fortran.analysis;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.ptp.pldt.common.IArtifactAnalysis;
+import org.eclipse.ptp.pldt.common.ScanReturn;
+import org.eclipse.ptp.pldt.mpi.fortran.actions.AnalyseMPIFortranHandler;
+
+/**
+ * MPI artifact analysis for Fortran.
+ *
+ * Contributed to the org.eclipse.ptp.pldt.mpi.core.artifactAnalysis
extension point.
+ *
+ * @author Jeff Overbey
+ */
+public class MPIFortranArtifactAnalysis implements IArtifactAnalysis {
+ public ScanReturn runArtifactAnalysis(String languageID, ITranslationUnit tu, List includes, boolean allowPrefixOnlyMatch) {
+ final ScanReturn msr = new ScanReturn();
+ new AnalyseMPIFortranHandler().run(languageID, tu, tu.getElementName(), msr);
+ return msr;
+ }
+}
diff --git tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/analysis/MpiFortranASTVisitor.java tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/analysis/MpiFortranASTVisitor.java
deleted file mode 100644
index 1437a64..0000000
--- tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/analysis/MpiFortranASTVisitor.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2005, 2010 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ptp.pldt.mpi.fortran.analysis;
-
-import org.eclipse.photran.internal.core.lexer.Token;
-import org.eclipse.photran.internal.core.parser.ASTCallStmtNode;
-import org.eclipse.photran.internal.core.parser.ASTNameNode;
-import org.eclipse.photran.internal.core.parser.ASTVarOrFnRefNode;
-import org.eclipse.photran.internal.core.parser.GenericASTVisitor;
-import org.eclipse.ptp.pldt.common.Artifact;
-import org.eclipse.ptp.pldt.common.ScanReturn;
-import org.eclipse.ptp.pldt.common.util.SourceInfo;
-
-/**
- * This dom-walker collects "artifacts" related to the specific domain
- * (e.g. MPI, OpenMP, etc.). Currently these artifacts include function calls
- * and constants. It adds markers to the source file for C code, marking the
- * position of the artifacts found.
- *
- * @author Beth Tibbitts
- * @since 4.0
- *
- */
-public class MpiFortranASTVisitor extends GenericASTVisitor {
- private static final String PREFIX = "MPI_"; //$NON-NLS-1$
-
- @SuppressWarnings("unused")
- private static final boolean traceOn = false;
- private final ScanReturn scanReturn;
- private final String fileName;
-
- @Override
- public void visitASTCallStmtNode(ASTCallStmtNode node) {
- Token subroutineName = node.getSubroutineName();
- addArtifact(subroutineName, Artifact.FUNCTION_CALL);
- }
-
- @Override
- public void visitASTVarOrFnRefNode(ASTVarOrFnRefNode node) {
- ASTNameNode nameNode = node.getName();
- if (nameNode != null) {
- Token varName = nameNode.getName();
- addArtifact(varName, Artifact.CONSTANT);
- }
- }
-
- private void addArtifact(Token subroutineName, int artifactType) {
- String callname = subroutineName.getText().toUpperCase();
- if (callname.startsWith(PREFIX)) {
- int start = subroutineName.getFileOffset();
- int end = subroutineName.getFileOffset() + subroutineName.getLength();
- SourceInfo si = new SourceInfo(subroutineName.getLine(), start, end, artifactType);
- scanReturn.addArtifact(new Artifact(fileName, subroutineName.getLine(), 1, callname, si));
- }
- }
-
- public MpiFortranASTVisitor(String fileName, ScanReturn scanReturn) {
- super();
- this.scanReturn = scanReturn;
- this.fileName = fileName;
- }
-
-}
\ No newline at end of file
diff --git tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/editorHelp/MpiFortranHelpProvider.java tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/editorHelp/MpiFortranHelpProvider.java
new file mode 100644
index 0000000..f3105a0
--- /dev/null
+++ tools/pldt/org.eclipse.ptp.pldt.mpi.fortran/src/org/eclipse/ptp/pldt/mpi/fortran/editorHelp/MpiFortranHelpProvider.java
@@ -0,0 +1,108 @@
+/**********************************************************************
+ * Copyright (c) 2005, 2011 IBM Corporation.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ptp.pldt.mpi.fortran.editorHelp;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.help.IHelpResource;
+import org.eclipse.photran.ui.IFortranAPIHelpProvider;
+import org.eclipse.ptp.pldt.mpi.core.MpiPlugin;
+import org.eclipse.ptp.pldt.mpi.fortran.Activator;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Help book for Fortran MPI functions
+ *
+ * @author Beth Tibbitts
+ * @author Jeff Overbey
+ */
+public class MpiFortranHelpProvider implements IFortranAPIHelpProvider {
+ private final Map fNameToCname;
+
+ /**
+ * builds the list of function summaries by parsing an XML file
+ */
+ public MpiFortranHelpProvider() {
+ Map fNameToCname;
+ URL fileURL = FileLocator.find(Platform.getBundle(MpiPlugin.getPluginId()), new Path("mpiref.xml"), null); //$NON-NLS-1$
+ try {
+ fNameToCname = parseDOM(fileURL.openStream());
+ } catch (IOException e) {
+ Activator.log(e);
+ fNameToCname = Collections.emptyMap();
+ }
+ this.fNameToCname = fNameToCname;
+ }
+
+ public static Map parseDOM(InputStream xmlIn) {
+ final Map fNameToCname = new HashMap();
+ if (xmlIn != null)
+ {
+ try {
+ DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document document = builder.parse(xmlIn);
+ NodeList functionList = document.getElementsByTagName("function");//$NON-NLS-1$
+ for (int i = 0; i < functionList.getLength(); i++) {
+ Node func = functionList.item(i);
+ NodeList child = func.getChildNodes();
+ String fname = null;
+ String cname = null;
+ // String desc = null;
+ for (int j = 0; j < child.getLength(); j++) {
+ Node sub = child.item(j);
+ if (sub.getNodeName().equals("cname")) {
+ cname = sub.getTextContent(); // java 5
+ //} else if (sub.getNodeName().equals("description")) {//$NON-NLS-1$
+ // desc = sub.getTextContent(); // java 5
+ } else if (sub.getNodeName().equals("fname")) {//$NON-NLS-1$
+ fname = sub.getTextContent(); // java 5
+ }
+ }
+ if (fname != null && cname != null) {
+ fNameToCname.put(fname.toUpperCase(), cname);
+ }
+ }
+ } catch (Exception e) {
+ Activator.log(e);
+ }
+ }
+ return fNameToCname;
+ }
+
+ public IHelpResource[] getHelpResources(ITextEditor fortranEditor, String name, String precedingText) {
+ final String fname = name.toUpperCase();
+ if (fNameToCname.containsKey(fname)) {
+ return new IHelpResource[] { new IHelpResource() {
+ public String getHref() {
+ return String.format("/%s/html/%s.html", MpiPlugin.getPluginId(), fNameToCname.get(fname));
+ }
+ public String getLabel() {
+ return fname;
+ }
+ } };
+ }
+ return null;
+ }
+}
diff --git tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/META-INF/MANIFEST.MF tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/META-INF/MANIFEST.MF
index 8aded0a..573e8d8 100644
--- tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/META-INF/MANIFEST.MF
+++ tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/META-INF/MANIFEST.MF
@@ -15,6 +15,9 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.cdt.ui,
org.eclipse.ptp.pldt.common,
org.eclipse.ptp.pldt.openacc,
+ org.eclipse.photran.core,
+ org.eclipse.photran.core.vpg,
+ org.eclipse.photran.cdtinterface,
org.eclipse.photran.ui;bundle-version="8.0.0"
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
diff --git tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/plugin.xml tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/plugin.xml
index 6fdd17f..49808c3 100644
--- tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/plugin.xml
+++ tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/plugin.xml
@@ -2,6 +2,13 @@
+
+
+
+
+
diff --git tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/src/org/eclipse/ptp/pldt/openacc/internal/fortran/actions/OpenACCFortranASTVisitor.java tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/src/org/eclipse/ptp/pldt/openacc/internal/fortran/actions/OpenACCFortranASTVisitor.java
new file mode 100644
index 0000000..0b1ff77
--- /dev/null
+++ tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/src/org/eclipse/ptp/pldt/openacc/internal/fortran/actions/OpenACCFortranASTVisitor.java
@@ -0,0 +1,85 @@
+/**********************************************************************
+ * Copyright (c) 2005, 2010 IBM Corporation.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ptp.pldt.openacc.internal.fortran.actions;
+
+import org.eclipse.photran.internal.core.lexer.Token;
+import org.eclipse.photran.internal.core.parser.ASTCallStmtNode;
+import org.eclipse.photran.internal.core.parser.ASTNameNode;
+import org.eclipse.photran.internal.core.parser.ASTVarOrFnRefNode;
+import org.eclipse.photran.internal.core.parser.GenericASTVisitor;
+import org.eclipse.ptp.pldt.common.Artifact;
+import org.eclipse.ptp.pldt.common.ScanReturn;
+import org.eclipse.ptp.pldt.common.util.SourceInfo;
+
+/**
+ * This dom-walker collects "artifacts" related to the specific domain
+ * (e.g. MPI, OpenMP, etc.). Currently these artifacts include function calls
+ * and constants. It adds markers to the source file for C code, marking the
+ * position of the artifacts found.
+ *
+ * @author Beth Tibbitts
+ * @since 4.0
+ *
+ */
+public class OpenACCFortranASTVisitor extends GenericASTVisitor {
+ private static final String PREFIX = "ACC_"; //$NON-NLS-1$
+
+ @SuppressWarnings("unused")
+ private static final boolean traceOn = false;
+ private final ScanReturn scanReturn;
+ private final String fileName;
+
+ @Override
+ public void visitToken(Token node) {
+ /*
+ * In Fortran, OpenACC directives are comments (e.g., !$acc parallel).
+ * Photran attaches comments to the following token. Since they appear
+ * before several types of statements (including END statements), it's
+ * easiest to just iterate through all the tokens in the AST and collect
+ * the preceding OpenMP directives.
+ */
+ for (Token accDirective : node.getOpenACCComments()) {
+ addArtifact(accDirective, Artifact.PRAGMA);
+ }
+ }
+
+ @Override
+ public void visitASTCallStmtNode(ASTCallStmtNode node) {
+ Token subroutineName = node.getSubroutineName();
+ addArtifact(subroutineName, Artifact.FUNCTION_CALL);
+ }
+
+ @Override
+ public void visitASTVarOrFnRefNode(ASTVarOrFnRefNode node) {
+ ASTNameNode nameNode = node.getName();
+ if (nameNode != null) {
+ Token varName = nameNode.getName();
+ addArtifact(varName, Artifact.CONSTANT);
+ }
+ }
+
+ private void addArtifact(Token subroutineName, int artifactType) {
+ String callname = subroutineName.getText().toUpperCase();
+ if (artifactType == Artifact.PRAGMA || callname.startsWith(PREFIX)) {
+ int start = subroutineName.getFileOffset();
+ int end = subroutineName.getFileOffset() + subroutineName.getLength();
+ SourceInfo si = new SourceInfo(subroutineName.getLine(), start, end, artifactType);
+ scanReturn.addArtifact(new Artifact(fileName, subroutineName.getLine(), 1, callname, si));
+ }
+ }
+
+ public OpenACCFortranASTVisitor(String fileName, ScanReturn scanReturn) {
+ super();
+ this.scanReturn = scanReturn;
+ this.fileName = fileName;
+ }
+
+}
\ No newline at end of file
diff --git tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/src/org/eclipse/ptp/pldt/openacc/internal/fortran/actions/OpenACCFortranArtifactAnalysis.java tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/src/org/eclipse/ptp/pldt/openacc/internal/fortran/actions/OpenACCFortranArtifactAnalysis.java
new file mode 100644
index 0000000..00c039d
--- /dev/null
+++ tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/src/org/eclipse/ptp/pldt/openacc/internal/fortran/actions/OpenACCFortranArtifactAnalysis.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2012 University of Illinois at Urbana-Champaign 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * UIUC - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ptp.pldt.openacc.internal.fortran.actions;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.photran.internal.cdtinterface.core.FortranLanguage;
+import org.eclipse.photran.internal.core.lexer.ASTLexerFactory;
+import org.eclipse.photran.internal.core.parser.ASTExecutableProgramNode;
+import org.eclipse.photran.internal.core.parser.Parser;
+import org.eclipse.ptp.pldt.common.IArtifactAnalysis;
+import org.eclipse.ptp.pldt.common.ScanReturn;
+
+/**
+ * OpenACC artifact analysis for Fortran.
+ *
+ * Contributed to the org.eclipse.ptp.pldt.mpi.core.artifactAnalysis
extension point.
+ *
+ * @author Jeff Overbey
+ */
+public class OpenACCFortranArtifactAnalysis implements IArtifactAnalysis {
+ @Override
+ public ScanReturn runArtifactAnalysis(String languageID, ITranslationUnit tu, List includes, boolean allowPrefixOnlyMatch) {
+ final ScanReturn msr = new ScanReturn();
+ final String fileName = tu.getElementName();
+ if (languageID.equals(FortranLanguage.LANGUAGE_ID)) {
+ IResource res = tu.getUnderlyingResource();
+ if (!(res instanceof IFile))
+ throw new IllegalStateException();
+ IFile file = (IFile) res;
+
+ try {
+ ASTExecutableProgramNode ast = new Parser().parse(new ASTLexerFactory().createLexer(file));
+ ast.accept(new OpenACCFortranASTVisitor(fileName, msr));
+ } catch (Exception e) {
+ e.printStackTrace(); // TODO
+ }
+ }
+ return msr;
+ }
+}
diff --git tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/src/org/eclipse/ptp/pldt/openacc/internal/fortran/editorHelp/OpenACCFortranHelpProvider.java tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/src/org/eclipse/ptp/pldt/openacc/internal/fortran/editorHelp/OpenACCFortranHelpProvider.java
index 36c6541..1ad798d 100644
--- tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/src/org/eclipse/ptp/pldt/openacc/internal/fortran/editorHelp/OpenACCFortranHelpProvider.java
+++ tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/src/org/eclipse/ptp/pldt/openacc/internal/fortran/editorHelp/OpenACCFortranHelpProvider.java
@@ -27,16 +27,21 @@ public class OpenACCFortranHelpProvider implements IFortranAPIHelpProvider {
/** Plug-in ID for the main (non-Fortran) OpenACC plug-in, which contains HTML documentation. */
private static final String OPENACC_PLUGIN_ID = "org.eclipse.ptp.pldt.openacc"; //$NON-NLS-1$
- /** Regular expression matching the start of an OpenACC directive */
- private static final Pattern OPENACC_DIRECTIVE_PREFIX = Pattern
+ /** Pattern matching the start of an OpenACC directive */
+ private static final Pattern OPENACC_DIRECTIVE_PREFIX_PATTERN = Pattern
.compile("(^[Cc*]|[ \\t]*!)\\$acc([ \\t]+end)?([ \\t]+parallel)?[ \\t]*"); //$NON-NLS-1$
+ /** Format string for an OpenACC directive. %s is replaced with a directive name. */
+ private static final String OPENACC_DIRECTIVE_REGEX_FORMAT =
+ "(^[Cc*]|[ \\t]*!)\\$acc([ \\t]+end)?([ \\t]+parallel)?[ \\t]+%s.*"; //$NON-NLS-1$
+
private final Set procedures = new HashSet(32);
private final Set directives = new HashSet(32);
/** Constructor */
public OpenACCFortranHelpProvider() {
- procedures.add("acc_get_num_devices"); // OpenACC Application Programming Interface, Version 1.0, Section 3.2.1 //$NON-NLS-1$
+ // Section numbers from the OpenACC specification: "The OpenACC Application Programming Interface, Version 1.0"
+ procedures.add("acc_get_num_devices"); // Section 3.2.1 //$NON-NLS-1$
procedures.add("acc_set_device_type"); // 3.2.2 //$NON-NLS-1$
procedures.add("acc_get_device_type"); // 3.2.3 //$NON-NLS-1$
procedures.add("acc_set_device_num"); // 3.2.4 //$NON-NLS-1$
@@ -67,8 +72,16 @@ public class OpenACCFortranHelpProvider implements IFortranAPIHelpProvider {
final String fname = apiName.toLowerCase();
if (procedures.contains(fname)) {
return getHelpResourceForFilename(fname);
- } else if (directives.contains(fname) && OPENACC_DIRECTIVE_PREFIX.matcher(precedingText).matches()) {
- return getHelpResourceForFilename("pragma_acc_" + fname); //$NON-NLS-1$
+ } else if (OPENACC_DIRECTIVE_PREFIX_PATTERN.matcher(precedingText).find()) {
+ if (directives.contains(fname)) {
+ return getHelpResourceForFilename("pragma_acc_" + fname); //$NON-NLS-1$
+ } else {
+ for (String directive : directives) {
+ if (precedingText.matches(String.format(OPENACC_DIRECTIVE_REGEX_FORMAT, directive))) {
+ return getHelpResourceForFilename("pragma_acc_" + directive); //$NON-NLS-1$
+ }
+ }
+ }
}
return null;
}
diff --git tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/templates/openacc_templates.xml tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/templates/openacc_templates.xml
index 45f3331..6709201 100644
--- tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/templates/openacc_templates.xml
+++ tools/pldt/org.eclipse.ptp.pldt.openacc.fortran/templates/openacc_templates.xml
@@ -1,7 +1,75 @@
+ !$$acc cache (${cursor})
+ !$$acc data${cursor}
+ !$$acc end data${cursor}
+ !$$acc declare ${cursor}
+ !$$acc host_data${cursor}
+ !$$acc end host_data${cursor}
+ !$$acc kernels${cursor}
+ !$$acc end kernels${cursor}
+ !$$acc kernels loop${cursor}
+ !$$acc end kernels loop${cursor}
+ !$$acc loop${cursor}
+ !$$acc end loop${cursor}
!$$acc parallel${cursor}
-
+ !$$acc end parallel${cursor}
+ !$$acc parallel loop${cursor}
+ !$$acc end parallel loop${cursor}
+ !$$acc update ${cursor}
+ !$$acc wait${cursor}
+
\ No newline at end of file
diff --git tools/pldt/org.eclipse.ptp.pldt.openacc/build.properties tools/pldt/org.eclipse.ptp.pldt.openacc/build.properties
index a52b1e7..07d2b05 100644
--- tools/pldt/org.eclipse.ptp.pldt.openacc/build.properties
+++ tools/pldt/org.eclipse.ptp.pldt.openacc/build.properties
@@ -11,5 +11,6 @@ bin.includes = META-INF/,\
about.mappings,\
about.properties,\
ptp_logo_icon32.png,\
- templates/
+ templates/,\
+ schema/
jre.compilation.profile = JavaSE-1.6
diff --git tools/pldt/org.eclipse.ptp.pldt.openacc/plugin.xml tools/pldt/org.eclipse.ptp.pldt.openacc/plugin.xml
index 436b832..fa89ed2 100644
--- tools/pldt/org.eclipse.ptp.pldt.openacc/plugin.xml
+++ tools/pldt/org.eclipse.ptp.pldt.openacc/plugin.xml
@@ -93,6 +93,21 @@
+
+
+
+
+
+
+
+
diff --git tools/pldt/org.eclipse.ptp.pldt.openacc/schema/artifactAnalysis.exsd tools/pldt/org.eclipse.ptp.pldt.openacc/schema/artifactAnalysis.exsd
new file mode 100644
index 0000000..f2662aa
--- /dev/null
+++ tools/pldt/org.eclipse.ptp.pldt.openacc/schema/artifactAnalysis.exsd
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+ Allows plug-ins to contribute OpenACC artifact analyses.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 6.0
+
+
+
+
+
+
+
+
diff --git tools/pldt/org.eclipse.ptp.pldt.openacc/src/org/eclipse/ptp/pldt/openacc/internal/actions/OpenACCCArtifactAnalysis.java tools/pldt/org.eclipse.ptp.pldt.openacc/src/org/eclipse/ptp/pldt/openacc/internal/actions/OpenACCCArtifactAnalysis.java
new file mode 100644
index 0000000..8e0513e
--- /dev/null
+++ tools/pldt/org.eclipse.ptp.pldt.openacc/src/org/eclipse/ptp/pldt/openacc/internal/actions/OpenACCCArtifactAnalysis.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011, 2012 IBM Corporation, University of Illinois, 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Jeff Overbey (UIUC) - modified to use extension point
+ *******************************************************************************/
+package org.eclipse.ptp.pldt.openacc.internal.actions;
+
+import java.util.List;
+import java.util.regex.Pattern;
+
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorPragmaStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.ptp.pldt.common.Artifact;
+import org.eclipse.ptp.pldt.common.ArtifactAnalysisBase;
+import org.eclipse.ptp.pldt.common.IArtifactAnalysis;
+import org.eclipse.ptp.pldt.common.ScanReturn;
+import org.eclipse.ptp.pldt.common.util.SourceInfo;
+import org.eclipse.ptp.pldt.openacc.internal.messages.Messages;
+
+/**
+ * OpenACC artifact analysis for C and C++.
+ *
+ * Contributed to the org.eclipse.ptp.pldt.openacc.artifactAnalysis
extension point.
+ *
+ * @author Beth Tibbitts
+ * @author Jeff Overbey
+ */
+public class OpenACCCArtifactAnalysis extends ArtifactAnalysisBase implements IArtifactAnalysis {
+
+ private static final Pattern ACC_PRAGMA_PATTERN = Pattern
+ .compile("acc[ \t]*(parallel|kernels|data|host_data|loop|cache|declare|update|wait).*"); //$NON-NLS-1$
+
+ @Override
+ public ScanReturn runArtifactAnalysis(String languageID, ITranslationUnit tu, List includes, boolean allowPrefixOnlyMatch) {
+ final ScanReturn msr = new ScanReturn();
+ final IASTTranslationUnit atu = getAST(tu); // use index; was tu.getAST();
+ if (atu != null) {
+ findOpenACCFunctionCalls(includes, msr, tu.getElementName(), atu, allowPrefixOnlyMatch);
+ findOpenACCPragmas(atu, msr);
+ }
+ return msr;
+ }
+
+ private void findOpenACCFunctionCalls(final List includes,
+ final ScanReturn msr, final String fileName,
+ final IASTTranslationUnit atu, boolean allowPrefixOnlyMatch) {
+ atu.accept(new OpenACCCASTVisitor(includes, fileName, allowPrefixOnlyMatch, msr));
+ }
+
+ private void findOpenACCPragmas(final IASTTranslationUnit atu, final ScanReturn msr) {
+ for (final IASTPreprocessorStatement preprocStmt : atu.getAllPreprocessorStatements()) {
+ if (preprocStmt instanceof IASTPreprocessorPragmaStatement) {
+ final String pragmaText = String.valueOf(((IASTPreprocessorPragmaStatement) preprocStmt).getMessage()).trim();
+ if (preprocStmt.isPartOfTranslationUnitFile() && ACC_PRAGMA_PATTERN.matcher(pragmaText).matches()) {
+ final IASTFileLocation astFileLocation = preprocStmt.getFileLocation();
+ final SourceInfo sourceInfo = new SourceInfo();
+ sourceInfo.setStartingLine(astFileLocation.getStartingLineNumber());
+ sourceInfo.setStart(astFileLocation.getNodeOffset());
+ sourceInfo.setEnd(astFileLocation.getNodeOffset() + astFileLocation.getNodeLength());
+ sourceInfo.setConstructType(Artifact.PRAGMA);
+
+ msr.addArtifact(
+ new Artifact(
+ preprocStmt.getContainingFilename(),
+ astFileLocation.getStartingLineNumber(),
+ 1,
+ "#pragma " + pragmaText, //$NON-NLS-1$
+ Messages.RunAnalyseOpenACCcommandHandler_OpenACC_directive,
+ sourceInfo,
+ null));
+ }
+ }
+ }
+ }
+}
diff --git tools/pldt/org.eclipse.ptp.pldt.openacc/src/org/eclipse/ptp/pldt/openacc/internal/actions/RunAnalyseOpenACCcommandHandler.java tools/pldt/org.eclipse.ptp.pldt.openacc/src/org/eclipse/ptp/pldt/openacc/internal/actions/RunAnalyseOpenACCcommandHandler.java
index 8380984..d878e23 100644
--- tools/pldt/org.eclipse.ptp.pldt.openacc/src/org/eclipse/ptp/pldt/openacc/internal/actions/RunAnalyseOpenACCcommandHandler.java
+++ tools/pldt/org.eclipse.ptp.pldt.openacc/src/org/eclipse/ptp/pldt/openacc/internal/actions/RunAnalyseOpenACCcommandHandler.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and University of Illinois.
+ * Copyright (c) 2007, 2011, 2012 IBM Corporation and University of Illinois.
* 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
@@ -7,30 +7,19 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Jeff Overbey - adaptation to OpenACC
+ * Jeff Overbey - adaptation to OpenACC, modified to use extension point
*******************************************************************************/
package org.eclipse.ptp.pldt.openacc.internal.actions;
import java.util.List;
-import java.util.regex.Pattern;
-import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
-import org.eclipse.cdt.core.dom.ast.IASTPreprocessorPragmaStatement;
-import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
-import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.ptp.pldt.common.Artifact;
import org.eclipse.ptp.pldt.common.ArtifactMarkingVisitor;
import org.eclipse.ptp.pldt.common.ScanReturn;
import org.eclipse.ptp.pldt.common.actions.RunAnalyseHandlerBase;
-import org.eclipse.ptp.pldt.common.util.SourceInfo;
import org.eclipse.ptp.pldt.common.util.ViewActivator;
import org.eclipse.ptp.pldt.openacc.internal.Activator;
import org.eclipse.ptp.pldt.openacc.internal.IDs;
-import org.eclipse.ptp.pldt.openacc.internal.messages.Messages;
/**
* Handler for the "Show OpenACC Artifacts" command.
@@ -39,10 +28,15 @@ import org.eclipse.ptp.pldt.openacc.internal.messages.Messages;
* @author Jeff Overbey
*/
public class RunAnalyseOpenACCcommandHandler extends RunAnalyseHandlerBase {
+ /**
+ * ID for the OpenACC Artifacts view, contributed in plugin.xml.
+ */
private static final String VIEW_ID = "org.eclipse.ptp.pldt.openacc.views.OpenACCArtifactView"; //$NON-NLS-1$
- private static final Pattern ACC_PRAGMA_PATTERN = Pattern
- .compile("acc[ \t]*(parallel|kernels|data|host_data|loop|cache|declare|update|wait).*"); //$NON-NLS-1$
+ /**
+ * ID for the extension point which allows plug-ins to contribute OpenMP artifact analyses based on language IDs.
+ */
+ private static final String EXTENSION_POINT_ID = "org.eclipse.ptp.pldt.openacc.artifactAnalysis"; //$NON-NLS-1$
/**
* Constructor. Invoked dynamically due to class reference in plugin.xml.
@@ -62,56 +56,8 @@ public class RunAnalyseOpenACCcommandHandler extends RunAnalyseHandlerBase {
*/
@Override
public ScanReturn doArtifactAnalysis(final ITranslationUnit tu, final List includes) {
- final ScanReturn msr = new ScanReturn();
- final boolean allowPrefixOnlyMatch = Activator.getDefault().getPreferenceStore()
- .getBoolean(IDs.PREF_RECOGNIZE_APIS_BY_PREFIX_ALONE);
- if (traceOn)
- {
- System.out.println("RALCH:OpenACC allowPrefixOnlyMatch=" + allowPrefixOnlyMatch); //$NON-NLS-1$
- }
- try {
- final IASTTranslationUnit atu = tu.getAST();
- final String languageID = tu.getLanguage().getId();
- if (languageID.equals(GCCLanguage.ID) || languageID.equals(GPPLanguage.ID)) {
- findOpenACCFunctionCalls(includes, msr, tu.getElementName(), atu, allowPrefixOnlyMatch);
- findOpenACCPragmas(atu, msr);
- }
- } catch (final CoreException e) {
- Activator.log(e);
- }
- return msr;
- }
-
- private void findOpenACCFunctionCalls(final List includes,
- final ScanReturn msr, final String fileName,
- final IASTTranslationUnit atu, boolean allowPrefixOnlyMatch) {
- atu.accept(new OpenACCCASTVisitor(includes, fileName, allowPrefixOnlyMatch, msr));
- }
-
- private void findOpenACCPragmas(final IASTTranslationUnit atu, final ScanReturn msr) {
- for (final IASTPreprocessorStatement preprocStmt : atu.getAllPreprocessorStatements()) {
- if (preprocStmt instanceof IASTPreprocessorPragmaStatement) {
- final String pragmaText = String.valueOf(((IASTPreprocessorPragmaStatement) preprocStmt).getMessage()).trim();
- if (preprocStmt.isPartOfTranslationUnitFile() && ACC_PRAGMA_PATTERN.matcher(pragmaText).matches()) {
- final IASTFileLocation astFileLocation = preprocStmt.getFileLocation();
- final SourceInfo sourceInfo = new SourceInfo();
- sourceInfo.setStartingLine(astFileLocation.getStartingLineNumber());
- sourceInfo.setStart(astFileLocation.getNodeOffset());
- sourceInfo.setEnd(astFileLocation.getNodeOffset() + astFileLocation.getNodeLength());
- sourceInfo.setConstructType(Artifact.PRAGMA);
-
- msr.addArtifact(
- new Artifact(
- preprocStmt.getContainingFilename(),
- astFileLocation.getStartingLineNumber(),
- 1,
- "#pragma " + pragmaText, //$NON-NLS-1$
- Messages.RunAnalyseOpenACCcommandHandler_OpenACC_directive,
- sourceInfo,
- null));
- }
- }
- }
+ final boolean allowPrefixOnlyMatch = Activator.getDefault().getPreferenceStore().getBoolean(IDs.PREF_RECOGNIZE_APIS_BY_PREFIX_ALONE);
+ return runArtifactAnalysisFromExtensionPoint(EXTENSION_POINT_ID, tu, includes, allowPrefixOnlyMatch);
}
@Override
diff --git tools/pldt/org.eclipse.ptp.pldt.openmp.core/build.properties tools/pldt/org.eclipse.ptp.pldt.openmp.core/build.properties
index 04cc212..dd2afe1 100644
--- tools/pldt/org.eclipse.ptp.pldt.openmp.core/build.properties
+++ tools/pldt/org.eclipse.ptp.pldt.openmp.core/build.properties
@@ -7,5 +7,6 @@ bin.includes = META-INF/,\
samples/,\
plugin.properties,\
html/,\
- about.html
+ about.html,\
+ schema/
bin.excludes = icons/.cvsignore
diff --git tools/pldt/org.eclipse.ptp.pldt.openmp.core/plugin.xml tools/pldt/org.eclipse.ptp.pldt.openmp.core/plugin.xml
index 1d1991c..7ca4fbf 100644
--- tools/pldt/org.eclipse.ptp.pldt.openmp.core/plugin.xml
+++ tools/pldt/org.eclipse.ptp.pldt.openmp.core/plugin.xml
@@ -105,4 +105,20 @@
class="org.eclipse.ptp.pldt.openmp.core.prefs.OpenMPPreferenceInitializer">
+
+
+
+
+
+
+
+
+
diff --git tools/pldt/org.eclipse.ptp.pldt.openmp.core/schema/artifactAnalysis.exsd tools/pldt/org.eclipse.ptp.pldt.openmp.core/schema/artifactAnalysis.exsd
new file mode 100644
index 0000000..ceab837
--- /dev/null
+++ tools/pldt/org.eclipse.ptp.pldt.openmp.core/schema/artifactAnalysis.exsd
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+ Allows plug-ins to contribute OpenMP artifact analyses.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 6.0
+
+
+
+
+
+
+
+
diff --git tools/pldt/org.eclipse.ptp.pldt.openmp.core/src/org/eclipse/ptp/pldt/openmp/core/actions/RunAnalyseOpenMPcommandHandler.java tools/pldt/org.eclipse.ptp.pldt.openmp.core/src/org/eclipse/ptp/pldt/openmp/core/actions/RunAnalyseOpenMPcommandHandler.java
index b4ee3e2..d94bd78 100644
--- tools/pldt/org.eclipse.ptp.pldt.openmp.core/src/org/eclipse/ptp/pldt/openmp/core/actions/RunAnalyseOpenMPcommandHandler.java
+++ tools/pldt/org.eclipse.ptp.pldt.openmp.core/src/org/eclipse/ptp/pldt/openmp/core/actions/RunAnalyseOpenMPcommandHandler.java
@@ -1,5 +1,5 @@
-/**********************************************************************
- * Copyright (c) 2007,2011 IBM Corporation.
+/*******************************************************************************
+ * Copyright (c) 2007, 2011, 2012 IBM Corporation, University of Illinois, 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
@@ -7,42 +7,27 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Jeff Overbey (UIUC) - modified to use extension point
*******************************************************************************/
-
package org.eclipse.ptp.pldt.openmp.core.actions;
-import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
-import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
-import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
-import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ptp.pldt.common.Artifact;
import org.eclipse.ptp.pldt.common.ScanReturn;
import org.eclipse.ptp.pldt.common.actions.RunAnalyseHandlerBase;
-import org.eclipse.ptp.pldt.common.util.SourceInfo;
import org.eclipse.ptp.pldt.common.util.ViewActivator;
-import org.eclipse.ptp.pldt.openmp.analysis.OpenMPAnalysisManager;
import org.eclipse.ptp.pldt.openmp.analysis.OpenMPError;
-import org.eclipse.ptp.pldt.openmp.analysis.OpenMPErrorManager;
-import org.eclipse.ptp.pldt.openmp.analysis.PAST.PASTNode;
-import org.eclipse.ptp.pldt.openmp.analysis.PAST.PASTPragma;
import org.eclipse.ptp.pldt.openmp.core.OpenMPArtifactMarkingVisitor;
import org.eclipse.ptp.pldt.openmp.core.OpenMPPlugin;
import org.eclipse.ptp.pldt.openmp.core.OpenMPScanReturn;
-import org.eclipse.ptp.pldt.openmp.core.analysis.OpenMPCASTVisitor;
import org.eclipse.ptp.pldt.openmp.core.internal.OpenMPIDs;
-import org.eclipse.ptp.pldt.openmp.core.messages.Messages;
import org.eclipse.ptp.pldt.openmp.ui.pv.internal.IDs;
import org.eclipse.ptp.pldt.openmp.ui.pv.views.ProblemMarkerAttrIds;
import org.eclipse.ui.texteditor.MarkerUtilities;
@@ -53,7 +38,11 @@ import org.eclipse.ui.texteditor.MarkerUtilities;
*
*/
public class RunAnalyseOpenMPcommandHandler extends RunAnalyseHandlerBase {
- private static final String OPENMP_DIRECTIVE = Messages.RunAnalyseOpenMPcommandHandler_OpenMP_directive;
+ /**
+ * ID for the extension point which allows plug-ins to contribute OpenMP artifact analyses based on language IDs.
+ */
+ private static final String EXTENSION_POINT_ID = "org.eclipse.ptp.pldt.openmp.core.artifactAnalysis";
+
private static final boolean traceOn = false;
/**
@@ -73,122 +62,8 @@ public class RunAnalyseOpenMPcommandHandler extends RunAnalyseHandlerBase {
*/
@Override
public ScanReturn doArtifactAnalysis(final ITranslationUnit tu, final List includes) {
- OpenMPScanReturn msr = new OpenMPScanReturn();
- final String fileName = tu.getElementName();
- IASTTranslationUnit atu = null;
- ILanguage lang;
- boolean allowPrefixOnlyMatch = OpenMPPlugin.getDefault().getPreferenceStore()
- .getBoolean(OpenMPIDs.OPENMP_RECOGNIZE_APIS_BY_PREFIX_ALONE);
- try {
- lang = tu.getLanguage();
-
- // atu = tu.getAST();
- atu = getAST(tu); // use index; was tu.getAST(); otherwise fortran fails?
- String languageID = lang.getId();
-
- if (languageID.equals(GCCLanguage.ID) || languageID.equals(GPPLanguage.ID)) {
- // null IASTTranslationUnit when we're doing C/C++ means we should quit.
- // but want to continue to see if this is a fortran file we are analyzing.
- if (atu == null) {// this is null for Fortran file during JUnit testing.
- System.out.println("RunAnalyseOpenMPCommandHandler.doArtifactAnalysis(), atu is null (testing?)"); //$NON-NLS-1$
- return msr;
- }
- }
-
- if (languageID.equals(GCCLanguage.ID)) {// cdt40
- atu.accept(new OpenMPCASTVisitor(includes, fileName, allowPrefixOnlyMatch, msr));
- } else {
- // Attempt to handle Fortran
- // Instantiate using reflection to avoid static Photran
- // dependencies
- try {
- Class> c = Class.forName("org.eclipse.ptp.pldt.openmp.fortran.actions.AnalyseOpenMPFortranHandler"); //$NON-NLS-1$
- Method method = c.getMethod("run", String.class, ITranslationUnit.class, String.class, ScanReturn.class); //$NON-NLS-1$
- method.invoke(c.newInstance(), languageID, tu, fileName, msr);
- } catch (Exception e) {
- System.err.println("RunAnalyseOpenMPcommandHandler.doArtifactAnalysis: Photran not installed"); //$NON-NLS-1$
- }
- }
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- IResource res = tu.getResource();
- IFile file = null;
- if (res instanceof IFile) {
- file = (IFile) res;
- } else {
- System.out.println("RunAnalyseOpenMP.doArtifactAnalysis, file cast won't work..."); //$NON-NLS-1$
- }
- // Find the OpenMP #pragmas
- if (atu != null) { // not for Fortran
- processOpenMPPragmas(msr, atu, file);
- }
- return msr;
- }
-
- /**
- * Special processing to find #pragmas, since the CDT AST does not normally include them.
- * Also adds the "OpenMP Problems"
- *
- * @param msr
- * @param astTransUnit
- * @param iFile
- */
- protected void processOpenMPPragmas(OpenMPScanReturn msr, IASTTranslationUnit astTransUnit, IFile iFile) {
- OpenMPAnalysisManager omgr = new OpenMPAnalysisManager(astTransUnit, iFile);
- PASTNode[] pList = omgr.getPAST();
-
- for (int i = 0; i < pList.length; i++) {// length local=3271; remote 4 (!!)
- PASTNode temp = pList[i];
- String tempStr = temp.getRawSignature();
- // local: will be a PASTOMPPragma node; remote: will be a PASTPragma node.
- // So workaround is to accept a PASTPragma node here so we can handle remote files.
- // Need to investigate what this does to further analysis e.g. concurrency analysis.
- if (pList[i] instanceof PASTPragma) {// was PASTOMPPragma
-
- PASTPragma pop = (PASTPragma) pList[i];
- if (traceOn) {
- System.out.println("found #pragma, line " + pop.getStartingLine()); //$NON-NLS-1$
- }
- SourceInfo si = getSourceInfo(pop, Artifact.PRAGMA);
- String shortName = pop.getContent();
- if (shortName.length() == 0) {
- shortName = "#pragma"; // HACK: workaround for remote files where getContent() is always empty.
- // The same reason why this is empty is also (I think) why it's not a PASTOMPPragma node.
- // PASTOMPFactory.parse() always finds empty token first on a remote file, so aborts.
- }
- Artifact a = new Artifact(pop.getFilename(), pop.getStartingLine(), pop.getStartLocation(), shortName,
- OPENMP_DIRECTIVE, si, pop);
- msr.addArtifact(a);
- }
- }
-
- msr.addProblems(OpenMPErrorManager.getCurrentErrorManager().getErrors());
- }
-
- /**
- * Get exact source locational info for a function call
- *
- * @param pastNode
- * @param constructType
- * @return
- */
- private SourceInfo getSourceInfo(PASTNode pastNode, int constructType) {
- SourceInfo sourceInfo = null;
- IASTNodeLocation[] locations = pastNode.getNodeLocations();
- if (locations.length == 1) {
- IASTFileLocation astFileLocation = null;
- if (locations[0] instanceof IASTFileLocation) {
- astFileLocation = (IASTFileLocation) locations[0];
- sourceInfo = new SourceInfo();
- sourceInfo.setStartingLine(astFileLocation.getStartingLineNumber());
- sourceInfo.setStart(astFileLocation.getNodeOffset());
- sourceInfo.setEnd(astFileLocation.getNodeOffset() + astFileLocation.getNodeLength());
- sourceInfo.setConstructType(constructType);
- }
- }
- return sourceInfo;
+ boolean allowPrefixOnlyMatch = OpenMPPlugin.getDefault().getPreferenceStore().getBoolean(OpenMPIDs.OPENMP_RECOGNIZE_APIS_BY_PREFIX_ALONE);
+ return runArtifactAnalysisFromExtensionPoint(EXTENSION_POINT_ID, tu, includes, allowPrefixOnlyMatch);
}
/**
diff --git tools/pldt/org.eclipse.ptp.pldt.openmp.core/src/org/eclipse/ptp/pldt/openmp/core/analysis/OpenMPCArtifactAnalysis.java tools/pldt/org.eclipse.ptp.pldt.openmp.core/src/org/eclipse/ptp/pldt/openmp/core/analysis/OpenMPCArtifactAnalysis.java
new file mode 100644
index 0000000..339f466
--- /dev/null
+++ tools/pldt/org.eclipse.ptp.pldt.openmp.core/src/org/eclipse/ptp/pldt/openmp/core/analysis/OpenMPCArtifactAnalysis.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011, 2012 IBM Corporation, University of Illinois, 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Jeff Overbey (UIUC) - modified to use extension point
+ *******************************************************************************/
+package org.eclipse.ptp.pldt.openmp.core.analysis;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.ptp.pldt.common.Artifact;
+import org.eclipse.ptp.pldt.common.ArtifactAnalysisBase;
+import org.eclipse.ptp.pldt.common.IArtifactAnalysis;
+import org.eclipse.ptp.pldt.common.ScanReturn;
+import org.eclipse.ptp.pldt.common.util.SourceInfo;
+import org.eclipse.ptp.pldt.openmp.analysis.OpenMPAnalysisManager;
+import org.eclipse.ptp.pldt.openmp.analysis.OpenMPErrorManager;
+import org.eclipse.ptp.pldt.openmp.analysis.PAST.PASTNode;
+import org.eclipse.ptp.pldt.openmp.analysis.PAST.PASTPragma;
+import org.eclipse.ptp.pldt.openmp.core.OpenMPScanReturn;
+import org.eclipse.ptp.pldt.openmp.core.messages.Messages;
+
+/**
+ * OpenMP artifact analysis for C.
+ *
+ * Contributed to the org.eclipse.ptp.pldt.openmp.core.artifactAnalysis
extension point.
+ *
+ * @author Beth Tibbitts
+ * @author Jeff Overbey
+ */
+public class OpenMPCArtifactAnalysis extends ArtifactAnalysisBase implements IArtifactAnalysis {
+
+ private static final String OPENMP_DIRECTIVE = Messages.RunAnalyseOpenMPcommandHandler_OpenMP_directive;
+
+ public ScanReturn runArtifactAnalysis(String languageID, ITranslationUnit tu, List includes, boolean allowPrefixOnlyMatch) {
+ final OpenMPScanReturn msr = new OpenMPScanReturn();
+ final String fileName = tu.getElementName();
+ final IASTTranslationUnit atu = getAST(tu); // use index; was tu.getAST()
+ if (atu != null) {
+ atu.accept(new OpenMPCASTVisitor(includes, fileName, allowPrefixOnlyMatch, msr));
+
+ // Find the OpenMP #pragmas
+ if (tu.getResource() instanceof IFile) {
+ processOpenMPPragmas(msr, atu, (IFile) tu.getResource());
+ }
+ }
+ return msr;
+ }
+
+
+ /**
+ * Special processing to find #pragmas, since the CDT AST does not normally include them.
+ * Also adds the "OpenMP Problems"
+ *
+ * @param msr
+ * @param astTransUnit
+ * @param iFile
+ */
+ protected void processOpenMPPragmas(OpenMPScanReturn msr, IASTTranslationUnit astTransUnit, IFile iFile) {
+ OpenMPAnalysisManager omgr = new OpenMPAnalysisManager(astTransUnit, iFile);
+ PASTNode[] pList = omgr.getPAST();
+
+ for (int i = 0; i < pList.length; i++) {// length local=3271; remote 4 (!!)
+ PASTNode temp = pList[i];
+ String tempStr = temp.getRawSignature();
+ // local: will be a PASTOMPPragma node; remote: will be a PASTPragma node.
+ // So workaround is to accept a PASTPragma node here so we can handle remote files.
+ // Need to investigate what this does to further analysis e.g. concurrency analysis.
+ if (pList[i] instanceof PASTPragma) {// was PASTOMPPragma
+
+ PASTPragma pop = (PASTPragma) pList[i];
+ //if (traceOn) {
+ // System.out.println("found #pragma, line " + pop.getStartingLine()); //$NON-NLS-1$
+ //}
+ SourceInfo si = getSourceInfo(pop, Artifact.PRAGMA);
+ String shortName = pop.getContent();
+ if (shortName.length() == 0) {
+ shortName = "#pragma"; // HACK: workaround for remote files where getContent() is always empty.
+ // The same reason why this is empty is also (I think) why it's not a PASTOMPPragma node.
+ // PASTOMPFactory.parse() always finds empty token first on a remote file, so aborts.
+ }
+ Artifact a = new Artifact(pop.getFilename(), pop.getStartingLine(), pop.getStartLocation(), shortName,
+ OPENMP_DIRECTIVE, si, pop);
+ msr.addArtifact(a);
+ }
+ }
+
+ msr.addProblems(OpenMPErrorManager.getCurrentErrorManager().getErrors());
+ }
+
+
+ /**
+ * Get exact source locational info for a function call
+ *
+ * @param pastNode
+ * @param constructType
+ * @return
+ */
+ private SourceInfo getSourceInfo(PASTNode pastNode, int constructType) {
+ SourceInfo sourceInfo = null;
+ IASTNodeLocation[] locations = pastNode.getNodeLocations();
+ if (locations.length == 1) {
+ IASTFileLocation astFileLocation = null;
+ if (locations[0] instanceof IASTFileLocation) {
+ astFileLocation = (IASTFileLocation) locations[0];
+ sourceInfo = new SourceInfo();
+ sourceInfo.setStartingLine(astFileLocation.getStartingLineNumber());
+ sourceInfo.setStart(astFileLocation.getNodeOffset());
+ sourceInfo.setEnd(astFileLocation.getNodeOffset() + astFileLocation.getNodeLength());
+ sourceInfo.setConstructType(constructType);
+ }
+ }
+ return sourceInfo;
+ }
+}
diff --git tools/pldt/org.eclipse.ptp.pldt.openmp.fortran/build.properties tools/pldt/org.eclipse.ptp.pldt.openmp.fortran/build.properties
index b67aba1..1500166 100644
--- tools/pldt/org.eclipse.ptp.pldt.openmp.fortran/build.properties
+++ tools/pldt/org.eclipse.ptp.pldt.openmp.fortran/build.properties
@@ -3,4 +3,5 @@ output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.properties,\
- about.html
+ about.html,\
+ plugin.xml
diff --git tools/pldt/org.eclipse.ptp.pldt.openmp.fortran/plugin.xml tools/pldt/org.eclipse.ptp.pldt.openmp.fortran/plugin.xml
new file mode 100644
index 0000000..f966ca0
--- /dev/null
+++ tools/pldt/org.eclipse.ptp.pldt.openmp.fortran/plugin.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
diff --git tools/pldt/org.eclipse.ptp.pldt.openmp.fortran/src/org/eclipse/ptp/pldt/openmp/fortran/actions/AnalyseOpenMPFortranHandler.java tools/pldt/org.eclipse.ptp.pldt.openmp.fortran/src/org/eclipse/ptp/pldt/openmp/fortran/actions/AnalyseOpenMPFortranHandler.java
deleted file mode 100644
index 87587c1..0000000
--- tools/pldt/org.eclipse.ptp.pldt.openmp.fortran/src/org/eclipse/ptp/pldt/openmp/fortran/actions/AnalyseOpenMPFortranHandler.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2010 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.ptp.pldt.openmp.fortran.actions;
-
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.photran.internal.cdtinterface.core.FortranLanguage;
-import org.eclipse.photran.internal.core.lexer.ASTLexerFactory;
-import org.eclipse.photran.internal.core.parser.ASTExecutableProgramNode;
-import org.eclipse.photran.internal.core.parser.Parser;
-import org.eclipse.ptp.pldt.common.ScanReturn;
-import org.eclipse.ptp.pldt.openmp.fortran.analysis.OpenMPFortranASTVisitor;
-
-/**
- * @since 4.0
- */
-public class AnalyseOpenMPFortranHandler {
- public void run(String languageID, ITranslationUnit tu, String fileName, ScanReturn msr) {
- if (languageID.equals(FortranLanguage.LANGUAGE_ID)) {
- IResource res = tu.getUnderlyingResource();
- if (!(res instanceof IFile))
- throw new IllegalStateException();
- IFile file = (IFile) res;
-
- try {
- ASTExecutableProgramNode ast = new Parser().parse(new ASTLexerFactory().createLexer(file));
- ast.accept(new OpenMPFortranASTVisitor(fileName, msr));
- } catch (Exception e) {
- e.printStackTrace(); // TODO
- }
- }
- }
-}
diff --git tools/pldt/org.eclipse.ptp.pldt.openmp.fortran/src/org/eclipse/ptp/pldt/openmp/fortran/analysis/OpenMPFortranArtifactAnalysis.java tools/pldt/org.eclipse.ptp.pldt.openmp.fortran/src/org/eclipse/ptp/pldt/openmp/fortran/analysis/OpenMPFortranArtifactAnalysis.java
new file mode 100644
index 0000000..c301aa1
--- /dev/null
+++ tools/pldt/org.eclipse.ptp.pldt.openmp.fortran/src/org/eclipse/ptp/pldt/openmp/fortran/analysis/OpenMPFortranArtifactAnalysis.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2012 University of Illinois at Urbana-Champaign 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * UIUC - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ptp.pldt.openmp.fortran.analysis;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.photran.internal.cdtinterface.core.FortranLanguage;
+import org.eclipse.photran.internal.core.lexer.ASTLexerFactory;
+import org.eclipse.photran.internal.core.parser.ASTExecutableProgramNode;
+import org.eclipse.photran.internal.core.parser.Parser;
+import org.eclipse.ptp.pldt.common.IArtifactAnalysis;
+import org.eclipse.ptp.pldt.common.ScanReturn;
+
+/**
+ * OpenMP artifact analysis for Fortran.
+ *
+ * Contributed to the org.eclipse.ptp.pldt.mpi.core.artifactAnalysis
extension point.
+ *
+ * @author Jeff Overbey
+ */
+public class OpenMPFortranArtifactAnalysis implements IArtifactAnalysis {
+ public ScanReturn runArtifactAnalysis(String languageID, ITranslationUnit tu, List includes, boolean allowPrefixOnlyMatch) {
+ final ScanReturn msr = new ScanReturn();
+ final String fileName = tu.getElementName();
+ if (languageID.equals(FortranLanguage.LANGUAGE_ID)) {
+ IResource res = tu.getUnderlyingResource();
+ if (!(res instanceof IFile))
+ throw new IllegalStateException();
+ IFile file = (IFile) res;
+
+ try {
+ ASTExecutableProgramNode ast = new Parser().parse(new ASTLexerFactory().createLexer(file));
+ ast.accept(new OpenMPFortranASTVisitor(fileName, msr));
+ } catch (Exception e) {
+ e.printStackTrace(); // TODO
+ }
+ }
+ return msr;
+ }
+}