[Tex/LaTex] meant by “! Package tikz Error: Giving up on this path. Did you forget a semicolon?.” when I use pgf-umlcd

pgf-umlcdtikz-pgf

My code is

\documentclass{standalone}
\usepackage{pgf-umlcd}

\renewcommand{\unidirectionalAssociation}[4]
{
  draw[umlcd style, ->] (#1) -- (#4)
  node[near end, auto]{#2}
  node[near end, auto,swap]{#3};
}

\begin{document}
\begin{tikzpicture}

  \begin{abstractclass}[text width = 6cm]{FileStore}{0,0}
    \attribute{$\sim$ com.alhelal.textpad}
    \operation{+ orderFile(file : File) : EditableFile} 
    \operation[0]{\# createFile(file : File) : EditableFile}
  \end{abstractclass}

  \begin{class}[text width = 6cm,anchor = west,xshift = 5cm]{ProgrammFileFactory}{FileStore.east}
    \inherit{FileStore}
    \attribute{$\sim$ com.alhelal.textpad}
    \operation{+ orderFile(file : File) : EditableFile} 
  \end{class}

  \begin{class}[text width = 11cm, yshift = -2cm]{EditableFile}{ProgrammFileFactory.south}
    \attribute{$\sim$ com.alhelal.textpad}
    \attribute{+ languageBehavior : LanguageBehavior} 
    \operation{+ options : Options} 
    \operation{+ getCodeAreaFromTab(tb : Tab) : CodeArea} 
    \operation{+ saveFile(fileTabArrayList : ArrayList$<$FileTab$>$, option : Options)}
    \operation{+ printFile(node : Node)}
    \operation{+ toggleLineNumber(cd : CodeArea)}
    \operation{+ setLanguageBehavior(langBehavior : LanguageBehavior)}
    \operation{+ performRunCode(file : File)}
    \operation{+ performBuildCode(file : File)}
    \operation{+ performSetHighlightableText()}
    \operation{+ performSetAutocompletableText()}
  \end{class}

  \begin{class}[text width = 3.5cm,anchor=north east,yshift = -2cm, xshift=-6cm]{TextFile}{EditableFile.south west}
    \inherit{EditableFile}
    \attribute{$\sim$ com.alhelal.textpad}
  \end{class}

  \begin{class}[text width = 3.5cm,anchor=north east,yshift = -2cm, xshift = -1.5cm]{CFile}{EditableFile.south west}
    \inherit{EditableFile}
    \attribute{$\sim$ com.alhelal.textpad}
    \attribute{-path : String}
  \end{class}

  \begin{class}[text width=3.5cm,anchor=north west,yshift = -2cm,xshift=-3cm]{CplusFile}{EditableFile.south}
    \inherit{EditableFile}
    \attribute{$\sim$ com.alhelal.textpad}
  \end{class}

  \begin{class}[text width  = 3.5cm, anchor = north west, yshift = -2cm, xshift = -4cm]{JavaFile}{EditableFile.south east}
    \inherit{EditableFile}
    \attribute{$\sim$ com.alhelal.textpad}
  \end{class}

  \begin{class}[text width = 3.5cm,yshift = -2cm,xshift = 1cm]{PythonFile}{EditableFile.south east}
    \inherit{EditableFile}
    \attribute{$\sim$ com.alhelal.textpad}
  \end{class}

  \begin{class}[text width = 3.5cm, anchor = north west, yshift =-2cm,xshift = 5cm]{LaTeXFile}{EditableFile.south east}
    \inherit{EditableFile}
    \attribute{$\sim$ com.alhelal.textpad}
  \end{class}
  \unidirectionalAssociation{ProgrammFileFactory}{}{$<<$instantiate$>>$}{EditableFile}
  \node [above=3mm] at (current bounding box.north) {Factory Method Pattern}
\end{tikzpicture}
\end{document}

I run this using pdflatex in terminal that results in

enter image description here

Best Answer

The general syntax of TikZ is to enter the stuff you want to be drawn in a format matching something like:

\command [ options ] ( location ) { stuff } ;

Where almost everything might not be needed. Just the \command (e.g. \draw) and the trailing ; to limit the scope of the command, are important. You forgot that ; in the last line of your tikzpicture and therefore get this error. And you forgot a \ at beginning of draw in the \unidirectionAssociation renaming block.
Use \draw[umlcd style, ->] (#1) -- (#4) instead of draw[umlcd style, ->] (#1) -- (#4)

The following compiles:

\documentclass{standalone}
\usepackage{pgf-umlcd}

\renewcommand{\unidirectionalAssociation}[4]
{
  \draw[umlcd style, ->] (#1) -- (#4)% <------
  node[near end, auto]{#2}
  node[near end, auto,swap]{#3};
}

\begin{document}
\begin{tikzpicture}

  \begin{abstractclass}[text width = 6cm]{FileStore}{0,0}
    \attribute{$\sim$ com.alhelal.textpad}
    \operation{+ orderFile(file : File) : EditableFile} 
    \operation[0]{\# createFile(file : File) : EditableFile}
  \end{abstractclass}

  \begin{class}[text width = 6cm,anchor = west,xshift = 5cm]{ProgrammFileFactory}{FileStore.east}
    \inherit{FileStore}
    \attribute{$\sim$ com.alhelal.textpad}
    \operation{+ orderFile(file : File) : EditableFile} 
  \end{class}

  \begin{class}[text width = 11cm, yshift = -2cm]{EditableFile}{ProgrammFileFactory.south}
    \attribute{$\sim$ com.alhelal.textpad}
    \attribute{+ languageBehavior : LanguageBehavior} 
    \operation{+ options : Options} 
    \operation{+ getCodeAreaFromTab(tb : Tab) : CodeArea} 
    \operation{+ saveFile(fileTabArrayList : ArrayList$<$FileTab$>$, option : Options)}
    \operation{+ printFile(node : Node)}
    \operation{+ toggleLineNumber(cd : CodeArea)}
    \operation{+ setLanguageBehavior(langBehavior : LanguageBehavior)}
    \operation{+ performRunCode(file : File)}
    \operation{+ performBuildCode(file : File)}
    \operation{+ performSetHighlightableText()}
    \operation{+ performSetAutocompletableText()}
  \end{class}

  \begin{class}[text width = 3.5cm,anchor=north east,yshift = -2cm, xshift=-6cm]{TextFile}{EditableFile.south west}
    \inherit{EditableFile}
    \attribute{$\sim$ com.alhelal.textpad}
  \end{class}

  \begin{class}[text width = 3.5cm,anchor=north east,yshift = -2cm, xshift = -1.5cm]{CFile}{EditableFile.south west}
    \inherit{EditableFile}
    \attribute{$\sim$ com.alhelal.textpad}
    \attribute{-path : String}
  \end{class}

  \begin{class}[text width=3.5cm,anchor=north west,yshift = -2cm,xshift=-3cm]{CplusFile}{EditableFile.south}
    \inherit{EditableFile}
    \attribute{$\sim$ com.alhelal.textpad}
  \end{class}

  \begin{class}[text width  = 3.5cm, anchor = north west, yshift = -2cm, xshift = -4cm]{JavaFile}{EditableFile.south east}
    \inherit{EditableFile}
    \attribute{$\sim$ com.alhelal.textpad}
  \end{class}

  \begin{class}[text width = 3.5cm,yshift = -2cm,xshift = 1cm]{PythonFile}{EditableFile.south east}
    \inherit{EditableFile}
    \attribute{$\sim$ com.alhelal.textpad}
  \end{class}

  \begin{class}[text width = 3.5cm, anchor = north west, yshift =-2cm,xshift = 5cm]{LaTeXFile}{EditableFile.south east}
    \inherit{EditableFile}
    \attribute{$\sim$ com.alhelal.textpad}
  \end{class}
  \unidirectionalAssociation{ProgrammFileFactory}{}{$<<$instantiate$>>$}{EditableFile}
  \node [above=3mm] at (current bounding box.north) {Factory Method Pattern};% <-------
\end{tikzpicture}
\end{document}

I marked the lines I changed with % <-------.

EDIT: I've updated the above code to include the correct redefinition of \unidirectionalAssociation thanks to the clarifications provided by @TorbjørnT.

enter image description here