ASM #15645 - Fix for AvnFPS: TAF syntax check fails when equal sign is missing

Change-Id: I1a4fb9be1253b4655bd43674aab4a4ddcf6d0ce7

Former-commit-id: d7cce22d02 [formerly 26c4bb2414] [formerly d7cce22d02 [formerly 26c4bb2414] [formerly a3cda853cf [formerly 192948e00538bcf0dfc0aaf20ea1dcb216313ffb]]]
Former-commit-id: a3cda853cf
Former-commit-id: ee2f893d21 [formerly eef5191d1c]
Former-commit-id: 350028e069
This commit is contained in:
Zhidong.Hao 2014-07-23 14:25:22 -04:00
parent df3b41ed7d
commit 2a4ea1243c

View file

@ -235,6 +235,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* 02/19/2014 16980 zhao add code to ensure the Alt flag is false after the Alt kay is released * 02/19/2014 16980 zhao add code to ensure the Alt flag is false after the Alt kay is released
* 09Apr2014 #3005 lvenable Added calls to mark the tabs as not current when the tabs are changed. * 09Apr2014 #3005 lvenable Added calls to mark the tabs as not current when the tabs are changed.
* This will show the tab as updating in the header and data text controls. * This will show the tab as updating in the header and data text controls.
* 07/23/2014 15645 zhao modified checkBasicSyntaxError()
* *
* </pre> * </pre>
* *
@ -2109,19 +2110,29 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
return editorComp; return editorComp;
} }
/** /**
* Check if there is an extra '=' sign in a TAF
* *
* @param doLogMessage * @param doLogMessage
* @return true if error found, otherwise false * @return true if error found, otherwise false
*/ */
private boolean checkBasicSyntaxError(boolean doLogMessage) { private boolean checkBasicSyntaxError(boolean doLogMessage) {
boolean errorFound = false;
String in = editorTafTabComp.getTextEditorControl().getText(); String in = editorTafTabComp.getTextEditorControl().getText();
clearSyntaxErrorLevel(); clearSyntaxErrorLevel();
st = editorTafTabComp.getTextEditorControl(); st = editorTafTabComp.getTextEditorControl();
in = in.toUpperCase().replaceAll("TAF", "\n\nTAF").trim();
while ( in.contains("\n\n\n") ) {
in = in.replace("\n\n\n", "\n\n");
}
st.setText(in);
final Map<StyleRange, String> syntaxMap = new HashMap<StyleRange, String>(); final Map<StyleRange, String> syntaxMap = new HashMap<StyleRange, String>();
st.addMouseTrackListener(new MouseTrackAdapter() { st.addMouseTrackListener(new MouseTrackAdapter() {
@ -2153,66 +2164,36 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
} }
}); });
int tafIndex = in.indexOf("TAF"); String msg = "Syntax error: There is an extra '=' sign or 'TAF' is missing at beginning of TAF";
int equalSignIndex = in.indexOf("="); String[] tafs = in.split("\n\n");
int lastEqualSignIndex = equalSignIndex; int tafStartIndex = 0;
for ( String taf : tafs ) {
if (tafIndex < 0 && equalSignIndex < 0) { // empty TAF int firstEqualSignIndex = taf.indexOf('=');
return false; if ( firstEqualSignIndex == -1 ) {
} tafStartIndex += taf.length() + 2;
continue;
while (tafIndex > -1 || equalSignIndex > -1) {
if (tafIndex == -1 || tafIndex > equalSignIndex) {
int lineIndexOfFirstEqualSign = st
.getLineAtOffset(lastEqualSignIndex);
int lineIndexOfSecondEqualSign = st
.getLineAtOffset(equalSignIndex);
if (lineIndexOfFirstEqualSign == lineIndexOfSecondEqualSign) {
StyleRange sr = new StyleRange(lastEqualSignIndex, 1, null,
qcColors[3]);
String msg = "Syntax error: there is an extra '=' sign in this line";
syntaxMap.put(sr, msg);
st.setStyleRange(null);
st.setStyleRange(sr);
if (doLogMessage) {
msgStatComp.setMessageText(msg, qcColors[3].getRGB());
}
return true;
}
int startIndex = lastEqualSignIndex;
while (!in.substring(startIndex, startIndex + 1).matches(
"[A-Z]")
&& !in.substring(startIndex, startIndex + 1).matches(
"[0-9]")) {
startIndex++;
}
int length = 6;
if ((equalSignIndex - startIndex) < 6) {
length = equalSignIndex - startIndex;
}
StyleRange sr = new StyleRange(startIndex, length, null,
qcColors[3]);
String msg = "Syntax error: There is an extra '=' sign before this point, or 'TAF' is missing at beginning of TAF";
syntaxMap.put(sr, msg);
st.setStyleRange(null);
st.setStyleRange(sr);
if (doLogMessage) {
msgStatComp.setMessageText(msg, qcColors[3].getRGB());
}
return true;
} }
int secondEqualSignIndex = taf.indexOf('=', firstEqualSignIndex+1);
tafIndex = in.indexOf("TAF", tafIndex + 1); if ( secondEqualSignIndex == -1 ) {
lastEqualSignIndex = equalSignIndex; tafStartIndex += taf.length() + 2;
equalSignIndex = in.indexOf("=", equalSignIndex + 1); continue;
}
while ( secondEqualSignIndex > -1 ) {
int secondEqualSignIndexInEditorText = tafStartIndex + secondEqualSignIndex;
StyleRange sr = new StyleRange(secondEqualSignIndexInEditorText, 1, null, qcColors[3]);
syntaxMap.put(sr, msg);
st.setStyleRange(sr);
secondEqualSignIndex = taf.indexOf('=', secondEqualSignIndex+1);
}
errorFound = true;
tafStartIndex += taf.length() + 2;
} }
return false; if ( doLogMessage ) {
msgStatComp.setMessageText(msg, qcColors[3].getRGB());
}
return errorFound;
} }
private void syntaxCheck() { private void syntaxCheck() {