Changeset 4133


Ignore:
Timestamp:
Dec 22, 2009, 8:50:54 PM (11 years ago)
Author:
yura
Message:
Location:
devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/core
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/core/RfpAbstractBuilder.java

    r4125 r4133  
    1818
    1919public abstract class RfpAbstractBuilder extends IncrementalProjectBuilder {
     20    private RfpProject rfpProject;
     21   
    2022    protected RfpProject getRfpProject () {
    21         return RfpCore.getRfpProject(getProject());
     23        if (rfpProject == null)
     24            rfpProject = RfpProject.get(getProject());
     25        return rfpProject;
    2226    }
    2327
     
    2832            fullBuild(monitor);
    2933        else {
    30             RfpProject rfpProject = getRfpProject();
    31             IResourceDelta delta = getDelta(rfpProject.getProject());
    32             if (delta == null || delta.findMember(rfpProject.getFile(".classpath").getProjectRelativePath()) != null)
     34            IResourceDelta delta = getDelta(getProject());
     35            if (delta == null || delta.findMember(getProject().getFile(".classpath").getProjectRelativePath()) != null)
    3336                fullBuild(monitor);
    3437            else
  • devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/core/RfpBuilder.java

    r4125 r4133  
    316316            return null;
    317317        deleteMarkers(file);
    318         if (RfpCore.getRfpProject(project).getModuleName(file) == null)
     318        if (RfpProject.get(project).getModuleName(file) == null)
    319319            return null;
    320320        if (RfpProject.isRefFile(file)) {
    321             Checker.getR5(new IdeCompilerEnvironment(RfpCore.getRfpProject(project), file,
     321            Checker.getR5(new IdeCompilerEnvironment(RfpProject.get(project), file,
    322322                    new StringReader(document)));
    323323            return null;
    324324        } else
    325             return Checker.getModuleImplementation(new IdeCompilerEnvironment(RfpCore.getRfpProject(project), file,
     325            return Checker.getModuleImplementation(new IdeCompilerEnvironment(RfpProject.get(project), file,
    326326                    new StringReader(document)));
    327327    }
  • devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/core/RfpCore.java

    r3655 r4133  
    11package org.refal.rfpdt.core;
    22
    3 import java.util.WeakHashMap;
    43
    5 import org.eclipse.core.resources.IProject;
    64import org.eclipse.core.runtime.IStatus;
    75import org.eclipse.core.runtime.Plugin;
     
    1311public class RfpCore extends Plugin {
    1412    private static RfpCore plugin = null;
    15 
    16     private static final WeakHashMap<IProject, RfpProject> rfpProjects = new WeakHashMap<IProject, RfpProject>();
    1713
    1814    private static void log (IStatus status) {
     
    3026
    3127    /**
    32      * Logs a message to the plugin's error log
     28     * Logs a message to the plugin's error log.
    3329     *
    3430     * @param message
     
    4137    }
    4238
    43     public static void log (Throwable e) {
    44         log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, "Internal error", e));
    45     }
    46 
    47     /** May return <code>null</code> if argument is <code>null</code>. */
    48     public static RfpProject getRfpProject (IProject project) {
    49         if (project == null)
    50             return null;
    51         RfpProject rfpProject = RfpCore.rfpProjects.get(project);
    52         if (rfpProject == null) {
    53             rfpProject = new RfpProject(project);
    54             RfpCore.rfpProjects.put(project, rfpProject);
    55         }
    56         return rfpProject;
     39    /**
     40     * Logs a exception to the plugin's error log.
     41     *
     42     * @param exception
     43     *            Exception to be logger
     44     */
     45    public static void log (Exception exception) {
     46        log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, "Internal error", exception));
    5747    }
    5848
  • devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/core/RfpNature.java

    r3642 r4133  
    3636        project.setDescription(projectDesc, null);
    3737        // setup the classpath
    38         IJavaProject javaProject = RfpCore.getRfpProject(project).getJavaProject();
     38        IJavaProject javaProject = RfpProject.get(project).getJavaProject();
    3939        IClasspathEntry[] entriesOld = javaProject.getRawClasspath();
    4040        IClasspathEntry[] entriesNew = new IClasspathEntry[entriesOld.length + 2];
  • devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/core/RfpProject.java

    r4125 r4133  
    22
    33import java.io.ByteArrayInputStream;
     4import java.util.WeakHashMap;
    45
    56import org.eclipse.core.resources.IFile;
     
    2223
    2324public class RfpProject {
     25    private static final WeakHashMap<IProject, RfpProject> rfpProjects = new WeakHashMap<IProject, RfpProject>();
     26
     27    /** May return <code>null</code> if argument is <code>null</code>. */
     28    public static RfpProject get (IProject project) {
     29        if (project == null)
     30            return null;
     31        RfpProject rfpProject = RfpProject.rfpProjects.get(project);
     32        if (rfpProject == null) {
     33            rfpProject = new RfpProject(project);
     34            RfpProject.rfpProjects.put(project, rfpProject);
     35        }
     36        return rfpProject;
     37    }
     38
     39    public static boolean isRfFile (IResource resource) {
     40        return resource instanceof IFile && resource.getFileExtension() != null
     41                && resource.getFileExtension().equals("rf");
     42    }
     43
     44    public static boolean isRfiFile (IResource resource) {
     45        return resource instanceof IFile && resource.getFileExtension() != null
     46                && resource.getFileExtension().equals("rfi");
     47    }
     48
     49    public static boolean isRefFile (IResource resource) {
     50        return resource instanceof IFile && resource.getFileExtension() != null
     51                && resource.getFileExtension().equals("ref");
     52    }
     53
    2454    private final IProject project;
    2555    private final IJavaProject javaProject;
     
    2858    private final IScopeContext[] scopes;
    2959
    30     RfpProject (IProject project) {
     60    private RfpProject (IProject project) {
    3161        this.project = project;
    3262        this.javaProject = JavaCore.create(project);
     
    156186
    157187    public static String staticGetModuleName (IFile file) {
    158         RfpProject rfpProject = RfpCore.getRfpProject(file.getProject());
     188        RfpProject rfpProject = RfpProject.get(file.getProject());
    159189        return rfpProject == null ? null : rfpProject.getModuleName(file);
    160190    }
     
    198228                ICompilerPreferences.ADD_SOURCE, false, scopes);
    199229    }
    200 
    201     public static boolean isRfFile (IResource resource) {
    202         return resource instanceof IFile && resource.getFileExtension() != null
    203                 && resource.getFileExtension().equals("rf");
    204     }
    205 
    206     public static boolean isRfiFile (IResource resource) {
    207         return resource instanceof IFile && resource.getFileExtension() != null
    208                 && resource.getFileExtension().equals("rfi");
    209     }
    210 
    211     public static boolean isRefFile (IResource resource) {
    212         return resource instanceof IFile && resource.getFileExtension() != null
    213                 && resource.getFileExtension().equals("ref");
    214     }
    215230}
Note: See TracChangeset for help on using the changeset viewer.