Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 293503 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jst/jsp/core/internal/java/JSPTranslator.java (-1 / +53 lines)
Lines 246-251 Link Here
246
	private String fELTranslatorID;
246
	private String fELTranslatorID;
247
247
248
	/**
248
	/**
249
	 * <code>true</code> if code has been found, such as HTML tags, that is not translated
250
	 * <code>false</code> otherwise.  Useful for deciding if a place holder needs to be
251
	 * written to translation
252
	 */
253
	private boolean fFoundNonTranslatedCode;
254
	
255
	/**
256
	 * <code>true</code> if code has been translated for the current region,
257
	 * <code>false</code> otherwise
258
	 */
259
	private boolean fCodeTranslated;
260
	
261
	/**
249
	 * A structure for holding a region collection marker and list of variable
262
	 * A structure for holding a region collection marker and list of variable
250
	 * information. The region can be used later for positioning validation
263
	 * information. The region can be used later for positioning validation
251
	 * messages.
264
	 * messages.
Lines 488-493 Link Here
488
501
489
		fELProblems = new ArrayList();
502
		fELProblems = new ArrayList();
490
503
504
		fFoundNonTranslatedCode = false;
505
		fCodeTranslated = false;
506
		
491
	}
507
	}
492
508
493
	/**
509
	/**
Lines 916-922 Link Here
916
		setCurrentNode(fStructuredDocument.getFirstStructuredDocumentRegion());
932
		setCurrentNode(fStructuredDocument.getFirstStructuredDocumentRegion());
917
933
918
		while (getCurrentNode() != null && !isCanceled()) {
934
		while (getCurrentNode() != null && !isCanceled()) {
919
935
			//no code has been translated for this region yet
936
			fCodeTranslated = false;
937
			
920
			// intercept HTML comment flat node
938
			// intercept HTML comment flat node
921
			// also handles UNDEFINED (which is what CDATA comes in as)
939
			// also handles UNDEFINED (which is what CDATA comes in as)
922
			// basically this part will handle any "embedded" JSP containers
940
			// basically this part will handle any "embedded" JSP containers
Lines 927-936 Link Here
927
				// iterate through each region in the flat node
945
				// iterate through each region in the flat node
928
				translateRegionContainer(getCurrentNode(), STANDARD_JSP);
946
				translateRegionContainer(getCurrentNode(), STANDARD_JSP);
929
			}
947
			}
948
			
949
			//if no code was translated for this region then found "non translated code"
950
			if(!fCodeTranslated) {
951
				fFoundNonTranslatedCode = true;
952
			}
953
			
930
			if (getCurrentNode() != null)
954
			if (getCurrentNode() != null)
931
				advanceNextNode();
955
				advanceNextNode();
932
		}
956
		}
933
		
957
		
958
		writePlaceHolderForNonTranslatedCode();
959
		
934
		/*
960
		/*
935
		 * Any contents left in the map indicate start tags that never had end
961
		 * Any contents left in the map indicate start tags that never had end
936
		 * tags. While the '{' that is present without the matching '}' would
962
		 * tags. While the '{' that is present without the matching '}' would
Lines 1066-1071 Link Here
1066
			else if (type != null && (type == DOMRegionContext.XML_TAG_OPEN || type == DOMRegionContext.XML_END_TAG_OPEN)) {
1092
			else if (type != null && (type == DOMRegionContext.XML_TAG_OPEN || type == DOMRegionContext.XML_END_TAG_OPEN)) {
1067
				translateXMLNode(containerRegion, regions);
1093
				translateXMLNode(containerRegion, regions);
1068
			}
1094
			}
1095
			//the end tags of these regions are "translated" in a sense
1096
			else if(type == DOMJSPRegionContexts.JSP_DIRECTIVE_CLOSE ||
1097
					type == DOMJSPRegionContexts.JSP_CLOSE) {
1098
				this.fCodeTranslated = true;
1099
			}
1069
		}
1100
		}
1070
		// }
1101
		// }
1071
	}
1102
	}
Lines 2112-2117 Link Here
2112
		// add a newline so translation looks cleaner
2143
		// add a newline so translation looks cleaner
2113
		if (!nonl && !newText.endsWith(ENDL))
2144
		if (!nonl && !newText.endsWith(ENDL))
2114
			newText += ENDL;
2145
			newText += ENDL;
2146
		
2147
		//dump any non translated code before writing translated code
2148
		writePlaceHolderForNonTranslatedCode();
2149
		
2150
		//if appending to the buffer can assume something got translated
2151
		fCodeTranslated = true;
2115
2152
2116
		if (buffer == fUserCode) {
2153
		if (buffer == fUserCode) {
2117
			buffer.append(newText);
2154
			buffer.append(newText);
Lines 2645-2648 Link Here
2645
	public IStructuredDocument getStructuredDocument() {
2682
	public IStructuredDocument getStructuredDocument() {
2646
		return fStructuredDocument;
2683
		return fStructuredDocument;
2647
	}
2684
	}
2685
	
2686
	/**
2687
	 * <p>Writes an empty expression to {@link #fUserCode} if previously
2688
	 * found non translated code</p>
2689
	 * <p>This should be done before appending any newly translated code.</p>
2690
	 */
2691
	private void writePlaceHolderForNonTranslatedCode() {
2692
		if(fFoundNonTranslatedCode) {
2693
			String text = (EXPRESSION_PREFIX + "\"\"" + EXPRESSION_SUFFIX +
2694
					" //non translated code placeholder"+ ENDL);
2695
			fUserCode.append(text);
2696
			fOffsetInUserCode += text.length();
2697
			fFoundNonTranslatedCode = false;
2698
		}
2699
	}
2648
}
2700
}

Return to bug 293503