Fixed MBS dependency bug; moved content type checks into FortranCorePlugin to eliminate duplication (TY)
diff --git a/org.eclipse.photran.cdtinterface/src/org/eclipse/photran/internal/cdtinterface/ui/FortranProjectWizard.java b/org.eclipse.photran.cdtinterface/src/org/eclipse/photran/internal/cdtinterface/ui/FortranProjectWizard.java
index 9cf6eb2..75ee6a6 100644
--- a/org.eclipse.photran.cdtinterface/src/org/eclipse/photran/internal/cdtinterface/ui/FortranProjectWizard.java
+++ b/org.eclipse.photran.cdtinterface/src/org/eclipse/photran/internal/cdtinterface/ui/FortranProjectWizard.java
@@ -6,6 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
+ * UIUC Photran modifications
* Intel Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.photran.internal.cdtinterface.ui;
@@ -27,6 +28,7 @@
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.photran.internal.cdtinterface.core.FortranLanguage;
import org.eclipse.photran.internal.core.FProjectNature;
/**
@@ -142,4 +144,9 @@
}
return false;
}
+
+ // This limits the wizard to Fortran project types
+ @Override public String[] getLanguageIDs (){
+ return new String[] { FortranLanguage.LANGUAGE_ID };
+ }
}
diff --git a/org.eclipse.photran.core.vpg.tests/src/org/eclipse/photran/internal/tests/RefactoringTestCase.java b/org.eclipse.photran.core.vpg.tests/src/org/eclipse/photran/internal/tests/RefactoringTestCase.java
index ceef99f..e48285a 100644
--- a/org.eclipse.photran.core.vpg.tests/src/org/eclipse/photran/internal/tests/RefactoringTestCase.java
+++ b/org.eclipse.photran.core.vpg.tests/src/org/eclipse/photran/internal/tests/RefactoringTestCase.java
@@ -23,6 +23,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Plugin;
+import org.eclipse.photran.internal.core.FortranCorePlugin;
import org.eclipse.photran.internal.core.util.LineCol;
import org.eclipse.photran.internal.core.vpg.PhotranVPG;
import org.eclipse.rephraserengine.core.util.Spawner;
@@ -33,7 +34,7 @@
public RefactoringTestCase()
{
- if (!PhotranVPG.inTestingMode()) fail("WHEN RUNNING JUNIT TESTS, THE \"TESTING\" ENVIRONMENT VARIABLE MUST BE SET");
+ if (!FortranCorePlugin.inTestingMode()) fail("WHEN RUNNING JUNIT TESTS, THE \"TESTING\" ENVIRONMENT VARIABLE MUST BE SET");
}
protected IFile importFile(Plugin activator, String srcDir, String filename) throws Exception
diff --git a/org.eclipse.photran.core.vpg/parser/org/eclipse/photran/internal/core/lexer/SourceForm.java b/org.eclipse.photran.core.vpg/parser/org/eclipse/photran/internal/core/lexer/SourceForm.java
index a78b9fb..179da19 100644
--- a/org.eclipse.photran.core.vpg/parser/org/eclipse/photran/internal/core/lexer/SourceForm.java
+++ b/org.eclipse.photran.core.vpg/parser/org/eclipse/photran/internal/core/lexer/SourceForm.java
@@ -18,6 +18,7 @@
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.photran.internal.core.FortranCorePlugin;
import org.eclipse.photran.internal.core.lexer.preprocessor.fortran_include.IncludeLoaderCallback;
import org.eclipse.photran.internal.core.lexer.preprocessor.fortran_include.PreprocessingFreeFormLexerPhase1;
import org.eclipse.photran.internal.core.vpg.PhotranVPG;
@@ -126,7 +127,7 @@
{
try
{
- IContentType ct = PhotranVPG.findContentType(filename);
+ IContentType ct = FortranCorePlugin.findContentType(filename);
if (ct == null) return null;
IConfigurationElement[] configs =
diff --git a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/EncapsulateVariableRefactoring.java b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/EncapsulateVariableRefactoring.java
index a442457..61d74d5 100644
--- a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/EncapsulateVariableRefactoring.java
+++ b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/EncapsulateVariableRefactoring.java
@@ -21,6 +21,7 @@
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.RefactoringStatusContext;
+import org.eclipse.photran.internal.core.FortranCorePlugin;
import org.eclipse.photran.internal.core.analysis.binding.Definition;
import org.eclipse.photran.internal.core.analysis.binding.Definition.Classification;
import org.eclipse.photran.internal.core.lexer.Terminal;
@@ -201,7 +202,7 @@
protected void checkForFixedForm(IFile file) throws PreconditionFailure
{
- if(PhotranVPG.hasFixedFormContentType(file))
+ if(FortranCorePlugin.hasFixedFormContentType(file))
{
fail("Fixed form files cannot currently be refactored. " +
"File " + file.getName() + " is in fixed form and "+
diff --git a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/RenameRefactoring.java b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/RenameRefactoring.java
index 4283657..2f8230c 100644
--- a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/RenameRefactoring.java
+++ b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/RenameRefactoring.java
@@ -21,6 +21,7 @@
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.RefactoringStatusContext;
+import org.eclipse.photran.internal.core.FortranCorePlugin;
import org.eclipse.photran.internal.core.analysis.binding.Definition;
import org.eclipse.photran.internal.core.lexer.Token;
import org.eclipse.photran.internal.core.refactoring.infrastructure.SingleFileFortranRefactoring;
@@ -218,7 +219,7 @@
{
continue;
}
- else if (PhotranVPG.hasFixedFormContentType(file))
+ else if (FortranCorePlugin.hasFixedFormContentType(file))
{
fixedFormFiles.add(file);
status.addError("The fixed form file " + file.getName() + " will not be refactored.");
@@ -251,7 +252,7 @@
{
continue;
}
- else if (PhotranVPG.hasCppContentType(file))
+ else if (FortranCorePlugin.hasCppContentType(file))
{
cppFormFiles.add(file);
status.addError("The C-Preprocessed form file " + file.getName() + " will not be refactored.");
diff --git a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/infrastructure/MultipleFileFortranRefactoring.java b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/infrastructure/MultipleFileFortranRefactoring.java
index 2167afc..eb94a43 100644
--- a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/infrastructure/MultipleFileFortranRefactoring.java
+++ b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/infrastructure/MultipleFileFortranRefactoring.java
@@ -29,6 +29,7 @@
import org.eclipse.ltk.core.refactoring.RefactoringStatusContext;
import org.eclipse.photran.core.IFortranAST;
import org.eclipse.photran.internal.core.FortranAST;
+import org.eclipse.photran.internal.core.FortranCorePlugin;
import org.eclipse.photran.internal.core.analysis.binding.Definition;
import org.eclipse.photran.internal.core.analysis.binding.ScopingNode;
import org.eclipse.photran.internal.core.analysis.loops.ASTProperLoopConstructNode;
@@ -93,7 +94,7 @@
protected void ensureProjectHasRefactoringEnabled(RefactoringStatus status) throws PreconditionFailure
{
- if (PhotranVPG.inTestingMode()) return;
+ if (FortranCorePlugin.inTestingMode()) return;
HashSet<IFile> filesToBeRemoved = new HashSet<IFile>();
@@ -125,7 +126,7 @@
for (IFile file : files)
{
- if (!filesToRemove.contains(file) && PhotranVPG.hasFixedFormContentType(file))
+ if (!filesToRemove.contains(file) && FortranCorePlugin.hasFixedFormContentType(file))
{
status.addError("The fixed form file " + file.getName() + " will not be refactored.");
filesToRemove.add(file);
@@ -141,7 +142,7 @@
for (IFile file : files)
{
- if (!filesToRemove.contains(file) && PhotranVPG.hasCppContentType(file))
+ if (!filesToRemove.contains(file) && FortranCorePlugin.hasCppContentType(file))
{
status.addError("The C-Preprocessed file " + file.getName() + " will not be refactored.");
filesToRemove.add(file);
diff --git a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/vpg/PhotranVPG.java b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/vpg/PhotranVPG.java
index f7748e7..78f5c63 100644
--- a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/vpg/PhotranVPG.java
+++ b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/vpg/PhotranVPG.java
@@ -2,13 +2,10 @@
import java.io.PrintStream;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.TreeSet;
import org.eclipse.core.resources.IFile;
@@ -17,11 +14,9 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.photran.core.IFortranAST;
import org.eclipse.photran.internal.cdtinterface.natures.ProjectNatures;
+import org.eclipse.photran.internal.core.FortranCorePlugin;
import org.eclipse.photran.internal.core.analysis.binding.Definition;
import org.eclipse.photran.internal.core.analysis.binding.ScopingNode;
import org.eclipse.photran.internal.core.analysis.binding.Definition.Visibility;
@@ -54,15 +49,7 @@
// Tested empirically on ibeam-cpp-mod: 5 does better than 3, but 10 does not do better than 5
private static final int MODULE_SYMTAB_CACHE_SIZE = 5;
- // Copied from FortranCorePlugin to avoid dependencies on the Photran Core plug-in
- // (since our parser declares classes with the same name)
- private static final String FIXED_FORM_CONTENT_TYPE = "org.eclipse.photran.core.fixedFormFortranSource";
- private static final String FREE_FORM_CONTENT_TYPE = "org.eclipse.photran.core.freeFormFortranSource";
-
- //Including a C-Preprocessor content type so that we can disable the refactorings if any of the files
- // involved are C-Preprocessed
- private static final String C_PREPROCESSOR_FIXED_FORM_CONTENT_TYPE = "org.eclipse.photran.core.cppFreeFormFortranSource";
- private static final String C_PREPROCESSOR_FREE_FORM_CONTENT_TYPE = "org.eclipse.photran.core.cppFixedFormFortranSource";
+
public static final int DEFINED_IN_SCOPE_EDGE_TYPE = 0;
//public static final int IMPORTED_INTO_SCOPE_EDGE_TYPE = 1;
@@ -172,7 +159,7 @@
@Override public void start()
{
- if (!inTestingMode()) super.start();
+ if (!FortranCorePlugin.inTestingMode()) super.start();
}
protected PhotranVPG()
@@ -181,11 +168,6 @@
db = super.db;
}
- public static boolean inTestingMode()
- {
- return System.getenv("TESTING") != null;
- }
-
@Override
public String describeEdgeType(int edgeType)
{
@@ -230,10 +212,10 @@
public boolean shouldProcessFile(IFile file)
{
String filename = file.getName();
- return hasFixedFormContentType(filename) ||
- hasFreeFormContentType(filename) ||
- hasCppFixedFormContentType(filename) ||
- hasCppFreeFormContentType(filename);
+ return FortranCorePlugin.hasFixedFormContentType(filename) ||
+ FortranCorePlugin.hasFreeFormContentType(filename) ||
+ FortranCorePlugin.hasCppFixedFormContentType(filename) ||
+ FortranCorePlugin.hasCppFreeFormContentType(filename);
}
@Override
@@ -243,7 +225,7 @@
{
if (!project.isAccessible()) return false;
if (!project.hasNature(ProjectNatures.C_NATURE_ID) && !project.hasNature(ProjectNatures.CC_NATURE_ID)) return false;
- return inTestingMode() || SearchPathProperties.getProperty(project, SearchPathProperties.ENABLE_VPG_PROPERTY_NAME).equals("true");
+ return FortranCorePlugin.inTestingMode() || SearchPathProperties.getProperty(project, SearchPathProperties.ENABLE_VPG_PROPERTY_NAME).equals("true");
}
catch (CoreException e)
{
@@ -727,110 +709,10 @@
marker.setAttributes(attribs);
}
-
- public static boolean hasFixedFormContentType(IFile file)
- {
- return hasFixedFormContentType(getFilenameForIFile(file));
- }
-
- public static boolean hasFreeFormContentType(IFile file)
- {
- return hasFreeFormContentType(getFilenameForIFile(file));
- }
- public static boolean hasCppFixedFormContentType(IFile file)
- {
- return hasCppFixedFormContentType(getFilenameForIFile(file));
- }
-
- public static boolean hasCppFreeFormContentType(IFile file)
- {
- return hasCppFreeFormContentType(getFilenameForIFile(file));
- }
-
- public static boolean hasCppContentType(IFile file)
- {
- return hasCppContentType(getFilenameForIFile(file));
- }
-
- protected static boolean hasFixedFormContentType(String filename)
- {
- if (inTestingMode()) // Fortran content types not set in testing workspace
- return filename.endsWith(".f");
- else
- {
- IContentType ct = getContentTypeOf(filename);
- return ct != null && ct.isKindOf(fixedFormContentType());
- }
- }
-
- protected static boolean hasFreeFormContentType(String filename)
- {
- if (inTestingMode()) // Fortran content types not set in testing workspace
- return filename.endsWith(".f90");
- else
- {
- IContentType ct = getContentTypeOf(filename);
- return ct != null && ct.isKindOf(freeFormContentType());
- }
- }
-
- protected static boolean hasCppFixedFormContentType(String filename)
- {
- if (inTestingMode()) // Fortran content types not set in testing workspace
- return filename.endsWith(".F");
- else
- {
- IContentType ct = getContentTypeOf(filename);
- return ct != null && ct.isKindOf(cppFixedFormContentType());
- }
- }
-
- protected static boolean hasCppFreeFormContentType(String filename)
- {
- if (inTestingMode()) // Fortran content types not set in testing workspace
- return filename.endsWith(".F90");
- else
- {
- IContentType ct = getContentTypeOf(filename);
- return ct != null && ct.isKindOf(cppFreeFormContentType());
- }
- }
-
- protected static boolean hasCppContentType(String filename)
- {
- return hasCppFreeFormContentType(filename) ||
- hasCppFixedFormContentType(filename);
- }
-
- protected static final IContentType getContentTypeOf(String filename)
- {
- return findContentType(filename);
- }
-
- protected static final IContentType fixedFormContentType()
- {
- return Platform.getContentTypeManager().getContentType(FIXED_FORM_CONTENT_TYPE);
- }
-
- protected static final IContentType freeFormContentType()
- {
- return Platform.getContentTypeManager().getContentType(FREE_FORM_CONTENT_TYPE);
- }
-
- protected static final IContentType cppFixedFormContentType()
- {
- return Platform.getContentTypeManager().getContentType(C_PREPROCESSOR_FIXED_FORM_CONTENT_TYPE);
- }
-
- protected static final IContentType cppFreeFormContentType()
- {
- return Platform.getContentTypeManager().getContentType(C_PREPROCESSOR_FREE_FORM_CONTENT_TYPE);
- }
-
public boolean doesProjectHaveRefactoringEnabled(IFile file)
{
- if (PhotranVPG.inTestingMode()) return true;
+ if (FortranCorePlugin.inTestingMode()) return true;
String vpgEnabledProperty = SearchPathProperties.getProperty(
file,
@@ -838,61 +720,6 @@
return vpgEnabledProperty != null && vpgEnabledProperty.equals("true");
}
- public static IContentType findContentType(String filename)
- {
- IContentType[] cts = Platform.getContentTypeManager().findContentTypesFor(filename);
- if (cts.length == 0)
- return null;
- else if (cts.length == 1)
- return cts[0];
-
- // Annoyingly, Eclipse does not do case-sensitive matching of filename
- // extensions (at least on case-insensitive filesystems), which is
- // important for Fortran filenames; we have to do that manually
-
- List<IContentType> possibilities = new ArrayList<IContentType>(cts.length);
-
- String ext = filename.substring(filename.lastIndexOf('.')+1);
- for (IContentType ct : cts)
- if (getFilenameExtensions(ct.getId()).contains(ext))
- possibilities.add(ct);
-
- if (possibilities.isEmpty()) return cts[0];
-
- // Now find the most specific of the possible content types
-
- IContentType result = null;
- for (IContentType ct : possibilities)
- {
- if (result == null)
- result = ct;
- else if (ct.isKindOf(result))
- result = ct;
- }
- return result;
- }
-
- private static Set<String> getFilenameExtensions(String contentType)
- {
- for (IConfigurationElement elt :
- Platform.getExtensionRegistry().getConfigurationElementsFor(
- "org.eclipse.core.contenttype.contentTypes"))
- {
- if (elt.getName().equals("file-association")
- && elt.getAttribute("content-type").equals(contentType))
- {
- Set<String> result = new HashSet<String>();
- String fileExts = elt.getAttribute("file-extensions");
- if(fileExts == null)
- continue;
- for (String ext : fileExts.split(","))
- result.add(ext.trim());
- return result;
- }
- }
- return Collections.emptySet();
- }
-
private boolean isDefinitionCachingEnabled = false;
public void enableDefinitionCaching() { isDefinitionCachingEnabled = true; }
public void disableDefinitionCaching() { isDefinitionCachingEnabled = false; }
diff --git a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/vpg/PhotranVPGBuilder.java b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/vpg/PhotranVPGBuilder.java
index 5d19a7a..7814434 100644
--- a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/vpg/PhotranVPGBuilder.java
+++ b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/vpg/PhotranVPGBuilder.java
@@ -22,6 +22,7 @@
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.photran.core.IFortranAST;
import org.eclipse.photran.internal.core.FortranAST;
+import org.eclipse.photran.internal.core.FortranCorePlugin;
import org.eclipse.photran.internal.core.SyntaxException;
import org.eclipse.photran.internal.core.analysis.binding.Binder;
import org.eclipse.photran.internal.core.analysis.binding.Definition;
@@ -203,7 +204,7 @@
IContentType contentType = Platform.getContentTypeManager().findContentTypeFor(filename);
SourceForm sourceForm;
- if (contentType != null && contentType.isKindOf(fixedFormContentType()))
+ if (contentType != null && contentType.isKindOf(FortranCorePlugin.fixedFormContentType()))
sourceForm = SourceForm.FIXED_FORM;
else if (file == null || file.getProject() == null)
sourceForm = SourceForm.UNPREPROCESSED_FREE_FORM;
diff --git a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/vpg/PhotranVPGDB.java b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/vpg/PhotranVPGDB.java
index c6670b2..a90188d 100644
--- a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/vpg/PhotranVPGDB.java
+++ b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/vpg/PhotranVPGDB.java
@@ -9,6 +9,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.photran.core.IFortranAST;
import org.eclipse.photran.internal.core.Activator;
+import org.eclipse.photran.internal.core.FortranCorePlugin;
import org.eclipse.photran.internal.core.lexer.Token;
import org.eclipse.photran.internal.core.preferences.FortranPreferences;
import org.eclipse.rephraserengine.core.vpg.db.caching.CachingDB;
@@ -25,7 +26,7 @@
{
public PhotranCDTDB()
{
- this(PhotranVPG.inTestingMode()
+ this(FortranCorePlugin.inTestingMode()
? createTempFile()
: Activator.getDefault().getStateLocation().addTrailingSeparator().toOSString() + "photran60vpg2");
}
diff --git a/org.eclipse.photran.core/src/org/eclipse/photran/internal/core/FortranCorePlugin.java b/org.eclipse.photran.core/src/org/eclipse/photran/internal/core/FortranCorePlugin.java
index f65f0a1..8b8ce89 100644
--- a/org.eclipse.photran.core/src/org/eclipse/photran/internal/core/FortranCorePlugin.java
+++ b/org.eclipse.photran.core/src/org/eclipse/photran/internal/core/FortranCorePlugin.java
@@ -10,6 +10,14 @@
*******************************************************************************/
package org.eclipse.photran.internal.core;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.content.IContentType;
@@ -22,8 +30,13 @@
*/
public class FortranCorePlugin extends Plugin
{
- private static final String FIXED_FORM_CONTENT_TYPE = "org.eclipse.photran.core.fixedFormFortranSource";
- private static final String FREE_FORM_CONTENT_TYPE = "org.eclipse.photran.core.freeFormFortranSource";
+ public static final String FIXED_FORM_CONTENT_TYPE = "org.eclipse.photran.core.fixedFormFortranSource";
+ public static final String FREE_FORM_CONTENT_TYPE = "org.eclipse.photran.core.freeFormFortranSource";
+
+ //Including a C-Preprocessor content type so that we can disable the refactorings if any of the files
+ // involved are C-Preprocessed
+ public static final String C_PREPROCESSOR_FIXED_FORM_CONTENT_TYPE = "org.eclipse.photran.core.cppFreeFormFortranSource";
+ public static final String C_PREPROCESSOR_FREE_FORM_CONTENT_TYPE = "org.eclipse.photran.core.cppFixedFormFortranSource";
public static final IContentType fixedFormContentType()
{
@@ -38,14 +51,175 @@
public static final boolean isFixedFormContentType(String contentTypeID)
{
if (contentTypeID == null) return false;
-
+ //Content types are defined in .xml files. Currently they are defined by file extensions.
+ // cppPreprocessor content types are children of Free and Fixed form content types,
+ // which in turn are children of FortranContentType
IContentType ct = Platform.getContentTypeManager().getContentType(contentTypeID);
return ct == null ? false : ct.isKindOf(fixedFormContentType());
}
+ protected static final IContentType getContentTypeOf(String filename)
+ {
+ return findContentType(filename);
+ }
+
+ protected static final IContentType cppFixedFormContentType()
+ {
+ return Platform.getContentTypeManager().getContentType(C_PREPROCESSOR_FIXED_FORM_CONTENT_TYPE);
+ }
+
+ protected static final IContentType cppFreeFormContentType()
+ {
+ return Platform.getContentTypeManager().getContentType(C_PREPROCESSOR_FREE_FORM_CONTENT_TYPE);
+ }
+
+ public static boolean hasFixedFormContentType(IFile file)
+ {
+ return hasFixedFormContentType(getFilenameForIFile(file));
+ }
+
+ public static boolean hasFreeFormContentType(IFile file)
+ {
+ return hasFreeFormContentType(getFilenameForIFile(file));
+ }
+
+ public static boolean hasCppFixedFormContentType(IFile file)
+ {
+ return hasCppFixedFormContentType(getFilenameForIFile(file));
+ }
+
+ public static boolean hasCppFreeFormContentType(IFile file)
+ {
+ return hasCppFreeFormContentType(getFilenameForIFile(file));
+ }
+
+ public static boolean hasCppContentType(IFile file)
+ {
+ return hasCppContentType(getFilenameForIFile(file));
+ }
+
+ private static String getFilenameForIFile(IFile file)
+ {
+ return file == null ? null : file.getFullPath().toString();
+ }
+
+ public static boolean hasFixedFormContentType(String filename)
+ {
+ if (inTestingMode()) // Fortran content types not set in testing workspace
+ return filename.endsWith(".f");
+ else
+ {
+ IContentType ct = getContentTypeOf(filename);
+ return ct != null && ct.isKindOf(fixedFormContentType());
+ }
+ }
+
+ public static boolean hasFreeFormContentType(String filename)
+ {
+ if (inTestingMode()) // Fortran content types not set in testing workspace
+ return filename.endsWith(".f90");
+ else
+ {
+ IContentType ct = getContentTypeOf(filename);
+ return ct != null && ct.isKindOf(freeFormContentType());
+ }
+ }
+
+ public static boolean hasCppFixedFormContentType(String filename)
+ {
+ if (inTestingMode()) // Fortran content types not set in testing workspace
+ return filename.endsWith(".F");
+ else
+ {
+ IContentType ct = getContentTypeOf(filename);
+ return ct != null && ct.isKindOf(cppFixedFormContentType());
+ }
+ }
+
+ public static boolean hasCppFreeFormContentType(String filename)
+ {
+ if (inTestingMode()) // Fortran content types not set in testing workspace
+ return filename.endsWith(".F90");
+ else
+ {
+ IContentType ct = getContentTypeOf(filename);
+ return ct != null && ct.isKindOf(cppFreeFormContentType());
+ }
+ }
+
+ public static boolean hasCppContentType(String filename)
+ {
+ return hasCppFreeFormContentType(filename) ||
+ hasCppFixedFormContentType(filename);
+ }
+
public static final String[] getAllFortranContentTypes()
{
- return new String[] { FortranCorePlugin.FIXED_FORM_CONTENT_TYPE, FortranCorePlugin.FREE_FORM_CONTENT_TYPE };
+ return new String[] { FortranCorePlugin.FIXED_FORM_CONTENT_TYPE,
+ FortranCorePlugin.FREE_FORM_CONTENT_TYPE,
+ FortranCorePlugin.C_PREPROCESSOR_FIXED_FORM_CONTENT_TYPE,
+ FortranCorePlugin.C_PREPROCESSOR_FREE_FORM_CONTENT_TYPE
+ };
+ }
+
+ public static IContentType findContentType(String filename)
+ {
+ IContentType[] cts = Platform.getContentTypeManager().findContentTypesFor(filename);
+ if (cts.length == 0)
+ return null;
+ else if (cts.length == 1)
+ return cts[0];
+
+ // Annoyingly, Eclipse does not do case-sensitive matching of filename
+ // extensions (at least on case-insensitive filesystems), which is
+ // important for Fortran filenames; we have to do that manually
+
+ List<IContentType> possibilities = new ArrayList<IContentType>(cts.length);
+
+ String ext = filename.substring(filename.lastIndexOf('.')+1);
+ for (IContentType ct : cts)
+ if (getFilenameExtensions(ct.getId()).contains(ext))
+ possibilities.add(ct);
+
+ if (possibilities.isEmpty()) return cts[0];
+
+ // Now find the most specific of the possible content types
+
+ IContentType result = null;
+ for (IContentType ct : possibilities)
+ {
+ if (result == null)
+ result = ct;
+ else if (ct.isKindOf(result))
+ result = ct;
+ }
+ return result;
+ }
+
+ private static Set<String> getFilenameExtensions(String contentType)
+ {
+ for (IConfigurationElement elt :
+ Platform.getExtensionRegistry().getConfigurationElementsFor(
+ "org.eclipse.core.contenttype.contentTypes"))
+ {
+ if (elt.getName().equals("file-association")
+ && elt.getAttribute("content-type").equals(contentType))
+ {
+ Set<String> result = new HashSet<String>();
+ String fileExts = elt.getAttribute("file-extensions");
+ if(fileExts == null)
+ continue;
+ for (String ext : fileExts.split(","))
+ result.add(ext.trim());
+ return result;
+ }
+ }
+ return Collections.emptySet();
+ }
+
+ public static boolean inTestingMode()
+ {
+ return System.getenv("TESTING") != null;
}
// The shared instance.
diff --git a/org.eclipse.photran.managedbuilder.core/META-INF/MANIFEST.MF b/org.eclipse.photran.managedbuilder.core/META-INF/MANIFEST.MF
index 724a4fd..1573427 100644
--- a/org.eclipse.photran.managedbuilder.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.photran.managedbuilder.core/META-INF/MANIFEST.MF
@@ -15,3 +15,5 @@
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: photranmngbuildcore.jar
Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Export-Package: org.eclipse.photran.managedbuilder.core,
+ org.eclipse.photran.managedbuilder.core.makegen
diff --git a/org.eclipse.photran.managedbuilder.core/src/org/eclipse/photran/managedbuilder/core/makegen/DefaultFortranDependencyCalculator.java b/org.eclipse.photran.managedbuilder.core/src/org/eclipse/photran/managedbuilder/core/makegen/DefaultFortranDependencyCalculator.java
index 828f3c3..2c7b36c 100644
--- a/org.eclipse.photran.managedbuilder.core/src/org/eclipse/photran/managedbuilder/core/makegen/DefaultFortranDependencyCalculator.java
+++ b/org.eclipse.photran.managedbuilder.core/src/org/eclipse/photran/managedbuilder/core/makegen/DefaultFortranDependencyCalculator.java
@@ -451,5 +451,4 @@
}
return (IPath[]) outs.toArray(new IPath[outs.size()]);
}
-
}
diff --git a/org.eclipse.photran.managedbuilder.gnu.ui/plugin.xml b/org.eclipse.photran.managedbuilder.gnu.ui/plugin.xml
index 053dd88..9341ce5 100644
--- a/org.eclipse.photran.managedbuilder.gnu.ui/plugin.xml
+++ b/org.eclipse.photran.managedbuilder.gnu.ui/plugin.xml
@@ -543,13 +543,18 @@
<!-- CDT does not yet support multiple content types so comment out these inputType attributes for now
sourceContentType="org.eclipse.photran.core.fortranSource"
dependencyContentType="org.eclipse.cdt.core.fortranSource"
+
+ sources="f,f90,ftn,for,i,fpp,F,FOR,FTN,FPP,F90,i90"
+ dependencyExtensions="f,f90,ftn,for,i,fpp,F,FOR,FTN,FPP,F90,i90"
+ languageId="org.eclipse.photran.cdtinterface.fortran">
-->
- <inputType
+ <inputType
sources="f,f90,ftn,for,i,fpp,F,FOR,FTN,FPP,F90,i90"
dependencyExtensions="f,f90,ftn,for,i,fpp,F,FOR,FTN,FPP,F90,i90"
dependencyCalculator="org.eclipse.photran.managedbuilder.core.makegen.DefaultFortranDependencyCalculator"
- id="photran.managedbuild.tool.gnu.fortran.compiler.input">
+ id="photran.managedbuild.tool.gnu.fortran.compiler.input"
+ languageId="org.eclipse.photran.cdtinterface.fortran">
</inputType>
<outputType
outputs="o"
diff --git a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/search/FortranSearchQuery.java b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/search/FortranSearchQuery.java
index db86994..0b6e251 100644
--- a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/search/FortranSearchQuery.java
+++ b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/search/FortranSearchQuery.java
@@ -22,6 +22,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.photran.core.IFortranAST;
+import org.eclipse.photran.internal.core.FortranCorePlugin;
import org.eclipse.photran.internal.core.analysis.binding.Definition;
import org.eclipse.photran.internal.core.analysis.binding.ScopingNode;
import org.eclipse.photran.internal.core.lexer.FileOrIFile;
@@ -248,7 +249,7 @@
@Override protected void finishSearch()
{
- if (!PhotranVPG.inTestingMode()
+ if (!FortranCorePlugin.inTestingMode()
&& Workbench.getInstance().getWorkbenchWindowCount() > 0
&& !projectsWithRefactoringDisabled.isEmpty())
{
diff --git a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/vpg/PhotranResourceFilter.java b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/vpg/PhotranResourceFilter.java
index 5c13fc6..de102c8 100644
--- a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/vpg/PhotranResourceFilter.java
+++ b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/vpg/PhotranResourceFilter.java
@@ -13,6 +13,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.photran.internal.core.FortranCorePlugin;
import org.eclipse.photran.internal.core.vpg.PhotranVPG;
import org.eclipse.rephraserengine.core.resources.IResourceFilter;
@@ -38,8 +39,8 @@
&& PhotranVPG.getInstance().shouldProcessProject(((IFile)resource).getProject())
&& PhotranVPG.getInstance().shouldProcessFile((IFile)resource)
&& ((IFile)resource).isAccessible()
- && !PhotranVPG.hasFixedFormContentType((IFile)resource)
- /*&& !PhotranVPG.hasCppContentType((IFile)resource)*/;
+ && !FortranCorePlugin.hasFixedFormContentType((IFile)resource)
+ /*&& !FortranCorePlugin.hasCppContentType((IFile)resource)*/;
else
return true;
}