Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 138991

Summary: Switching between PHP versions php4<->php5 does not refreshes opened files
Product: z_Archived Reporter: Moty Keret <moty>
Component: PDTAssignee: moshe <moshe>
Status: CLOSED FIXED QA Contact: Yossi Luson <yossi.l>
Severity: normal    
Priority: P1 CC: gadi, jackie
Version: unspecifiedKeywords: plan
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Moty Keret CLA 2006-04-27 12:52:23 EDT
I have a files opened for editing, my project set to PHP5. I am switching to
PHP4, opened files are not refreshed, and still highlighted according to PHP5
settings.
Comment 1 Guy Gurfinkel CLA 2006-10-17 14:35:43 EDT
*** Bug 146516 has been marked as a duplicate of this bug. ***
Comment 2 Guy Gurfinkel CLA 2007-01-18 10:49:05 EST
*** Bug 162201 has been marked as a duplicate of this bug. ***
Comment 3 Gadi Goldbarg CLA 2007-01-29 10:18:54 EST
1. Enter any php code, using <? tags
2. Verify all code is colored correctly
3. Change start and tags to <%
4. Save - all code is black
5. Change PHP interpreter to support ASP tags, click apply - click ok to 
rebuild 6. The code is still black - until you close and open the file , or 
make a  change and save
Comment 4 moshe CLA 2007-02-01 08:29:38 EST
Change the method in PHPStructuredEditor (line 406) with the following lines:
	private IPreferencesPropagatorListener phpVersionListener = new IPreferencesPropagatorListener() {
		public void preferencesEventOccured(PreferencesPropagatorEvent event) {
			try {
				// get the structured document and go over its regions
				// in case of PhpScriptRegion reparse the region text
				IDocument doc = getDocumentProvider().getDocument(getEditorInput());
				if (doc instanceof IStructuredDocument) {
					IStructuredDocumentRegion[] sdRegions = ((IStructuredDocument) doc).getStructuredDocumentRegions();
					for (int i = 0; i < sdRegions.length; i++) {
						Iterator regionsIt = sdRegions[i].getRegions().iterator();
						reparseRegion(doc, regionsIt, sdRegions[i].getStartOffset());
					}
				}
			} catch (BadLocationException e) {
			}
		}

		public IProject getProject() {
			return getFile().getProject();
		}
	};
	
	/**
	 * iterate over regions 
	 * in case of PhpScriptRegion reparse the region.
	 * in case of region contaioner iterate over the container regions. 
	 * @param doc structured document
	 * @param regionsIt regions iterator
	 * @param offset the container region start offset
	 * @throws BadLocationException
	 */
	private void reparseRegion(IDocument doc, Iterator regionsIt, int offset) throws BadLocationException {
		while (regionsIt.hasNext()) {
			ITextRegion region = (ITextRegion) regionsIt.next();
			if (region instanceof ITextRegionContainer) {
				reparseRegion(doc, ((ITextRegionContainer)region).getRegions().iterator(), offset + region.getStart());
			}
			if (region instanceof PhpScriptRegion) {
				int length = region.getLength();
				String newText = doc.get(offset + region.getStart(), length);
				((PhpScriptRegion) region).completeReparse(newText);
			}
		}
	}
Comment 5 Guy Gurfinkel CLA 2007-02-04 10:07:42 EST
fixed, thanks Moshe.
Comment 6 Gadi Goldbarg CLA 2007-02-11 08:16:45 EST
closed by Yosi.l (checked with interface)