Changeset 3511 for devel-tools
- Timestamp:
- Mar 13, 2008, 8:58:24 PM (13 years ago)
- Location:
- devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/comp/ExpChecker.java
r3508 r3511 212 212 213 213 public void visit (AstUse astUse) { 214 astUse.interf.accept(this); 214 if (astUse.interf != null) 215 astUse.interf.accept(this); 215 216 } 216 217 -
devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/core/RfpBuilder.java
r3508 r3511 14 14 import java.util.TreeMap; 15 15 import java.util.TreeSet; 16 import java.util.jar.JarEntry; 17 import java.util.jar.JarFile; 16 18 17 19 import org.eclipse.core.resources.IFile; … … 31 33 import org.eclipse.core.runtime.OperationCanceledException; 32 34 import org.eclipse.core.runtime.QualifiedName; 35 import org.eclipse.jdt.core.IClasspathContainer; 36 import org.eclipse.jdt.core.IClasspathEntry; 37 import org.eclipse.jdt.core.IJavaProject; 38 import org.eclipse.jdt.core.JavaCore; 33 39 import org.refal.plus.Expr; 34 40 import org.refal.plus.Reference; … … 44 50 public class RfpBuilder extends IncrementalProjectBuilder { 45 51 private void makeClass (String className, byte[] bytes) { 46 IFile classFile = getIFile(className, "class"); 47 InputStream inputStream = new ByteArrayInputStream(bytes); 48 try { 52 IProject project = getProject(); 53 IJavaProject javaProject = RfpCorePlugin.getJavaProject(project); 54 try { 55 IPath projectPath = project.getFullPath(); 56 IPath path = javaProject.getOutputLocation(); 57 if (projectPath.isPrefixOf(path)) 58 path = path.removeFirstSegments(projectPath.segmentCount()); 59 path = path.append(className.replace('.', '/') + ".class"); 60 IFile classFile = project.getFile(path); 61 InputStream inputStream = new ByteArrayInputStream(bytes); 49 62 classFile.create(inputStream, true, null); 50 63 inputStream.close(); … … 62 75 public IdeMsgHandler (IFile implemFile) { 63 76 this.implemFile = implemFile; 64 interfFile = RfpBuilder.get IFile(project, moduleName, "rfi");77 interfFile = RfpBuilder.getSource(project, moduleName, "rfi"); 65 78 RfpBuilder.deleteMarkers(implemFile); 66 if (interfFile .exists())79 if (interfFile != null && interfFile.exists()) 67 80 RfpBuilder.deleteMarkers(interfFile); 68 81 } … … 123 136 if (this.moduleName.equals(moduleName) && reader != null) 124 137 return reader; 125 IFile file = RfpBuilder.get IFile(project, moduleName, "rf");126 if ( !file.exists())138 IFile file = RfpBuilder.getSource(project, moduleName, "rf"); 139 if (file == null || !file.exists()) 127 140 return null; 128 141 try { … … 135 148 136 149 public Reader getRFIReader (String moduleName) { 137 IFile file = RfpBuilder.get IFile(project, moduleName, "rfi");138 if ( !file.exists())150 IFile file = RfpBuilder.getSource(project, moduleName, "rfi"); 151 if (file == null || !file.exists()) 139 152 return null; 140 153 try { … … 147 160 148 161 public Reader getClassReader (String moduleName) { 149 IFile file = RfpBuilder.getIFile(project, moduleName, "class");150 String formats = null;151 162 try { 152 if (file.exists()) { 153 InputStream inputStream = file.getContents(); 154 formats = FormatReader.ReadFormatsFromClass(inputStream); 155 inputStream.close(); 156 } else { 157 InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream( 158 file.getProjectRelativePath().toString()); 159 if (inputStream != null) { 160 formats = FormatReader.ReadFormatsFromClass(inputStream); 161 inputStream.close(); 163 for (IClasspathEntry entry : getClasspathEntries(project)) 164 if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { 165 IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), RfpCorePlugin 166 .getJavaProject(project)); 167 for (IClasspathEntry entry2 : container.getClasspathEntries()) { 168 if (entry2.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { 169 JarFile jarFile = new JarFile(entry2.getPath().toFile()); 170 JarEntry jarEntry = jarFile.getJarEntry(moduleName.replace('.', '/') + ".class"); 171 if (jarEntry != null) { 172 String formats = FormatReader 173 .ReadFormatsFromClass(jarFile.getInputStream(jarEntry)); 174 return formats == null ? null : new StringReader(formats); 175 } 176 } 177 } 162 178 } 163 }164 179 } catch (Exception e) { 165 180 RfpCorePlugin.log(e); 166 181 } 167 return formats == null ? null : new StringReader(formats);182 return null; 168 183 } 169 184 … … 176 191 sb.append(name); 177 192 } 178 IFile rfFile = RfpBuilder.get IFile(project, getModuleName(), "rf");193 IFile rfFile = RfpBuilder.getSource(project, getModuleName(), "rf"); 179 194 try { 180 rfFile.setPersistentProperty(RfpBuilder.IMPORTED_MODULES_PROPKEY, sb.toString()); 195 if (rfFile != null) 196 rfFile.setPersistentProperty(RfpBuilder.IMPORTED_MODULES_PROPKEY, sb.toString()); 181 197 } catch (CoreException e) {} 182 198 } … … 358 374 return; 359 375 monitor.subTask("Compiling the module " + moduleName); 360 checkAndCompileModuleImplem(get IFile(moduleName, "rf"));376 checkAndCompileModuleImplem(getSource(getProject(), moduleName, "rf")); 361 377 // try { 362 378 // Thread.sleep(1000); … … 419 435 } 420 436 421 private IFile getIFile (String moduleName, String ext) { 422 return getIFile(getProject(), moduleName, ext); 423 } 424 425 private static IFile getIFile (IProject project, String moduleName, String ext) { 426 return project.getFile(moduleName.replace('.', '/') + "." + ext); 437 private static IFile getSource (IProject project, String moduleName, String ext) { 438 IPath projectPath = project.getFullPath(); 439 for (IClasspathEntry entry : getClasspathEntries(project)) 440 if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { 441 IPath entryPath = entry.getPath(); 442 if (projectPath.isPrefixOf(entryPath)) { 443 IFile file = project.getFile(entryPath.removeFirstSegments(projectPath.segmentCount()).append( 444 moduleName.replace('.', '/') + "." + ext)); 445 if (file.exists()) 446 return file; 447 } 448 } 449 return null; 450 } 451 452 private static IClasspathEntry[] getClasspathEntries (IProject project) { 453 try { 454 return RfpCorePlugin.getJavaProject(project).getRawClasspath(); 455 } catch (Exception e) { 456 RfpCorePlugin.log(e); 457 return new IClasspathEntry[0]; 458 } 427 459 } 428 460 … … 430 462 if (!isRfFile(file) && !isRfiFile(file)) 431 463 throw new IllegalArgumentException(); 432 return file.getProjectRelativePath().removeFileExtension().toString().replace('/', '.'); 464 IPath filePath = file.getFullPath().removeFileExtension(); 465 for (IClasspathEntry entry : getClasspathEntries(file.getProject())) 466 if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { 467 IPath entryPath = entry.getPath(); 468 if (entryPath.isPrefixOf(filePath)) 469 return filePath.removeFirstSegments(entryPath.segmentCount()).toString().replace('/', '.'); 470 } 471 return null; 433 472 } 434 473 -
devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/core/RfpNature.java
r3508 r3511 15 15 16 16 public class RfpNature implements IProjectNature { 17 private static final String EXCLUSION_FILTER_ID = "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"; 18 private static final String EXCLUSION_EXTENTIONS = "*.rf,*.rfi"; 19 17 20 public static final String NATURE_ID = "org.refal.rfpdt.core.rfpnature"; 18 21 … … 50 53 javaProject.setRawClasspath(entriesNew, null); 51 54 javaProject.save(null, true); 55 String filters = javaProject.getOption(EXCLUSION_FILTER_ID, true); 56 if (filters == null) 57 filters = ""; 58 else if (!filters.equals("")) 59 filters += ","; 60 filters += EXCLUSION_EXTENTIONS; 61 javaProject.setOption(EXCLUSION_FILTER_ID, filters); 52 62 } 53 63 }
Note: See TracChangeset
for help on using the changeset viewer.